diff options
author | Lars Hjemli <hjemli@gmail.com> | 2008-02-16 11:53:40 +0100 |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2008-02-16 12:07:28 +0100 |
commit | d14d77fe95c3b6224b40df9b101dded0deea913c (patch) | |
tree | 7e0d9c8f2c0f86b8946aea0bb823085c33b164b3 /shared.c | |
parent | e5ed227ef0da561e2bde8646ec816842392377ee (diff) | |
download | cgit-d14d77fe95c3b6224b40df9b101dded0deea913c.tar.gz cgit-d14d77fe95c3b6224b40df9b101dded0deea913c.tar.xz |
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>
Diffstat (limited to 'shared.c')
-rw-r--r-- | shared.c | 43 |
1 files changed, 14 insertions, 29 deletions
@@ -10,6 +10,7 @@ struct repolist cgit_repolist; struct repoinfo *cgit_repo; +struct cgit_context ctx; int cgit_cmd; const char *cgit_version = CGIT_VERSION; @@ -49,24 +50,8 @@ int cgit_max_msg_len = 60; int cgit_max_repodesc_len = 60; int cgit_max_commit_count = 50; -int cgit_query_has_symref = 0; -int cgit_query_has_sha1 = 0; - -char *cgit_querystring = NULL; -char *cgit_query_repo = NULL; -char *cgit_query_page = NULL; -char *cgit_query_head = NULL; -char *cgit_query_search = NULL; -char *cgit_query_grep = NULL; -char *cgit_query_sha1 = NULL; -char *cgit_query_sha2 = NULL; -char *cgit_query_path = NULL; -char *cgit_query_name = NULL; -int cgit_query_ofs = 0; - int htmlfd = 0; - int cgit_get_cmd_index(const char *cmd) { static char *cmds[] = {"log", "commit", "diff", "tree", "blob", @@ -239,32 +224,32 @@ void cgit_global_config_cb(const char *name, const char *value) void cgit_querystring_cb(const char *name, const char *value) { if (!strcmp(name,"r")) { - cgit_query_repo = xstrdup(value); + ctx.qry.repo = xstrdup(value); cgit_repo = cgit_get_repoinfo(value); } else if (!strcmp(name, "p")) { - cgit_query_page = xstrdup(value); + ctx.qry.page = xstrdup(value); cgit_cmd = cgit_get_cmd_index(value); } else if (!strcmp(name, "url")) { cgit_parse_url(value); } else if (!strcmp(name, "qt")) { - cgit_query_grep = xstrdup(value); + ctx.qry.grep = xstrdup(value); } else if (!strcmp(name, "q")) { - cgit_query_search = xstrdup(value); + ctx.qry.search = xstrdup(value); } else if (!strcmp(name, "h")) { - cgit_query_head = xstrdup(value); - cgit_query_has_symref = 1; + ctx.qry.head = xstrdup(value); + ctx.qry.has_symref = 1; } else if (!strcmp(name, "id")) { - cgit_query_sha1 = xstrdup(value); - cgit_query_has_sha1 = 1; + ctx.qry.sha1 = xstrdup(value); + ctx.qry.has_sha1 = 1; } else if (!strcmp(name, "id2")) { - cgit_query_sha2 = xstrdup(value); - cgit_query_has_sha1 = 1; + ctx.qry.sha2 = xstrdup(value); + ctx.qry.has_sha1 = 1; } else if (!strcmp(name, "ofs")) { - cgit_query_ofs = atoi(value); + ctx.qry.ofs = atoi(value); } else if (!strcmp(name, "path")) { - cgit_query_path = trim_end(value, '/'); + ctx.qry.path = trim_end(value, '/'); } else if (!strcmp(name, "name")) { - cgit_query_name = xstrdup(value); + ctx.qry.name = xstrdup(value); } } |