home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: InfoMgt / InfoMgt.zip / dbadm101.zip / cgic.h < prev    next >
C/C++ Source or Header  |  1996-08-03  |  4KB  |  161 lines

  1. /* The CGI_C library, by Thomas Boutell, version 1.0. CGI_C is intended
  2.     to be a high-quality API to simplify CGI programming tasks. */
  3.  
  4. /* Make sure this is only included once. */
  5.  
  6. #ifndef CGI_C
  7. #define CGI_C 1
  8.  
  9. /* Bring in standard I/O since some of the functions refer to
  10.     types defined by it, such as FILE *. */
  11.  
  12. #include <stdio.h>
  13.  
  14. /* The various CGI environment variables. Instead of using getenv(),
  15.     the programmer should refer to these, which are always
  16.     valid null-terminated strings (they may be empty, but they 
  17.     will never be null). If these variables are used instead
  18.     of calling getenv(), then it will be possible to save
  19.     and restore CGI environments, which is highly convenient
  20.     for debugging. */
  21.  
  22. extern char *cgiServerSoftware;
  23. extern char *cgiServerName;
  24. extern char *cgiGatewayInterface;
  25. extern char *cgiServerProtocol;
  26. extern char *cgiServerPort;
  27. extern char *cgiRequestMethod;
  28. extern char *cgiPathInfo;
  29. extern char *cgiPathTranslated;
  30. extern char *cgiScriptName;
  31. extern char *cgiQueryString;
  32. extern char *cgiRemoteHost;
  33. extern char *cgiRemoteAddr;
  34. extern char *cgiAuthType;
  35. extern char *cgiRemoteUser;
  36. extern char *cgiRemoteIdent;
  37. extern char *cgiContentType;
  38. extern char *cgiAccept;
  39. extern char *cgiUserAgent;
  40.  
  41. /* The number of bytes of data received.
  42.     Note that if the submission is a form submission
  43.     the library will read and parse all the information
  44.     directly from cgiIn; the programmer need not do so. */
  45.  
  46. extern int cgiContentLength;
  47.  
  48. /* Pointer to CGI output. The cgiHeader functions should be used
  49.     first to output the mime headers; the output HTML
  50.     page, GIF image or other web document should then be written
  51.     to cgiOut by the programmer. */
  52.  
  53. extern FILE *cgiOut;
  54.  
  55. /* Pointer to CGI input. In 99% of cases, the programmer will NOT
  56.     need this. However, in some applications, things other than 
  57.     forms are posted to the server, in which case this file may
  58.     be read from in order to retrieve the contents. */
  59.  
  60. extern FILE *cgiIn;
  61.  
  62. /* Possible return codes from the cgiForm family of functions (see below). */
  63.  
  64. typedef enum {
  65.     cgiFormSuccess,
  66.     cgiFormTruncated,
  67.     cgiFormBadType,
  68.     cgiFormEmpty,
  69.     cgiFormNotFound,
  70.     cgiFormConstrained,
  71.     cgiFormNoSuchChoice,
  72.     cgiFormMemory
  73. } cgiFormResultType;
  74.  
  75. /* These functions are used to retrieve form data. See
  76.     cgic.html for documentation. */
  77.  
  78.  
  79. extern cgiFormResultType cgiFormString(
  80.     char *name, char *result, int max);
  81.  
  82.  
  83. extern cgiFormResultType cgiFormStringNoNewlines(
  84.     char *name, char *result, int max);
  85.  
  86.  
  87. extern cgiFormResultType cgiFormStringSpaceNeeded(
  88.     char *name, int *length);
  89.  
  90.  
  91. extern cgiFormResultType cgiFormStringMultiple(
  92.     char *name, char ***ptrToStringArray);
  93.  
  94.  
  95. extern void cgiStringArrayFree(char **stringArray);
  96.     
  97.  
  98. extern cgiFormResultType cgiFormInteger(
  99.     char *name, int *result, int defaultV);
  100.  
  101.  
  102. extern cgiFormResultType cgiFormIntegerBounded(
  103.     char *name, int *result, int min, int max, int defaultV);
  104.  
  105. extern cgiFormResultType cgiFormDouble(
  106.     char *name, double *result, double defaultV);
  107.  
  108.  
  109. extern cgiFormResultType cgiFormDoubleBounded(
  110.     char *name, double *result, double min, double max, double defaultV);
  111.  
  112.  
  113. extern cgiFormResultType cgiFormSelectSingle(
  114.     char *name, char **choicesText, int choicesTotal, 
  115.     int *result, int defaultV);    
  116.  
  117.  
  118. extern cgiFormResultType cgiFormSelectMultiple(
  119.     char *name, char **choicesText, int choicesTotal, 
  120.     int *result, int *invalid);
  121.  
  122.  
  123. extern cgiFormResultType cgiFormCheckboxSingle(
  124.     char *name);
  125.  
  126.  
  127. extern cgiFormResultType cgiFormCheckboxMultiple(
  128.     char *name, char **valuesText, int valuesTotal, 
  129.     int *result, int *invalid);
  130.  
  131.  
  132. extern cgiFormResultType cgiFormRadio(
  133.     char *name, char **valuesText, int valuesTotal, 
  134.     int *result, int defaultV);    
  135.  
  136.  
  137. extern void cgiHeaderLocation(char *redirectUrl);
  138. extern void cgiHeaderStatus(int status, char *statusMessage);
  139. extern void cgiHeaderContentType(char *mimeType);
  140.  
  141. #ifndef NO_SYSTEM
  142.  
  143. extern int cgiSaferSystem(char *command);
  144.  
  145. #endif /* NO_SYSTEM */
  146.  
  147. typedef enum {
  148.     cgiEnvironmentIO,
  149.     cgiEnvironmentMemory,
  150.     cgiEnvironmentSuccess
  151. } cgiEnvironmentResultType;
  152.  
  153. extern cgiEnvironmentResultType cgiWriteEnvironment(char *filename);
  154. extern cgiEnvironmentResultType cgiReadEnvironment(char *filename);
  155.  
  156.  
  157. extern int cgiMain();
  158.  
  159. #endif /* CGI_C */
  160.  
  161.