gcgi  0.9.5
About: GCGI implements NCSA's Common Gateway Interface along with the extensions to that interface defined in RFC2388.
  Fossies Dox: gcgi-0.9.5.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

gcgi.h
Go to the documentation of this file.
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 {
51 } gcgiEnvVars;
52 
53 /*------ Return Values ------*/
54 typedef enum {
62 
63 
64 /*------ MIME types ------*/
65 typedef enum {
66  text,
74 } MimeType;
75 
76 typedef enum {
82 } MimeEncoding;
83 
84 typedef enum {
87 } MimeFormat;
88 
89 typedef enum {
94 
95 typedef enum {
102 } MimeHeader;
103 
104 typedef enum {
105  NONE = 0,
110 } HTTPHeader;
111 
112 /*------ CGI Functions ------*/
113 
114 /* Initialization Functions */
115 gcgiReturnType initCgi( void );
116 void freeCgi( void );
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);
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 
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);
169 gcgiReturnType gcgiFetchSelectIndex(char *field, char **data, int size, int *ret, int defaultVal);
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__ */
gcgiContentLength
Definition: gcgi.h:35
GCGITRUNCATED
Definition: gcgi.h:59
initCgi
gcgiReturnType initCgi(void)
Definition: gcgi.c:61
gcgiResetMultipleField
gcgiReturnType gcgiResetMultipleField(char *field)
Definition: gcgi.c:1099
gcgiHttpReferer
Definition: gcgi.h:33
MimeHeader
MimeHeader
Definition: gcgi.h:95
gcgiSendCookie
gcgiReturnType gcgiSendCookie(char *name, char *value, char *path, char *domain, char *expires, int secure, HTTPHeader header)
Definition: gcgi.c:420
gcgiFetchString
gcgiReturnType gcgiFetchString(char *field, char *ret, int max)
Definition: gcgi.c:858
gcgiFieldSizeCur
gcgiReturnType gcgiFieldSizeCur(char *field, int *ret)
Definition: gcgi.c:819
gcgiPathTranslated
Definition: gcgi.h:39
formdata
Definition: gcgi.h:92
gcgiRemoteUser
Definition: gcgi.h:44
gcgiEncodeUrlString
gcgiReturnType gcgiEncodeUrlString(char *text, char **encodedText, int *size)
Definition: code.c:318
gcgiDecodeBaseSixtyFourString
gcgiReturnType gcgiDecodeBaseSixtyFourString(char *text, char **decodedText, int *numBytes)
Definition: code.c:41
video
Definition: gcgi.h:69
gcgiFetchInteger
gcgiReturnType gcgiFetchInteger(char *field, int *ret, int defaultRet)
Definition: gcgi.c:630
gcgiFetchDouble
gcgiReturnType gcgiFetchDouble(char *field, double *ret, double defaultRet)
Definition: gcgi.c:688
gcgiPathInfo
Definition: gcgi.h:38
contentDescription
Definition: gcgi.h:99
text
Definition: gcgi.h:66
gcgiQueryString
Definition: gcgi.h:40
gcgiFetchCookies
gcgiReturnType gcgiFetchCookies(char ***cookies)
Definition: gcgi.c:448
gcgiFetchSelectIndex
gcgiReturnType gcgiFetchSelectIndex(char *field, char **data, int size, int *ret, int defaultVal)
Definition: gcgi.c:1113
gcgiSendContentDisp
gcgiReturnType gcgiSendContentDisp(MimeDisposition disp, char *filename, HTTPHeader header)
Definition: gcgi.c:353
binary
Definition: gcgi.h:79
sevenbit
Definition: gcgi.h:77
GCGIFATALERROR
Definition: gcgi.h:55
gcgiNumFields
gcgiReturnType gcgiNumFields(char *field, int *ret)
Definition: gcgi.c:614
gcgiScriptName
Definition: gcgi.h:46
DISPOSITION
Definition: gcgi.h:107
gcgiFetchMultipleCheckbox
gcgiReturnType gcgiFetchMultipleCheckbox(char *field, char **data, int size, int **ret)
Definition: gcgi.c:1153
inlined
Definition: gcgi.h:90
gcgiRequestMethod
Definition: gcgi.h:45
gcgiContentType
Definition: gcgi.h:36
GCGIBADDATA
Definition: gcgi.h:60
gcgiSendContentLength
gcgiReturnType gcgiSendContentLength(int length, HTTPHeader header)
Definition: gcgi.c:374
gcgiNumFormFields
gcgiReturnType gcgiNumFormFields(int *ret)
Definition: gcgi.c:605
unknown
Definition: gcgi.h:73
gcgiSendStatus
gcgiReturnType gcgiSendStatus(int status, char *message)
Definition: gcgi.c:397
multipart
Definition: gcgi.h:71
mimeVersion
Definition: gcgi.h:100
LENGTH
Definition: gcgi.h:108
gcgiSendCacheControl
gcgiReturnType gcgiSendCacheControl(char *cache, HTTPHeader header)
Definition: gcgi.c:406
eightbit
Definition: gcgi.h:78
gcgiReadKeyFromFile
gcgiReturnType gcgiReadKeyFromFile(char *path, unsigned char **key)
gcgiDecodeRfc2047String
gcgiReturnType gcgiDecodeRfc2047String(char *text, char **charset, char **decodedText)
Definition: code.c:229
basesixtyfour
Definition: gcgi.h:81
gcgiEncodeBaseSixtyFourString
gcgiReturnType gcgiEncodeBaseSixtyFourString(char *text, int numBytes, char **encodedText)
Definition: code.c:96
gcgiWriteKeyToFile
gcgiReturnType gcgiWriteKeyToFile(unsigned char *key, char *path)
gcgiRemoteAddr
Definition: gcgi.h:41
gcgiDebug
gcgiReturnType gcgiDebug(char *envVarsPath, char *cgiQueryPath)
Definition: gcgi.c:1248
gcgiFetchStringNoNewLinesNext
gcgiReturnType gcgiFetchStringNoNewLinesNext(char *field, char *ret, int max)
Definition: gcgi.c:947
gcgiOut
FILE * gcgiOut
Definition: gcgi.h:188
GCGIFIELDNOTFOUND
Definition: gcgi.h:57
gcgiFetchData
gcgiReturnType gcgiFetchData(char *field, char *ret, int max, MimeType *type, char **subtype, MimeEncoding *encoding, char **filename, int *truncated)
Definition: gcgi.c:987
gcgiFetchEnvVar
char * gcgiFetchEnvVar(int env)
Definition: gcgi.c:851
MimeDisposition
MimeDisposition
Definition: gcgi.h:89
NONE
Definition: gcgi.h:105
image
Definition: gcgi.h:67
gcgiGenerateKey
gcgiReturnType gcgiGenerateKey(unsigned char **key)
gcgiFieldSizeNext
gcgiReturnType gcgiFieldSizeNext(char *field, int *ret)
Definition: gcgi.c:835
gcgiSaveEnvVariables
gcgiReturnType gcgiSaveEnvVariables(char *path)
Definition: gcgi.c:1226
gcgiParseCookie
gcgiReturnType gcgiParseCookie(char *cookie, char **name, char **value)
Definition: gcgi.c:457
attachment
Definition: gcgi.h:91
fieldLimit
static size_t fieldLimit
Definition: gcgi.c:53
COOKIE
Definition: gcgi.h:106
gcgiServerSoftware
Definition: gcgi.h:50
gcgiRemoteIdent
Definition: gcgi.h:43
gcgiDecodeQuotedPrintableString
gcgiReturnType gcgiDecodeQuotedPrintableString(char *text, char **decodedText, int *size)
Definition: code.c:133
gcgiFetchCheckbox
gcgiReturnType gcgiFetchCheckbox(char *field, int *ret)
Definition: gcgi.c:1137
gcgiServerPort
Definition: gcgi.h:48
gcgiServerName
Definition: gcgi.h:47
gcgiEnvVars
gcgiEnvVars
Definition: gcgi.h:31
quotedprintable
Definition: gcgi.h:80
GCGIFIELDEMPTY
Definition: gcgi.h:58
gcgiHttpCookie
Definition: gcgi.h:32
message
Definition: gcgi.h:72
MimeType
MimeType
Definition: gcgi.h:65
HTTPHeader
HTTPHeader
Definition: gcgi.h:104
gcgiDecodeUrlEncodedString
gcgiReturnType gcgiDecodeUrlEncodedString(char *text, char **decodedText, int *size)
Definition: code.c:290
application
Definition: gcgi.h:70
gcgiSendEncryptedCookie
gcgiReturnType gcgiSendEncryptedCookie(char *name, char *value, char *path, char *domain, char *expires, int secure, unsigned char *key, HTTPHeader header)
gcgiGatewayInterface
Definition: gcgi.h:37
freeCgi
void freeCgi(void)
Definition: gcgi.c:96
fixed
Definition: gcgi.h:85
gcgiReturnType
gcgiReturnType
Definition: gcgi.h:54
gcgiSendLocation
gcgiReturnType gcgiSendLocation(char *redirectURL)
Definition: gcgi.c:388
MimeEncoding
MimeEncoding
Definition: gcgi.h:76
gcgiLoadEnvVariables
gcgiReturnType gcgiLoadEnvVariables(char *path)
Definition: gcgi.c:1170
unknownHeader
Definition: gcgi.h:101
gcgiFreeCookies
gcgiReturnType gcgiFreeCookies(char **cookies)
Definition: gcgi.c:478
gcgiRemoteHost
Definition: gcgi.h:42
contentType
Definition: gcgi.h:96
gcgiFieldLengthCur
gcgiReturnType gcgiFieldLengthCur(char *field, int *ret)
Definition: gcgi.c:765
gcgiFieldLengthNext
gcgiReturnType gcgiFieldLengthNext(char *field, int *ret)
Definition: gcgi.c:784
queryLimit
static size_t queryLimit
Definition: gcgi.c:54
gcgiFieldLength
gcgiReturnType gcgiFieldLength(char *field, int *ret)
Definition: gcgi.c:746
gcgiServerProtocol
Definition: gcgi.h:49
gcgiAuthType
Definition: gcgi.h:34
contentDisposition
Definition: gcgi.h:98
gcgiSendContentType
gcgiReturnType gcgiSendContentType(char *mimeType, char *name, char *charset, HTTPHeader header)
Definition: gcgi.c:333
gcgiFetchIntegerNext
gcgiReturnType gcgiFetchIntegerNext(char *field, int *ret, int defaultRet)
Definition: gcgi.c:659
gcgiEncodeQuotedPrintableString
gcgiReturnType gcgiEncodeQuotedPrintableString(char *text, char **encodedText, int *size)
Definition: code.c:175
flowed
Definition: gcgi.h:86
gcgiFreeMultipleString
gcgiReturnType gcgiFreeMultipleString(char **data)
Definition: gcgi.c:1083
LAST
Definition: gcgi.h:109
MimeFormat
MimeFormat
Definition: gcgi.h:84
gcgiFetchDataNext
gcgiReturnType gcgiFetchDataNext(char *field, char *ret, int max, MimeType *type, char **subtype, MimeEncoding *encoding, char **filename, int *truncated)
Definition: gcgi.c:1028
gcgiSetLimits
gcgiReturnType gcgiSetLimits(size_t fieldLimit, size_t queryLimit)
Definition: gcgi.c:108
audio
Definition: gcgi.h:68
contentEncoding
Definition: gcgi.h:97
gcgiFetchMultipleString
gcgiReturnType gcgiFetchMultipleString(char *field, char ***data)
Definition: gcgi.c:1054
gcgiFetchDoubleNext
gcgiReturnType gcgiFetchDoubleNext(char *field, double *ret, double defaultRet)
Definition: gcgi.c:717
gcgiParseEncryptedCookie
gcgiReturnType gcgiParseEncryptedCookie(char *cookie, unsigned char *key, char **name, char **value)
gcgiFieldSize
gcgiReturnType gcgiFieldSize(char *field, int *ret)
Definition: gcgi.c:803
gcgiFetchStringNoNewLines
gcgiReturnType gcgiFetchStringNoNewLines(char *field, char *ret, int max)
Definition: gcgi.c:909
GCGISUCCESS
Definition: gcgi.h:56
gcgiFetchStringNext
gcgiReturnType gcgiFetchStringNext(char *field, char *ret, int max)
Definition: gcgi.c:884
printQuery
gcgiReturnType printQuery(FILE *stream)
Definition: gcgi.c:1616