|
diff --git a/shared.c b/shared.c index 54b1813..45fde7f 100644 --- a/ shared.c+++ b/ shared.c |
|
@@ -10,6 +10,7 @@ |
10 | |
10 | |
11 | struct repolist cgit_repolist; |
11 | struct repolist cgit_repolist; |
12 | struct repoinfo *cgit_repo; |
12 | struct repoinfo *cgit_repo; |
| |
13 | int cgit_cmd; |
13 | |
14 | |
14 | char *cgit_root_title = "Git repository browser"; |
15 | char *cgit_root_title = "Git repository browser"; |
15 | char *cgit_css = "/cgit.css"; |
16 | char *cgit_css = "/cgit.css"; |
@@ -52,6 +53,18 @@ int cgit_query_ofs = 0; |
52 | |
53 | |
53 | int htmlfd = 0; |
54 | int htmlfd = 0; |
54 | |
55 | |
| |
56 | |
| |
57 | int cgit_get_cmd_index(const char *cmd) |
| |
58 | { |
| |
59 | static char *cmds[] = {"log", "commit", "diff", "tree", "view", "blob", "snapshot", NULL}; |
| |
60 | int i; |
| |
61 | |
| |
62 | for(i = 0; cmds[i]; i++) |
| |
63 | if (!strcmp(cmd, cmds[i])) |
| |
64 | return i + 1; |
| |
65 | return 0; |
| |
66 | } |
| |
67 | |
55 | int chk_zero(int result, char *msg) |
68 | int chk_zero(int result, char *msg) |
56 | { |
69 | { |
57 | if (result != 0) |
70 | if (result != 0) |
@@ -94,6 +107,19 @@ struct repoinfo *add_repo(const char *url) |
94 | return ret; |
107 | return ret; |
95 | } |
108 | } |
96 | |
109 | |
| |
110 | struct repoinfo *cgit_get_repoinfo(const char *url) |
| |
111 | { |
| |
112 | int i; |
| |
113 | struct repoinfo *repo; |
| |
114 | |
| |
115 | for (i=0; i<cgit_repolist.count; i++) { |
| |
116 | repo = &cgit_repolist.repos[i]; |
| |
117 | if (!strcmp(repo->url, url)) |
| |
118 | return repo; |
| |
119 | } |
| |
120 | return NULL; |
| |
121 | } |
| |
122 | |
97 | void cgit_global_config_cb(const char *name, const char *value) |
123 | void cgit_global_config_cb(const char *name, const char *value) |
98 | { |
124 | { |
99 | if (!strcmp(name, "root-title")) |
125 | if (!strcmp(name, "root-title")) |
@@ -162,8 +188,12 @@ void cgit_querystring_cb(const char *name, const char *value) |
162 | { |
188 | { |
163 | if (!strcmp(name,"r")) { |
189 | if (!strcmp(name,"r")) { |
164 | cgit_query_repo = xstrdup(value); |
190 | cgit_query_repo = xstrdup(value); |
| |
191 | cgit_repo = cgit_get_repoinfo(value); |
165 | } else if (!strcmp(name, "p")) { |
192 | } else if (!strcmp(name, "p")) { |
166 | cgit_query_page = xstrdup(value); |
193 | cgit_query_page = xstrdup(value); |
| |
194 | cgit_cmd = cgit_get_cmd_index(value); |
| |
195 | } else if (!strcmp(name, "url")) { |
| |
196 | cgit_parse_url(value); |
167 | } else if (!strcmp(name, "q")) { |
197 | } else if (!strcmp(name, "q")) { |
168 | cgit_query_search = xstrdup(value); |
198 | cgit_query_search = xstrdup(value); |
169 | } else if (!strcmp(name, "h")) { |
199 | } else if (!strcmp(name, "h")) { |
|