home *** CD-ROM | disk | FTP | other *** search
/ PC Format (South-Africa) 2001 May / PCFMay2001.iso / Xenon / C++ / FreeCommandLineTools.exe / Include / httpext.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-01-31  |  11.4 KB  |  331 lines

  1. /********
  2. *
  3. *  Copyright (c) 1995  Process Software Corporation
  4. *
  5. *  Copyright (c) 1995-1999  Microsoft Corporation
  6. *
  7. *
  8. *  Module Name  : HttpExt.h
  9. *
  10. *  Abstract :
  11. *
  12. *     This module contains  the structure definitions and prototypes for the
  13. *      HTTP Server Extension interface used to build ISAPI Applications
  14. *
  15. ******************/
  16.  
  17. #ifndef _HTTPEXT_H_
  18. #pragma option push -b -a8 -pc -A- /*P_O_Push*/
  19. #define _HTTPEXT_H_
  20.  
  21. #include <windows.h>
  22.  
  23. #ifdef __cplusplus
  24. extern "C" {
  25. #endif
  26.  
  27.  
  28. /************************************************************
  29.  *   Manifest Constants
  30.  ************************************************************/
  31.  
  32. #define   HSE_VERSION_MAJOR           4      // major version of this spec
  33. #define   HSE_VERSION_MINOR           0      // minor version of this spec
  34. #define   HSE_LOG_BUFFER_LEN         80
  35. #define   HSE_MAX_EXT_DLL_NAME_LEN  256
  36.  
  37. #define   HSE_VERSION     MAKELONG( HSE_VERSION_MINOR, HSE_VERSION_MAJOR )
  38.  
  39. //
  40. // the following are the status codes returned by the Extension DLL
  41. //
  42.  
  43. #define   HSE_STATUS_SUCCESS                       1
  44. #define   HSE_STATUS_SUCCESS_AND_KEEP_CONN         2
  45. #define   HSE_STATUS_PENDING                       3
  46. #define   HSE_STATUS_ERROR                         4
  47.  
  48. //
  49. // The following are the values to request services with the
  50. //   ServerSupportFunction().
  51. //  Values from 0 to 1000 are reserved for future versions of the interface
  52.  
  53. #define   HSE_REQ_BASE                             0
  54. #define   HSE_REQ_SEND_URL_REDIRECT_RESP           ( HSE_REQ_BASE + 1 )
  55. #define   HSE_REQ_SEND_URL                         ( HSE_REQ_BASE + 2 )
  56. #define   HSE_REQ_SEND_RESPONSE_HEADER             ( HSE_REQ_BASE + 3 )
  57. #define   HSE_REQ_DONE_WITH_SESSION                ( HSE_REQ_BASE + 4 )
  58. #define   HSE_REQ_END_RESERVED                     1000
  59.  
  60. //
  61. //  These are Microsoft specific extensions
  62. //
  63.  
  64. #define   HSE_REQ_MAP_URL_TO_PATH                  (HSE_REQ_END_RESERVED+1)
  65. #define   HSE_REQ_GET_SSPI_INFO                    (HSE_REQ_END_RESERVED+2)
  66. #define   HSE_APPEND_LOG_PARAMETER                 (HSE_REQ_END_RESERVED+3)
  67. #define   HSE_REQ_IO_COMPLETION                    (HSE_REQ_END_RESERVED+5)
  68. #define   HSE_REQ_TRANSMIT_FILE                    (HSE_REQ_END_RESERVED+6)
  69. #define   HSE_REQ_REFRESH_ISAPI_ACL                (HSE_REQ_END_RESERVED+7)
  70. #define   HSE_REQ_IS_KEEP_CONN                     (HSE_REQ_END_RESERVED+8)
  71. #define   HSE_REQ_ASYNC_READ_CLIENT                (HSE_REQ_END_RESERVED+10)
  72. #define   HSE_REQ_GET_IMPERSONATION_TOKEN          (HSE_REQ_END_RESERVED+11)
  73. #define   HSE_REQ_MAP_URL_TO_PATH_EX               (HSE_REQ_END_RESERVED+12)
  74. #define   HSE_REQ_ABORTIVE_CLOSE                   (HSE_REQ_END_RESERVED+14)
  75. #define   HSE_REQ_GET_CERT_INFO_EX                 (HSE_REQ_END_RESERVED+15)
  76. #define   HSE_REQ_SEND_RESPONSE_HEADER_EX          (HSE_REQ_END_RESERVED+16)
  77. #define   HSE_REQ_CLOSE_CONNECTION                 (HSE_REQ_END_RESERVED+17)
  78. #define   HSE_REQ_IS_CONNECTED                     (HSE_REQ_END_RESERVED+18)
  79. #define   HSE_REQ_EXTENSION_TRIGGER                (HSE_REQ_END_RESERVED+20)
  80.  
  81. //
  82. //  Bit Flags for TerminateExtension
  83. //
  84. //    HSE_TERM_ADVISORY_UNLOAD - Server wants to unload the extension,
  85. //          extension can return TRUE if OK, FALSE if the server should not
  86. //          unload the extension
  87. //
  88. //    HSE_TERM_MUST_UNLOAD - Server indicating the extension is about to be
  89. //          unloaded, the extension cannot refuse.
  90. //
  91.  
  92. #define HSE_TERM_ADVISORY_UNLOAD                   0x00000001
  93. #define HSE_TERM_MUST_UNLOAD                       0x00000002
  94.  
  95. //
  96. // Flags for IO Functions, supported for IO Funcs.
  97. //  TF means ServerSupportFunction( HSE_REQ_TRANSMIT_FILE)
  98. //
  99.  
  100. # define HSE_IO_SYNC                      0x00000001   // for WriteClient
  101. # define HSE_IO_ASYNC                     0x00000002   // for WriteClient/TF
  102. # define HSE_IO_DISCONNECT_AFTER_SEND     0x00000004   // for TF
  103. # define HSE_IO_SEND_HEADERS              0x00000008   // for TF
  104. # define HSE_IO_NODELAY                   0x00001000   // turn off nagling 
  105.  
  106.  
  107. /************************************************************
  108.  *   Type Definitions
  109.  ************************************************************/
  110.  
  111. typedef   LPVOID          HCONN;
  112.  
  113. //
  114. // structure passed to GetExtensionVersion()
  115. //
  116.  
  117. typedef struct   _HSE_VERSION_INFO {
  118.  
  119.     DWORD  dwExtensionVersion;
  120.     CHAR   lpszExtensionDesc[HSE_MAX_EXT_DLL_NAME_LEN];
  121.  
  122. } HSE_VERSION_INFO, *LPHSE_VERSION_INFO;
  123.  
  124.  
  125. //
  126. // structure passed to extension procedure on a new request
  127. //
  128. typedef struct _EXTENSION_CONTROL_BLOCK {
  129.  
  130.     DWORD     cbSize;                 // size of this struct.
  131.     DWORD     dwVersion;              // version info of this spec
  132.     HCONN     ConnID;                 // Context number not to be modified!
  133.     DWORD     dwHttpStatusCode;       // HTTP Status code
  134.     CHAR      lpszLogData[HSE_LOG_BUFFER_LEN];// null terminated log info specific to this Extension DLL
  135.  
  136.     LPSTR     lpszMethod;             // REQUEST_METHOD
  137.     LPSTR     lpszQueryString;        // QUERY_STRING
  138.     LPSTR     lpszPathInfo;           // PATH_INFO
  139.     LPSTR     lpszPathTranslated;     // PATH_TRANSLATED
  140.  
  141.     DWORD     cbTotalBytes;           // Total bytes indicated from client
  142.     DWORD     cbAvailable;            // Available number of bytes
  143.     LPBYTE    lpbData;                // pointer to cbAvailable bytes
  144.  
  145.     LPSTR     lpszContentType;        // Content type of client data
  146.  
  147.     BOOL (WINAPI * GetServerVariable) ( HCONN       hConn,
  148.                                         LPSTR       lpszVariableName,
  149.                                         LPVOID      lpvBuffer,
  150.                                         LPDWORD     lpdwSize );
  151.  
  152.     BOOL (WINAPI * WriteClient)  ( HCONN      ConnID,
  153.                                    LPVOID     Buffer,
  154.                                    LPDWORD    lpdwBytes,
  155.                                    DWORD      dwReserved );
  156.  
  157.     BOOL (WINAPI * ReadClient)  ( HCONN      ConnID,
  158.                                   LPVOID     lpvBuffer,
  159.                                   LPDWORD    lpdwSize );
  160.  
  161.     BOOL (WINAPI * ServerSupportFunction)( HCONN      hConn,
  162.                                            DWORD      dwHSERequest,
  163.                                            LPVOID     lpvBuffer,
  164.                                            LPDWORD    lpdwSize,
  165.                                            LPDWORD    lpdwDataType );
  166.  
  167. } EXTENSION_CONTROL_BLOCK, *LPEXTENSION_CONTROL_BLOCK;
  168.  
  169.  
  170.  
  171.  
  172. //
  173. //  Bit field of flags that can be on a virtual directory
  174. //
  175.  
  176. #define HSE_URL_FLAGS_READ          0x00000001    // Allow for Read
  177. #define HSE_URL_FLAGS_WRITE         0x00000002    // Allow for Write
  178. #define HSE_URL_FLAGS_EXECUTE       0x00000004    // Allow for Execute
  179. #define HSE_URL_FLAGS_SSL           0x00000008    // Require SSL
  180. #define HSE_URL_FLAGS_DONT_CACHE    0x00000010    // Don't cache (vroot only)
  181. #define HSE_URL_FLAGS_NEGO_CERT     0x00000020    // Allow client SSL certs
  182. #define HSE_URL_FLAGS_REQUIRE_CERT  0x00000040    // Require client SSL certs
  183. #define HSE_URL_FLAGS_MAP_CERT      0x00000080    // Map SSL cert to NT account
  184. #define HSE_URL_FLAGS_SSL128        0x00000100    // Require 128 bit SSL
  185. #define HSE_URL_FLAGS_SCRIPT        0x00000200    // Allow for Script execution
  186.  
  187. #define HSE_URL_FLAGS_MASK          0x000003ff
  188.  
  189. //
  190. //  Structure for extended information on a URL mapping
  191. //
  192.  
  193. typedef struct _HSE_URL_MAPEX_INFO {
  194.  
  195.     CHAR   lpszPath[MAX_PATH]; // Physical path root mapped to
  196.     DWORD  dwFlags;            // Flags associated with this URL path
  197.     DWORD  cchMatchingPath;    // Number of matching characters in physical path
  198.     DWORD  cchMatchingURL;     // Number of matching characters in URL
  199.  
  200.     DWORD  dwReserved1;
  201.     DWORD  dwReserved2;
  202.  
  203. } HSE_URL_MAPEX_INFO, * LPHSE_URL_MAPEX_INFO;
  204.  
  205.  
  206.  
  207. //
  208. // PFN_HSE_IO_COMPLETION - callback function for the Async I/O Completion.
  209. //
  210.  
  211. typedef VOID
  212.   (WINAPI * PFN_HSE_IO_COMPLETION)(
  213.                                    IN EXTENSION_CONTROL_BLOCK * pECB,
  214.                                    IN PVOID    pContext,
  215.                                    IN DWORD    cbIO,
  216.                                    IN DWORD    dwError
  217.                                    );
  218.  
  219.  
  220.  
  221. //
  222. // HSE_TF_INFO defines the type for HTTP SERVER EXTENSION support for
  223. //  ISAPI applications to send files using TransmitFile.
  224. // A pointer to this object should be used with ServerSupportFunction()
  225. //  for HSE_REQ_TRANSMIT_FILE.
  226. //
  227.  
  228. typedef struct _HSE_TF_INFO  {
  229.  
  230.     //
  231.     // callback and context information
  232.     // the callback function will be called when IO is completed.
  233.     // the context specified will be used during such callback.
  234.     //
  235.     // These values (if non-NULL) will override the one set by calling
  236.     //  ServerSupportFunction() with HSE_REQ_IO_COMPLETION
  237.     //
  238.     PFN_HSE_IO_COMPLETION   pfnHseIO;
  239.     PVOID  pContext;
  240.  
  241.     // file should have been opened with FILE_FLAG_SEQUENTIAL_SCAN
  242.     HANDLE hFile;
  243.  
  244.     //
  245.     // HTTP header and status code
  246.     // These fields are used only if HSE_IO_SEND_HEADERS is present in dwFlags
  247.     //
  248.  
  249.     LPCSTR pszStatusCode; // HTTP Status Code  eg: "200 OK"
  250.  
  251.     DWORD  BytesToWrite;  // special value of "0" means write entire file.
  252.     DWORD  Offset;        // offset value within the file to start from
  253.  
  254.     PVOID  pHead;         // Head buffer to be sent before file data
  255.     DWORD  HeadLength;    // header length
  256.     PVOID  pTail;         // Tail buffer to be sent after file data
  257.     DWORD  TailLength;    // tail length
  258.  
  259.     DWORD  dwFlags;       // includes HSE_IO_DISCONNECT_AFTER_SEND, ...
  260.  
  261. } HSE_TF_INFO, * LPHSE_TF_INFO;
  262.  
  263.  
  264. //
  265. //      HSE_SEND_HEADER_EX_INFO allows an ISAPI application to send headers
  266. //      and specify keep-alive behavior in the same call.
  267. //
  268.  
  269. typedef struct _HSE_SEND_HEADER_EX_INFO  {
  270.  
  271.     //
  272.     // HTTP status code and header
  273.     //
  274.  
  275.     LPCSTR  pszStatus;  // HTTP status code  eg: "200 OK"
  276.     LPCSTR  pszHeader;  // HTTP header
  277.  
  278.     DWORD   cchStatus;  // number of characters in status code
  279.     DWORD   cchHeader;  // number of characters in header
  280.  
  281.     BOOL    fKeepConn;  // keep client connection alive?
  282.  
  283. } HSE_SEND_HEADER_EX_INFO, * LPHSE_SEND_HEADER_EX_INFO;
  284.  
  285.  
  286. #if(_WIN32_WINNT >= 0x400)
  287. #include <wincrypt.h>
  288. //
  289. //      CERT_CONTEXT_EX is passed as an an argument to 
  290. //  ServerSupportFunction( HSE_REQ_GET_CERT_INFO_EX )
  291. //
  292.  
  293. typedef struct _CERT_CONTEXT_EX {
  294.     CERT_CONTEXT    CertContext;
  295.     DWORD           cbAllocated;
  296.     DWORD           dwCertificateFlags;
  297. } CERT_CONTEXT_EX;
  298. #endif
  299.  
  300.  
  301.  
  302. /************************************************************
  303.  *   Function Prototypes 
  304.  *   o  for functions exported from the ISAPI Application DLL
  305.  ************************************************************/
  306.  
  307. BOOL  WINAPI   GetExtensionVersion( HSE_VERSION_INFO  *pVer );
  308. DWORD WINAPI   HttpExtensionProc(  EXTENSION_CONTROL_BLOCK *pECB );
  309. BOOL  WINAPI   TerminateExtension( DWORD dwFlags );
  310.  
  311. // the following type declarations is for use in the server side
  312.  
  313. typedef BOOL
  314.     (WINAPI * PFN_GETEXTENSIONVERSION)( HSE_VERSION_INFO  *pVer );
  315.  
  316. typedef DWORD 
  317.     (WINAPI * PFN_HTTPEXTENSIONPROC )( EXTENSION_CONTROL_BLOCK * pECB );
  318.  
  319. typedef BOOL  (WINAPI * PFN_TERMINATEEXTENSION )( DWORD dwFlags );
  320.  
  321.  
  322. #ifdef __cplusplus
  323. }
  324. #endif
  325.  
  326.  
  327. #pragma option pop /*P_O_Pop*/
  328. #endif  // end definition _HTTPEXT_H_
  329.  
  330.  
  331.