|
diff --git a/shared.c b/shared.c index 06693b0..077934f 100644 --- a/ shared.c+++ b/ shared.c |
|
@@ -77,24 +77,31 @@ int chk_zero(int result, char *msg) |
77 | if (result != 0) |
77 | if (result != 0) |
78 | die("%s: %s", msg, strerror(errno)); |
78 | die("%s: %s", msg, strerror(errno)); |
79 | return result; |
79 | return result; |
80 | } |
80 | } |
81 | |
81 | |
82 | int chk_positive(int result, char *msg) |
82 | int chk_positive(int result, char *msg) |
83 | { |
83 | { |
84 | if (result <= 0) |
84 | if (result <= 0) |
85 | die("%s: %s", msg, strerror(errno)); |
85 | die("%s: %s", msg, strerror(errno)); |
86 | return result; |
86 | return result; |
87 | } |
87 | } |
88 | |
88 | |
| |
89 | int chk_non_negative(int result, char *msg) |
| |
90 | { |
| |
91 | if (result < 0) |
| |
92 | die("%s: %s",msg, strerror(errno)); |
| |
93 | return result; |
| |
94 | } |
| |
95 | |
89 | struct repoinfo *add_repo(const char *url) |
96 | struct repoinfo *add_repo(const char *url) |
90 | { |
97 | { |
91 | struct repoinfo *ret; |
98 | struct repoinfo *ret; |
92 | |
99 | |
93 | if (++cgit_repolist.count > cgit_repolist.length) { |
100 | if (++cgit_repolist.count > cgit_repolist.length) { |
94 | if (cgit_repolist.length == 0) |
101 | if (cgit_repolist.length == 0) |
95 | cgit_repolist.length = 8; |
102 | cgit_repolist.length = 8; |
96 | else |
103 | else |
97 | cgit_repolist.length *= 2; |
104 | cgit_repolist.length *= 2; |
98 | cgit_repolist.repos = xrealloc(cgit_repolist.repos, |
105 | cgit_repolist.repos = xrealloc(cgit_repolist.repos, |
99 | cgit_repolist.length * |
106 | cgit_repolist.length * |
100 | sizeof(struct repoinfo)); |
107 | sizeof(struct repoinfo)); |
@@ -139,25 +146,25 @@ void cgit_global_config_cb(const char *name, const char *value) |
139 | cgit_logo = xstrdup(value); |
146 | cgit_logo = xstrdup(value); |
140 | else if (!strcmp(name, "index-header")) |
147 | else if (!strcmp(name, "index-header")) |
141 | cgit_index_header = xstrdup(value); |
148 | cgit_index_header = xstrdup(value); |
142 | else if (!strcmp(name, "logo-link")) |
149 | else if (!strcmp(name, "logo-link")) |
143 | cgit_logo_link = xstrdup(value); |
150 | cgit_logo_link = xstrdup(value); |
144 | else if (!strcmp(name, "module-link")) |
151 | else if (!strcmp(name, "module-link")) |
145 | cgit_module_link = xstrdup(value); |
152 | cgit_module_link = xstrdup(value); |
146 | else if (!strcmp(name, "virtual-root")) |
153 | else if (!strcmp(name, "virtual-root")) |
147 | cgit_virtual_root = xstrdup(value); |
154 | cgit_virtual_root = xstrdup(value); |
148 | else if (!strcmp(name, "nocache")) |
155 | else if (!strcmp(name, "nocache")) |
149 | cgit_nocache = atoi(value); |
156 | cgit_nocache = atoi(value); |
150 | else if (!strcmp(name, "snapshots")) |
157 | else if (!strcmp(name, "snapshots")) |
151 | cgit_snapshots = atoi(value); |
158 | cgit_snapshots = cgit_parse_snapshots_mask(value); |
152 | else if (!strcmp(name, "enable-index-links")) |
159 | else if (!strcmp(name, "enable-index-links")) |
153 | cgit_enable_index_links = atoi(value); |
160 | cgit_enable_index_links = atoi(value); |
154 | else if (!strcmp(name, "enable-log-filecount")) |
161 | else if (!strcmp(name, "enable-log-filecount")) |
155 | cgit_enable_log_filecount = atoi(value); |
162 | cgit_enable_log_filecount = atoi(value); |
156 | else if (!strcmp(name, "enable-log-linecount")) |
163 | else if (!strcmp(name, "enable-log-linecount")) |
157 | cgit_enable_log_linecount = atoi(value); |
164 | cgit_enable_log_linecount = atoi(value); |
158 | else if (!strcmp(name, "cache-root")) |
165 | else if (!strcmp(name, "cache-root")) |
159 | cgit_cache_root = xstrdup(value); |
166 | cgit_cache_root = xstrdup(value); |
160 | else if (!strcmp(name, "cache-root-ttl")) |
167 | else if (!strcmp(name, "cache-root-ttl")) |
161 | cgit_cache_root_ttl = atoi(value); |
168 | cgit_cache_root_ttl = atoi(value); |
162 | else if (!strcmp(name, "cache-repo-ttl")) |
169 | else if (!strcmp(name, "cache-repo-ttl")) |
163 | cgit_cache_repo_ttl = atoi(value); |
170 | cgit_cache_repo_ttl = atoi(value); |
@@ -181,25 +188,25 @@ void cgit_global_config_cb(const char *name, const char *value) |
181 | cgit_repo = add_repo(value); |
188 | cgit_repo = add_repo(value); |
182 | else if (!strcmp(name, "repo.name")) |
189 | else if (!strcmp(name, "repo.name")) |
183 | cgit_repo->name = xstrdup(value); |
190 | cgit_repo->name = xstrdup(value); |
184 | else if (cgit_repo && !strcmp(name, "repo.path")) |
191 | else if (cgit_repo && !strcmp(name, "repo.path")) |
185 | cgit_repo->path = xstrdup(value); |
192 | cgit_repo->path = xstrdup(value); |
186 | else if (cgit_repo && !strcmp(name, "repo.desc")) |
193 | else if (cgit_repo && !strcmp(name, "repo.desc")) |
187 | cgit_repo->desc = xstrdup(value); |
194 | cgit_repo->desc = xstrdup(value); |
188 | else if (cgit_repo && !strcmp(name, "repo.owner")) |
195 | else if (cgit_repo && !strcmp(name, "repo.owner")) |
189 | cgit_repo->owner = xstrdup(value); |
196 | cgit_repo->owner = xstrdup(value); |
190 | else if (cgit_repo && !strcmp(name, "repo.defbranch")) |
197 | else if (cgit_repo && !strcmp(name, "repo.defbranch")) |
191 | cgit_repo->defbranch = xstrdup(value); |
198 | cgit_repo->defbranch = xstrdup(value); |
192 | else if (cgit_repo && !strcmp(name, "repo.snapshots")) |
199 | else if (cgit_repo && !strcmp(name, "repo.snapshots")) |
193 | cgit_repo->snapshots = cgit_snapshots * atoi(value); |
200 | cgit_repo->snapshots = cgit_snapshots & cgit_parse_snapshots_mask(value); /* XXX: &? */ |
194 | else if (cgit_repo && !strcmp(name, "repo.enable-log-filecount")) |
201 | else if (cgit_repo && !strcmp(name, "repo.enable-log-filecount")) |
195 | cgit_repo->enable_log_filecount = cgit_enable_log_filecount * atoi(value); |
202 | cgit_repo->enable_log_filecount = cgit_enable_log_filecount * atoi(value); |
196 | else if (cgit_repo && !strcmp(name, "repo.enable-log-linecount")) |
203 | else if (cgit_repo && !strcmp(name, "repo.enable-log-linecount")) |
197 | cgit_repo->enable_log_linecount = cgit_enable_log_linecount * atoi(value); |
204 | cgit_repo->enable_log_linecount = cgit_enable_log_linecount * atoi(value); |
198 | else if (cgit_repo && !strcmp(name, "repo.module-link")) |
205 | else if (cgit_repo && !strcmp(name, "repo.module-link")) |
199 | cgit_repo->module_link= xstrdup(value); |
206 | cgit_repo->module_link= xstrdup(value); |
200 | else if (cgit_repo && !strcmp(name, "repo.readme") && value != NULL) { |
207 | else if (cgit_repo && !strcmp(name, "repo.readme") && value != NULL) { |
201 | if (*value == '/') |
208 | if (*value == '/') |
202 | cgit_repo->readme = xstrdup(value); |
209 | cgit_repo->readme = xstrdup(value); |
203 | else |
210 | else |
204 | cgit_repo->readme = xstrdup(fmt("%s/%s", cgit_repo->path, value)); |
211 | cgit_repo->readme = xstrdup(fmt("%s/%s", cgit_repo->path, value)); |
205 | } else if (!strcmp(name, "include")) |
212 | } else if (!strcmp(name, "include")) |
|