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