From 305414df1246531baf0f2c959c2c61df4e93c526 Mon Sep 17 00:00:00 2001 From: Lars Hjemli Date: Fri, 18 May 2007 00:47:47 +0200 Subject: Move cgit_get_repoinfo into shared.c This function will be usefull when parsing url arguments. Signed-off-by: Lars Hjemli --- shared.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'shared.c') diff --git a/shared.c b/shared.c index 53cd9b0..b164d81 100644 --- a/shared.c +++ b/shared.c @@ -93,6 +93,19 @@ struct repoinfo *add_repo(const char *url) return ret; } +struct repoinfo *cgit_get_repoinfo(const char *url) +{ + int i; + struct repoinfo *repo; + + for (i=0; iurl, url)) + return repo; + } + return NULL; +} + void cgit_global_config_cb(const char *name, const char *value) { if (!strcmp(name, "root-title")) -- cgit v1.2.3-24-g4f1b From 43d40f2b704151d145a1383b2b964210915ecae4 Mon Sep 17 00:00:00 2001 From: Lars Hjemli Date: Fri, 18 May 2007 00:50:46 +0200 Subject: Add lookup-function for valid repo commands This will be usefull when parsing url arguments. Signed-off-by: Lars Hjemli --- shared.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'shared.c') diff --git a/shared.c b/shared.c index b164d81..fb05427 100644 --- a/shared.c +++ b/shared.c @@ -51,6 +51,18 @@ int cgit_query_ofs = 0; int htmlfd = 0; + +int cgit_get_cmd_index(const char *cmd) +{ + static char *cmds[] = {"log", "commit", "diff", "tree", "view", "blob", "snapshot", NULL}; + int i; + + for(i = 0; cmds[i]; i++) + if (!strcmp(cmd, cmds[i])) + return i + 1; + return 0; +} + int chk_zero(int result, char *msg) { if (result != 0) -- cgit v1.2.3-24-g4f1b From 30ccdcaa74ebc0aab2b7843b0db8251d0ddf56de Mon Sep 17 00:00:00 2001 From: Lars Hjemli Date: Fri, 18 May 2007 03:00:54 +0200 Subject: Enable url=value querystring parameter This makes is possible to use repo-urls like '/pub/scm/git/git.git' and even add path specifications, like '/pub/scm/git/git.git/log/documentation'. Signed-off-by: Lars Hjemli --- shared.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'shared.c') diff --git a/shared.c b/shared.c index fb05427..0b074da 100644 --- a/shared.c +++ b/shared.c @@ -10,6 +10,7 @@ struct repolist cgit_repolist; struct repoinfo *cgit_repo; +int cgit_cmd; char *cgit_root_title = "Git repository browser"; char *cgit_css = "/cgit.css"; @@ -184,8 +185,12 @@ void cgit_querystring_cb(const char *name, const char *value) { if (!strcmp(name,"r")) { cgit_query_repo = xstrdup(value); + cgit_repo = cgit_get_repoinfo(value); } else if (!strcmp(name, "p")) { cgit_query_page = xstrdup(value); + cgit_cmd = cgit_get_cmd_index(value); + } else if (!strcmp(name, "url")) { + cgit_parse_url(value); } else if (!strcmp(name, "q")) { cgit_query_search = xstrdup(value); } else if (!strcmp(name, "h")) { -- cgit v1.2.3-24-g4f1b