b2f0702d9548acaf85fd929834bf5bce52af4d99
kent
  Mon Feb 9 15:20:53 2015 -0800
Adding cgiEncodeHash and cgiParseNext functions.

diff --git src/inc/cheapcgi.h src/inc/cheapcgi.h
index da6b102..8c0617b 100644
--- src/inc/cheapcgi.h
+++ src/inc/cheapcgi.h
@@ -222,30 +222,34 @@
 /* Out will be a cgi-decoded version of in (no space from plus!).
  * Out will be a little shorter than in typically, and
  * can be the same buffer. */
 
 char *cgiEncode(char *inString);
 /* Return a cgi-encoded version of inString.
  * Alphanumerics kept as is, space translated to plus,
  * and all other characters translated to %hexVal.
  * You can free return value with freeMem(). */
 
 char *cgiEncodeFull(char *inString);
 /* Return a cgi-encoded version of inString (no + for space!).
  * Alphanumerics/./_ kept as is and all other characters translated to
  * %hexVal. */
 
+void cgiEncodeHash(struct hash *hash, struct dyString *dy);
+/* Put a cgi-encoding of a string valued hash into dy.  Tags are always
+ * alphabetical to make it easier to compare if two hashes are same. */
+
 void cgiMakeButtonWithMsg(char *name, char *value, char *msg);
 /* Make 'submit' type button. Display msg on mouseover, if present*/
 
 void cgiMakeButtonWithOnClick(char *name, char *value, char *msg, char *onClick);
 /* Make 'submit' type button, with onclick javascript */
 
 void cgiMakeButton(char *name, char *value);
 /* Make 'submit' type button. */
 
 void cgiMakeOnClickButton(char *command, char *value);
 /* Make 'push' type button with client side onClick (java)script. */
 
 void cgiMakeOnClickSubmitButton(char *command, char *name, char *value);
 /* Make submit button with both variable name and value with client side
  * onClick (java)script. */
@@ -534,30 +538,39 @@
  * execution.  No effect if state has not yet been initialized. */
 
 void cgiDown(float lines);
 // Drop down a certain number of lines (may be fractional)
 
 char *commonCssStyles();
 /* Returns a string of common CSS styles */
 
 char *javaScriptLiteralEncode(char *inString);
 /* Use backslash escaping on newline
  * and quote chars, backslash and others.
  * Intended that the encoded string will be
  * put between quotes at a higher level and
  * then interpreted by Javascript. */
 
+boolean cgiParseNext(char **pInput, char **retVar, char **retVal);
+/* Parse out next var/val in a var=val&var=val... cgi formatted string 
+ * This will insert zeroes and other things into string. 
+ * Usage:
+ *     char *pt = cgiStringStart;
+ *     char *var, *val
+ *     while (cgiParseNext(&pt, &var, &val))
+ *          printf("%s\t%s\n", var, val); */
+
 struct cgiParsedVars
 /* A parsed out cgi variable string */
     {
     struct cgiParsedVars *next;	/* In case want to make a list of these. */
     char *stringBuf;		/* Holds strings inside vars. */
     struct cgiVar *list;    /* List of variables. */
     struct hash *hash;	    /* Keyed by varName, value is just value, not cgiVar. */
     };
 
 struct cgiParsedVars *cgiParsedVarsNew(char *cgiString);
 /* Build structure containing parsed out cgiString */
 
 void cgiParsedVarsFree(struct cgiParsedVars **pTags);
 /* Free up memory associated with cgiParsedVars */