]> gitweb.ps.run Git - ps-cgit/blobdiff - parsing.c
Rename config.c to parsing.c + move cgit_parse_query from cgit.c to parsing.c
[ps-cgit] / parsing.c
similarity index 78%
rename from config.c
rename to parsing.c
index 871edf228f2088ef980c0dc2f2e68d83b27ab395..98b32434b6157bffce33ae47f664c6a43e8f1a8b 100644 (file)
--- a/config.c
+++ b/parsing.c
@@ -79,3 +79,28 @@ int cgit_read_config(const char *filename, configfn fn)
        return ret;
 }
 
+int cgit_parse_query(char *txt, configfn fn)
+{
+       char *t, *value = NULL, c;
+
+       if (!txt)
+               return 0;
+
+       t = txt = xstrdup(txt);
+       while((c=*t) != '\0') {
+               if (c=='=') {
+                       *t = '\0';
+                       value = t+1;
+               } else if (c=='&') {
+                       *t = '\0';
+                       (*fn)(txt, value);
+                       txt = t+1;
+                       value = NULL;
+               }
+               t++;
+       }
+       if (t!=txt)
+               (*fn)(txt, value);
+       return 0;
+}