source: trunk/thirds/cgic206/cgic.h @ 27

Last change on this file since 27 was 1, checked in by djay, 15 years ago

Initial ZOO SVN Repository Import.

File size: 9.0 KB
Line 
1/* The CGI_C library, by Thomas Boutell, version 2.01. 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 "fcgi_stdio.h"
13//#include <stdio.h>
14
15/* The various CGI environment variables. Instead of using getenv(),
16        the programmer should refer to these, which are always
17        valid null-terminated strings (they may be empty, but they
18        will never be null). If these variables are used instead
19        of calling getenv(), then it will be possible to save
20        and restore CGI environments, which is highly convenient
21        for debugging. */
22
23extern 
24#ifdef __cplusplus
25"C" 
26#endif
27char *cgiServerSoftware;
28extern 
29#ifdef __cplusplus
30"C" 
31#endif
32char *cgiServerName;
33extern 
34#ifdef __cplusplus
35"C" 
36#endif
37char *cgiGatewayInterface;
38extern 
39#ifdef __cplusplus
40"C" 
41#endif
42char *cgiServerProtocol;
43extern 
44#ifdef __cplusplus
45"C" 
46#endif
47char *cgiServerPort;
48extern 
49#ifdef __cplusplus
50"C" 
51#endif
52char *cgiRequestMethod;
53extern 
54#ifdef __cplusplus
55"C" 
56#endif
57char *cgiPathInfo;
58extern 
59#ifdef __cplusplus
60"C" 
61#endif
62char *cgiPathTranslated;
63extern 
64#ifdef __cplusplus
65"C" 
66#endif
67char *cgiScriptName;
68extern 
69#ifdef __cplusplus
70"C" 
71#endif
72char *cgiQueryString;
73extern 
74#ifdef __cplusplus
75"C" 
76#endif
77char *cgiRemoteHost;
78extern 
79#ifdef __cplusplus
80"C" 
81#endif
82char *cgiRemoteAddr;
83extern 
84#ifdef __cplusplus
85"C" 
86#endif
87char *cgiAuthType;
88extern 
89#ifdef __cplusplus
90"C" 
91#endif
92char *cgiRemoteUser;
93extern 
94#ifdef __cplusplus
95"C" 
96#endif
97char *cgiRemoteIdent;
98extern 
99#ifdef __cplusplus
100"C" 
101#endif
102char *cgiContentType;
103extern 
104#ifdef __cplusplus
105"C" 
106#endif
107char *cgiAccept;
108extern 
109#ifdef __cplusplus
110"C" 
111#endif
112char *cgiUserAgent;
113extern 
114#ifdef __cplusplus
115"C" 
116#endif
117char *cgiReferrer;
118
119/* Cookies as sent to the server. You can also get them
120        individually, or as a string array; see the documentation. */
121extern 
122#ifdef __cplusplus
123"C" 
124#endif
125char *cgiCookie;
126
127/* A macro providing the same incorrect spelling that is
128        found in the HTTP/CGI specifications */
129#define cgiReferer cgiReferrer
130
131/* The number of bytes of data received.
132        Note that if the submission is a form submission
133        the library will read and parse all the information
134        directly from cgiIn; the programmer need not do so. */
135
136extern 
137#ifdef __cplusplus
138"C" 
139#endif
140int cgiContentLength;
141
142/* Pointer to CGI output. The cgiHeader functions should be used
143        first to output the mime headers; the output HTML
144        page, GIF image or other web document should then be written
145        to cgiOut by the programmer. In the standard CGIC library,
146        cgiOut is always equivalent to stdout. */
147
148extern 
149#ifdef __cplusplus
150"C" 
151#endif
152FILE *cgiOut;
153
154/* Pointer to CGI input. The programmer does not read from this.
155        We have continued to export it for backwards compatibility
156        so that cgic 1.x applications link properly. */
157
158extern 
159#ifdef __cplusplus
160"C" 
161#endif
162FILE *cgiIn;
163
164/* Possible return codes from the cgiForm family of functions (see below). */
165
166typedef enum {
167        cgiFormSuccess,
168        cgiFormTruncated,
169        cgiFormBadType,
170        cgiFormEmpty,
171        cgiFormNotFound,
172        cgiFormConstrained,
173        cgiFormNoSuchChoice,
174        cgiFormMemory,
175        cgiFormNoFileName,
176        cgiFormNoContentType,
177        cgiFormNotAFile,
178        cgiFormOpenFailed,
179        cgiFormIO,
180        cgiFormEOF
181} cgiFormResultType;
182
183/* These functions are used to retrieve form data. See
184        cgic.html for documentation. */
185
186extern 
187#ifdef __cplusplus
188"C" 
189#endif
190cgiFormResultType cgiFormString(
191        char *name, char *result, int max);
192
193extern 
194#ifdef __cplusplus
195"C" 
196#endif
197cgiFormResultType cgiFormStringNoNewlines(
198        char *name, char *result, int max);
199
200
201extern 
202#ifdef __cplusplus
203"C" 
204#endif
205cgiFormResultType cgiFormStringSpaceNeeded(
206        char *name, int *length);
207
208
209extern 
210#ifdef __cplusplus
211"C" 
212#endif
213cgiFormResultType cgiFormStringMultiple(
214        char *name, char ***ptrToStringArray);
215
216extern 
217#ifdef __cplusplus
218"C" 
219#endif
220void cgiStringArrayFree(char **stringArray);
221
222extern 
223#ifdef __cplusplus
224"C" 
225#endif
226cgiFormResultType cgiFormInteger(
227        char *name, int *result, int defaultV);
228
229extern 
230#ifdef __cplusplus
231"C" 
232#endif
233cgiFormResultType cgiFormIntegerBounded(
234        char *name, int *result, int min, int max, int defaultV);
235
236extern 
237#ifdef __cplusplus
238"C" 
239#endif
240cgiFormResultType cgiFormDouble(
241        char *name, double *result, double defaultV);
242
243extern 
244#ifdef __cplusplus
245"C" 
246#endif
247cgiFormResultType cgiFormDoubleBounded(
248        char *name, double *result, double min, double max, double defaultV);
249
250extern 
251#ifdef __cplusplus
252"C" 
253#endif
254cgiFormResultType cgiFormSelectSingle(
255        char *name, char **choicesText, int choicesTotal, 
256        int *result, int defaultV);     
257
258
259extern 
260#ifdef __cplusplus
261"C" 
262#endif
263cgiFormResultType cgiFormSelectMultiple(
264        char *name, char **choicesText, int choicesTotal, 
265        int *result, int *invalid);
266
267/* Just an alias; users have asked for this */
268#define cgiFormSubmitClicked cgiFormCheckboxSingle
269
270extern 
271#ifdef __cplusplus
272"C" 
273#endif
274cgiFormResultType cgiFormCheckboxSingle(
275        char *name);
276
277extern 
278#ifdef __cplusplus
279"C" 
280#endif
281cgiFormResultType cgiFormCheckboxMultiple(
282        char *name, char **valuesText, int valuesTotal, 
283        int *result, int *invalid);
284
285extern 
286#ifdef __cplusplus
287"C" 
288#endif
289cgiFormResultType cgiFormRadio(
290        char *name, char **valuesText, int valuesTotal, 
291        int *result, int defaultV);     
292
293/* The paths returned by this function are the original names of files
294        as reported by the uploading web browser and shoult NOT be
295        blindly assumed to be "safe" names for server-side use! */
296extern 
297#ifdef __cplusplus
298"C" 
299#endif
300cgiFormResultType cgiFormFileName(
301        char *name, char *result, int max);
302
303/* The content type of the uploaded file, as reported by the browser.
304        It should NOT be assumed that browsers will never falsify
305        such information. */
306extern 
307#ifdef __cplusplus
308"C" 
309#endif
310cgiFormResultType cgiFormFileContentType(
311        char *name, char *result, int max);
312
313extern 
314#ifdef __cplusplus
315"C" 
316#endif
317cgiFormResultType cgiFormFileSize(
318        char *name, int *sizeP);
319
320typedef struct cgiFileStruct *cgiFilePtr;
321
322extern 
323#ifdef __cplusplus
324"C" 
325#endif
326cgiFormResultType cgiFormFileOpen(
327        char *name, cgiFilePtr *cfpp);
328
329extern 
330#ifdef __cplusplus
331"C" 
332#endif
333cgiFormResultType cgiFormFileRead(
334        cgiFilePtr cfp, char *buffer, int bufferSize, int *gotP);
335
336extern 
337#ifdef __cplusplus
338"C" 
339#endif
340cgiFormResultType cgiFormFileClose(
341        cgiFilePtr cfp);
342
343extern 
344#ifdef __cplusplus
345"C" 
346#endif
347cgiFormResultType cgiCookieString(
348        char *name, char *result, int max);
349
350extern 
351#ifdef __cplusplus
352"C" 
353#endif
354cgiFormResultType cgiCookieInteger(
355        char *name, int *result, int defaultV);
356
357cgiFormResultType cgiCookies(
358        char ***ptrToStringArray);
359
360/* path can be null or empty in which case a path of / (entire site) is set.
361        domain can be a single web site; if it is an entire domain, such as
362        'boutell.com', it should begin with a dot: '.boutell.com' */
363extern 
364#ifdef __cplusplus
365"C" 
366#endif
367void cgiHeaderCookieSetString(char *name, char *value, 
368        int secondsToLive, char *path, char *domain);
369extern 
370#ifdef __cplusplus
371"C" 
372#endif
373void cgiHeaderCookieSetInteger(char *name, int value,
374        int secondsToLive, char *path, char *domain);
375extern 
376#ifdef __cplusplus
377"C" 
378#endif
379void cgiHeaderLocation(char *redirectUrl);
380extern 
381#ifdef __cplusplus
382"C" 
383#endif
384void cgiHeaderStatus(int status, char *statusMessage);
385extern 
386#ifdef __cplusplus
387"C" 
388#endif
389void cgiHeaderContentType(char *mimeType);
390
391typedef enum {
392        cgiEnvironmentIO,
393        cgiEnvironmentMemory,
394        cgiEnvironmentSuccess,
395        cgiEnvironmentWrongVersion
396} cgiEnvironmentResultType;
397
398extern 
399#ifdef __cplusplus
400"C" 
401#endif
402cgiEnvironmentResultType cgiWriteEnvironment(char *filename);
403extern cgiEnvironmentResultType cgiReadEnvironment(char *filename);
404
405extern 
406#ifdef __cplusplus
407"C" 
408#endif
409int cgiMain();
410extern 
411#ifdef __cplusplus
412"C" 
413#endif
414int cgiMain_init();
415
416
417extern 
418#ifdef __cplusplus
419"C" 
420#endif
421cgiFormResultType cgiFormEntries(
422        char ***ptrToStringArray);
423
424/* Output string with the <, &, and > characters HTML-escaped.
425        's' is null-terminated. Returns cgiFormIO in the event
426        of error, cgiFormSuccess otherwise. */
427cgiFormResultType cgiHtmlEscape(char *s);
428
429/* Output data with the <, &, and > characters HTML-escaped.
430        'data' is not null-terminated; 'len' is the number of
431        bytes in 'data'. Returns cgiFormIO in the event
432        of error, cgiFormSuccess otherwise. */
433cgiFormResultType cgiHtmlEscapeData(char *data, int len);
434
435/* Output string with the " character HTML-escaped, and no
436        other characters escaped. This is useful when outputting
437        the contents of a tag attribute such as 'href' or 'src'.
438        's' is null-terminated. Returns cgiFormIO in the event
439        of error, cgiFormSuccess otherwise. */
440cgiFormResultType cgiValueEscape(char *s);
441
442/* Output data with the " character HTML-escaped, and no
443        other characters escaped. This is useful when outputting
444        the contents of a tag attribute such as 'href' or 'src'.
445        'data' is not null-terminated; 'len' is the number of
446        bytes in 'data'. Returns cgiFormIO in the event
447        of error, cgiFormSuccess otherwise. */
448cgiFormResultType cgiValueEscapeData(char *data, int len);
449
450#endif /* CGI_C */
451
Note: See TracBrowser for help on using the repository browser.

Search

Context Navigation

ZOO Sponsors

http://www.zoo-project.org/trac/chrome/site/img/geolabs-logo.pnghttp://www.zoo-project.org/trac/chrome/site/img/neogeo-logo.png http://www.zoo-project.org/trac/chrome/site/img/apptech-logo.png http://www.zoo-project.org/trac/chrome/site/img/3liz-logo.png http://www.zoo-project.org/trac/chrome/site/img/gateway-logo.png

Become a sponsor !

Knowledge partners

http://www.zoo-project.org/trac/chrome/site/img/ocu-logo.png http://www.zoo-project.org/trac/chrome/site/img/gucas-logo.png http://www.zoo-project.org/trac/chrome/site/img/polimi-logo.png http://www.zoo-project.org/trac/chrome/site/img/fem-logo.png http://www.zoo-project.org/trac/chrome/site/img/supsi-logo.png http://www.zoo-project.org/trac/chrome/site/img/cumtb-logo.png

Become a knowledge partner

Related links

http://zoo-project.org/img/ogclogo.png http://zoo-project.org/img/osgeologo.png