00001
00002
00003
00004
00005
00006 #ifndef CGI_C
00007 #define CGI_C 1
00008
00009
00010
00011
00012 #include <stdio.h>
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 extern char *cgiServerSoftware;
00023 extern char *cgiServerName;
00024 extern char *cgiGatewayInterface;
00025 extern char *cgiServerProtocol;
00026 extern char *cgiServerPort;
00027 extern char *cgiRequestMethod;
00028 extern char *cgiPathInfo;
00029 extern char *cgiPathTranslated;
00030 extern char *cgiScriptName;
00031 extern char *cgiQueryString;
00032 extern char *cgiRemoteHost;
00033 extern char *cgiRemoteAddr;
00034 extern char *cgiAuthType;
00035 extern char *cgiRemoteUser;
00036 extern char *cgiRemoteIdent;
00037 extern char *cgiContentType;
00038 extern char *cgiAccept;
00039 extern char *cgiUserAgent;
00040 extern char *cgiReferrer;
00041
00042
00043
00044 extern char *cgiCookie;
00045
00046
00047
00048 #define cgiReferer cgiReferrer
00049
00050
00051
00052
00053
00054
00055 extern int cgiContentLength;
00056
00057
00058
00059
00060
00061
00062
00063 extern FILE *cgiOut;
00064
00065
00066
00067
00068
00069 extern FILE *cgiIn;
00070
00071
00072
00073 typedef enum {
00074 cgiFormSuccess,
00075 cgiFormTruncated,
00076 cgiFormBadType,
00077 cgiFormEmpty,
00078 cgiFormNotFound,
00079 cgiFormConstrained,
00080 cgiFormNoSuchChoice,
00081 cgiFormMemory,
00082 cgiFormNoFileName,
00083 cgiFormNoContentType,
00084 cgiFormNotAFile,
00085 cgiFormOpenFailed,
00086 cgiFormIO,
00087 cgiFormEOF
00088 } cgiFormResultType;
00089
00090
00091
00092
00093 extern cgiFormResultType cgiFormString(
00094 char *name, char *result, int max);
00095
00096 extern cgiFormResultType cgiFormStringNoNewlines(
00097 char *name, char *result, int max);
00098
00099
00100 extern cgiFormResultType cgiFormStringSpaceNeeded(
00101 char *name, int *length);
00102
00103
00104 extern cgiFormResultType cgiFormStringMultiple(
00105 char *name, char ***ptrToStringArray);
00106
00107 extern void cgiStringArrayFree(char **stringArray);
00108
00109 extern cgiFormResultType cgiFormInteger(
00110 char *name, int *result, int defaultV);
00111
00112 extern cgiFormResultType cgiFormIntegerBounded(
00113 char *name, int *result, int min, int max, int defaultV);
00114
00115 extern cgiFormResultType cgiFormDouble(
00116 char *name, double *result, double defaultV);
00117
00118 extern cgiFormResultType cgiFormDoubleBounded(
00119 char *name, double *result, double min, double max, double defaultV);
00120
00121 extern cgiFormResultType cgiFormSelectSingle(
00122 char *name, char **choicesText, int choicesTotal,
00123 int *result, int defaultV);
00124
00125
00126 extern cgiFormResultType cgiFormSelectMultiple(
00127 char *name, char **choicesText, int choicesTotal,
00128 int *result, int *invalid);
00129
00130
00131 #define cgiFormSubmitClicked cgiFormCheckboxSingle
00132
00133 extern cgiFormResultType cgiFormCheckboxSingle(
00134 char *name);
00135
00136 extern cgiFormResultType cgiFormCheckboxMultiple(
00137 char *name, char **valuesText, int valuesTotal,
00138 int *result, int *invalid);
00139
00140 extern cgiFormResultType cgiFormRadio(
00141 char *name, char **valuesText, int valuesTotal,
00142 int *result, int defaultV);
00143
00144
00145
00146
00147 extern cgiFormResultType cgiFormFileName(
00148 char *name, char *result, int max);
00149
00150
00151
00152
00153 extern cgiFormResultType cgiFormFileContentType(
00154 char *name, char *result, int max);
00155
00156 extern cgiFormResultType cgiFormFileSize(
00157 char *name, int *sizeP);
00158
00159 typedef struct cgiFileStruct *cgiFilePtr;
00160
00161 extern cgiFormResultType cgiFormFileOpen(
00162 char *name, cgiFilePtr *cfpp);
00163
00164 extern cgiFormResultType cgiFormFileRead(
00165 cgiFilePtr cfp, char *buffer, int bufferSize, int *gotP);
00166
00167 extern cgiFormResultType cgiFormFileClose(
00168 cgiFilePtr cfp);
00169
00170 extern cgiFormResultType cgiCookieString(
00171 char *name, char *result, int max);
00172
00173 extern cgiFormResultType cgiCookieInteger(
00174 char *name, int *result, int defaultV);
00175
00176 cgiFormResultType cgiCookies(
00177 char ***ptrToStringArray);
00178
00179
00180
00181
00182 extern void cgiHeaderCookieSetString(char *name, char *value,
00183 int secondsToLive, char *path, char *domain);
00184 extern void cgiHeaderCookieSetInteger(char *name, int value,
00185 int secondsToLive, char *path, char *domain);
00186 extern void cgiHeaderLocation(char *redirectUrl);
00187 extern void cgiHeaderStatus(int status, char *statusMessage);
00188 extern void cgiHeaderContentType(char *mimeType);
00189
00190 typedef enum {
00191 cgiEnvironmentIO,
00192 cgiEnvironmentMemory,
00193 cgiEnvironmentSuccess,
00194 cgiEnvironmentWrongVersion
00195 } cgiEnvironmentResultType;
00196
00197 extern cgiEnvironmentResultType cgiWriteEnvironment(char *filename);
00198 extern cgiEnvironmentResultType cgiReadEnvironment(char *filename);
00199
00200 extern int cgiMain();
00201
00202 extern cgiFormResultType cgiFormEntries(
00203 char ***ptrToStringArray);
00204
00205
00206
00207
00208 cgiFormResultType cgiHtmlEscape(char *s);
00209
00210
00211
00212
00213
00214 cgiFormResultType cgiHtmlEscapeData(char *data, int len);
00215
00216
00217
00218
00219
00220
00221 cgiFormResultType cgiValueEscape(char *s);
00222
00223
00224
00225
00226
00227
00228
00229 cgiFormResultType cgiValueEscapeData(char *data, int len);
00230
00231 #endif
00232