#include "common.h"#include "hash.h"#include "cheapcgi.h"#include "portable.h"#include "linefile.h"#include "errabort.h"#include "mime.h"Include dependency graph for cheapcgi.c:

Go to the source code of this file.
Defines | |
| #define | memmem(hay, haySize, needle, needleSize) memMatch(needle, needleSize, hay, haySize) |
Functions | |
| void | dumpCookieList () |
| void | useTempFile () |
| boolean | cgiIsOnWeb () |
| char * | cgiScriptName () |
| char * | cgiServerName () |
| char * | _cgiRawInput () |
| static void | getQueryInput () |
| static void | getPostInput () |
| static void | cgiParseMultipart (struct hash **retHash, struct cgiVar **retList) |
| static void | parseCookies (struct hash **retHash, struct cgiVar **retList) |
| char * | findCookieData (char *varName) |
| static char * | cgiInputSource (char *s) |
| static void | _cgiFindInput (char *method) |
| static void | cgiParseInputAbort (char *input, struct hash **retHash, struct cgiVar **retList) |
| static void | cgiParseAbort () |
| boolean | cgiParseInput (char *input, struct hash **retHash, struct cgiVar **retList) |
| static void | initCgiInput () |
| cgiVar * | cgiVarList () |
| static char * | findVarData (char *varName) |
| void | cgiBadVar (char *varName) |
| static char * | mustFindVarData (char *varName) |
| void | cgiDecode (char *in, char *out, int inLength) |
| char * | cgiEncode (char *inString) |
| char * | cgiEncodeFull (char *inString) |
| char * | cgiOptionalString (char *varName) |
| char * | cgiString (char *varName) |
| char * | cgiUsualString (char *varName, char *usual) |
| slName * | cgiStringList (char *varName) |
| int | cgiInt (char *varName) |
| int | cgiIntExp (char *varName) |
| int | cgiOptionalInt (char *varName, int defaultVal) |
| double | cgiDouble (char *varName) |
| double | cgiOptionalDouble (char *varName, double defaultVal) |
| boolean | cgiVarExists (char *varName) |
| boolean | cgiBoolean (char *varName) |
| int | cgiOneChoice (char *varName, struct cgiChoice *choices, int choiceSize) |
| void | cgiMakeSubmitButton () |
| void | cgiMakeResetButton () |
| void | cgiMakeClearButton (char *form, char *field) |
| void | cgiMakeButtonWithMsg (char *name, char *value, char *msg) |
| void | cgiMakeButton (char *name, char *value) |
| void | cgiMakeOnClickButton (char *command, char *value) |
| void | cgiMakeOptionalButton (char *name, char *value, boolean disabled) |
| void | cgiMakeFileEntry (char *name) |
| void | cgiSimpleTableStart () |
| void | cgiTableEnd () |
| void | cgiSimpleTableRowStart () |
| void | cgiTableRowEnd () |
| void | cgiSimpleTableFieldStart () |
| void | cgiTableFieldEnd () |
| void | cgiTableField (char *text) |
| void | cgiTableFieldWithMsg (char *text, char *msg) |
| void | cgiParagraph (char *text) |
| void | cgiMakeRadioButton (char *name, char *value, boolean checked) |
| void | cgiMakeOnClickRadioButton (char *name, char *value, boolean checked, char *command) |
| char * | cgiBooleanShadowPrefix () |
| boolean | cgiBooleanDefined (char *name) |
| void | cgiMakeCheckBoxWithMsg (char *name, boolean checked, char *msg) |
| void | cgiMakeCheckBox (char *name, boolean checked) |
| void | cgiMakeHiddenBoolean (char *name, boolean on) |
| void | cgiMakeTextArea (char *varName, char *initialVal, int rowCount, int columnCount) |
| void | cgiMakeTextAreaDisableable (char *varName, char *initialVal, int rowCount, int columnCount, boolean disabled) |
| void | cgiMakeTextVar (char *varName, char *initialVal, int charSize) |
| void | cgiMakeIntVar (char *varName, int initialVal, int maxDigits) |
| void | cgiMakeDoubleVar (char *varName, double initialVal, int maxDigits) |
| void | cgiMakeDropList (char *name, char *menu[], int menuSize, char *checked) |
| void | cgiMakeDropListClass (char *name, char *menu[], int menuSize, char *checked, char *class) |
| void | cgiMakeMultList (char *name, char *menu[], int menuSize, char *checked, int length) |
| void | cgiMakeDropListFull (char *name, char *menu[], char *values[], int menuSize, char *checked, char *extraAttribs) |
| void | cgiMakeDropListWithVals (char *name, char *menu[], char *values[], int menuSize, char *checked) |
| void | cgiMakeHiddenVar (char *varName, char *string) |
| void | cgiContinueHiddenVar (char *varName) |
| void | cgiVarExclude (char *varName) |
| void | cgiVarExcludeExcept (char **varNames) |
| void | cgiVarSet (char *varName, char *val) |
| dyString * | cgiUrlString () |
| void | cgiContinueAllVars () |
| boolean | cgiFromCommandLine (int *pArgc, char *argv[], boolean preferWeb) |
| boolean | cgiSpoof (int *pArgc, char *argv[]) |
| boolean | cgiFromFile (char *fileName) |
Variables | |
| static char const | rcsid [] = "$Id: cheapcgi.c,v 1.85 2006/12/19 18:49:52 kent Exp $" |
| static char * | inputString = NULL |
| static unsigned long | inputSize |
| static struct hash * | inputHash = NULL |
| static struct cgiVar * | inputList = NULL |
| static boolean | haveCookiesHash = FALSE |
| static struct hash * | cookieHash = NULL |
| static struct cgiVar * | cookieList = NULL |
| static boolean | doUseTempFile = FALSE |
| static jmp_buf | cgiParseRecover |
| #define memmem | ( | hay, | |||
| haySize, | |||||
| needle, | |||||
| needleSize | ) | memMatch(needle, needleSize, hay, haySize) |
Definition at line 107 of file cheapcgi.c.
| static void _cgiFindInput | ( | char * | method | ) | [static] |
Definition at line 340 of file cheapcgi.c.
References cgiInputSource(), errAbort(), getPostInput(), getQueryInput(), inputString, and sameWord.
Referenced by initCgiInput().
00343 { 00344 if (inputString == NULL) 00345 { 00346 method = cgiInputSource(method); 00347 if (sameWord(method, "POST")) 00348 getPostInput(); 00349 else if (sameWord(method, "QUERY") || sameWord(method, "GET")) 00350 getQueryInput(); 00351 else 00352 errAbort("Unknown form method"); 00353 } 00354 }
Here is the call graph for this function:

Here is the caller graph for this function:

| char* _cgiRawInput | ( | ) |
Definition at line 62 of file cheapcgi.c.
References inputString.
00064 { 00065 return inputString; 00066 }
| void cgiBadVar | ( | char * | varName | ) |
Definition at line 477 of file cheapcgi.c.
References errAbort().
Referenced by htmlBadVar(), and mustFindVarData().
00479 { 00480 if (varName == NULL) varName = ""; 00481 errAbort("Sorry, didn't find input variable %s\n" 00482 "Probably the web page didn't mean to call this program.", 00483 varName); 00484 }
Here is the call graph for this function:

