author | Lars Hjemli <hjemli@gmail.com> | 2007-05-17 22:47:47 (UTC) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2007-05-18 20:51:01 (UTC) |
commit | 305414df1246531baf0f2c959c2c61df4e93c526 (patch) (unidiff) | |
tree | 18f071e269f01b875fd0045723faab30345d93ae | |
parent | 08cc2e5f0e24773dad81d38bd6b689e36afe9dda (diff) | |
download | cgit-305414df1246531baf0f2c959c2c61df4e93c526.zip cgit-305414df1246531baf0f2c959c2c61df4e93c526.tar.gz cgit-305414df1246531baf0f2c959c2c61df4e93c526.tar.bz2 |
Move cgit_get_repoinfo into shared.c
This function will be usefull when parsing url arguments.
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
-rw-r--r-- | cgit.c | 14 | ||||
-rw-r--r-- | cgit.h | 1 | ||||
-rw-r--r-- | shared.c | 13 |
3 files changed, 14 insertions, 14 deletions
@@ -1,91 +1,77 @@ | |||
1 | /* cgit.c: cgi for the git scm | 1 | /* cgit.c: cgi for the git scm |
2 | * | 2 | * |
3 | * Copyright (C) 2006 Lars Hjemli | 3 | * Copyright (C) 2006 Lars Hjemli |
4 | * | 4 | * |
5 | * Licensed under GNU General Public License v2 | 5 | * Licensed under GNU General Public License v2 |
6 | * (see COPYING for full license text) | 6 | * (see COPYING for full license text) |
7 | */ | 7 | */ |
8 | 8 | ||
9 | #include "cgit.h" | 9 | #include "cgit.h" |
10 | 10 | ||
11 | const char cgit_version[] = CGIT_VERSION; | 11 | const char cgit_version[] = CGIT_VERSION; |
12 | 12 | ||
13 | 13 | ||
14 | static struct repoinfo *cgit_get_repoinfo(char *url) | ||
15 | { | ||
16 | int i; | ||
17 | struct repoinfo *repo; | ||
18 | |||
19 | for (i=0; i<cgit_repolist.count; i++) { | ||
20 | repo = &cgit_repolist.repos[i]; | ||
21 | if (!strcmp(repo->url, url)) | ||
22 | return repo; | ||
23 | } | ||
24 | return NULL; | ||
25 | } | ||
26 | |||
27 | |||
28 | static int cgit_prepare_cache(struct cacheitem *item) | 14 | static int cgit_prepare_cache(struct cacheitem *item) |
29 | { | 15 | { |
30 | if (!cgit_query_repo) { | 16 | if (!cgit_query_repo) { |
31 | item->name = xstrdup(fmt("%s/index.html", cgit_cache_root)); | 17 | item->name = xstrdup(fmt("%s/index.html", cgit_cache_root)); |
32 | item->ttl = cgit_cache_root_ttl; | 18 | item->ttl = cgit_cache_root_ttl; |
33 | return 1; | 19 | return 1; |
34 | } | 20 | } |
35 | cgit_repo = cgit_get_repoinfo(cgit_query_repo); | 21 | cgit_repo = cgit_get_repoinfo(cgit_query_repo); |
36 | if (!cgit_repo) { | 22 | if (!cgit_repo) { |
37 | char *title = fmt("%s - %s", cgit_root_title, "Bad request"); | 23 | char *title = fmt("%s - %s", cgit_root_title, "Bad request"); |
38 | cgit_print_docstart(title, item); | 24 | cgit_print_docstart(title, item); |
39 | cgit_print_pageheader(title, 0); | 25 | cgit_print_pageheader(title, 0); |
40 | cgit_print_error(fmt("Unknown repo: %s", cgit_query_repo)); | 26 | cgit_print_error(fmt("Unknown repo: %s", cgit_query_repo)); |
41 | cgit_print_docend(); | 27 | cgit_print_docend(); |
42 | return 0; | 28 | return 0; |
43 | } | 29 | } |
44 | 30 | ||
45 | if (!cgit_query_page) { | 31 | if (!cgit_query_page) { |
46 | item->name = xstrdup(fmt("%s/%s/index.html", cgit_cache_root, | 32 | item->name = xstrdup(fmt("%s/%s/index.html", cgit_cache_root, |
47 | cgit_repo->url)); | 33 | cgit_repo->url)); |
48 | item->ttl = cgit_cache_repo_ttl; | 34 | item->ttl = cgit_cache_repo_ttl; |
49 | } else { | 35 | } else { |
50 | item->name = xstrdup(fmt("%s/%s/%s/%s.html", cgit_cache_root, | 36 | item->name = xstrdup(fmt("%s/%s/%s/%s.html", cgit_cache_root, |
51 | cgit_repo->url, cgit_query_page, | 37 | cgit_repo->url, cgit_query_page, |
52 | cache_safe_filename(cgit_querystring))); | 38 | cache_safe_filename(cgit_querystring))); |
53 | if (cgit_query_has_symref) | 39 | if (cgit_query_has_symref) |
54 | item->ttl = cgit_cache_dynamic_ttl; | 40 | item->ttl = cgit_cache_dynamic_ttl; |
55 | else if (cgit_query_has_sha1) | 41 | else if (cgit_query_has_sha1) |
56 | item->ttl = cgit_cache_static_ttl; | 42 | item->ttl = cgit_cache_static_ttl; |
57 | else | 43 | else |
58 | item->ttl = cgit_cache_repo_ttl; | 44 | item->ttl = cgit_cache_repo_ttl; |
59 | } | 45 | } |
60 | return 1; | 46 | return 1; |
61 | } | 47 | } |
62 | 48 | ||
63 | static void cgit_print_repo_page(struct cacheitem *item) | 49 | static void cgit_print_repo_page(struct cacheitem *item) |
64 | { | 50 | { |
65 | char *title; | 51 | char *title; |
66 | int show_search; | 52 | int show_search; |
67 | 53 | ||
68 | if (!cgit_query_head) | 54 | if (!cgit_query_head) |
69 | cgit_query_head = cgit_repo->defbranch; | 55 | cgit_query_head = cgit_repo->defbranch; |
70 | 56 | ||
71 | if (chdir(cgit_repo->path)) { | 57 | if (chdir(cgit_repo->path)) { |
72 | title = fmt("%s - %s", cgit_root_title, "Bad request"); | 58 | title = fmt("%s - %s", cgit_root_title, "Bad request"); |
73 | cgit_print_docstart(title, item); | 59 | cgit_print_docstart(title, item); |
74 | cgit_print_pageheader(title, 0); | 60 | cgit_print_pageheader(title, 0); |
75 | cgit_print_error(fmt("Unable to scan repository: %s", | 61 | cgit_print_error(fmt("Unable to scan repository: %s", |
76 | strerror(errno))); | 62 | strerror(errno))); |
77 | cgit_print_docend(); | 63 | cgit_print_docend(); |
78 | return; | 64 | return; |
79 | } | 65 | } |
80 | 66 | ||
81 | title = fmt("%s - %s", cgit_repo->name, cgit_repo->desc); | 67 | title = fmt("%s - %s", cgit_repo->name, cgit_repo->desc); |
82 | show_search = 0; | 68 | show_search = 0; |
83 | setenv("GIT_DIR", cgit_repo->path, 1); | 69 | setenv("GIT_DIR", cgit_repo->path, 1); |
84 | 70 | ||
85 | if (cgit_query_page) { | 71 | if (cgit_query_page) { |
86 | if (cgit_repo->snapshots && !strcmp(cgit_query_page, "snapshot")) { | 72 | if (cgit_repo->snapshots && !strcmp(cgit_query_page, "snapshot")) { |
87 | cgit_print_snapshot(item, cgit_query_sha1, "zip", | 73 | cgit_print_snapshot(item, cgit_query_sha1, "zip", |
88 | cgit_repo->url, cgit_query_name); | 74 | cgit_repo->url, cgit_query_name); |
89 | return; | 75 | return; |
90 | } | 76 | } |
91 | if (!strcmp(cgit_query_page, "blob")) { | 77 | if (!strcmp(cgit_query_page, "blob")) { |
@@ -51,128 +51,129 @@ struct repolist { | |||
51 | struct commitinfo { | 51 | struct commitinfo { |
52 | struct commit *commit; | 52 | struct commit *commit; |
53 | char *author; | 53 | char *author; |
54 | char *author_email; | 54 | char *author_email; |
55 | unsigned long author_date; | 55 | unsigned long author_date; |
56 | char *committer; | 56 | char *committer; |
57 | char *committer_email; | 57 | char *committer_email; |
58 | unsigned long committer_date; | 58 | unsigned long committer_date; |
59 | char *subject; | 59 | char *subject; |
60 | char *msg; | 60 | char *msg; |
61 | }; | 61 | }; |
62 | 62 | ||
63 | struct taginfo { | 63 | struct taginfo { |
64 | char *tagger; | 64 | char *tagger; |
65 | char *tagger_email; | 65 | char *tagger_email; |
66 | int tagger_date; | 66 | int tagger_date; |
67 | char *msg; | 67 | char *msg; |
68 | }; | 68 | }; |
69 | 69 | ||
70 | extern const char cgit_version[]; | 70 | extern const char cgit_version[]; |
71 | 71 | ||
72 | extern struct repolist cgit_repolist; | 72 | extern struct repolist cgit_repolist; |
73 | extern struct repoinfo *cgit_repo; | 73 | extern struct repoinfo *cgit_repo; |
74 | 74 | ||
75 | extern char *cgit_root_title; | 75 | extern char *cgit_root_title; |
76 | extern char *cgit_css; | 76 | extern char *cgit_css; |
77 | extern char *cgit_logo; | 77 | extern char *cgit_logo; |
78 | extern char *cgit_logo_link; | 78 | extern char *cgit_logo_link; |
79 | extern char *cgit_module_link; | 79 | extern char *cgit_module_link; |
80 | extern char *cgit_virtual_root; | 80 | extern char *cgit_virtual_root; |
81 | extern char *cgit_script_name; | 81 | extern char *cgit_script_name; |
82 | extern char *cgit_cache_root; | 82 | extern char *cgit_cache_root; |
83 | 83 | ||
84 | extern int cgit_nocache; | 84 | extern int cgit_nocache; |
85 | extern int cgit_snapshots; | 85 | extern int cgit_snapshots; |
86 | extern int cgit_enable_log_filecount; | 86 | extern int cgit_enable_log_filecount; |
87 | extern int cgit_enable_log_linecount; | 87 | extern int cgit_enable_log_linecount; |
88 | extern int cgit_max_lock_attempts; | 88 | extern int cgit_max_lock_attempts; |
89 | extern int cgit_cache_root_ttl; | 89 | extern int cgit_cache_root_ttl; |
90 | extern int cgit_cache_repo_ttl; | 90 | extern int cgit_cache_repo_ttl; |
91 | extern int cgit_cache_dynamic_ttl; | 91 | extern int cgit_cache_dynamic_ttl; |
92 | extern int cgit_cache_static_ttl; | 92 | extern int cgit_cache_static_ttl; |
93 | extern int cgit_cache_max_create_time; | 93 | extern int cgit_cache_max_create_time; |
94 | 94 | ||
95 | extern int cgit_max_msg_len; | 95 | extern int cgit_max_msg_len; |
96 | extern int cgit_max_repodesc_len; | 96 | extern int cgit_max_repodesc_len; |
97 | extern int cgit_max_commit_count; | 97 | extern int cgit_max_commit_count; |
98 | 98 | ||
99 | extern int cgit_query_has_symref; | 99 | extern int cgit_query_has_symref; |
100 | extern int cgit_query_has_sha1; | 100 | extern int cgit_query_has_sha1; |
101 | 101 | ||
102 | extern char *cgit_querystring; | 102 | extern char *cgit_querystring; |
103 | extern char *cgit_query_repo; | 103 | extern char *cgit_query_repo; |
104 | extern char *cgit_query_page; | 104 | extern char *cgit_query_page; |
105 | extern char *cgit_query_search; | 105 | extern char *cgit_query_search; |
106 | extern char *cgit_query_head; | 106 | extern char *cgit_query_head; |
107 | extern char *cgit_query_sha1; | 107 | extern char *cgit_query_sha1; |
108 | extern char *cgit_query_sha2; | 108 | extern char *cgit_query_sha2; |
109 | extern char *cgit_query_path; | 109 | extern char *cgit_query_path; |
110 | extern char *cgit_query_name; | 110 | extern char *cgit_query_name; |
111 | extern int cgit_query_ofs; | 111 | extern int cgit_query_ofs; |
112 | 112 | ||
113 | extern int htmlfd; | 113 | extern int htmlfd; |
114 | 114 | ||
115 | extern struct repoinfo *cgit_get_repoinfo(const char *url); | ||
115 | extern void cgit_global_config_cb(const char *name, const char *value); | 116 | extern void cgit_global_config_cb(const char *name, const char *value); |
116 | extern void cgit_repo_config_cb(const char *name, const char *value); | 117 | extern void cgit_repo_config_cb(const char *name, const char *value); |
117 | extern void cgit_querystring_cb(const char *name, const char *value); | 118 | extern void cgit_querystring_cb(const char *name, const char *value); |
118 | 119 | ||
119 | extern int chk_zero(int result, char *msg); | 120 | extern int chk_zero(int result, char *msg); |
120 | extern int chk_positive(int result, char *msg); | 121 | extern int chk_positive(int result, char *msg); |
121 | 122 | ||
122 | extern int hextoint(char c); | 123 | extern int hextoint(char c); |
123 | 124 | ||
124 | extern void *cgit_free_commitinfo(struct commitinfo *info); | 125 | extern void *cgit_free_commitinfo(struct commitinfo *info); |
125 | 126 | ||
126 | extern int cgit_diff_files(const unsigned char *old_sha1, | 127 | extern int cgit_diff_files(const unsigned char *old_sha1, |
127 | const unsigned char *new_sha1, | 128 | const unsigned char *new_sha1, |
128 | linediff_fn fn); | 129 | linediff_fn fn); |
129 | 130 | ||
130 | extern void cgit_diff_tree(const unsigned char *old_sha1, | 131 | extern void cgit_diff_tree(const unsigned char *old_sha1, |
131 | const unsigned char *new_sha1, | 132 | const unsigned char *new_sha1, |
132 | filepair_fn fn); | 133 | filepair_fn fn); |
133 | 134 | ||
134 | extern void cgit_diff_commit(struct commit *commit, filepair_fn fn); | 135 | extern void cgit_diff_commit(struct commit *commit, filepair_fn fn); |
135 | 136 | ||
136 | extern char *fmt(const char *format,...); | 137 | extern char *fmt(const char *format,...); |
137 | 138 | ||
138 | extern void html(const char *txt); | 139 | extern void html(const char *txt); |
139 | extern void htmlf(const char *format,...); | 140 | extern void htmlf(const char *format,...); |
140 | extern void html_txt(char *txt); | 141 | extern void html_txt(char *txt); |
141 | extern void html_ntxt(int len, char *txt); | 142 | extern void html_ntxt(int len, char *txt); |
142 | extern void html_attr(char *txt); | 143 | extern void html_attr(char *txt); |
143 | extern void html_hidden(char *name, char *value); | 144 | extern void html_hidden(char *name, char *value); |
144 | extern void html_link_open(char *url, char *title, char *class); | 145 | extern void html_link_open(char *url, char *title, char *class); |
145 | extern void html_link_close(void); | 146 | extern void html_link_close(void); |
146 | extern void html_filemode(unsigned short mode); | 147 | extern void html_filemode(unsigned short mode); |
147 | 148 | ||
148 | extern int cgit_read_config(const char *filename, configfn fn); | 149 | extern int cgit_read_config(const char *filename, configfn fn); |
149 | extern int cgit_parse_query(char *txt, configfn fn); | 150 | extern int cgit_parse_query(char *txt, configfn fn); |
150 | extern struct commitinfo *cgit_parse_commit(struct commit *commit); | 151 | extern struct commitinfo *cgit_parse_commit(struct commit *commit); |
151 | extern struct taginfo *cgit_parse_tag(struct tag *tag); | 152 | extern struct taginfo *cgit_parse_tag(struct tag *tag); |
152 | 153 | ||
153 | extern char *cache_safe_filename(const char *unsafe); | 154 | extern char *cache_safe_filename(const char *unsafe); |
154 | extern int cache_lock(struct cacheitem *item); | 155 | extern int cache_lock(struct cacheitem *item); |
155 | extern int cache_unlock(struct cacheitem *item); | 156 | extern int cache_unlock(struct cacheitem *item); |
156 | extern int cache_cancel_lock(struct cacheitem *item); | 157 | extern int cache_cancel_lock(struct cacheitem *item); |
157 | extern int cache_exist(struct cacheitem *item); | 158 | extern int cache_exist(struct cacheitem *item); |
158 | extern int cache_expired(struct cacheitem *item); | 159 | extern int cache_expired(struct cacheitem *item); |
159 | 160 | ||
160 | extern char *cgit_repourl(const char *reponame); | 161 | extern char *cgit_repourl(const char *reponame); |
161 | extern char *cgit_pageurl(const char *reponame, const char *pagename, | 162 | extern char *cgit_pageurl(const char *reponame, const char *pagename, |
162 | const char *query); | 163 | const char *query); |
163 | 164 | ||
164 | extern void cgit_print_error(char *msg); | 165 | extern void cgit_print_error(char *msg); |
165 | extern void cgit_print_date(unsigned long secs); | 166 | extern void cgit_print_date(unsigned long secs); |
166 | extern void cgit_print_docstart(char *title, struct cacheitem *item); | 167 | extern void cgit_print_docstart(char *title, struct cacheitem *item); |
167 | extern void cgit_print_docend(); | 168 | extern void cgit_print_docend(); |
168 | extern void cgit_print_pageheader(char *title, int show_search); | 169 | extern void cgit_print_pageheader(char *title, int show_search); |
169 | extern void cgit_print_snapshot_start(const char *mimetype, | 170 | extern void cgit_print_snapshot_start(const char *mimetype, |
170 | const char *filename, | 171 | const char *filename, |
171 | struct cacheitem *item); | 172 | struct cacheitem *item); |
172 | 173 | ||
173 | extern void cgit_print_repolist(struct cacheitem *item); | 174 | extern void cgit_print_repolist(struct cacheitem *item); |
174 | extern void cgit_print_summary(); | 175 | extern void cgit_print_summary(); |
175 | extern void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *path); | 176 | extern void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *path); |
176 | extern void cgit_print_view(const char *hex, char *path); | 177 | extern void cgit_print_view(const char *hex, char *path); |
177 | extern void cgit_print_blob(struct cacheitem *item, const char *hex, char *path); | 178 | extern void cgit_print_blob(struct cacheitem *item, const char *hex, char *path); |
178 | extern void cgit_print_tree(const char *rev, const char *hex, char *path); | 179 | extern void cgit_print_tree(const char *rev, const char *hex, char *path); |
@@ -32,128 +32,141 @@ int cgit_cache_static_ttl = -1; | |||
32 | int cgit_cache_max_create_time = 5; | 32 | int cgit_cache_max_create_time = 5; |
33 | 33 | ||
34 | int cgit_max_msg_len = 60; | 34 | int cgit_max_msg_len = 60; |
35 | int cgit_max_repodesc_len = 60; | 35 | int cgit_max_repodesc_len = 60; |
36 | int cgit_max_commit_count = 50; | 36 | int cgit_max_commit_count = 50; |
37 | 37 | ||
38 | int cgit_query_has_symref = 0; | 38 | int cgit_query_has_symref = 0; |
39 | int cgit_query_has_sha1 = 0; | 39 | int cgit_query_has_sha1 = 0; |
40 | 40 | ||
41 | char *cgit_querystring = NULL; | 41 | char *cgit_querystring = NULL; |
42 | char *cgit_query_repo = NULL; | 42 | char *cgit_query_repo = NULL; |
43 | char *cgit_query_page = NULL; | 43 | char *cgit_query_page = NULL; |
44 | char *cgit_query_head = NULL; | 44 | char *cgit_query_head = NULL; |
45 | char *cgit_query_search = NULL; | 45 | char *cgit_query_search = NULL; |
46 | char *cgit_query_sha1 = NULL; | 46 | char *cgit_query_sha1 = NULL; |
47 | char *cgit_query_sha2 = NULL; | 47 | char *cgit_query_sha2 = NULL; |
48 | char *cgit_query_path = NULL; | 48 | char *cgit_query_path = NULL; |
49 | char *cgit_query_name = NULL; | 49 | char *cgit_query_name = NULL; |
50 | int cgit_query_ofs = 0; | 50 | int cgit_query_ofs = 0; |
51 | 51 | ||
52 | int htmlfd = 0; | 52 | int htmlfd = 0; |
53 | 53 | ||
54 | int chk_zero(int result, char *msg) | 54 | int chk_zero(int result, char *msg) |
55 | { | 55 | { |
56 | if (result != 0) | 56 | if (result != 0) |
57 | die("%s: %s", msg, strerror(errno)); | 57 | die("%s: %s", msg, strerror(errno)); |
58 | return result; | 58 | return result; |
59 | } | 59 | } |
60 | 60 | ||
61 | int chk_positive(int result, char *msg) | 61 | int chk_positive(int result, char *msg) |
62 | { | 62 | { |
63 | if (result <= 0) | 63 | if (result <= 0) |
64 | die("%s: %s", msg, strerror(errno)); | 64 | die("%s: %s", msg, strerror(errno)); |
65 | return result; | 65 | return result; |
66 | } | 66 | } |
67 | 67 | ||
68 | struct repoinfo *add_repo(const char *url) | 68 | struct repoinfo *add_repo(const char *url) |
69 | { | 69 | { |
70 | struct repoinfo *ret; | 70 | struct repoinfo *ret; |
71 | 71 | ||
72 | if (++cgit_repolist.count > cgit_repolist.length) { | 72 | if (++cgit_repolist.count > cgit_repolist.length) { |
73 | if (cgit_repolist.length == 0) | 73 | if (cgit_repolist.length == 0) |
74 | cgit_repolist.length = 8; | 74 | cgit_repolist.length = 8; |
75 | else | 75 | else |
76 | cgit_repolist.length *= 2; | 76 | cgit_repolist.length *= 2; |
77 | cgit_repolist.repos = xrealloc(cgit_repolist.repos, | 77 | cgit_repolist.repos = xrealloc(cgit_repolist.repos, |
78 | cgit_repolist.length * | 78 | cgit_repolist.length * |
79 | sizeof(struct repoinfo)); | 79 | sizeof(struct repoinfo)); |
80 | } | 80 | } |
81 | 81 | ||
82 | ret = &cgit_repolist.repos[cgit_repolist.count-1]; | 82 | ret = &cgit_repolist.repos[cgit_repolist.count-1]; |
83 | ret->url = xstrdup(url); | 83 | ret->url = xstrdup(url); |
84 | ret->name = ret->url; | 84 | ret->name = ret->url; |
85 | ret->path = NULL; | 85 | ret->path = NULL; |
86 | ret->desc = NULL; | 86 | ret->desc = NULL; |
87 | ret->owner = NULL; | 87 | ret->owner = NULL; |
88 | ret->defbranch = "master"; | 88 | ret->defbranch = "master"; |
89 | ret->snapshots = cgit_snapshots; | 89 | ret->snapshots = cgit_snapshots; |
90 | ret->enable_log_filecount = cgit_enable_log_filecount; | 90 | ret->enable_log_filecount = cgit_enable_log_filecount; |
91 | ret->enable_log_linecount = cgit_enable_log_linecount; | 91 | ret->enable_log_linecount = cgit_enable_log_linecount; |
92 | ret->module_link = cgit_module_link; | 92 | ret->module_link = cgit_module_link; |
93 | return ret; | 93 | return ret; |
94 | } | 94 | } |
95 | 95 | ||
96 | struct repoinfo *cgit_get_repoinfo(const char *url) | ||
97 | { | ||
98 | int i; | ||
99 | struct repoinfo *repo; | ||
100 | |||
101 | for (i=0; i<cgit_repolist.count; i++) { | ||
102 | repo = &cgit_repolist.repos[i]; | ||
103 | if (!strcmp(repo->url, url)) | ||
104 | return repo; | ||
105 | } | ||
106 | return NULL; | ||
107 | } | ||
108 | |||
96 | void cgit_global_config_cb(const char *name, const char *value) | 109 | void cgit_global_config_cb(const char *name, const char *value) |
97 | { | 110 | { |
98 | if (!strcmp(name, "root-title")) | 111 | if (!strcmp(name, "root-title")) |
99 | cgit_root_title = xstrdup(value); | 112 | cgit_root_title = xstrdup(value); |
100 | else if (!strcmp(name, "css")) | 113 | else if (!strcmp(name, "css")) |
101 | cgit_css = xstrdup(value); | 114 | cgit_css = xstrdup(value); |
102 | else if (!strcmp(name, "logo")) | 115 | else if (!strcmp(name, "logo")) |
103 | cgit_logo = xstrdup(value); | 116 | cgit_logo = xstrdup(value); |
104 | else if (!strcmp(name, "logo-link")) | 117 | else if (!strcmp(name, "logo-link")) |
105 | cgit_logo_link = xstrdup(value); | 118 | cgit_logo_link = xstrdup(value); |
106 | else if (!strcmp(name, "module-link")) | 119 | else if (!strcmp(name, "module-link")) |
107 | cgit_module_link = xstrdup(value); | 120 | cgit_module_link = xstrdup(value); |
108 | else if (!strcmp(name, "virtual-root")) | 121 | else if (!strcmp(name, "virtual-root")) |
109 | cgit_virtual_root = xstrdup(value); | 122 | cgit_virtual_root = xstrdup(value); |
110 | else if (!strcmp(name, "nocache")) | 123 | else if (!strcmp(name, "nocache")) |
111 | cgit_nocache = atoi(value); | 124 | cgit_nocache = atoi(value); |
112 | else if (!strcmp(name, "snapshots")) | 125 | else if (!strcmp(name, "snapshots")) |
113 | cgit_snapshots = atoi(value); | 126 | cgit_snapshots = atoi(value); |
114 | else if (!strcmp(name, "enable-log-filecount")) | 127 | else if (!strcmp(name, "enable-log-filecount")) |
115 | cgit_enable_log_filecount = atoi(value); | 128 | cgit_enable_log_filecount = atoi(value); |
116 | else if (!strcmp(name, "enable-log-linecount")) | 129 | else if (!strcmp(name, "enable-log-linecount")) |
117 | cgit_enable_log_linecount = atoi(value); | 130 | cgit_enable_log_linecount = atoi(value); |
118 | else if (!strcmp(name, "cache-root")) | 131 | else if (!strcmp(name, "cache-root")) |
119 | cgit_cache_root = xstrdup(value); | 132 | cgit_cache_root = xstrdup(value); |
120 | else if (!strcmp(name, "cache-root-ttl")) | 133 | else if (!strcmp(name, "cache-root-ttl")) |
121 | cgit_cache_root_ttl = atoi(value); | 134 | cgit_cache_root_ttl = atoi(value); |
122 | else if (!strcmp(name, "cache-repo-ttl")) | 135 | else if (!strcmp(name, "cache-repo-ttl")) |
123 | cgit_cache_repo_ttl = atoi(value); | 136 | cgit_cache_repo_ttl = atoi(value); |
124 | else if (!strcmp(name, "cache-static-ttl")) | 137 | else if (!strcmp(name, "cache-static-ttl")) |
125 | cgit_cache_static_ttl = atoi(value); | 138 | cgit_cache_static_ttl = atoi(value); |
126 | else if (!strcmp(name, "cache-dynamic-ttl")) | 139 | else if (!strcmp(name, "cache-dynamic-ttl")) |
127 | cgit_cache_dynamic_ttl = atoi(value); | 140 | cgit_cache_dynamic_ttl = atoi(value); |
128 | else if (!strcmp(name, "max-message-length")) | 141 | else if (!strcmp(name, "max-message-length")) |
129 | cgit_max_msg_len = atoi(value); | 142 | cgit_max_msg_len = atoi(value); |
130 | else if (!strcmp(name, "max-repodesc-length")) | 143 | else if (!strcmp(name, "max-repodesc-length")) |
131 | cgit_max_repodesc_len = atoi(value); | 144 | cgit_max_repodesc_len = atoi(value); |
132 | else if (!strcmp(name, "max-commit-count")) | 145 | else if (!strcmp(name, "max-commit-count")) |
133 | cgit_max_commit_count = atoi(value); | 146 | cgit_max_commit_count = atoi(value); |
134 | else if (!strcmp(name, "repo.url")) | 147 | else if (!strcmp(name, "repo.url")) |
135 | cgit_repo = add_repo(value); | 148 | cgit_repo = add_repo(value); |
136 | else if (!strcmp(name, "repo.name")) | 149 | else if (!strcmp(name, "repo.name")) |
137 | cgit_repo->name = xstrdup(value); | 150 | cgit_repo->name = xstrdup(value); |
138 | else if (cgit_repo && !strcmp(name, "repo.path")) | 151 | else if (cgit_repo && !strcmp(name, "repo.path")) |
139 | cgit_repo->path = xstrdup(value); | 152 | cgit_repo->path = xstrdup(value); |
140 | else if (cgit_repo && !strcmp(name, "repo.desc")) | 153 | else if (cgit_repo && !strcmp(name, "repo.desc")) |
141 | cgit_repo->desc = xstrdup(value); | 154 | cgit_repo->desc = xstrdup(value); |
142 | else if (cgit_repo && !strcmp(name, "repo.owner")) | 155 | else if (cgit_repo && !strcmp(name, "repo.owner")) |
143 | cgit_repo->owner = xstrdup(value); | 156 | cgit_repo->owner = xstrdup(value); |
144 | else if (cgit_repo && !strcmp(name, "repo.defbranch")) | 157 | else if (cgit_repo && !strcmp(name, "repo.defbranch")) |
145 | cgit_repo->defbranch = xstrdup(value); | 158 | cgit_repo->defbranch = xstrdup(value); |
146 | else if (cgit_repo && !strcmp(name, "repo.snapshots")) | 159 | else if (cgit_repo && !strcmp(name, "repo.snapshots")) |
147 | cgit_repo->snapshots = cgit_snapshots * atoi(value); | 160 | cgit_repo->snapshots = cgit_snapshots * atoi(value); |
148 | else if (cgit_repo && !strcmp(name, "repo.enable-log-filecount")) | 161 | else if (cgit_repo && !strcmp(name, "repo.enable-log-filecount")) |
149 | cgit_repo->enable_log_filecount = cgit_enable_log_filecount * atoi(value); | 162 | cgit_repo->enable_log_filecount = cgit_enable_log_filecount * atoi(value); |
150 | else if (cgit_repo && !strcmp(name, "repo.enable-log-linecount")) | 163 | else if (cgit_repo && !strcmp(name, "repo.enable-log-linecount")) |
151 | cgit_repo->enable_log_linecount = cgit_enable_log_linecount * atoi(value); | 164 | cgit_repo->enable_log_linecount = cgit_enable_log_linecount * atoi(value); |
152 | else if (cgit_repo && !strcmp(name, "repo.module-link")) | 165 | else if (cgit_repo && !strcmp(name, "repo.module-link")) |
153 | cgit_repo->module_link= xstrdup(value); | 166 | cgit_repo->module_link= xstrdup(value); |
154 | else if (!strcmp(name, "include")) | 167 | else if (!strcmp(name, "include")) |
155 | cgit_read_config(value, cgit_global_config_cb); | 168 | cgit_read_config(value, cgit_global_config_cb); |
156 | } | 169 | } |
157 | 170 | ||
158 | void cgit_querystring_cb(const char *name, const char *value) | 171 | void cgit_querystring_cb(const char *name, const char *value) |
159 | { | 172 | { |