X-Git-Url: https://gitweb.ps.run/ps-cgit/blobdiff_plain/318d106300102c19d114a4ea89265b0a4060d9cb:/config.c..51ada4fda2b47710351e6e4da8a95807d6d9f729:/parsing.c?ds=inline diff --git a/config.c b/parsing.c similarity index 78% rename from config.c rename to parsing.c index 871edf2..98b3243 100644 --- 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; +}