diff options
Diffstat (limited to 'shared.c')
-rw-r--r-- | shared.c | 33 |
1 files changed, 33 insertions, 0 deletions
@@ -10,10 +10,12 @@ | |||
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"; |
16 | char *cgit_logo = "/git-logo.png"; | 17 | char *cgit_logo = "/git-logo.png"; |
18 | char *cgit_index_header = NULL; | ||
17 | char *cgit_logo_link = "http://www.kernel.org/pub/software/scm/git/docs/"; | 19 | char *cgit_logo_link = "http://www.kernel.org/pub/software/scm/git/docs/"; |
18 | char *cgit_module_link = "./?repo=%s&page=commit&id=%s"; | 20 | char *cgit_module_link = "./?repo=%s&page=commit&id=%s"; |
19 | char *cgit_virtual_root = NULL; | 21 | char *cgit_virtual_root = NULL; |
@@ -52,6 +54,18 @@ int cgit_query_ofs = 0; | |||
52 | 54 | ||
53 | int htmlfd = 0; | 55 | int htmlfd = 0; |
54 | 56 | ||
57 | |||
58 | int cgit_get_cmd_index(const char *cmd) | ||
59 | { | ||
60 | static char *cmds[] = {"log", "commit", "diff", "tree", "view", "blob", "snapshot", NULL}; | ||
61 | int i; | ||
62 | |||
63 | for(i = 0; cmds[i]; i++) | ||
64 | if (!strcmp(cmd, cmds[i])) | ||
65 | return i + 1; | ||
66 | return 0; | ||
67 | } | ||
68 | |||
55 | int chk_zero(int result, char *msg) | 69 | int chk_zero(int result, char *msg) |
56 | { | 70 | { |
57 | if (result != 0) | 71 | if (result != 0) |
@@ -95,6 +109,19 @@ struct repoinfo *add_repo(const char *url) | |||
95 | return ret; | 109 | return ret; |
96 | } | 110 | } |
97 | 111 | ||
112 | struct repoinfo *cgit_get_repoinfo(const char *url) | ||
113 | { | ||
114 | int i; | ||
115 | struct repoinfo *repo; | ||
116 | |||
117 | for (i=0; i<cgit_repolist.count; i++) { | ||
118 | repo = &cgit_repolist.repos[i]; | ||
119 | if (!strcmp(repo->url, url)) | ||
120 | return repo; | ||
121 | } | ||
122 | return NULL; | ||
123 | } | ||
124 | |||
98 | void cgit_global_config_cb(const char *name, const char *value) | 125 | void cgit_global_config_cb(const char *name, const char *value) |
99 | { | 126 | { |
100 | if (!strcmp(name, "root-title")) | 127 | if (!strcmp(name, "root-title")) |
@@ -103,6 +130,8 @@ void cgit_global_config_cb(const char *name, const char *value) | |||
103 | cgit_css = xstrdup(value); | 130 | cgit_css = xstrdup(value); |
104 | else if (!strcmp(name, "logo")) | 131 | else if (!strcmp(name, "logo")) |
105 | cgit_logo = xstrdup(value); | 132 | cgit_logo = xstrdup(value); |
133 | else if (!strcmp(name, "index-header")) | ||
134 | cgit_index_header = xstrdup(value); | ||
106 | else if (!strcmp(name, "logo-link")) | 135 | else if (!strcmp(name, "logo-link")) |
107 | cgit_logo_link = xstrdup(value); | 136 | cgit_logo_link = xstrdup(value); |
108 | else if (!strcmp(name, "module-link")) | 137 | else if (!strcmp(name, "module-link")) |
@@ -163,8 +192,12 @@ void cgit_querystring_cb(const char *name, const char *value) | |||
163 | { | 192 | { |
164 | if (!strcmp(name,"r")) { | 193 | if (!strcmp(name,"r")) { |
165 | cgit_query_repo = xstrdup(value); | 194 | cgit_query_repo = xstrdup(value); |
195 | cgit_repo = cgit_get_repoinfo(value); | ||
166 | } else if (!strcmp(name, "p")) { | 196 | } else if (!strcmp(name, "p")) { |
167 | cgit_query_page = xstrdup(value); | 197 | cgit_query_page = xstrdup(value); |
198 | cgit_cmd = cgit_get_cmd_index(value); | ||
199 | } else if (!strcmp(name, "url")) { | ||
200 | cgit_parse_url(value); | ||
168 | } else if (!strcmp(name, "q")) { | 201 | } else if (!strcmp(name, "q")) { |
169 | cgit_query_search = xstrdup(value); | 202 | cgit_query_search = xstrdup(value); |
170 | } else if (!strcmp(name, "h")) { | 203 | } else if (!strcmp(name, "h")) { |