86dcaa6650bc69009796c3bdcd7e078aa65976ae
kent
  Tue Sep 24 17:43:01 2013 -0700
Adding cgiDictionary - something you can make from a cgi-encoded string.
diff --git src/lib/cheapcgi.c src/lib/cheapcgi.c
index 18d673d..1ba081e 100644
--- src/lib/cheapcgi.c
+++ src/lib/cheapcgi.c
@@ -587,30 +587,54 @@
 /* Get raw CGI input into inputString.  Method can be "POST", "QUERY", "GET" or NULL
  * for unknown. */
 {
 if (inputString == NULL)
     {
     method = cgiInputSource(method);
     if (sameWord(method, "POST"))
         getPostInput();
     else if (sameWord(method, "QUERY") || sameWord(method, "GET"))
         getQueryInput();
     else
         errAbort("Unknown form method");
     }
 }
 
+struct cgiDictionary *cgiDictionaryFromEncodedString(char *encodedString)
+/* Giving a this=that&this=that string,  return cgiDictionary parsed out from it. 
+ * This does *not* destroy input like the lower level cgiParse functions do. */
+{
+struct cgiDictionary *d;
+AllocVar(d);
+d->stringData = cloneString(encodedString);
+cgiParseInputAbort(d->stringData, &d->hash, &d->list);
+return d;
+}
+
+void cgiDictionaryFree(struct cgiDictionary **pD)
+/* Free up resources associated with dictionary. */
+{
+struct cgiDictionary *d = *pD;
+if (d != NULL)
+    {
+    slFreeList(&d->list);
+    hashFree(&d->hash);
+    freez(&d->stringData);
+    freez(pD);
+    }
+}
+
 void cgiParseInputAbort(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 aborts if there's an error.
  * To clean up - slFreeList, hashFree, and only then free input. */
 {
 char *namePt, *dataPt, *nextNamePt;
 struct hash *hash = *retHash;
 struct cgiVar *list = *retList, *el;
 
 if (!hash)
   hash = newHash(6);
 slReverse(&list);