Here is the caller graph for this function:

| boolean cgiBoolean | ( | char * | varName | ) |
Definition at line 716 of file cheapcgi.c.
References cgiVarExists().
00717 { 00718 return cgiVarExists(varName); 00719 }
Here is the call graph for this function:

| boolean cgiBooleanDefined | ( | char * | name | ) |
Definition at line 880 of file cheapcgi.c.
References cgiBooleanShadowPrefix(), cgiVarExists(), and safef().
00883 { 00884 char buf[256]; 00885 safef(buf, sizeof(buf), "%s%s", cgiBooleanShadowPrefix(), name); 00886 return cgiVarExists(buf); 00887 }
Here is the call graph for this function:

| char* cgiBooleanShadowPrefix | ( | ) |
Definition at line 874 of file cheapcgi.c.
Referenced by cgiBooleanDefined(), cgiMakeCheckBoxWithMsg(), and cgiMakeHiddenBoolean().
Here is the caller graph for this function:

| void cgiContinueAllVars | ( | ) |
Definition at line 1146 of file cheapcgi.c.
References cgiMakeHiddenVar(), inputList, cgiVar::name, cgiVar::next, and cgiVar::val.
01148 { 01149 struct cgiVar *cv; 01150 for (cv = inputList; cv != NULL; cv = cv->next) 01151 cgiMakeHiddenVar(cv->name, cv->val); 01152 }
Here is the call graph for this function:

| void cgiContinueHiddenVar | ( | char * | varName | ) |
Definition at line 1070 of file cheapcgi.c.
References cgiMakeHiddenVar(), cgiString(), and cgiVarExists().
01072 { 01073 if (cgiVarExists(varName)) 01074 cgiMakeHiddenVar(varName, cgiString(varName)); 01075 }
Here is the call graph for this function:

| void cgiDecode | ( | char * | in, | |
| char * | out, | |||
| int | inLength | |||
| ) |
Definition at line 495 of file cheapcgi.c.
Referenced by cgiParseInputAbort(), and parseCookies().
00499 { 00500 char c; 00501 int i; 00502 for (i=0; i<inLength;++i) 00503 { 00504 c = *in++; 00505 if (c == '+') 00506 *out++ = ' '; 00507 else if (c == '%') 00508 { 00509 int code; 00510 if (sscanf(in, "%2x", &code) != 1) 00511 code = '?'; 00512 in += 2; 00513 i += 2; 00514 *out++ = code; 00515 } 00516 else 00517 *out++ = c; 00518 } 00519 *out++ = 0; 00520 }
Here is the caller graph for this function:

| double cgiDouble | ( | char * | varName | ) |
Definition at line 689 of file cheapcgi.c.
References errAbort(), and mustFindVarData().
Referenced by cgiOptionalDouble().
00691 { 00692 char *data; 00693 double x; 00694 00695 data = mustFindVarData(varName); 00696 if (sscanf(data, "%lf", &x)<1) 00697 errAbort("Expecting real number in %s, got \"%s\"\n", varName, data); 00698 return x; 00699 }
Here is the call graph for this function:

Here is the caller graph for this function:

| char* cgiEncode | ( | char * | inString | ) |
Definition at line 522 of file cheapcgi.c.
References cloneString(), needMem(), and safef().
Referenced by appendCgiVar(), cgiUrlString(), and htmlSetCookie().
00526 { 00527 char c; 00528 int outSize = 0; 00529 char *outString, *out, *in; 00530 00531 if (inString == NULL) 00532 return(cloneString("")); 00533 00534 /* Count up how long it will be */ 00535 in = inString; 00536 while ((c = *in++) != 0) 00537 { 00538 if (isalnum(c) || c == ' ' || c == '.' || c == '_') 00539 outSize += 1; 00540 else 00541 outSize += 3; 00542 } 00543 outString = needMem(outSize+1); 00544 00545 /* Encode string */ 00546 in = inString; 00547 out = outString; 00548 while ((c = *in++) != 0) 00549 { 00550 if (isalnum(c) || c == '.' || c == '_') 00551 *out++ = c; 00552 else if (c == ' ') 00553 *out++ = '+'; 00554 else 00555 { 00556 unsigned char uc = c; 00557 char buf[4]; 00558 *out++ = '%'; 00559 safef(buf, sizeof(buf), "%02X", uc); 00560 *out++ = buf[0]; 00561 *out++ = buf[1]; 00562 } 00563 } 00564 *out++ = 0; 00565 return outString; 00566 }
Here is the call graph for this function:

Here is the caller graph for this function:

| char* cgiEncodeFull | ( | char * | inString | ) |
Definition at line 568 of file cheapcgi.c.
References cloneString(), needMem(), and safef().
00572 { 00573 char c; 00574 int outSize = 0; 00575 char *outString, *out, *in; 00576 00577 if (inString == NULL) 00578 return(cloneString("")); 00579 00580 /* Count up how long it will be */ 00581 in = inString; 00582 while ((c = *in++) != 0) 00583 { 00584 if (isalnum(c) || c == '.' || c == '_') 00585 outSize += 1; 00586 else 00587 outSize += 3; 00588 } 00589 outString = needMem(outSize+1); 00590 00591 /* Encode string */ 00592 in = inString; 00593 out = outString; 00594 while ((c = *in++) != 0) 00595 { 00596 if (isalnum(c) || c == '.' || c == '_') 00597 *out++ = c; 00598 else 00599 { 00600 unsigned char uc = c; 00601 char buf[4]; 00602 *out++ = '%'; 00603 safef(buf, sizeof(buf), "%02X", uc); 00604 *out++ = buf[0]; 00605 *out++ = buf[1]; 00606 } 00607 } 00608 *out++ = 0; 00609 return outString; 00610 }
Here is the call graph for this function:

