author | Lars Hjemli <hjemli@gmail.com> | 2008-02-16 10:53:40 (UTC) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2008-02-16 11:07:28 (UTC) |
commit | d14d77fe95c3b6224b40df9b101dded0deea913c (patch) (unidiff) | |
tree | 7e0d9c8f2c0f86b8946aea0bb823085c33b164b3 /shared.c | |
parent | e5ed227ef0da561e2bde8646ec816842392377ee (diff) | |
download | cgit-d14d77fe95c3b6224b40df9b101dded0deea913c.zip cgit-d14d77fe95c3b6224b40df9b101dded0deea913c.tar.gz cgit-d14d77fe95c3b6224b40df9b101dded0deea913c.tar.bz2 |
Introduce struct cgit_context
This struct will hold all the cgit runtime information currently found in
a multitude of global variables.
The first cleanup removes all querystring-related variables.
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
-rw-r--r-- | shared.c | 43 |
1 files changed, 14 insertions, 29 deletions
@@ -11,4 +11,5 @@ | |||
11 | struct repolist cgit_repolist; | 11 | struct repolist cgit_repolist; |
12 | struct repoinfo *cgit_repo; | 12 | struct repoinfo *cgit_repo; |
13 | struct cgit_context ctx; | ||
13 | int cgit_cmd; | 14 | int cgit_cmd; |
14 | 15 | ||
@@ -50,22 +51,6 @@ int cgit_max_repodesc_len = 60; | |||
50 | int cgit_max_commit_count = 50; | 51 | int cgit_max_commit_count = 50; |
51 | 52 | ||
52 | int cgit_query_has_symref = 0; | ||
53 | int cgit_query_has_sha1 = 0; | ||
54 | |||
55 | char *cgit_querystring = NULL; | ||
56 | char *cgit_query_repo = NULL; | ||
57 | char *cgit_query_page = NULL; | ||
58 | char *cgit_query_head = NULL; | ||
59 | char *cgit_query_search = NULL; | ||
60 | char *cgit_query_grep = NULL; | ||
61 | char *cgit_query_sha1 = NULL; | ||
62 | char *cgit_query_sha2 = NULL; | ||
63 | char *cgit_query_path = NULL; | ||
64 | char *cgit_query_name = NULL; | ||
65 | int cgit_query_ofs = 0; | ||
66 | |||
67 | int htmlfd = 0; | 53 | int htmlfd = 0; |
68 | 54 | ||
69 | |||
70 | int cgit_get_cmd_index(const char *cmd) | 55 | int cgit_get_cmd_index(const char *cmd) |
71 | { | 56 | { |
@@ -240,30 +225,30 @@ void cgit_querystring_cb(const char *name, const char *value) | |||
240 | { | 225 | { |
241 | if (!strcmp(name,"r")) { | 226 | if (!strcmp(name,"r")) { |
242 | cgit_query_repo = xstrdup(value); | 227 | ctx.qry.repo = xstrdup(value); |
243 | cgit_repo = cgit_get_repoinfo(value); | 228 | cgit_repo = cgit_get_repoinfo(value); |
244 | } else if (!strcmp(name, "p")) { | 229 | } else if (!strcmp(name, "p")) { |
245 | cgit_query_page = xstrdup(value); | 230 | ctx.qry.page = xstrdup(value); |
246 | cgit_cmd = cgit_get_cmd_index(value); | 231 | cgit_cmd = cgit_get_cmd_index(value); |
247 | } else if (!strcmp(name, "url")) { | 232 | } else if (!strcmp(name, "url")) { |
248 | cgit_parse_url(value); | 233 | cgit_parse_url(value); |
249 | } else if (!strcmp(name, "qt")) { | 234 | } else if (!strcmp(name, "qt")) { |
250 | cgit_query_grep = xstrdup(value); | 235 | ctx.qry.grep = xstrdup(value); |
251 | } else if (!strcmp(name, "q")) { | 236 | } else if (!strcmp(name, "q")) { |
252 | cgit_query_search = xstrdup(value); | 237 | ctx.qry.search = xstrdup(value); |
253 | } else if (!strcmp(name, "h")) { | 238 | } else if (!strcmp(name, "h")) { |
254 | cgit_query_head = xstrdup(value); | 239 | ctx.qry.head = xstrdup(value); |
255 | cgit_query_has_symref = 1; | 240 | ctx.qry.has_symref = 1; |
256 | } else if (!strcmp(name, "id")) { | 241 | } else if (!strcmp(name, "id")) { |
257 | cgit_query_sha1 = xstrdup(value); | 242 | ctx.qry.sha1 = xstrdup(value); |
258 | cgit_query_has_sha1 = 1; | 243 | ctx.qry.has_sha1 = 1; |
259 | } else if (!strcmp(name, "id2")) { | 244 | } else if (!strcmp(name, "id2")) { |
260 | cgit_query_sha2 = xstrdup(value); | 245 | ctx.qry.sha2 = xstrdup(value); |
261 | cgit_query_has_sha1 = 1; | 246 | ctx.qry.has_sha1 = 1; |
262 | } else if (!strcmp(name, "ofs")) { | 247 | } else if (!strcmp(name, "ofs")) { |
263 | cgit_query_ofs = atoi(value); | 248 | ctx.qry.ofs = atoi(value); |
264 | } else if (!strcmp(name, "path")) { | 249 | } else if (!strcmp(name, "path")) { |
265 | cgit_query_path = trim_end(value, '/'); | 250 | ctx.qry.path = trim_end(value, '/'); |
266 | } else if (!strcmp(name, "name")) { | 251 | } else if (!strcmp(name, "name")) { |
267 | cgit_query_name = xstrdup(value); | 252 | ctx.qry.name = xstrdup(value); |
268 | } | 253 | } |
269 | } | 254 | } |