source: trunk/thirds/cgic206/cgic.h

Last change on this file was 348, checked in by neteler, 8 years ago

set correctly svn propset

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/x-chdr
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
127extern 
128#ifdef __cplusplus
129"C" 
130#endif
131char *cgiSid;
132
133/* A macro providing the same incorrect spelling that is
134        found in the HTTP/CGI specifications */
135#define cgiReferer cgiReferrer
136
137/* The number of bytes of data received.
138        Note that if the submission is a form submission
139        the library will read and parse all the information
140        directly from cgiIn; the programmer need not do so. */
141
142extern 
143#ifdef __cplusplus
144"C" 
145#endif
146int cgiContentLength;
147
148/* Pointer to CGI output. The cgiHeader functions should be used
149        first to output the mime headers; the output HTML
150        page, GIF image or other web document should then be written
151        to cgiOut by the programmer. In the standard CGIC library,
152        cgiOut is always equivalent to stdout. */
153
154extern 
155#ifdef __cplusplus
156"C" 
157#endif
158FILE *cgiOut;
159
160/* Pointer to CGI input. The programmer does not read from this.
161        We have continued to export it for backwards compatibility
162        so that cgic 1.x applications link properly. */
163
164extern 
165#ifdef __cplusplus
166"C" 
167#endif
168FILE *cgiIn;
169
170/* Possible return codes from the cgiForm family of functions (see below). */
171
172typedef enum {
173        cgiFormSuccess,
174        cgiFormTruncated,
175        cgiFormBadType,
176        cgiFormEmpty,
177        cgiFormNotFound,
178        cgiFormConstrained,
179        cgiFormNoSuchChoice,
180        cgiFormMemory,
181        cgiFormNoFileName,
182        cgiFormNoContentType,
183        cgiFormNotAFile,
184        cgiFormOpenFailed,
185        cgiFormIO,
186        cgiFormEOF
187} cgiFormResultType;
188
189/* These functions are used to retrieve form data. See
190        cgic.html for documentation. */
191
192extern 
193#ifdef __cplusplus
194"C" 
195#endif
196cgiFormResultType cgiFormString(
197        char *name, char *result, int max);
198
199extern 
200#ifdef __cplusplus
201"C" 
202#endif
203cgiFormResultType cgiFormStringNoNewlines(
204        char *name, char *result, int max);
205
206
207extern 
208#ifdef __cplusplus
209"C" 
210#endif
211cgiFormResultType cgiFormStringSpaceNeeded(
212        char *name, int *length);
213
214
215extern 
216#ifdef __cplusplus
217"C" 
218#endif
219cgiFormResultType cgiFormStringMultiple(
220        char *name, char ***ptrToStringArray);
221
222extern 
223#ifdef __cplusplus
224"C" 
225#endif
226void cgiStringArrayFree(char **stringArray);
227
228extern 
229#ifdef __cplusplus
230"C" 
231#endif
232cgiFormResultType cgiFormInteger(
233        char *name, int *result, int defaultV);
234
235extern 
236#ifdef __cplusplus
237"C" 
238#endif
239cgiFormResultType cgiFormIntegerBounded(
240        char *name, int *result, int min, int max, int defaultV);
241
242extern 
243#ifdef __cplusplus
244"C" 
245#endif
246cgiFormResultType cgiFormDouble(
247        char *name, double *result, double defaultV);
248
249extern 
250#ifdef __cplusplus
251"C" 
252#endif
253cgiFormResultType cgiFormDoubleBounded(
254        char *name, double *result, double min, double max, double defaultV);
255
256extern 
257#ifdef __cplusplus
258"C" 
259#endif
260cgiFormResultType cgiFormSelectSingle(
261        char *name, char **choicesText, int choicesTotal, 
262        int *result, int defaultV);     
263
264
265extern 
266#ifdef __cplusplus
267"C" 
268#endif
269cgiFormResultType cgiFormSelectMultiple(
270        char *name, char **choicesText, int choicesTotal, 
271        int *result, int *invalid);
272
273/* Just an alias; users have asked for this */
274#define cgiFormSubmitClicked cgiFormCheckboxSingle
275
276extern 
277#ifdef __cplusplus
278"C" 
279#endif
280cgiFormResultType cgiFormCheckboxSingle(
281        char *name);
282
283extern 
284#ifdef __cplusplus
285"C" 
286#endif
287cgiFormResultType cgiFormCheckboxMultiple(
288        char *name, char **valuesText, int valuesTotal, 
289        int *result, int *invalid);
290
291extern 
292#ifdef __cplusplus
293"C" 
294#endif
295cgiFormResultType cgiFormRadio(
296        char *name, char **valuesText, int valuesTotal, 
297        int *result, int defaultV);     
298
299/* The paths returned by this function are the original names of files
300        as reported by the uploading web browser and shoult NOT be
301        blindly assumed to be "safe" names for server-side use! */
302extern 
303#ifdef __cplusplus
304"C" 
305#endif
306cgiFormResultType cgiFormFileName(
307        char *name, char *result, int max);
308
309/* The content type of the uploaded file, as reported by the browser.
310        It should NOT be assumed that browsers will never falsify
311        such information. */
312extern 
313#ifdef __cplusplus
314"C" 
315#endif
316cgiFormResultType cgiFormFileContentType(
317        char *name, char *result, int max);
318
319extern 
320#ifdef __cplusplus
321"C" 
322#endif
323cgiFormResultType cgiFormFileSize(
324        char *name, int *sizeP);
325
326typedef struct cgiFileStruct *cgiFilePtr;
327
328extern 
329#ifdef __cplusplus
330"C" 
331#endif
332cgiFormResultType cgiFormFileOpen(
333        char *name, cgiFilePtr *cfpp);
334
335extern 
336#ifdef __cplusplus
337"C" 
338#endif
339cgiFormResultType cgiFormFileRead(
340        cgiFilePtr cfp, char *buffer, int bufferSize, int *gotP);
341
342extern 
343#ifdef __cplusplus
344"C" 
345#endif
346cgiFormResultType cgiFormFileClose(
347        cgiFilePtr cfp);
348
349extern 
350#ifdef __cplusplus
351"C" 
352#endif
353cgiFormResultType cgiCookieString(
354        char *name, char *result, int max);
355
356extern 
357#ifdef __cplusplus
358"C" 
359#endif
360cgiFormResultType cgiCookieInteger(
361        char *name, int *result, int defaultV);
362
363cgiFormResultType cgiCookies(
364        char ***ptrToStringArray);
365
366/* path can be null or empty in which case a path of / (entire site) is set.
367        domain can be a single web site; if it is an entire domain, such as
368        'boutell.com', it should begin with a dot: '.boutell.com' */
369extern 
370#ifdef __cplusplus
371"C" 
372#endif
373void cgiHeaderCookieSetString(char *name, char *value, 
374        int secondsToLive, char *path, char *domain);
375extern 
376#ifdef __cplusplus
377"C" 
378#endif
379void cgiHeaderCookieSetInteger(char *name, int value,
380        int secondsToLive, char *path, char *domain);
381extern 
382#ifdef __cplusplus
383"C" 
384#endif
385void cgiHeaderLocation(char *redirectUrl);
386extern 
387#ifdef __cplusplus
388"C" 
389#endif
390void cgiHeaderStatus(int status, char *statusMessage);
391extern 
392#ifdef __cplusplus
393"C" 
394#endif
395void cgiHeaderContentType(char *mimeType);
396
397typedef enum {
398        cgiEnvironmentIO,
399        cgiEnvironmentMemory,
400        cgiEnvironmentSuccess,
401        cgiEnvironmentWrongVersion
402} cgiEnvironmentResultType;
403
404extern 
405#ifdef __cplusplus
406"C" 
407#endif
408cgiEnvironmentResultType cgiWriteEnvironment(char *filename);
409extern cgiEnvironmentResultType cgiReadEnvironment(char *filename);
410
411extern 
412#ifdef __cplusplus
413"C" 
414#endif
415int cgiMain();
416extern 
417#ifdef __cplusplus
418"C" 
419#endif
420int cgiMain_init();
421
422
423extern 
424#ifdef __cplusplus
425"C" 
426#endif
427cgiFormResultType cgiFormEntries(
428        char ***ptrToStringArray);
429
430/* Output string with the <, &, and > characters HTML-escaped.
431        's' is null-terminated. Returns cgiFormIO in the event
432        of error, cgiFormSuccess otherwise. */
433cgiFormResultType cgiHtmlEscape(char *s);
434
435/* Output data with the <, &, and > characters HTML-escaped.
436        'data' is not null-terminated; 'len' is the number of
437        bytes in 'data'. Returns cgiFormIO in the event
438        of error, cgiFormSuccess otherwise. */
439cgiFormResultType cgiHtmlEscapeData(char *data, int len);
440
441/* Output string with the " character HTML-escaped, and no
442        other characters escaped. This is useful when outputting
443        the contents of a tag attribute such as 'href' or 'src'.
444        's' is null-terminated. Returns cgiFormIO in the event
445        of error, cgiFormSuccess otherwise. */
446cgiFormResultType cgiValueEscape(char *s);
447
448/* Output data with the " character HTML-escaped, and no
449        other characters escaped. This is useful when outputting
450        the contents of a tag attribute such as 'href' or 'src'.
451        'data' is not null-terminated; 'len' is the number of
452        bytes in 'data'. Returns cgiFormIO in the event
453        of error, cgiFormSuccess otherwise. */
454cgiFormResultType cgiValueEscapeData(char *data, int len);
455
456#endif /* CGI_C */
457
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