aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile5
-rw-r--r--cgit.c26
-rw-r--r--cgit.h1
-rw-r--r--parsing.c (renamed from config.c)25
4 files changed, 29 insertions, 28 deletions
diff --git a/Makefile b/Makefile
index c71e39c..eab7926 100644
--- a/Makefile
+++ b/Makefile
@@ -5,7 +5,7 @@ INSTALL_CSS = /var/www/htdocs/cgit.css
5CACHE_ROOT = /var/cache/cgit 5CACHE_ROOT = /var/cache/cgit
6 6
7EXTLIBS = ../git/libgit.a ../git/xdiff/lib.a -lz -lcrypto 7EXTLIBS = ../git/libgit.a ../git/xdiff/lib.a -lz -lcrypto
8OBJECTS = config.o html.o cache.o 8OBJECTS = parsing.o html.o cache.o
9 9
10CFLAGS += -Wall 10CFLAGS += -Wall
11 11
@@ -17,7 +17,8 @@ install: all
17 rm -rf $(CACHE_ROOT)/* 17 rm -rf $(CACHE_ROOT)/*
18 18
19cgit: cgit.c cgit.h git.h $(OBJECTS) 19cgit: cgit.c cgit.h git.h $(OBJECTS)
20 $(CC) $(CFLAGS) -DCGIT_VERSION='"$(CGIT_VERSION)"' cgit.c -o cgit $(OBJECTS) $(EXTLIBS) 20 $(CC) $(CFLAGS) -DCGIT_VERSION='"$(CGIT_VERSION)"' cgit.c -o cgit \
21 $(OBJECTS) $(EXTLIBS)
21 22
22$(OBJECTS): cgit.h git.h 23$(OBJECTS): cgit.h git.h
23 24
diff --git a/cgit.c b/cgit.c
index dc91125..5567859 100644
--- a/cgit.c
+++ b/cgit.c
@@ -53,32 +53,6 @@ char *cgit_query_sha1 = NULL;
53 53
54struct cacheitem cacheitem; 54struct cacheitem cacheitem;
55 55
56int cgit_parse_query(char *txt, configfn fn)
57{
58 char *t, *value = NULL, c;
59
60 if (!txt)
61 return 0;
62
63 t = txt = xstrdup(txt);
64
65 while((c=*t) != '\0') {
66 if (c=='=') {
67 *t = '\0';
68 value = t+1;
69 } else if (c=='&') {
70 *t = '\0';
71 (*fn)(txt, value);
72 txt = t+1;
73 value = NULL;
74 }
75 t++;
76 }
77 if (t!=txt)
78 (*fn)(txt, value);
79 return 0;
80}
81
82void cgit_global_config_cb(const char *name, const char *value) 56void cgit_global_config_cb(const char *name, const char *value)
83{ 57{
84 if (!strcmp(name, "root")) 58 if (!strcmp(name, "root"))
diff --git a/cgit.h b/cgit.h
index 7e4bfef..6c0aa3b 100644
--- a/cgit.h
+++ b/cgit.h
@@ -56,6 +56,7 @@ extern void html_link_close(void);
56 56
57 57
58extern int cgit_read_config(const char *filename, configfn fn); 58extern int cgit_read_config(const char *filename, configfn fn);
59extern int cgit_parse_query(char *txt, configfn fn);
59 60
60extern void cache_prepare(struct cacheitem *item); 61extern void cache_prepare(struct cacheitem *item);
61extern int cache_lock(struct cacheitem *item); 62extern int cache_lock(struct cacheitem *item);
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)
79 return ret; 79 return ret;
80} 80}
81 81
82int cgit_parse_query(char *txt, configfn fn)
83{
84 char *t, *value = NULL, c;
85
86 if (!txt)
87 return 0;
88
89 t = txt = xstrdup(txt);
90
91 while((c=*t) != '\0') {
92 if (c=='=') {
93 *t = '\0';
94 value = t+1;
95 } else if (c=='&') {
96 *t = '\0';
97 (*fn)(txt, value);
98 txt = t+1;
99 value = NULL;
100 }
101 t++;
102 }
103 if (t!=txt)
104 (*fn)(txt, value);
105 return 0;
106}