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