diff options
author | Johan Herland <johan@herland.net> | 2010-06-10 08:09:24 (JST) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2010-06-19 17:40:21 (JST) |
commit | c3f23d4571c06c979eddbd4c973163ba76c7e50f (patch) | |
tree | ef73940ab3ac1ccc3d3a8dcb0ba0279c6a2a6fa0 | |
parent | 026980c270354c59b8a192f5e6db7efe9c66dd62 (diff) | |
download | cgit-c3f23d4571c06c979eddbd4c973163ba76c7e50f.zip cgit-c3f23d4571c06c979eddbd4c973163ba76c7e50f.tar.gz |
ui-shared: Improve const-ness in API
This is needed to prevent const-related warnings in later patches.
Signed-off-by: Johan Herland <johan@herland.net>
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
-rw-r--r-- | ui-shared.c | 76 | ||||
-rw-r--r-- | ui-shared.h | 69 |
2 files changed, 80 insertions, 65 deletions
diff --git a/ui-shared.c b/ui-shared.c index 8827fff..7d7fff0 100644 --- a/ui-shared.c +++ b/ui-shared.c | |||
@@ -27,7 +27,7 @@ static char *http_date(time_t t) | |||
27 | tm->tm_hour, tm->tm_min, tm->tm_sec); | 27 | tm->tm_hour, tm->tm_min, tm->tm_sec); |
28 | } | 28 | } |
29 | 29 | ||
30 | void cgit_print_error(char *msg) | 30 | void cgit_print_error(const char *msg) |
31 | { | 31 | { |
32 | html("<div class='error'>"); | 32 | html("<div class='error'>"); |
33 | html_txt(msg); | 33 | html_txt(msg); |
@@ -133,7 +133,7 @@ char *cgit_currurl() | |||
133 | return fmt("%s/", ctx.cfg.virtual_root); | 133 | return fmt("%s/", ctx.cfg.virtual_root); |
134 | } | 134 | } |
135 | 135 | ||
136 | static void site_url(char *page, char *search, int ofs) | 136 | static void site_url(const char *page, const char *search, int ofs) |
137 | { | 137 | { |
138 | char *delim = "?"; | 138 | char *delim = "?"; |
139 | 139 | ||
@@ -160,8 +160,8 @@ static void site_url(char *page, char *search, int ofs) | |||
160 | } | 160 | } |
161 | } | 161 | } |
162 | 162 | ||
163 | static void site_link(char *page, char *name, char *title, char *class, | 163 | static void site_link(const char *page, const char *name, const char *title, |
164 | char *search, int ofs) | 164 | const char *class, const char *search, int ofs) |
165 | { | 165 | { |
166 | html("<a"); | 166 | html("<a"); |
167 | if (title) { | 167 | if (title) { |
@@ -181,14 +181,14 @@ static void site_link(char *page, char *name, char *title, char *class, | |||
181 | html("</a>"); | 181 | html("</a>"); |
182 | } | 182 | } |
183 | 183 | ||
184 | void cgit_index_link(char *name, char *title, char *class, char *pattern, | 184 | void cgit_index_link(const char *name, const char *title, const char *class, |
185 | int ofs) | 185 | const char *pattern, int ofs) |
186 | { | 186 | { |
187 | site_link(NULL, name, title, class, pattern, ofs); | 187 | site_link(NULL, name, title, class, pattern, ofs); |
188 | } | 188 | } |
189 | 189 | ||
190 | static char *repolink(char *title, char *class, char *page, char *head, | 190 | static char *repolink(const char *title, const char *class, const char *page, |
191 | char *path) | 191 | const char *head, const char *path) |
192 | { | 192 | { |
193 | char *delim = "?"; | 193 | char *delim = "?"; |
194 | 194 | ||
@@ -240,8 +240,9 @@ static char *repolink(char *title, char *class, char *page, char *head, | |||
240 | return fmt("%s", delim); | 240 | return fmt("%s", delim); |
241 | } | 241 | } |
242 | 242 | ||
243 | static void reporevlink(char *page, char *name, char *title, char *class, | 243 | static void reporevlink(const char *page, const char *name, const char *title, |
244 | char *head, char *rev, char *path) | 244 | const char *class, const char *head, const char *rev, |
245 | const char *path) | ||
245 | { | 246 | { |
246 | char *delim; | 247 | char *delim; |
247 | 248 | ||
@@ -256,32 +257,33 @@ static void reporevlink(char *page, char *name, char *title, char *class, | |||
256 | html("</a>"); | 257 | html("</a>"); |
257 | } | 258 | } |
258 | 259 | ||
259 | void cgit_summary_link(char *name, char *title, char *class, char *head) | 260 | void cgit_summary_link(const char *name, const char *title, const char *class, |
261 | const char *head) | ||
260 | { | 262 | { |
261 | reporevlink(NULL, name, title, class, head, NULL, NULL); | 263 | reporevlink(NULL, name, title, class, head, NULL, NULL); |
262 | } | 264 | } |
263 | 265 | ||
264 | void cgit_tag_link(char *name, char *title, char *class, char *head, | 266 | void cgit_tag_link(const char *name, const char *title, const char *class, |
265 | char *rev) | 267 | const char *head, const char *rev) |
266 | { | 268 | { |
267 | reporevlink("tag", name, title, class, head, rev, NULL); | 269 | reporevlink("tag", name, title, class, head, rev, NULL); |
268 | } | 270 | } |
269 | 271 | ||
270 | void cgit_tree_link(char *name, char *title, char *class, char *head, | 272 | void cgit_tree_link(const char *name, const char *title, const char *class, |
271 | char *rev, char *path) | 273 | const char *head, const char *rev, const char *path) |
272 | { | 274 | { |
273 | reporevlink("tree", name, title, class, head, rev, path); | 275 | reporevlink("tree", name, title, class, head, rev, path); |
274 | } | 276 | } |
275 | 277 | ||
276 | void cgit_plain_link(char *name, char *title, char *class, char *head, | 278 | void cgit_plain_link(const char *name, const char *title, const char *class, |
277 | char *rev, char *path) | 279 | const char *head, const char *rev, const char *path) |
278 | { | 280 | { |
279 | reporevlink("plain", name, title, class, head, rev, path); | 281 | reporevlink("plain", name, title, class, head, rev, path); |
280 | } | 282 | } |
281 | 283 | ||
282 | void cgit_log_link(char *name, char *title, char *class, char *head, | 284 | void cgit_log_link(const char *name, const char *title, const char *class, |
283 | char *rev, char *path, int ofs, char *grep, char *pattern, | 285 | const char *head, const char *rev, const char *path, |
284 | int showmsg) | 286 | int ofs, const char *grep, const char *pattern, int showmsg) |
285 | { | 287 | { |
286 | char *delim; | 288 | char *delim; |
287 | 289 | ||
@@ -316,8 +318,8 @@ void cgit_log_link(char *name, char *title, char *class, char *head, | |||
316 | html("</a>"); | 318 | html("</a>"); |
317 | } | 319 | } |
318 | 320 | ||
319 | void cgit_commit_link(char *name, char *title, char *class, char *head, | 321 | void cgit_commit_link(char *name, const char *title, const char *class, |
320 | char *rev, int toggle_ssdiff) | 322 | const char *head, const char *rev, int toggle_ssdiff) |
321 | { | 323 | { |
322 | if (strlen(name) > ctx.cfg.max_msg_len && ctx.cfg.max_msg_len >= 15) { | 324 | if (strlen(name) > ctx.cfg.max_msg_len && ctx.cfg.max_msg_len >= 15) { |
323 | name[ctx.cfg.max_msg_len] = '\0'; | 325 | name[ctx.cfg.max_msg_len] = '\0'; |
@@ -344,21 +346,22 @@ void cgit_commit_link(char *name, char *title, char *class, char *head, | |||
344 | html("</a>"); | 346 | html("</a>"); |
345 | } | 347 | } |
346 | 348 | ||
347 | void cgit_refs_link(char *name, char *title, char *class, char *head, | 349 | void cgit_refs_link(const char *name, const char *title, const char *class, |
348 | char *rev, char *path) | 350 | const char *head, const char *rev, const char *path) |
349 | { | 351 | { |
350 | reporevlink("refs", name, title, class, head, rev, path); | 352 | reporevlink("refs", name, title, class, head, rev, path); |
351 | } | 353 | } |
352 | 354 | ||
353 | void cgit_snapshot_link(char *name, char *title, char *class, char *head, | 355 | void cgit_snapshot_link(const char *name, const char *title, const char *class, |
354 | char *rev, char *archivename) | 356 | const char *head, const char *rev, |
357 | const char *archivename) | ||
355 | { | 358 | { |
356 | reporevlink("snapshot", name, title, class, head, rev, archivename); | 359 | reporevlink("snapshot", name, title, class, head, rev, archivename); |
357 | } | 360 | } |
358 | 361 | ||
359 | void cgit_diff_link(char *name, char *title, char *class, char *head, | 362 | void cgit_diff_link(const char *name, const char *title, const char *class, |
360 | char *new_rev, char *old_rev, char *path, | 363 | const char *head, const char *new_rev, const char *old_rev, |
361 | int toggle_ssdiff) | 364 | const char *path, int toggle_ssdiff) |
362 | { | 365 | { |
363 | char *delim; | 366 | char *delim; |
364 | 367 | ||
@@ -384,14 +387,14 @@ void cgit_diff_link(char *name, char *title, char *class, char *head, | |||
384 | html("</a>"); | 387 | html("</a>"); |
385 | } | 388 | } |
386 | 389 | ||
387 | void cgit_patch_link(char *name, char *title, char *class, char *head, | 390 | void cgit_patch_link(const char *name, const char *title, const char *class, |
388 | char *rev) | 391 | const char *head, const char *rev) |
389 | { | 392 | { |
390 | reporevlink("patch", name, title, class, head, rev, NULL); | 393 | reporevlink("patch", name, title, class, head, rev, NULL); |
391 | } | 394 | } |
392 | 395 | ||
393 | void cgit_stats_link(char *name, char *title, char *class, char *head, | 396 | void cgit_stats_link(const char *name, const char *title, const char *class, |
394 | char *path) | 397 | const char *head, const char *path) |
395 | { | 398 | { |
396 | reporevlink("stats", name, title, class, head, NULL, path); | 399 | reporevlink("stats", name, title, class, head, NULL, path); |
397 | } | 400 | } |
@@ -417,7 +420,7 @@ void cgit_object_link(struct object *obj) | |||
417 | reporevlink(page, name, NULL, NULL, ctx.qry.head, fullrev, NULL); | 420 | reporevlink(page, name, NULL, NULL, ctx.qry.head, fullrev, NULL); |
418 | } | 421 | } |
419 | 422 | ||
420 | void cgit_print_date(time_t secs, char *format, int local_time) | 423 | void cgit_print_date(time_t secs, const char *format, int local_time) |
421 | { | 424 | { |
422 | char buf[64]; | 425 | char buf[64]; |
423 | struct tm *time; | 426 | struct tm *time; |
@@ -432,7 +435,7 @@ void cgit_print_date(time_t secs, char *format, int local_time) | |||
432 | html_txt(buf); | 435 | html_txt(buf); |
433 | } | 436 | } |
434 | 437 | ||
435 | void cgit_print_age(time_t t, time_t max_relative, char *format) | 438 | void cgit_print_age(time_t t, time_t max_relative, const char *format) |
436 | { | 439 | { |
437 | time_t now, secs; | 440 | time_t now, secs; |
438 | 441 | ||
@@ -611,7 +614,8 @@ int print_archive_ref(const char *refname, const unsigned char *sha1, | |||
611 | return 0; | 614 | return 0; |
612 | } | 615 | } |
613 | 616 | ||
614 | void cgit_add_hidden_formfields(int incl_head, int incl_search, char *page) | 617 | void cgit_add_hidden_formfields(int incl_head, int incl_search, |
618 | const char *page) | ||
615 | { | 619 | { |
616 | char *url; | 620 | char *url; |
617 | 621 | ||
diff --git a/ui-shared.h b/ui-shared.h index 9ebc1f9..308c982 100644 --- a/ui-shared.h +++ b/ui-shared.h | |||
@@ -10,36 +10,47 @@ extern char *cgit_fileurl(const char *reponame, const char *pagename, | |||
10 | extern char *cgit_pageurl(const char *reponame, const char *pagename, | 10 | extern char *cgit_pageurl(const char *reponame, const char *pagename, |
11 | const char *query); | 11 | const char *query); |
12 | 12 | ||
13 | extern void cgit_index_link(char *name, char *title, char *class, | 13 | extern void cgit_index_link(const char *name, const char *title, |
14 | char *pattern, int ofs); | 14 | const char *class, const char *pattern, int ofs); |
15 | extern void cgit_summary_link(char *name, char *title, char *class, char *head); | 15 | extern void cgit_summary_link(const char *name, const char *title, |
16 | extern void cgit_tag_link(char *name, char *title, char *class, char *head, | 16 | const char *class, const char *head); |
17 | char *rev); | 17 | extern void cgit_tag_link(const char *name, const char *title, |
18 | extern void cgit_tree_link(char *name, char *title, char *class, char *head, | 18 | const char *class, const char *head, |
19 | char *rev, char *path); | 19 | const char *rev); |
20 | extern void cgit_plain_link(char *name, char *title, char *class, char *head, | 20 | extern void cgit_tree_link(const char *name, const char *title, |
21 | char *rev, char *path); | 21 | const char *class, const char *head, |
22 | extern void cgit_log_link(char *name, char *title, char *class, char *head, | 22 | const char *rev, const char *path); |
23 | char *rev, char *path, int ofs, char *grep, | 23 | extern void cgit_plain_link(const char *name, const char *title, |
24 | char *pattern, int showmsg); | 24 | const char *class, const char *head, |
25 | extern void cgit_commit_link(char *name, char *title, char *class, char *head, | 25 | const char *rev, const char *path); |
26 | char *rev, int toggle_ssdiff); | 26 | extern void cgit_log_link(const char *name, const char *title, |
27 | extern void cgit_patch_link(char *name, char *title, char *class, char *head, | 27 | const char *class, const char *head, const char *rev, |
28 | char *rev); | 28 | const char *path, int ofs, const char *grep, |
29 | extern void cgit_refs_link(char *name, char *title, char *class, char *head, | 29 | const char *pattern, int showmsg); |
30 | char *rev, char *path); | 30 | extern void cgit_commit_link(char *name, const char *title, |
31 | extern void cgit_snapshot_link(char *name, char *title, char *class, | 31 | const char *class, const char *head, |
32 | char *head, char *rev, char *archivename); | 32 | const char *rev, int toggle_ssdiff); |
33 | extern void cgit_diff_link(char *name, char *title, char *class, char *head, | 33 | extern void cgit_patch_link(const char *name, const char *title, |
34 | char *new_rev, char *old_rev, char *path, | 34 | const char *class, const char *head, |
35 | int toggle_ssdiff); | 35 | const char *rev); |
36 | extern void cgit_stats_link(char *name, char *title, char *class, char *head, | 36 | extern void cgit_refs_link(const char *name, const char *title, |
37 | char *path); | 37 | const char *class, const char *head, |
38 | const char *rev, const char *path); | ||
39 | extern void cgit_snapshot_link(const char *name, const char *title, | ||
40 | const char *class, const char *head, | ||
41 | const char *rev, const char *archivename); | ||
42 | extern void cgit_diff_link(const char *name, const char *title, | ||
43 | const char *class, const char *head, | ||
44 | const char *new_rev, const char *old_rev, | ||
45 | const char *path, int toggle_ssdiff); | ||
46 | extern void cgit_stats_link(const char *name, const char *title, | ||
47 | const char *class, const char *head, | ||
48 | const char *path); | ||
38 | extern void cgit_object_link(struct object *obj); | 49 | extern void cgit_object_link(struct object *obj); |
39 | 50 | ||
40 | extern void cgit_print_error(char *msg); | 51 | extern void cgit_print_error(const char *msg); |
41 | extern void cgit_print_date(time_t secs, char *format, int local_time); | 52 | extern void cgit_print_date(time_t secs, const char *format, int local_time); |
42 | extern void cgit_print_age(time_t t, time_t max_relative, char *format); | 53 | extern void cgit_print_age(time_t t, time_t max_relative, const char *format); |
43 | extern void cgit_print_http_headers(struct cgit_context *ctx); | 54 | extern void cgit_print_http_headers(struct cgit_context *ctx); |
44 | extern void cgit_print_docstart(struct cgit_context *ctx); | 55 | extern void cgit_print_docstart(struct cgit_context *ctx); |
45 | extern void cgit_print_docend(); | 56 | extern void cgit_print_docend(); |
@@ -48,5 +59,5 @@ extern void cgit_print_filemode(unsigned short mode); | |||
48 | extern void cgit_print_snapshot_links(const char *repo, const char *head, | 59 | extern void cgit_print_snapshot_links(const char *repo, const char *head, |
49 | const char *hex, int snapshots); | 60 | const char *hex, int snapshots); |
50 | extern void cgit_add_hidden_formfields(int incl_head, int incl_search, | 61 | extern void cgit_add_hidden_formfields(int incl_head, int incl_search, |
51 | char *page); | 62 | const char *page); |
52 | #endif /* UI_SHARED_H */ | 63 | #endif /* UI_SHARED_H */ |