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