home *** CD-ROM | disk | FTP | other *** search
/ Programming with VisualAge for Java / IBMVJAVA.ISO / icswin95 / httpdw32.z / HTAPI.h < prev    next >
C/C++ Source or Header  |  1997-04-07  |  10KB  |  276 lines

  1. #ifndef HTAPI_H
  2. #define HTAPI_H
  3.  
  4. /*
  5.  * Return values from user-written functions
  6.  * Refer to the Web Programming Guide and HTTP specification for details.
  7.  */
  8. #define HTTP_NOACTION              0
  9.  
  10. /* 1xx Informational */
  11. #define HTTP_CONTINUE            100
  12. #define HTTP_SWITCHING_PROTOCOLS 101
  13.  
  14. /* 2xx Successful */
  15. #define HTTP_OK                  200
  16. #define HTTP_CREATED             201
  17. #define HTTP_ACCEPTED            202
  18. #define HTTP_NON_AUTHORITATIVE   203
  19. #define HTTP_NO_CONTENT          204
  20. #define HTTP_RESET_CONTENT       205
  21. #define HTTP_PARTIAL_CONENT      206
  22.  
  23. /* 3xx Redirection */
  24. #define HTTP_MULTIPLE_CHOICES    300
  25. #define HTTP_MOVED_PERMANENTLY   301
  26. #define HTTP_MOVED_TEMPORARILY   302
  27. #define HTTP_SEE_OTHER           303
  28. #define HTTP_NOT_MODIFIED        304
  29. #define HTTP_USE_PROXY           305
  30.  
  31. /* 4xx Client Error */
  32. #define HTTP_BAD_REQUEST         400
  33. #define HTTP_UNAUTHORIZED        401
  34. #define HTTP_FORBIDDEN           403
  35. #define HTTP_NOT_FOUND           404
  36. #define HTTP_METHOD_NOT_ALLOWED  405
  37. #define HTTP_NOT_ACCEPTABLE      406
  38. #define HTTP_PROXY_UNAUTHORIZED  407
  39. #define HTTP_REQUEST_TIMEOUT     408
  40. #define HTTP_CONFLICT            409
  41. #define HTTP_GONE                410
  42. #define HTTP_LENGTH_REQUIRED     411
  43. #define HTTP_PRECONDITION_FAILED 412
  44. #define HTTP_ENTITY_TOO_LARGE    413
  45. #define HTTP_URI_TOO_LONG        414
  46. #define HTTP_BAD_MEDIA_TYPE      415
  47.  
  48. /* 5xx Server Error */
  49. #define HTTP_SERVER_ERROR        500
  50. #define HTTP_NOT_IMPLEMENTED     501
  51. #define HTTP_BAD_GATEWAY         502
  52. #define HTTP_SERVICE_UNAVAILABLE 503
  53. #define HTTP_GATEWAY_TIMEOUT     504
  54. #define HTTP_BAD_VERSION         505
  55.  
  56. /* Return values from ICS provided functions */
  57. #define HTTPD_UNSUPPORTED        -1
  58. #define HTTPD_SUCCESS             0
  59. #define HTTPD_FAILURE             1
  60. #define HTTPD_INTERNAL_ERROR      2
  61. #define HTTPD_PARAMETER_ERROR     3
  62. #define HTTPD_STATE_CHECK         4
  63. #define HTTPD_READ_ONLY           5
  64. #define HTTPD_BUFFER_TOO_SMALL    6
  65. #define HTTPD_AUTHENTICATE_FAILED 7
  66. #define HTTPD_EOF                 8
  67. #define HTTPD_ABORT_REQUEST       9
  68. #define HTTPD_REQUEST_SERVICED    10
  69. #define HTTPD_RESPONSE_ALREADY_COMPLETED   11
  70.  
  71. /* prototypes for ICS provided functions */
  72.  
  73. #if defined(__OS2__)
  74. #define HTTPD_LINKAGE _System
  75. #elif defined(WIN32)
  76. #define HTTPD_LINKAGE __stdcall
  77. #else
  78. #define HTTPD_LINKAGE
  79. #endif
  80.  
  81. /* Long name to short name mapping */
  82. #define HTTPD_authenticate   HTAUTHEN
  83. #define HTTPD_extract        HTXTRACT
  84. #define HTTPD_set            HTSET
  85. #define HTTPD_file           HTFILE
  86. #define HTTPD_exec           HTEXEC
  87. #define HTTPD_read           HTREAD
  88. #define HTTPD_write          HTWRITE
  89. #define HTTPD_log_error      HTLOGE
  90. #define HTTPD_log_trace      HTLOGT
  91. #define HTTPD_restart        HTREST
  92. #define HTTPD_proxy          HTPROXY
  93. #define HTTPD_attributes     HTATTRIB
  94. #define HTTPD_reverse_translate      HTREVTRA
  95. #define HTTPD_translate      HTTRANS
  96. #define HTTPD_supply_label   HTSUPLBL
  97.  
  98. #ifdef __cplusplus
  99. extern "C" {
  100. #endif /* __cplusplus */
  101.  
  102. /* authenticate a userid/password                */
  103. /* valid only in PreExit, Authentication, and Authorization steps */
  104. void
  105. HTTPD_LINKAGE
  106. HTTPD_authenticate(
  107.              unsigned char *handle,  /* i; handle (NULL right now) */
  108.              long *return_code);     /* o; return code */
  109.  
  110. /* extract the value of a variable associated with this request */
  111. /* the available variables are the same as CGI                  */
  112. /* valid in all steps, though not all variables will be         */
  113. void
  114. HTTPD_LINKAGE
  115. HTTPD_extract(
  116.     unsigned char *handle,       /* i; handle (NULL right now) */
  117.     unsigned char *name,         /* i; name of the value to extract */
  118.     unsigned long *name_length,  /* i; length of the name */
  119.     unsigned char *value,        /* o; buffer in which to place the value */
  120.     unsigned long *value_length, /* i/o; size of buffer/length of value */
  121.              long *return_code); /* o; return code */
  122.  
  123. /* set the value of a variable associated with this request     */
  124. /* the available variables are the same as CGI                  */
  125. /* - note that one can create variables with this function      */
  126. /* - if created variables are prefixed by "HTTP_", they will    */
  127. /*   be sent as headers in the response, without the "HTTP_"    */
  128. /*   prefix                                                     */
  129. /* valid in all steps, though not all variables are             */
  130. void
  131. HTTPD_LINKAGE
  132. HTTPD_set(
  133.     unsigned char *handle,       /* i; handle (NULL right now) */
  134.     unsigned char *name,         /* i; name of the value to set */
  135.     unsigned long *name_length,  /* i; length of the name */
  136.     unsigned char *value,        /* o; buffer which contains the value */
  137.     unsigned long *value_length, /* i; length of value */
  138.              long *return_code); /* o; return code */
  139.  
  140. /* send a file to satisfy this request */
  141. /* valid only in PreExit, Service, Error and Datafilter steps  */
  142. void
  143. HTTPD_LINKAGE
  144. HTTPD_file(
  145.     unsigned char *handle,       /* i; handle (NULL right now) */
  146.     unsigned char *name,         /* i; name of file to send */
  147.     unsigned long *name_length,  /* i; length of the name */
  148.              long *return_code); /* o; return code */
  149.  
  150. /* execute a script to satisfy this request */
  151. /* valid only in PreExit, Service, and Error steps  */
  152. void
  153. HTTPD_LINKAGE
  154. HTTPD_exec(
  155.     unsigned char *handle,       /* i; handle (NULL right now) */
  156.     unsigned char *name,         /* i; name of script to execute */
  157.     unsigned long *name_length,  /* i; length of the name */
  158.              long *return_code); /* o; return code */
  159.  
  160. /* read the body of the client's request - use set/extract for headers */
  161. /* Keep reading until HTTPD_EOF is returned; 4k is a good buffer size  */
  162. /* valid only in the PreExit, Service, and Datafilter steps  */
  163. void
  164. HTTPD_LINKAGE
  165. HTTPD_read(
  166.     unsigned char *handle,       /* i; handle (NULL right now) */
  167.     unsigned char *value,        /* i; buffer in which to place the value */
  168.     unsigned long *value_length, /* i/o; size of buffer/length of header */
  169.              long *return_code); /* o; return code */
  170.  
  171. /* write the body of the response - use set/extract for headers */
  172. /* valid only in PreExit, Service, Error and Datafilter steps  */
  173. void
  174. HTTPD_LINKAGE
  175. HTTPD_write(
  176.     unsigned char *handle,       /* i; handle (NULL right now) */
  177.     unsigned char *value,        /* i; data to send */
  178.     unsigned long *value_length, /* i; length of the data */
  179.              long *return_code); /* o; return code */
  180.  
  181. /* write a string to the server's error log */
  182. /* valid in all steps */
  183. void
  184. HTTPD_LINKAGE
  185. HTTPD_log_error(
  186.     unsigned char *handle,       /* i; handle (NULL right now) */
  187.     unsigned char *value,        /* i; data to write */
  188.     unsigned long *value_length, /* i; length of the data */
  189.              long *return_code); /* o; return code */
  190.  
  191. /* write a string to the server's trace log */
  192. /* valid in all steps */
  193. void
  194. HTTPD_LINKAGE
  195. HTTPD_log_trace(
  196.     unsigned char *handle,       /* i; handle (NULL right now) */
  197.     unsigned char *value,        /* i; data to write */
  198.     unsigned long *value_length, /* i; length of the data */
  199.              long *return_code); /* o; return code */
  200.  
  201.  
  202. /* restart the server after all active requests have been processed */
  203. /* valid in all steps except ServerInit and ServerTerm */
  204. void
  205. HTTPD_LINKAGE
  206. HTTPD_restart(
  207.              long *return_code); /* o; return code */
  208.  
  209. /* make a proxy request */
  210. /* valid in PreExit and Service steps  */
  211. /* Note: This is a completion function; i.e, the response is complete after this */
  212. void
  213. HTTPD_LINKAGE
  214. HTTPD_proxy(
  215.     unsigned char *handle,       /* i; handle (NULL right now) */
  216.     unsigned char *url_name,     /* i; url to which the proxy request is made */
  217.     unsigned long *name_length,  /* i; length of the url */
  218.     unsigned char *request_body, /* i; body of the request */
  219.     unsigned long *body_length,  /* i; length of the body */
  220.              long *return_code); /* o; return code */
  221.  
  222. /* get the attributes of a file */
  223. /* valid in all steps */
  224. void
  225. HTTPD_LINKAGE
  226. HTTPD_attributes(
  227.     unsigned char *handle,       /* i; handle (NULL right now) */
  228.     unsigned char *name,         /* i; name of the file */
  229.     unsigned long *name_length,  /* i; length of the name */
  230.     unsigned char *value,        /* o; buffer which contains the attributes */
  231.     unsigned long *value_length, /* i/o; size of buffer/length of attributes */
  232.              long *return_code); /* o; return code */
  233.  
  234. /* reverse translate a file system object to a URL */
  235. /* valid in all steps */
  236. void
  237. HTTPD_LINKAGE
  238. HTTPD_reverse_translate(
  239.     unsigned char *handle,       /* i; handle (NULL right now) */
  240.     unsigned char *name,         /* i; name of the file system object */
  241.     unsigned long *name_length,  /* i; length of the name */
  242.     unsigned char *value,        /* o; buffer which contains the URL */
  243.     unsigned long *value_length, /* i/o; size of buffer/length of URL */
  244.              long *return_code); /* o; return code */
  245.  
  246. /* translate a URL */
  247. /* valid in all steps */
  248. void
  249. HTTPD_LINKAGE
  250. HTTPD_translate(
  251.     unsigned char *handle,       /* i; handle (NULL right now) */
  252.     unsigned char *name,         /* i; name of the URL */
  253.     unsigned long *name_length,  /* i; length of the name */
  254.     unsigned char *url_value,    /* o; buffer which contains the translated URL */
  255.     unsigned long *url_value_length, /* i/o; size of buffer/length of translated URL */
  256.     unsigned char *path_trans,   /* o; buffer which contains PATH_TRANSLATED */
  257.     unsigned long *path_trans_length, /* i/o; size of buffer/length of PATH_TRANSLATED */
  258.     unsigned char *query_string, /* o; buffer which contains QUERY_STRING */
  259.     unsigned long *query_string_length, /* i/o; size of buffer/length of QUERY_STRING */
  260.              long *return_code); /* o; return code */
  261.  
  262. void
  263. HTTPD_LINKAGE
  264. HTTPD_supply_label(
  265.     unsigned char *handle,       /* i; handle */
  266.     unsigned char *value,        /* i; PICS label being supplied */
  267.     unsigned long *value_size,   /* i; length of the PICS label */
  268.              long *return_code); /* o; return code */
  269.  
  270.  
  271. #ifdef __cplusplus
  272. }
  273. #endif /* __cplusplus */
  274.  
  275. #endif /* HTAPI_H */
  276.