"Fossies" - the Fresh Open Source Software Archive

Member "libgcgi.a-0.9.5/src/gcgi.h" (22 Jun 2002, 6710 Bytes) of package /linux/www/old/gcgi-0.9.5.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "gcgi.h" see the Fossies "Dox" file reference documentation.

    1 /* -*-mode:c; c-style:k&r; c-basic-offset:4; -*- */
    2 /*
    3  * GCGI Library, implementing NCSA'a Common Gateway Interface and RFC2338.
    4  * Copyright (C) 2001-2002 Julian Catchen, julian@catchen.org
    5  *
    6  * This library is free software; you can redistribute it and/or
    7  * modify it under the terms of the GNU Lesser General Public
    8  * License as published by the Free Software Foundation; either
    9  * version 2.1 of the License, or (at your option) any later version.
   10  *
   11  * This library is distributed in the hope that it will be useful,
   12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
   13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   14  * Lesser General Public License for more details.
   15  *
   16  * You should have received a copy of the GNU Lesser General Public
   17  * License along with this library; if not, write to the Free Software
   18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   19  */
   20 
   21 #ifndef __GCGI_H__
   22 #define __GCGI_H__
   23 
   24 #include <stdio.h>
   25 
   26 #ifdef __cplusplus
   27 extern "C" {
   28 #endif
   29 
   30 /*------ Enumerations ------*/
   31 typedef enum {
   32     gcgiHttpCookie = 0,
   33     gcgiHttpReferer,
   34     gcgiAuthType,
   35     gcgiContentLength,
   36     gcgiContentType,
   37     gcgiGatewayInterface,
   38     gcgiPathInfo,
   39     gcgiPathTranslated,
   40     gcgiQueryString,
   41     gcgiRemoteAddr,
   42     gcgiRemoteHost,
   43     gcgiRemoteIdent,
   44     gcgiRemoteUser,
   45     gcgiRequestMethod,
   46     gcgiScriptName,
   47     gcgiServerName,
   48     gcgiServerPort,
   49     gcgiServerProtocol,
   50     gcgiServerSoftware
   51 } gcgiEnvVars;
   52 
   53 /*------ Return Values ------*/
   54 typedef enum {
   55     GCGIFATALERROR = -1,
   56     GCGISUCCESS,
   57     GCGIFIELDNOTFOUND,
   58     GCGIFIELDEMPTY,
   59     GCGITRUNCATED,
   60     GCGIBADDATA
   61 } gcgiReturnType;
   62 
   63 
   64 /*------ MIME types ------*/
   65 typedef enum {
   66     text, 
   67     image, 
   68     audio, 
   69     video, 
   70     application, 
   71     multipart, 
   72     message, 
   73     unknown
   74 } MimeType;
   75 
   76 typedef enum {
   77     sevenbit, 
   78     eightbit, 
   79     binary, 
   80     quotedprintable, 
   81     basesixtyfour
   82 } MimeEncoding;
   83 
   84 typedef enum {
   85     fixed,
   86     flowed
   87 } MimeFormat;
   88 
   89 typedef enum {
   90     inlined,
   91     attachment,
   92     formdata
   93 } MimeDisposition;
   94 
   95 typedef enum {
   96     contentType,
   97     contentEncoding,
   98     contentDisposition,
   99     contentDescription,
  100     mimeVersion,
  101     unknownHeader
  102 } MimeHeader;
  103     
  104 typedef enum {
  105     NONE = 0,
  106     COOKIE,
  107     DISPOSITION,
  108     LENGTH,
  109     LAST
  110 } HTTPHeader;
  111 
  112 /*------ CGI Functions ------*/
  113 
  114 /* Initialization Functions */
  115 gcgiReturnType  initCgi( void );
  116 void            freeCgi( void );
  117 gcgiReturnType  gcgiSetLimits(size_t fieldLimit, size_t queryLimit);
  118 
  119 /* HTTP Header Functions */
  120 gcgiReturnType  gcgiSendContentType(char *mimeType, char *name, char *charset, HTTPHeader header);
  121 gcgiReturnType  gcgiSendContentDisp(MimeDisposition disp, char *filename, HTTPHeader header);
  122 gcgiReturnType  gcgiSendContentLength(int length, HTTPHeader header);
  123 gcgiReturnType  gcgiSendCacheControl(char *cache, HTTPHeader header);
  124 gcgiReturnType  gcgiSendLocation(char *redirectURL);
  125 gcgiReturnType  gcgiSendStatus(int status, char *message);
  126 
  127 /* Cookie Handling Functions */
  128 gcgiReturnType  gcgiSendCookie(char *name, char *value, char *path, char *domain, char *expires, 
  129                    int secure, HTTPHeader header);
  130 gcgiReturnType  gcgiFetchCookies(char ***cookies);
  131 gcgiReturnType  gcgiParseCookie(char *cookie, char **name, char **value);
  132 gcgiReturnType  gcgiFreeCookies(char **cookies);
  133 
  134 gcgiReturnType  gcgiSendEncryptedCookie(char *name, char *value, char *path, char *domain, char *expires, 
  135                     int secure, unsigned char *key, HTTPHeader header);
  136 gcgiReturnType  gcgiParseEncryptedCookie(char *cookie, unsigned char *key, char **name, char **value);
  137 gcgiReturnType  gcgiGenerateKey(unsigned char **key);
  138 gcgiReturnType  gcgiWriteKeyToFile(unsigned char *key, char *path);
  139 gcgiReturnType  gcgiReadKeyFromFile(char *path, unsigned char **key);
  140 
  141 /* Data Fetching Functions */
  142 char           *gcgiFetchEnvVar(int env);
  143 gcgiReturnType  gcgiFetchInteger(char *field, int *ret, int defaultRet);
  144 gcgiReturnType  gcgiFetchIntegerNext(char *field, int *ret, int defaultRet);
  145 gcgiReturnType  gcgiFetchDouble(char *field, double *ret, double defaultRet);
  146 gcgiReturnType  gcgiFetchDoubleNext(char *field, double *ret, double defaultRet);
  147 gcgiReturnType  gcgiFetchString(char *field, char *ret, int max);
  148 gcgiReturnType  gcgiFetchStringNext(char *field, char *ret, int max);
  149 gcgiReturnType  gcgiFetchStringNoNewLines(char *field, char *ret, int max);
  150 gcgiReturnType  gcgiFetchStringNoNewLinesNext(char *field, char *ret, int max);
  151 gcgiReturnType  gcgiFetchData(char *field, char *ret, int max, MimeType *type, 
  152                   char **subtype, MimeEncoding *encoding, char **filename, int *truncated);
  153 gcgiReturnType  gcgiFetchDataNext(char *field, char *ret, int max, MimeType *type, 
  154                   char **subtype, MimeEncoding *encoding, char **filename, int *truncated);
  155 gcgiReturnType  gcgiFieldLength(char *field, int *ret);
  156 gcgiReturnType  gcgiFieldLengthCur(char *field, int *ret);
  157 gcgiReturnType  gcgiFieldLengthNext(char *field, int *ret);
  158 gcgiReturnType  gcgiFieldSize(char *field, int *ret);
  159 gcgiReturnType  gcgiFieldSizeCur(char *field, int *ret);
  160 gcgiReturnType  gcgiFieldSizeNext(char *field, int *ret);
  161 
  162 gcgiReturnType  gcgiNumFormFields(int *ret);
  163 gcgiReturnType  gcgiNumFields(char *field, int *ret);
  164 
  165 gcgiReturnType  gcgiFetchCheckbox(char *field, int *ret);
  166 gcgiReturnType  gcgiFetchMultipleCheckbox(char *field, char **data, int size, int **ret);
  167 gcgiReturnType  gcgiFetchMultipleString(char *field, char ***data);
  168 gcgiReturnType  gcgiFreeMultipleString(char **data);
  169 gcgiReturnType  gcgiFetchSelectIndex(char *field, char **data, int size, int *ret, int defaultVal);
  170 gcgiReturnType  gcgiResetMultipleField(char *field);
  171 gcgiReturnType  gcgiLoadEnvVariables(char *path);
  172 gcgiReturnType  gcgiSaveEnvVariables(char *path);
  173 gcgiReturnType  gcgiDebug(char *envVarsPath, char *cgiQueryPath);
  174 
  175 /* Encoding/Decoding Functions */
  176 gcgiReturnType  gcgiDecodeBaseSixtyFourString(char *text, char **decodedText, int *numBytes);
  177 gcgiReturnType  gcgiEncodeBaseSixtyFourString(char *text, int numBytes, char **encodedText);
  178 gcgiReturnType  gcgiDecodeQuotedPrintableString(char *text, char **decodedText, int *size);
  179 gcgiReturnType  gcgiEncodeQuotedPrintableString(char *text, char **encodedText, int *size);
  180 gcgiReturnType  gcgiDecodeRfc2047String(char *text, char **charset, char **decodedText);
  181 gcgiReturnType  gcgiDecodeUrlEncodedString(char *text, char **decodedText, int *size);
  182 gcgiReturnType  gcgiEncodeUrlString(char *text, char **encodedText, int *size);
  183 
  184 /*------ Debugging Functions ------*/
  185 gcgiReturnType  printQuery(FILE *stream);
  186 
  187 /*------ Global Variables ------*/
  188 FILE *gcgiOut;
  189 
  190 #ifdef __cplusplus
  191 };
  192 #endif
  193 
  194 #endif  /* __GCGI_H__ */