f1437cec3b3c4441c9da6fa80bee99fe8e328d87 kent Wed Apr 3 00:33:14 2013 -0700 Adding cgiEncodeIntoDy into library. Exposing cgiParseInputAbort to public. Improving a comment. diff --git src/inc/cheapcgi.h src/inc/cheapcgi.h index 413320a..e339b86 100644 --- src/inc/cheapcgi.h +++ src/inc/cheapcgi.h @@ -389,30 +389,33 @@ void cgiVarExclude(char *varName); /* If varName exists, remove it. */ void cgiVarExcludeExcept(char **varNames); /* Exclude all variables except for those in NULL * terminated array varNames. varNames may be NULL * in which case nothing is excluded. */ void cgiVarSet(char *varName, char *val); /* Set a cgi variable to a particular value. */ struct dyString *cgiUrlString(); /* Get URL-formatted that expresses current CGI variable state. */ +void cgiEncodeIntoDy(char *var, char *val, struct dyString *dy); +/* Add a CGI-encoded &var=val string to dy. */ + boolean cgiSpoof(int *pArgc, char *argv[]); /* Use the command line to set up things as if we were a CGI program. * User types in command line (assuming your program called cgiScript) * like: * cgiScript nonCgiArg1 var1=value1 var2=value2 var3=value3 nonCgiArg2 * or like * cgiScript nonCgiArg1 var1=value1&var2=value2&var3=value3 nonCgiArg2 * (The non-cgi arguments can occur anywhere. The cgi arguments (all containing * the character '=') are erased from argc/argv. Normally you call this * cgiSpoof(&argc, argv); */ boolean cgiFromCommandLine(int *pArgc, char *argv[], boolean preferWeb); /* Use the command line to set up things as if we were a CGI program. * If preferWeb is TRUE will choose real CGI variables over command @@ -426,31 +429,36 @@ * Takes file with arguments in the form: * argument1=someVal * # This is a comment * argument2=someOtherVal * ... * and puts them into the cgi environment so that the usual * cgiGetVar() commands can be used. Useful when a program * has a lot of possible parameters. */ boolean cgiParseInput(char *input, struct hash **retHash, struct cgiVar **retList); /* Parse cgi-style input into a hash table and list. This will alter * the input data. The hash table will contain references back * into input, so please don't free input until you're done with - * the hash. Prints message and returns FALSE if there's an error.*/ + * the hash. Prints message and returns FALSE if there's an error. + * To clean up - slFreeList, hashFree, and only then free input. */ + +void cgiParseInputAbort(char *input, struct hash **retHash, + struct cgiVar **retList); +/* Parse cgi-style input into a hash table and list as above but abort if there's an error. */ void cgiSimpleTableStart(); /* start HTML table -- no customization. Leaves room * for a fancier implementation */ void cgiTableEnd(); /* end HTML table */ void cgiMakeSubmitButton(); /* Make 'submit' type button. */ void cgiMakeResetButton(); /* Make 'reset' type button. */ void cgiMakeClearButton(char *form, char *field);