summaryrefslogtreecommitdiff
path: root/parsing.c
diff options
context:
space:
mode:
authorLars Hjemli <hjemli@gmail.com>2006-12-11 16:11:40 +0100
committerLars Hjemli <hjemli@gmail.com>2006-12-11 16:11:40 +0100
commit51ada4fda2b47710351e6e4da8a95807d6d9f729 (patch)
tree48b543fd16b666db7024038506ffc4eadb0ca966 /parsing.c
parent318d106300102c19d114a4ea89265b0a4060d9cb (diff)
downloadcgit-51ada4fda2b47710351e6e4da8a95807d6d9f729.tar.gz
cgit-51ada4fda2b47710351e6e4da8a95807d6d9f729.tar.bz2
cgit-51ada4fda2b47710351e6e4da8a95807d6d9f729.zip
Rename config.c to parsing.c + move cgit_parse_query from cgit.c to parsing.c
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Diffstat (limited to '')
-rw-r--r--parsing.c (renamed from config.c)25
1 files changed, 25 insertions, 0 deletions
diff --git a/config.c b/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;
+}