Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

188 lines
4.6 KiB

  1. #include "isapi.h"
  2. #pragma hdrstop
  3. static
  4. DWORD
  5. BufferSize(
  6. PFAX_PORT_INFOW PortInfo,
  7. DWORD PortCount
  8. )
  9. {
  10. DWORD i;
  11. DWORD Size = 0;
  12. for (i=0; i<PortCount; i++) {
  13. Size += sizeof(FAX_PORT_INFOW);
  14. Size += StringSize( PortInfo[i].DeviceName );
  15. Size += StringSize( PortInfo[i].Tsid );
  16. Size += StringSize( PortInfo[i].Csid );
  17. }
  18. return Size;
  19. }
  20. BOOL
  21. IsapiFaxEnumPorts(
  22. LPEXTENSION_CONTROL_BLOCK Ecb
  23. )
  24. {
  25. LPBYTE Data = (LPBYTE)(((LPBYTE)Ecb->lpbData)+sizeof(DWORD));
  26. HANDLE FaxHandle;
  27. PFAX_PORT_INFOW PortInfo = NULL;
  28. DWORD PortsReturned = 0;
  29. FaxHandle = (HANDLE) *((LPDWORD)Data);
  30. if (!FaxEnumPortsW( FaxHandle, (LPBYTE*)&PortInfo, &PortsReturned )) {
  31. SendError( Ecb, GetLastError() );
  32. return FALSE;
  33. }
  34. DWORD Size = BufferSize( PortInfo, PortsReturned );
  35. for (DWORD i=0; i<PortsReturned; i++) {
  36. FixupStringOut( PortInfo[i].DeviceName, PortInfo );
  37. FixupStringOut( PortInfo[i].Tsid, PortInfo );
  38. FixupStringOut( PortInfo[i].Csid, PortInfo );
  39. }
  40. SendResponseWithData( Ecb, (LPBYTE) &PortsReturned, sizeof(DWORD) );
  41. SendResponseWithData( Ecb, (LPBYTE) PortInfo, Size );
  42. FaxFreeBuffer( PortInfo );
  43. return TRUE;
  44. }
  45. BOOL
  46. IsapiFaxGetPort(
  47. LPEXTENSION_CONTROL_BLOCK Ecb
  48. )
  49. {
  50. PIFAX_GENERAL iFaxGeneral = (PIFAX_GENERAL) Ecb->lpbData;
  51. PFAX_PORT_INFOW PortInfo = NULL;
  52. if (!FaxGetPortW( iFaxGeneral->FaxHandle, (LPBYTE*)&PortInfo )) {
  53. SendError( Ecb, GetLastError() );
  54. return FALSE;
  55. }
  56. DWORD Size = BufferSize( PortInfo, 1 );
  57. FixupStringOut( PortInfo->DeviceName, PortInfo );
  58. FixupStringOut( PortInfo->Tsid, PortInfo );
  59. FixupStringOut( PortInfo->Csid, PortInfo );
  60. SendResponseWithData( Ecb, (LPBYTE) PortInfo, Size );
  61. FaxFreeBuffer( PortInfo );
  62. return TRUE;
  63. }
  64. BOOL
  65. IsapiFaxSetPort(
  66. LPEXTENSION_CONTROL_BLOCK Ecb
  67. )
  68. {
  69. PIFAX_SET_PORT iFaxSetPort = (PIFAX_SET_PORT) Ecb->lpbData;
  70. FixupStringIn( iFaxSetPort->PortInfo.DeviceName, &iFaxSetPort->PortInfo );
  71. FixupStringIn( iFaxSetPort->PortInfo.Tsid, &iFaxSetPort->PortInfo );
  72. FixupStringIn( iFaxSetPort->PortInfo.Csid, &iFaxSetPort->PortInfo );
  73. if (!FaxSetPortW( iFaxSetPort->FaxPortHandle, (LPBYTE)&iFaxSetPort->PortInfo )) {
  74. SendError( Ecb, GetLastError() );
  75. return FALSE;
  76. }
  77. return TRUE;
  78. }
  79. BOOL
  80. IsapiFaxOpenPort(
  81. LPEXTENSION_CONTROL_BLOCK Ecb
  82. )
  83. {
  84. PIFAX_OPEN_PORT iFaxOpenPort = (PIFAX_OPEN_PORT) Ecb->lpbData;
  85. HANDLE FaxPortHandle = NULL;
  86. if (!FaxOpenPort(
  87. iFaxOpenPort->FaxHandle,
  88. iFaxOpenPort->DeviceId,
  89. iFaxOpenPort->Flags,
  90. &FaxPortHandle ))
  91. {
  92. SendError( Ecb, GetLastError() );
  93. return FALSE;
  94. }
  95. SendResponseWithData( Ecb, (LPBYTE) &FaxPortHandle, sizeof(DWORD) );
  96. return TRUE;
  97. }
  98. DWORD
  99. DeviceStatusSize(
  100. PFAX_DEVICE_STATUSW DeviceStatus
  101. )
  102. {
  103. DWORD Size = sizeof(FAX_DEVICE_STATUSW);
  104. Size += StringSize( DeviceStatus->CallerId );
  105. Size += StringSize( DeviceStatus->Csid );
  106. Size += StringSize( DeviceStatus->DeviceName );
  107. Size += StringSize( DeviceStatus->DocumentName );
  108. Size += StringSize( DeviceStatus->PhoneNumber );
  109. Size += StringSize( DeviceStatus->RoutingString );
  110. Size += StringSize( DeviceStatus->SenderName );
  111. Size += StringSize( DeviceStatus->RecipientName );
  112. Size += StringSize( DeviceStatus->StatusString );
  113. Size += StringSize( DeviceStatus->Tsid );
  114. return Size;
  115. }
  116. BOOL
  117. IsapiFaxGetDeviceStatus(
  118. LPEXTENSION_CONTROL_BLOCK Ecb
  119. )
  120. {
  121. PIFAX_GENERAL iFaxGeneral = (PIFAX_GENERAL) Ecb->lpbData;
  122. PFAX_DEVICE_STATUSW DeviceStatus = NULL;
  123. if (!FaxGetDeviceStatusW( iFaxGeneral->FaxHandle, (LPBYTE*) &DeviceStatus )) {
  124. SendError( Ecb, GetLastError() );
  125. return FALSE;
  126. }
  127. DWORD Size = DeviceStatusSize( DeviceStatus );
  128. FixupStringOut( DeviceStatus->CallerId, DeviceStatus );
  129. FixupStringOut( DeviceStatus->Csid, DeviceStatus );
  130. FixupStringOut( DeviceStatus->DeviceName, DeviceStatus );
  131. FixupStringOut( DeviceStatus->DocumentName, DeviceStatus );
  132. FixupStringOut( DeviceStatus->PhoneNumber, DeviceStatus );
  133. FixupStringOut( DeviceStatus->RoutingString, DeviceStatus );
  134. FixupStringOut( DeviceStatus->SenderName, DeviceStatus );
  135. FixupStringOut( DeviceStatus->RecipientName, DeviceStatus );
  136. FixupStringOut( DeviceStatus->StatusString, DeviceStatus );
  137. FixupStringOut( DeviceStatus->Tsid, DeviceStatus );
  138. SendResponseWithData( Ecb, (LPBYTE) DeviceStatus, Size );
  139. FaxFreeBuffer( DeviceStatus );
  140. return TRUE;
  141. }