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.

187 lines
4.0 KiB

  1. #include "isapi.h"
  2. #pragma hdrstop
  3. #define MIN_RESPONSE "Content-type: text/html\r\n\r\n"
  4. BOOL
  5. SendHeaders(
  6. LPEXTENSION_CONTROL_BLOCK Ecb
  7. )
  8. {
  9. DWORD Length;
  10. DWORD ec;
  11. Length = strlen(MIN_RESPONSE);
  12. if (!Ecb->ServerSupportFunction( Ecb->ConnID, HSE_REQ_SEND_RESPONSE_HEADER, NULL, &Length, (LPDWORD) MIN_RESPONSE )) {
  13. ec = GetLastError();
  14. return FALSE;
  15. }
  16. return TRUE;
  17. }
  18. BOOL
  19. SendError(
  20. LPEXTENSION_CONTROL_BLOCK Ecb,
  21. DWORD ErrorCode
  22. )
  23. {
  24. IFAX_RESPONSE_HEADER Response;
  25. Response.Size = sizeof(IFAX_RESPONSE_HEADER);
  26. Response.ErrorCode = ErrorCode;
  27. DWORD Length = sizeof(IFAX_RESPONSE_HEADER);
  28. return Ecb->WriteClient( Ecb->ConnID, &Response, &Length, 0 );
  29. }
  30. BOOL
  31. SendResponse(
  32. LPEXTENSION_CONTROL_BLOCK Ecb
  33. )
  34. {
  35. DWORD Length = sizeof(IFAX_RESPONSE_HEADER);
  36. IFAX_RESPONSE_HEADER Response;
  37. Response.Size = Length;
  38. Response.ErrorCode = 0;
  39. return Ecb->WriteClient( Ecb->ConnID, &Response, &Length, 0 );
  40. }
  41. BOOL
  42. SendResponseWithData(
  43. LPEXTENSION_CONTROL_BLOCK Ecb,
  44. LPBYTE Data,
  45. DWORD DataSize
  46. )
  47. {
  48. DWORD Length = sizeof(IFAX_RESPONSE_HEADER) + DataSize;
  49. PIFAX_RESPONSE_HEADER Response = (PIFAX_RESPONSE_HEADER) MemAlloc( Length );
  50. if (!Response) {
  51. return FALSE;
  52. }
  53. Response->Size = Length;
  54. Response->ErrorCode = 0;
  55. CopyMemory( (LPBYTE)((LPBYTE)Response+sizeof(IFAX_RESPONSE_HEADER)), Data, DataSize );
  56. BOOL Rval = Ecb->WriteClient( Ecb->ConnID, Response, &Length, 0 );
  57. MemFree( Response );
  58. return Rval;
  59. }
  60. DWORD
  61. HttpExtensionProc(
  62. LPEXTENSION_CONTROL_BLOCK Ecb
  63. )
  64. {
  65. DWORD Command = *((LPDWORD)Ecb->lpbData);
  66. LPBYTE Data = (LPBYTE)(((LPBYTE)Ecb->lpbData)+sizeof(DWORD));
  67. DWORD Rval = HSE_STATUS_SUCCESS;
  68. DebugPrint(( L"HttpExtensionProc(): ConnId=0x%08x, Command=0x%08x", Ecb->ConnID, Command ));
  69. Ecb->dwHttpStatusCode = 0;
  70. if (!SendHeaders( Ecb )) {
  71. return FALSE;
  72. }
  73. Ecb->dwHttpStatusCode = 200;
  74. switch (Command) {
  75. case ICMD_CONNECT:
  76. if (!IsapiFaxConnect( Ecb )) {
  77. Rval = HSE_STATUS_ERROR;
  78. }
  79. break;
  80. case ICMD_DISCONNECT:
  81. if (!IsapiFaxDisConnect( Ecb )) {
  82. Rval = HSE_STATUS_ERROR;
  83. }
  84. break;
  85. case ICMD_ENUM_PORTS:
  86. if (!IsapiFaxEnumPorts( Ecb )) {
  87. Rval = HSE_STATUS_ERROR;
  88. }
  89. break;
  90. case ICMD_GET_PORT:
  91. if (!IsapiFaxGetPort( Ecb )) {
  92. Rval = HSE_STATUS_ERROR;
  93. }
  94. break;
  95. case ICMD_SET_PORT:
  96. if (!IsapiFaxSetPort( Ecb )) {
  97. Rval = HSE_STATUS_ERROR;
  98. }
  99. break;
  100. case ICMD_OPEN_PORT:
  101. if (!IsapiFaxOpenPort( Ecb )) {
  102. Rval = HSE_STATUS_ERROR;
  103. }
  104. break;
  105. case ICMD_CLOSE:
  106. if (!IsapiFaxClose( Ecb )) {
  107. Rval = HSE_STATUS_ERROR;
  108. }
  109. break;
  110. case ICMD_GET_ROUTINGINFO:
  111. if (!IsapiFaxGetRoutingInfo( Ecb )) {
  112. Rval = HSE_STATUS_ERROR;
  113. }
  114. break;
  115. case ICMD_GET_DEVICE_STATUS:
  116. if (!IsapiFaxGetDeviceStatus( Ecb )) {
  117. Rval = HSE_STATUS_ERROR;
  118. }
  119. break;
  120. case ICMD_ENUM_ROUTING_METHODS:
  121. if (!IsapiFaxEnumRoutingMethods( Ecb )) {
  122. Rval = HSE_STATUS_ERROR;
  123. }
  124. break;
  125. case ICMD_ENABLE_ROUTING_METHOD:
  126. if (!IsapiFaxEnableRoutingMethod( Ecb )) {
  127. Rval = HSE_STATUS_ERROR;
  128. }
  129. break;
  130. case ICMD_GET_VERSION:
  131. if (!IsapiFaxGetVersion( Ecb )) {
  132. Rval = HSE_STATUS_ERROR;
  133. }
  134. break;
  135. default:
  136. break;
  137. }
  138. DebugPrint(( L"HttpExtensionProc(): ConnId=0x%08x, Rval=0x%08x", Ecb->ConnID, Rval ));
  139. return Rval;
  140. }