| boolean cgiFromCommandLine | ( | int * | pArgc, | |
| char * | argv[], | |||
| boolean | preferWeb | |||
| ) |
Definition at line 1155 of file cheapcgi.c.
References cgiIsOnWeb(), FALSE, initCgiInput(), name, safef(), and TRUE.
Referenced by cgiSpoof().
01158 : 01159 * cgiScript nonCgiArg1 var1=value1 var2=value2 var3=value3 nonCgiArg2 01160 * or like 01161 * cgiScript nonCgiArg1 var1=value1&var2=value2&var3=value3 nonCgiArg2 01162 * or even like 01163 * cgiScript nonCgiArg1 -x -y=bogus z=really 01164 * (The non-cgi arguments can occur anywhere. The cgi arguments (all containing 01165 * the character '=' or starting with '-') are erased from argc/argv. Normally 01166 * you call this cgiSpoof(&argc, argv); 01167 */ 01168 { 01169 int argc = *pArgc; 01170 int i; 01171 int argcLeft = argc; 01172 char *name; 01173 static char queryString[4096]; 01174 char *q = queryString; 01175 boolean needAnd = TRUE; 01176 boolean gotAny = FALSE; 01177 boolean startDash; 01178 boolean gotEq; 01179 static char hostLine[512]; 01180 01181 if (preferWeb && cgiIsOnWeb()) 01182 return TRUE; /* No spoofing required! */ 01183 q += safef(q, queryString + sizeof(queryString) - q, 01184 "%s", "QUERY_STRING=cgiSpoof=on"); 01185 for (i=0; i<argcLeft; ) 01186 { 01187 name = argv[i]; 01188 if ((startDash = (name[0] == '-'))) 01189 ++name; 01190 gotEq = (strchr(name, '=') != NULL); 01191 if (gotEq || startDash) 01192 { 01193 if (needAnd) 01194 *q++ = '&'; 01195 q += safef(q, queryString + sizeof(queryString) - q, "%s", name); 01196 if (!gotEq || strchr(name, '&') == NULL) 01197 needAnd = TRUE; 01198 if (!gotEq) 01199 q += safef(q, queryString + sizeof(queryString) - q, "=on"); 01200 memcpy(&argv[i], &argv[i+1], sizeof(argv[i]) * (argcLeft-i-1)); 01201 argcLeft -= 1; 01202 gotAny = TRUE; 01203 } 01204 else 01205 i++; 01206 } 01207 if (gotAny) 01208 { 01209 *pArgc = argcLeft; 01210 } 01211 putenv("REQUEST_METHOD=GET"); 01212 putenv(queryString); 01213 safef(hostLine, sizeof(hostLine), "SERVER_NAME=%s", getenv("HOST")); 01214 putenv(hostLine); 01215 initCgiInput(); 01216 return gotAny; 01217 }
Here is the call graph for this function:

Here is the caller graph for this function:

| boolean cgiFromFile | ( | char * | fileName | ) |
Definition at line 1227 of file cheapcgi.c.
References AllocArray, cgiSpoof(), cloneString(), ExpandArray, FALSE, freez(), lineFileClose(), lineFileNext(), lineFileOpen(), sameString, and TRUE.
01229 : 01230 * argument1=someVal 01231 * # This is a comment 01232 * argument2=someOtherVal 01233 * ... 01234 * and puts them into the cgi environment so that the usual 01235 * cgiGetVar() commands can be used. Useful when a program 01236 * has a lot of possible parameters. 01237 */ 01238 { 01239 char **argv = NULL; 01240 int argc = 0; 01241 int maxArgc = 10; 01242 int i; 01243 struct lineFile *lf = lineFileOpen(fileName, TRUE); 01244 char *line; 01245 boolean spoof= FALSE; 01246 AllocArray(argv, maxArgc); 01247 /* Remember that first arg is program name. 01248 Put filename there instead. */ 01249 argc = 1; 01250 argv[0] = cloneString(fileName); 01251 for(;;) 01252 { 01253 /* If we are at the end we're done. */ 01254 if(!lineFileNext(lf, &line, NULL)) 01255 break; 01256 /* If it is a comment or blank line skip it. */ 01257 if (line[0] == '#' || sameString(line, "")) 01258 continue; 01259 /* If our argv array is full expand it. */ 01260 if((argc+1) >= maxArgc) 01261 { 01262 ExpandArray(argv, maxArgc, 2*maxArgc); 01263 maxArgc *= 2; 01264 } 01265 /* Fill in another argument to our psuedo arguments. */ 01266 argv[argc++] = cloneString(line); 01267 } 01268 spoof = cgiSpoof(&argc, argv); 01269 /* Cleanup. */ 01270 lineFileClose(&lf); 01271 for(i=0; i<argc; i++) 01272 freez(&argv[i]); 01273 freez(&argv); 01274 return spoof; 01275 } }
Here is the call graph for this function:

| static char* cgiInputSource | ( | char * | s | ) | [static] |
Definition at line 322 of file cheapcgi.c.
Referenced by _cgiFindInput().
00324 { 00325 char *qs; 00326 if (s != NULL) 00327 return s; 00328 qs = getenv("QUERY_STRING"); 00329 if (qs == NULL) 00330 return "POST"; 00331 if (qs[0] == 0) 00332 { 00333 char *cl = getenv("CONTENT_LENGTH"); 00334 if (cl != NULL && atoi(cl) > 0) 00335 return "POST"; 00336 } 00337 return "QUERY"; 00338 }
Here is the caller graph for this function:

| int cgiInt | ( | char * | varName | ) |
Definition at line 657 of file cheapcgi.c.
References errAbort(), mustFindVarData(), and skipLeadingSpaces().
Referenced by cgiOptionalInt(), and doDetailLine().
00659 { 00660 char *data; 00661 char c; 00662 00663 data = mustFindVarData(varName); 00664 data = skipLeadingSpaces(data); 00665 c = data[0]; 00666 if (!(isdigit(c) || (c == '-' && isdigit(data[1])))) 00667 errAbort("Expecting number in %s, got \"%s\"\n", varName, data); 00668 return atoi(data); 00669 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int cgiIntExp | ( | char * | varName | ) |
Definition at line 671 of file cheapcgi.c.
References cgiString(), and intExp().
Here is the call graph for this function:

| boolean cgiIsOnWeb | ( | ) |
Definition at line 44 of file cheapcgi.c.
Referenced by cgiFromCommandLine(), and main().
Here is the caller graph for this function:

| void cgiMakeButton | ( | char * | name, | |
| char * | value | |||
| ) |
Definition at line 770 of file cheapcgi.c.
References cgiMakeButtonWithMsg().
Referenced by cgiMakeSubmitButton(), and doGetSeq().
00772 { 00773 cgiMakeButtonWithMsg(name, value, NULL); 00774 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void cgiMakeButtonWithMsg | ( | char * | name, | |
| char * | value, | |||
| char * | msg | |||
| ) |
Definition at line 762 of file cheapcgi.c.
Referenced by cgiMakeButton().
00764 { 00765 printf("<INPUT TYPE=SUBMIT NAME=\"%s\" VALUE=\"%s\" %s%s%s>", 00766 name, value, 00767 (msg ? " TITLE=\"" : ""), (msg ? msg : ""), (msg ? "\"" : "" )); 00768 }
Here is the caller graph for this function:

| void cgiMakeCheckBox | ( | char * | name, | |
| boolean | checked | |||
| ) |
Definition at line 903 of file cheapcgi.c.
References cgiMakeCheckBoxWithMsg().
00905 { 00906 cgiMakeCheckBoxWithMsg(name, checked, NULL); 00907 }
Here is the call graph for this function:

| void cgiMakeCheckBoxWithMsg | ( | char * | name, | |
| boolean | checked, | |||
| char * | msg | |||
| ) |
Definition at line 889 of file cheapcgi.c.
References cgiBooleanShadowPrefix(), cgiMakeHiddenVar(), and safef().
Referenced by cgiMakeCheckBox().
00893 { 00894 char buf[256]; 00895 00896 printf("<INPUT TYPE=CHECKBOX NAME=\"%s\" VALUE=on %s%s%s %s>", name, 00897 (msg ? " TITLE=\"" : ""), (msg ? msg : ""), (msg ? "\"" : "" ), 00898 (checked ? " CHECKED" : "")); 00899 safef(buf, sizeof(buf), "%s%s", cgiBooleanShadowPrefix(), name); 00900 cgiMakeHiddenVar(buf, "1"); 00901 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void cgiMakeClearButton | ( | char * | form, | |
| char * | field | |||
| ) |
Definition at line 752 of file cheapcgi.c.
References cgiMakeOnClickButton(), and safef().
00754 { 00755 char javascript[1024]; 00756 00757 safef(javascript, sizeof(javascript), 00758 "document.%s.%s.value = ''; document.%s.submit();", form, field, form); 00759 cgiMakeOnClickButton(javascript, " Clear "); 00760 }
Here is the call graph for this function:

| void cgiMakeDoubleVar | ( | char * | varName, | |
| double | initialVal, | |||
| int | maxDigits | |||
| ) |
Definition at line 957 of file cheapcgi.c.
00959 { 00960 if (maxDigits == 0) maxDigits = 4; 00961 00962 printf("<INPUT TYPE=TEXT NAME=\"%s\" SIZE=%d VALUE=%g>", varName, 00963 maxDigits, initialVal); 00964 }
| void cgiMakeDropList | ( | char * | name, | |
| char * | menu[], | |||
| int | menuSize, | |||
| char * | checked | |||
| ) |
Definition at line 968 of file cheapcgi.c.
References cgiMakeDropListClass().
Referenced by doGetSeq().
00971 { 00972 cgiMakeDropListClass(name, menu, menuSize, checked, "normalText"); 00973 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void cgiMakeDropListClass | ( | char * | name, | |
| char * | menu[], | |||
| int | menuSize, | |||
| char * | checked, | |||
| char * | class | |||
| ) |
Definition at line 976 of file cheapcgi.c.
References sameWord.
Referenced by cgiMakeDropList().
00979 { 00980 int i; 00981 char *selString; 00982 if (checked == NULL) checked = menu[0]; 00983 printf("<SELECT NAME=\"%s\" class=%s>\n", name, class); 00984 for (i=0; i<menuSize; ++i) 00985 { 00986 if (sameWord(menu[i], checked)) 00987 selString = " SELECTED"; 00988 else 00989 selString = ""; 00990 printf("<OPTION%s>%s</OPTION>\n", selString, menu[i]); 00991 } 00992 printf("</SELECT>\n"); 00993 }
Here is the caller graph for this function:

| void cgiMakeDropListFull | ( | char * | name, | |
| char * | menu[], | |||
| char * | values[], | |||
| int | menuSize, | |||
| char * | checked, | |||
| char * | extraAttribs | |||
| ) |
Definition at line 1015 of file cheapcgi.c.
References sameWord.
01018 { 01019 int i; 01020 char *selString; 01021 if (checked == NULL) checked = menu[0]; 01022 01023 if (NULL != extraAttribs) 01024 { 01025 printf("<SELECT NAME=\"%s\" %s>\n", name, extraAttribs); 01026 } 01027 else 01028 { 01029 printf("<SELECT NAME=\"%s\">\n", name); 01030 } 01031 01032 for (i=0; i<menuSize; ++i) 01033 { 01034 if (sameWord(values[i], checked)) 01035 selString = " SELECTED"; 01036 else 01037 selString = ""; 01038 printf("<OPTION%s VALUE=\"%s\">%s</OPTION>\n", selString, values[i], menu[i]); 01039 } 01040 printf("</SELECT>\n"); 01041 }
| void cgiMakeDropListWithVals | ( | char * | name, | |
| char * | menu[], | |||
| char * | values[], | |||
| int | menuSize, | |||
| char * | checked | |||
| ) |
Definition at line 1043 of file cheapcgi.c.
References sameWord.
01047 { 01048 int i; 01049 char *selString; 01050 if (checked == NULL) checked = values[0]; 01051 01052 printf("<SELECT NAME=\"%s\">\n", name); 01053 for (i=0; i<menuSize; ++i) 01054 { 01055 if (sameWord(values[i], checked)) 01056 selString = " SELECTED"; 01057 else 01058 selString = ""; 01059 printf("<OPTION%s VALUE=\"%s\">%s</OPTION>\n", selString, values[i], menu[i]); 01060 } 01061 printf("</SELECT>\n"); 01062 }
| void cgiMakeFileEntry | ( | char * | name | ) |
| void cgiMakeHiddenBoolean | ( | char * | name, | |
| boolean | on | |||
| ) |
Definition at line 909 of file cheapcgi.c.
References cgiBooleanShadowPrefix(), cgiMakeHiddenVar(), and safef().
00913 { 00914 char buf[256]; 00915 cgiMakeHiddenVar(name, on ? "on" : "off"); 00916 safef(buf, sizeof(buf), "%s%s", cgiBooleanShadowPrefix(), name); 00917 cgiMakeHiddenVar(buf, "1"); 00918 }
Here is the call graph for this function:

| void cgiMakeHiddenVar | ( | char * | varName, | |
| char * | string | |||
| ) |
Definition at line 1064 of file cheapcgi.c.
Referenced by cgiContinueAllVars(), cgiContinueHiddenVar(), cgiMakeCheckBoxWithMsg(), and cgiMakeHiddenBoolean().
Here is the caller graph for this function:

| void cgiMakeIntVar | ( | char * | varName, | |
| int | initialVal, | |||
| int | maxDigits | |||
| ) |
Definition at line 948 of file cheapcgi.c.
00950 { 00951 if (maxDigits == 0) maxDigits = 4; 00952 00953 printf("<INPUT TYPE=TEXT NAME=\"%s\" SIZE=%d VALUE=%d>", varName, 00954 maxDigits, initialVal); 00955 }
| void cgiMakeMultList | ( | char * | name, | |
| char * | menu[], | |||
| int | menuSize, | |||
| char * | checked, | |||
| int | length | |||
| ) |
Definition at line 995 of file cheapcgi.c.
References sameWord.
00999 { 01000 int i; 01001 char *selString; 01002 if (checked == NULL) checked = menu[0]; 01003 printf("<SELECT MULTIPLE SIZE=%d ALIGN=CENTER NAME=\"%s\">\n", length, name); 01004 for (i=0; i<menuSize; ++i) 01005 { 01006 if (sameWord(menu[i], checked)) 01007 selString = " SELECTED"; 01008 else 01009 selString = ""; 01010 printf("<OPTION%s>%s</OPTION>\n", selString, menu[i]); 01011 } 01012 printf("</SELECT>\n"); 01013 }
| void cgiMakeOnClickButton | ( | char * | command, | |
| char * | value | |||
| ) |
Definition at line 776 of file cheapcgi.c.
Referenced by cgiMakeClearButton().
00778 { 00779 printf("<INPUT TYPE=\"button\" VALUE=\"%s\" onClick=\"%s\">", value, command); 00780 }
Here is the caller graph for this function:

| void cgiMakeOnClickRadioButton | ( | char * | name, | |
| char * | value, | |||
| boolean | checked, | |||
| char * | command | |||
| ) |
Definition at line 863 of file cheapcgi.c.
00869 { 00870 printf("<INPUT TYPE=RADIO NAME=\"%s\" VALUE=\"%s\" %s %s>", 00871 name, value, command, (checked ? "CHECKED" : "")); 00872 }
| void cgiMakeOptionalButton | ( | char * | name, | |
| char * | value, | |||
| boolean | disabled | |||
| ) |
Definition at line 782 of file cheapcgi.c.
00784 { 00785 printf("<INPUT TYPE=SUBMIT NAME=\"%s\" VALUE=\"%s\"", name, value); 00786 if (disabled) 00787 printf(" DISABLED"); 00788 printf(">"); 00789 }
| void cgiMakeRadioButton | ( | char * | name, | |
| char * | value, | |||
| boolean | checked | |||
| ) |
Definition at line 854 of file cheapcgi.c.
00858 { 00859 printf("<INPUT TYPE=RADIO NAME=\"%s\" VALUE=\"%s\" %s>", name, value, 00860 (checked ? "CHECKED" : "")); 00861 }
| void cgiMakeResetButton | ( | ) |
| void cgiMakeSubmitButton | ( | ) |
Definition at line 740 of file cheapcgi.c.
References cgiMakeButton().
00742 { 00743 cgiMakeButton("Submit", "Submit"); 00744 }
Here is the call graph for this function:

| void cgiMakeTextArea | ( | char * | varName, | |
| char * | initialVal, | |||
| int | rowCount, | |||
| int | columnCount | |||
| ) |
Definition at line 920 of file cheapcgi.c.
References cgiMakeTextAreaDisableable(), and FALSE.
Referenced by doGetSeq().
00921 : intialVal */ 00922 { 00923 cgiMakeTextAreaDisableable(varName, initialVal, rowCount, columnCount, FALSE); 00924 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void cgiMakeTextAreaDisableable | ( | char * | varName, | |
| char * | initialVal, | |||
| int | rowCount, | |||
| int | columnCount, | |||
| boolean | disabled | |||
| ) |
Definition at line 926 of file cheapcgi.c.
Referenced by cgiMakeTextArea().
00928 : intialVal */ 00929 { 00930 printf("<TEXTAREA NAME=\"%s\" ROWS=%d COLS=%d %s>%s</TEXTAREA>", varName, 00931 rowCount, columnCount, disabled ? "DISABLED" : "", 00932 (initialVal != NULL ? initialVal : "")); 00933 }
Here is the caller graph for this function:

| void cgiMakeTextVar | ( | char * | varName, | |
| char * | initialVal, | |||
| int | charSize | |||
| ) |
Definition at line 935 of file cheapcgi.c.
00938 { 00939 if (initialVal == NULL) 00940 initialVal = ""; 00941 if (charSize == 0) charSize = strlen(initialVal); 00942 if (charSize == 0) charSize = 8; 00943 00944 printf("<INPUT TYPE=TEXT NAME=\"%s\" SIZE=%d VALUE=\"%s\">", varName, 00945 charSize, initialVal); 00946 }
| int cgiOneChoice | ( | char * | varName, | |
| struct cgiChoice * | choices, | |||
| int | choiceSize | |||
| ) |
Definition at line 721 of file cheapcgi.c.
References cgiString(), errAbort(), name, and sameWord.
00723 { 00724 char *key = cgiString(varName); 00725 int i; 00726 int val = -1; 00727 00728 for (i=0; i<choiceSize; ++i) 00729 { 00730 if (sameWord(choices[i].name, key)) 00731 { 00732 val = choices[i].value; 00733 return val; 00734 } 00735 } 00736 errAbort("Unknown key %s for variable %s\n", key, varName); 00737 return val; 00738 }
Here is the call graph for this function:

| double cgiOptionalDouble | ( | char * | varName, | |
| double | defaultVal | |||
| ) |
Definition at line 701 of file cheapcgi.c.
References cgiDouble(), and cgiVarExists().
00703 { 00704 if (!cgiVarExists(varName)) 00705 return defaultVal; 00706 return cgiDouble(varName); 00707 }
Here is the call graph for this function:

| int cgiOptionalInt | ( | char * | varName, | |
| int | defaultVal | |||
| ) |
Definition at line 678 of file cheapcgi.c.
References cgiInt(), cgiOptionalString(), isEmpty, and skipLeadingSpaces().
00681 { 00682 char *s = cgiOptionalString(varName); 00683 s = skipLeadingSpaces(s); 00684 if (isEmpty(s)) 00685 return defaultVal; 00686 return cgiInt(varName); 00687 }
Here is the call graph for this function:

| char* cgiOptionalString | ( | char * | varName | ) |
Definition at line 612 of file cheapcgi.c.
References findVarData().
Referenced by cgiOptionalInt(), and initCgiInput().
00614 { 00615 return findVarData(varName); 00616 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void cgiParagraph | ( | char * | text | ) |
| static void cgiParseAbort | ( | ) | [static] |
Definition at line 396 of file cheapcgi.c.
References cgiParseRecover.
Referenced by cgiParseInput().
00398 { 00399 longjmp(cgiParseRecover, -1); 00400 }
Here is the caller graph for this function:

Definition at line 402 of file cheapcgi.c.
References cgiParseAbort(), cgiParseInputAbort(), cgiParseRecover, FALSE, popAbortHandler(), pushAbortHandler(), and TRUE.
00408 { 00409 boolean ok = TRUE; 00410 int status = setjmp(cgiParseRecover); 00411 if (status == 0) /* Always true except after long jump. */ 00412 { 00413 pushAbortHandler(cgiParseAbort); 00414 cgiParseInputAbort(input, retHash, retList); 00415 } 00416 else /* They long jumped here because of an error. */ 00417 { 00418 ok = FALSE; 00419 } 00420 popAbortHandler(); 00421 return ok; 00422 }
Here is the call graph for this function:

| static void cgiParseInputAbort | ( | char * | input, | |
| struct hash ** | retHash, | |||
| struct cgiVar ** | retList | |||
| ) | [static] |
Definition at line 356 of file cheapcgi.c.
References AllocVar, cgiDecode(), errAbort(), hashAddSaveName(), newHash(), slAddHead, and slReverse().
Referenced by cgiParseInput(), and initCgiInput().
00362 { 00363 char *namePt, *dataPt, *nextNamePt; 00364 struct hash *hash = newHash(6); 00365 struct cgiVar *list = NULL, *el; 00366 00367 namePt = input; 00368 while (namePt != NULL && namePt[0] != 0) 00369 { 00370 dataPt = strchr(namePt, '='); 00371 if (dataPt == NULL) 00372 { 00373 errAbort("Mangled CGI input string %s", namePt); 00374 } 00375 *dataPt++ = 0; 00376 nextNamePt = strchr(dataPt, '&'); 00377 if (nextNamePt == NULL) 00378 nextNamePt = strchr(dataPt, ';'); /* Accomodate DAS. */ 00379 if (nextNamePt != NULL) 00380 *nextNamePt++ = 0; 00381 cgiDecode(namePt,namePt,strlen(namePt)); /* for unusual ct names */ 00382 cgiDecode(dataPt,dataPt,strlen(dataPt)); 00383 AllocVar(el); 00384 el->val = dataPt; 00385 slAddHead(&list, el); 00386 hashAddSaveName(hash, namePt, el, &el->name); 00387 namePt = nextNamePt; 00388 } 00389 slReverse(&list); 00390 *retList = list; 00391 *retHash = hash; 00392 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 110 of file cheapcgi.c.
References AllocVar, mimePart::binary, cloneString(), mimePart::data, dyStringAppend(), dyStringPrintf(), errAbort(), mimePart::fileName, freeDyString(), freez(), getMimeHeaderFieldVal(), getMimeHeaderMainVal(), hashAddSaveName(), hashFindVal(), mimePart::hdr, initMimeBuf(), mimePart::multi, newDyString(), newHash(), mimePart::next, parseMultiParts(), safef(), sameString, mimePart::size, slAddHead, slReverse(), startsWith(), dyString::string, and warn().
Referenced by initCgiInput().
00112 { 00113 char h[1024]; /* hold mime header line */ 00114 char *s = NULL, *ct = NULL; 00115 struct dyString *dy = newDyString(256); 00116 struct mimeBuf *mb = NULL; 00117 struct mimePart *mp = NULL; 00118 char **env = NULL; 00119 struct hash *hash = newHash(6); 00120 struct cgiVar *list = NULL, *el; 00121 extern char **environ; 00122 00123 00124 //debug 00125 //fprintf(stderr,"GALT: top of cgiParseMultipart()\n"); 00126 //fflush(stderr); 00127 00128 /* find the CONTENT_ environment strings, use to make Alternate Header string for MIME */ 00129 for(env=environ; *env; env++) 00130 if (startsWith("CONTENT_",*env)) 00131 { 00132 //debug 00133 //fprintf(stderr,"%s\n",*env); //debug 00134 safef(h,sizeof(h),"%s",*env); 00135 s = strchr(h,'_'); /* change env syntax to MIME style header, from _= to -: */ 00136 if (!s) 00137 errAbort("expecting '_' parsing env var %s for MIME alt header", *env); 00138 *s = '-'; 00139 s = strchr(h,'='); 00140 if (!s) 00141 errAbort("expecting '=' parsing env var %s for MIME alt header", *env); 00142 *s = ':'; 00143 dyStringPrintf(dy,"%s\r\n",h); 00144 } 00145 dyStringAppend(dy,"\r\n"); /* blank line at end means end of headers */ 00146 00147 //debug 00148 //fprintf(stderr,"Alternate Header Text:\n%s",dy->string); 00149 //fflush(stderr); 00150 mb = initMimeBuf(STDIN_FILENO); 00151 //debug 00152 //fprintf(stderr,"got past initMimeBuf(STDIN_FILENO)\n"); 00153 //fflush(stderr); 00154 mp = parseMultiParts(mb, cloneString(dy->string)); /* The Alternate Header will get freed */ 00155 freeDyString(&dy); 00156 if(!mp->multi) /* expecting multipart child parts */ 00157 errAbort("Malformatted multipart-form."); 00158 00159 //debug 00160 //fprintf(stderr,"GALT: Wow got past parse of MIME!\n"); 00161 //fflush(stderr); 00162 00163 ct = hashFindVal(mp->hdr,"content-type"); 00164 //debug 00165 //fprintf(stderr,"GALT: main content-type: %s\n",ct); 00166 //fflush(stderr); 00167 if (!startsWith("multipart/form-data",ct)) 00168 errAbort("main content-type expected starts with [multipart/form-data], found [%s]",ct); 00169 00170 for(mp=mp->multi;mp;mp=mp->next) 00171 { 00172 char *cd = NULL, *cdMain = NULL, *cdName = NULL, *cdFileName = NULL, *ct = NULL; 00173 cd = hashFindVal(mp->hdr,"content-disposition"); 00174 ct = hashFindVal(mp->hdr,"content-type"); 00175 //debug 00176 //fprintf(stderr,"GALT: content-disposition: %s\n",cd); 00177 //fprintf(stderr,"GALT: content-type: %s\n",ct); 00178 //fflush(stderr); 00179 cdMain=getMimeHeaderMainVal(cd); 00180 cdName=getMimeHeaderFieldVal(cd,"name"); 00181 cdFileName=getMimeHeaderFieldVal(cd,"filename"); 00182 //debug 00183 //fprintf(stderr,"GALT: main:[%s], name:[%s], filename:[%s]\n",cdMain,cdName,cdFileName); 00184 //fflush(stderr); 00185 if (!sameString(cdMain,"form-data")) 00186 errAbort("main content-type expected [form-data], found [%s]",cdMain); 00187 00188 //debug 00189 //fprintf(stderr,"GALT: mp->size[%llu], mp->binary=[%d], mp->fileName=[%s], mp=>data:[%s]\n", 00190 //(unsigned long long) mp->size, mp->binary, mp->fileName, 00191 //mp->binary && mp->data ? "<binary data not safe to print>" : mp->data); 00192 //fflush(stderr); 00193 00194 /* filename if there is one */ 00195 if(cdFileName) 00196 { 00197 char varNameFilename[256]; 00198 safef(varNameFilename, sizeof(varNameFilename), "%s__filename", cdName); 00199 AllocVar(el); 00200 el->val = cloneString(cdFileName); 00201 slAddHead(&list, el); 00202 hashAddSaveName(hash, varNameFilename, el, &el->name); 00203 } 00204 00205 if (mp->data) 00206 { 00207 if (mp->binary) 00208 { 00209 char varNameBinary[256]; 00210 char addrSizeBuf[40]; 00211 safef(varNameBinary,sizeof(varNameBinary),"%s__binary",cdName); 00212 safef(addrSizeBuf,sizeof(addrSizeBuf),"%lu %llu", 00213 (unsigned long)mp->data, 00214 (unsigned long long)mp->size); 00215 AllocVar(el); 00216 el->val = cloneString(addrSizeBuf); 00217 slAddHead(&list, el); 00218 hashAddSaveName(hash, varNameBinary, el, &el->name); 00219 } 00220 else /* normal variable, not too big, does not contain zeros */ 00221 { 00222 AllocVar(el); 00223 el->val = mp->data; 00224 slAddHead(&list, el); 00225 hashAddSaveName(hash, cdName, el, &el->name); 00226 } 00227 } 00228 else if (mp->fileName) 00229 { 00230 char varNameData[256]; 00231 safef(varNameData, sizeof(varNameData), "%s__data", cdName); 00232 AllocVar(el); 00233 el->val = mp->fileName; 00234 slAddHead(&list, el); 00235 hashAddSaveName(hash, varNameData, el, &el->name); 00236 //debug 00237 //fprintf(stderr,"GALT special: saved varNameData:[%s], mp=>fileName:[%s]\n",el->name,el->val); 00238 //fflush(stderr); 00239 } 00240 else if (mp->multi) 00241 { 00242 warn("unexpected nested MIME structures"); 00243 } 00244 else 00245 { 00246 errAbort("mp-> type not data,fileName, or multi - unexpected MIME structure"); 00247 } 00248 00249 freez(&cdMain); 00250 freez(&cdName); 00251 freez(&cdFileName); 00252 } 00253 00254 slReverse(&list); 00255 *retList = list; 00256 *retHash = hash; 00257 }
Here is the call graph for this function:

Here is the caller graph for this function:

| char* cgiScriptName | ( | ) |
| char* cgiServerName | ( | ) |
| void cgiSimpleTableFieldStart | ( | ) |
| void cgiSimpleTableRowStart | ( | ) |
| void cgiSimpleTableStart | ( | ) |
| boolean cgiSpoof | ( | int * | pArgc, | |
| char * | argv[] | |||
| ) |
Definition at line 1219 of file cheapcgi.c.
References cgiFromCommandLine(), and TRUE.
Referenced by cgiFromFile(), and main().
01223 { 01224 return cgiFromCommandLine(pArgc, argv, TRUE); 01225 }
Here is the call graph for this function:

Here is the caller graph for this function:

| char* cgiString | ( | char * | varName | ) |
Definition at line 619 of file cheapcgi.c.
References mustFindVarData().
Referenced by cgiContinueHiddenVar(), cgiIntExp(), cgiOneChoice(), doBlat(), doDetailLine(), and gfWebFindServer().
00621 { 00622 return mustFindVarData(varName); 00623 }
Here is the call graph for this function:

Here is the caller graph for this function:

| struct slName* cgiStringList | ( | char * | varName | ) | [read] |
Definition at line 636 of file cheapcgi.c.
References hashLookup(), initCgiInput(), inputHash, hashEl::name, newSlName(), hashEl::next, sameString, slAddHead, and hashEl::val.
00639 { 00640 struct hashEl *hel; 00641 struct slName *stringList = NULL, *string; 00642 00643 initCgiInput(); 00644 for (hel = hashLookup(inputHash, varName); hel != NULL; hel = hel->next) 00645 { 00646 if (sameString(hel->name, varName)) 00647 { 00648 struct cgiVar *var = hel->val; 00649 string = newSlName(var->val); 00650 slAddHead(&stringList, string); 00651 } 00652 } 00653 return stringList; 00654 }
Here is the call graph for this function:

| void cgiTableEnd | ( | ) |
| void cgiTableField | ( | char * | text | ) |
| void cgiTableFieldEnd | ( | ) |
| void cgiTableFieldWithMsg | ( | char * | text, | |
| char * | msg | |||
| ) |
Definition at line 840 of file cheapcgi.c.
00842 { 00843 printf("<TD %s%s%s> %s </TD>\n", 00844 (msg ? " TITLE=\"" : ""), (msg ? msg : ""), (msg ? "\"" : "" ), 00845 text); 00846 }
| void cgiTableRowEnd | ( | ) |
| struct dyString* cgiUrlString | ( | ) | [read] |
Definition at line 1126 of file cheapcgi.c.
References cgiEncode(), dyStringAppend(), dyStringPrintf(), freez(), inputList, cgiVar::name, newDyString(), cgiVar::next, and cgiVar::val.
01128 { 01129 struct dyString *dy = newDyString(0); 01130 struct cgiVar *cv; 01131 char *e; 01132 01133 01134 for (cv = inputList; cv != NULL; cv = cv->next) 01135 { 01136 if (cv != inputList) 01137 dyStringAppend(dy, "&"); 01138 e = cgiEncode(cv->val); 01139 dyStringPrintf(dy, "%s=", cv->name); 01140 dyStringAppend(dy, e); 01141 freez(&e); 01142 } 01143 return dy; 01144 }
Here is the call graph for this function:

| char* cgiUsualString | ( | char * | varName, | |
| char * | usual | |||
| ) |
Definition at line 625 of file cheapcgi.c.
References findVarData().
Referenced by aliLines(), doBlat(), and doGetSeq().
00628 { 00629 char *pt; 00630 pt = findVarData(varName); 00631 if (pt == NULL) 00632 pt = usual; 00633 return pt; 00634 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void cgiVarExclude | ( | char * | varName | ) |
Definition at line 1077 of file cheapcgi.c.
References cgiVarExists(), hashRemove(), inputHash, inputList, and slRemoveEl().
Referenced by cgiVarExcludeExcept().
01079 { 01080 if (cgiVarExists(varName)) 01081 { 01082 struct cgiVar *cv = hashRemove(inputHash, varName); 01083 slRemoveEl(&inputList, cv); 01084 } 01085 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void cgiVarExcludeExcept | ( | char ** | varNames | ) |
Definition at line 1087 of file cheapcgi.c.
References cgiVarExclude(), freeHash(), hashAdd(), hashElFreeList(), hashElListHash(), hashLookup(), initCgiInput(), inputHash, hashEl::name, newHash(), and hashEl::next.
01091 { 01092 struct hashEl *list, *el; 01093 struct hash *exclude = newHash(8); 01094 char *s; 01095 01096 /* Build up hash of things to exclude */ 01097 if (varNames != NULL) 01098 { 01099 while ((s = *varNames++) != NULL) 01100 hashAdd(exclude, s, NULL); 01101 } 01102 01103 /* Step through variable list and remove them if not 01104 * excluded. */ 01105 initCgiInput(); 01106 list = hashElListHash(inputHash); 01107 for (el = list; el != NULL; el = el->next) 01108 { 01109 if (!hashLookup(exclude, el->name)) 01110 cgiVarExclude(el->name); 01111 } 01112 hashElFreeList(&list); 01113 freeHash(&exclude); 01114 }
Here is the call graph for this function:

| boolean cgiVarExists | ( | char * | varName | ) |
Definition at line 709 of file cheapcgi.c.
References hashLookup(), initCgiInput(), and inputHash.
Referenced by cgiBoolean(), cgiBooleanDefined(), cgiContinueHiddenVar(), cgiOptionalDouble(), cgiVarExclude(), gfWebFindServer(), and webBlat().
00711 { 00712 initCgiInput(); 00713 return hashLookup(inputHash, varName) != NULL; 00714 }
Here is the call graph for this function:

Here is the caller graph for this function:

| struct cgiVar* cgiVarList | ( | ) | [read] |
Definition at line 459 of file cheapcgi.c.
References initCgiInput(), and inputList.
00461 { 00462 initCgiInput(); 00463 return inputList; 00464 }
Here is the call graph for this function:

| void cgiVarSet | ( | char * | varName, | |
| char * | val | |||
| ) |
Definition at line 1116 of file cheapcgi.c.
References AllocVar, cloneString(), hashAddSaveName(), initCgiInput(), inputHash, cgiVar::name, and cgiVar::val.
01118 { 01119 struct cgiVar *var; 01120 initCgiInput(); 01121 AllocVar(var); 01122 var->val = cloneString(val); 01123 hashAddSaveName(inputHash, varName, var, &var->name); 01124 }
Here is the call graph for this function:

| void dumpCookieList | ( | ) |
Definition at line 30 of file cheapcgi.c.
References cookieList, cgiVar::name, cgiVar::next, cgiVar::saved, and cgiVar::val.
00032 { 00033 struct cgiVar *v; 00034 for (v=cookieList; v != NULL; v = v->next) 00035 printf("%s=%s (%d)\n", v->name, v->val, v->saved); 00036 }
| char* findCookieData | ( | char * | varName | ) |
Definition at line 308 of file cheapcgi.c.
References cookieHash, cookieList, hashFindVal(), parseCookies(), and cgiVar::val.
00310 { 00311 struct cgiVar *var; 00312 00313 /* make sure that the cookie hash table has been created */ 00314 parseCookies(&cookieHash, &cookieList); 00315 if (cookieHash == NULL) 00316 return NULL; 00317 if ((var = hashFindVal(cookieHash, varName)) == NULL) 00318 return NULL; 00319 return var->val; 00320 }
Here is the call graph for this function:

| static char* findVarData | ( | char * | varName | ) | [static] |
Definition at line 466 of file cheapcgi.c.
References hashFindVal(), initCgiInput(), inputHash, and cgiVar::val.
Referenced by cgiOptionalString(), cgiUsualString(), and mustFindVarData().
00468 { 00469 struct cgiVar *var; 00470 00471 initCgiInput(); 00472 if ((var = hashFindVal(inputHash, varName)) == NULL) 00473 return NULL; 00474 return var->val; 00475 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void getPostInput | ( | ) | [static] |
Definition at line 77 of file cheapcgi.c.
References errAbort(), inputSize, inputString, needMem(), and startsWith().
Referenced by _cgiFindInput().
00079 { 00080 char *s; 00081 long i; 00082 int r; 00083 00084 s = getenv("CONTENT_LENGTH"); 00085 if (s == NULL) 00086 errAbort("No CONTENT_LENGTH in environment."); 00087 if (sscanf(s, "%lu", &inputSize) != 1) 00088 errAbort("CONTENT_LENGTH isn't a number."); 00089 s = getenv("CONTENT_TYPE"); 00090 if (s != NULL && startsWith("multipart/form-data", s)) 00091 { 00092 /* use MIME parse on input stream instead, can handle large uploads */ 00093 inputString = ""; // must not be NULL so it knows it was set 00094 return; 00095 } 00096 inputString = needMem((size_t)inputSize+1); 00097 for (i=0; i<inputSize; ++i) 00098 { 00099 r = getc(stdin); 00100 if (r == EOF) 00101 errAbort("Short POST input."); 00102 inputString[i] = r; 00103 } 00104 inputString[inputSize] = 0; 00105 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void getQueryInput | ( | ) | [static] |
Definition at line 68 of file cheapcgi.c.
References cloneString(), errAbort(), and inputString.
Referenced by _cgiFindInput().
00070 { 00071 inputString = getenv("QUERY_STRING"); 00072 if (inputString == NULL) 00073 errAbort("No QUERY_STRING in environment."); 00074 inputString = cloneString(inputString); 00075 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void initCgiInput | ( | ) | [static] |
Definition at line 424 of file cheapcgi.c.
References _cgiFindInput(), cgiOptionalString(), cgiParseInputAbort(), cgiParseMultipart(), cookieHash, cookieList, envUpdate(), inputHash, inputList, inputString, parseCookies(), and startsWith().
Referenced by cgiFromCommandLine(), cgiStringList(), cgiVarExcludeExcept(), cgiVarExists(), cgiVarList(), cgiVarSet(), and findVarData().
00428 { 00429 char* s; 00430 00431 if (inputString != NULL) 00432 return; 00433 _cgiFindInput(NULL); 00434 00435 /* check to see if the input is a multipart form */ 00436 s = getenv("CONTENT_TYPE"); 00437 if (s != NULL && startsWith("multipart/form-data", s)) 00438 { 00439 cgiParseMultipart(&inputHash, &inputList); 00440 } 00441 else 00442 { 00443 cgiParseInputAbort(inputString, &inputHash, &inputList); 00444 } 00445 00446 /* now parse the cookies */ 00447 parseCookies(&cookieHash, &cookieList); 00448 00449 /* Set enviroment variables CGIs to enable sql tracing and/or profiling */ 00450 s = cgiOptionalString("JKSQL_TRACE"); 00451 if (s != NULL) 00452 envUpdate("JKSQL_TRACE", s); 00453 s = cgiOptionalString("JKSQL_PROF"); 00454 if (s != NULL) 00455 envUpdate("JKSQL_PROF", s); 00456 00457 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static char* mustFindVarData | ( | char * | varName | ) | [static] |
Definition at line 486 of file cheapcgi.c.
References cgiBadVar(), and findVarData().
Referenced by cgiDouble(), cgiInt(), and cgiString().
00488 { 00489 char *res = findVarData(varName); 00490 if (res == NULL) 00491 cgiBadVar(varName); 00492 return res; 00493 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 262 of file cheapcgi.c.
References AllocVar, cgiDecode(), cloneString(), errAbort(), hashAddSaveName(), haveCookiesHash, newHash(), slAddHead, slReverse(), and TRUE.
Referenced by findCookieData(), and initCgiInput().
00264 { 00265 char* str; 00266 char *namePt, *dataPt, *nextNamePt; 00267 struct hash *hash; 00268 struct cgiVar *list = NULL, *el; 00269 00270 /* don't build the hash table again */ 00271 if(haveCookiesHash == TRUE) 00272 return; 00273 00274 str = cloneString(getenv("HTTP_COOKIE")); 00275 if(str == NULL) /* don't have a cookie */ 00276 return; 00277 00278 hash = newHash(6); 00279 00280 namePt = str; 00281 while (namePt != NULL) 00282 { 00283 dataPt = strchr(namePt, '='); 00284 if (dataPt == NULL) 00285 errAbort("Mangled Cookie input string %s", namePt); 00286 *dataPt++ = 0; 00287 nextNamePt = strchr(dataPt, ';'); 00288 if (nextNamePt != NULL) 00289 { 00290 *nextNamePt++ = 0; 00291 nextNamePt++; 00292 } 00293 cgiDecode(dataPt,dataPt,strlen(dataPt)); 00294 AllocVar(el); 00295 el->val = dataPt; 00296 slAddHead(&list, el); 00297 hashAddSaveName(hash, namePt, el, &el->name); 00298 namePt = nextNamePt; 00299 } 00300 00301 haveCookiesHash = TRUE; 00302 00303 slReverse(&list); 00304 *retList = list; 00305 *retHash = hash; 00306 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void useTempFile | ( | ) |
Definition at line 38 of file cheapcgi.c.
References doUseTempFile, and TRUE.
00040 { 00041 doUseTempFile = TRUE; 00042 }
jmp_buf cgiParseRecover [static] |
struct hash* cookieHash = NULL [static] |
struct cgiVar* cookieList = NULL [static] |
Definition at line 25 of file cheapcgi.c.
Referenced by cookieOutput(), dumpCookieList(), findCookieData(), and initCgiInput().
boolean doUseTempFile = FALSE [static] |
boolean haveCookiesHash = FALSE [static] |
Definition at line 20 of file cheapcgi.c.
Referenced by cgiStringList(), cgiVarExclude(), cgiVarExcludeExcept(), cgiVarExists(), cgiVarSet(), findVarData(), and initCgiInput().
Definition at line 21 of file cheapcgi.c.
Referenced by cgiContinueAllVars(), cgiUrlString(), cgiVarExclude(), cgiVarList(), and initCgiInput().
unsigned long inputSize [static] |
char* inputString = NULL [static] |
Definition at line 18 of file cheapcgi.c.
Referenced by _cgiFindInput(), _cgiRawInput(), getPostInput(), getQueryInput(), and initCgiInput().
char const rcsid[] = "$Id: cheapcgi.c,v 1.85 2006/12/19 18:49:52 kent Exp $" [static] |
Definition at line 15 of file cheapcgi.c.
1.5.2