home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 2000 March / VPR0003B.ISO / alpha / httpext.h < prev    next >
C/C++ Source or Header  |  1999-10-14  |  11KB  |  327 lines

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