summaryrefslogtreecommitdiff
path: root/shared.c
diff options
context:
space:
mode:
authorLars Hjemli <hjemli@gmail.com>2007-05-20 20:09:55 +0000
committerLars Hjemli <hjemli@gmail.com>2007-05-20 20:09:55 +0000
commitdc3ac3f76077c5d612d42e8beb4878e43acfc58a (patch)
treedfb996c0ce9833841578e1f0accbb5a387c01237 /shared.c
parent977a0b173df6fe1a4d362fe4c70f9badff1fd46c (diff)
parent3de63b264c36888dfd42dfdf3fc0aad4ce0c2b5c (diff)
downloadcgit-dc3ac3f76077c5d612d42e8beb4878e43acfc58a.tar
cgit-dc3ac3f76077c5d612d42e8beb4878e43acfc58a.tar.gz
cgit-dc3ac3f76077c5d612d42e8beb4878e43acfc58a.zip
Merge branch 'virtual-url'
* virtual-url: Don't be fooled by trailing '/' in url-parameter cache_safe_filename() needs more buffers Enable url=value querystring parameter Add lookup-function for valid repo commands Move cgit_get_repoinfo into shared.c
Diffstat (limited to 'shared.c')
-rw-r--r--shared.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/shared.c b/shared.c
index 54b1813..45fde7f 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";
@@ -52,6 +53,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)
@@ -94,6 +107,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; i<cgit_repolist.count; i++) {
+ repo = &cgit_repolist.repos[i];
+ if (!strcmp(repo->url, url))
+ return repo;
+ }
+ return NULL;
+}
+
void cgit_global_config_cb(const char *name, const char *value)
{
if (!strcmp(name, "root-title"))
@@ -162,8 +188,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")) {