summaryrefslogtreecommitdiffabout
path: root/ui-shared.c
authorJohan Herland <johan@herland.net>2010-06-09 23:09:24 (UTC)
committer Lars Hjemli <hjemli@gmail.com>2010-06-19 08:40:21 (UTC)
commitc3f23d4571c06c979eddbd4c973163ba76c7e50f (patch) (side-by-side diff)
treeef73940ab3ac1ccc3d3a8dcb0ba0279c6a2a6fa0 /ui-shared.c
parent026980c270354c59b8a192f5e6db7efe9c66dd62 (diff)
downloadcgit-c3f23d4571c06c979eddbd4c973163ba76c7e50f.zip
cgit-c3f23d4571c06c979eddbd4c973163ba76c7e50f.tar.gz
cgit-c3f23d4571c06c979eddbd4c973163ba76c7e50f.tar.bz2
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>
Diffstat (limited to 'ui-shared.c') (more/less context) (ignore whitespace changes)
-rw-r--r--ui-shared.c76
1 files changed, 40 insertions, 36 deletions
diff --git a/ui-shared.c b/ui-shared.c
index 8827fff..7d7fff0 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -24,13 +24,13 @@ static char *http_date(time_t t)
struct tm *tm = gmtime(&t);
return fmt("%s, %02d %s %04d %02d:%02d:%02d GMT", day[tm->tm_wday],
tm->tm_mday, month[tm->tm_mon], 1900+tm->tm_year,
tm->tm_hour, tm->tm_min, tm->tm_sec);
}
-void cgit_print_error(char *msg)
+void cgit_print_error(const char *msg)
{
html("<div class='error'>");
html_txt(msg);
html("</div>\n");
}
@@ -130,13 +130,13 @@ char *cgit_currurl()
else if (ctx.qry.repo)
return fmt("%s/%s/", ctx.cfg.virtual_root, ctx.qry.repo);
else
return fmt("%s/", ctx.cfg.virtual_root);
}
-static void site_url(char *page, char *search, int ofs)
+static void site_url(const char *page, const char *search, int ofs)
{
char *delim = "?";
if (ctx.cfg.virtual_root) {
html_attr(ctx.cfg.virtual_root);
if (ctx.cfg.virtual_root[strlen(ctx.cfg.virtual_root) - 1] != '/')
@@ -157,14 +157,14 @@ static void site_url(char *page, char *search, int ofs)
if (ofs) {
html(delim);
htmlf("ofs=%d", ofs);
}
}
-static void site_link(char *page, char *name, char *title, char *class,
- char *search, int ofs)
+static void site_link(const char *page, const char *name, const char *title,
+ const char *class, const char *search, int ofs)
{
html("<a");
if (title) {
html(" title='");
html_attr(title);
html("'");
@@ -178,20 +178,20 @@ static void site_link(char *page, char *name, char *title, char *class,
site_url(page, search, ofs);
html("'>");
html_txt(name);
html("</a>");
}
-void cgit_index_link(char *name, char *title, char *class, char *pattern,
- int ofs)
+void cgit_index_link(const char *name, const char *title, const char *class,
+ const char *pattern, int ofs)
{
site_link(NULL, name, title, class, pattern, ofs);
}
-static char *repolink(char *title, char *class, char *page, char *head,
- char *path)
+static char *repolink(const char *title, const char *class, const char *page,
+ const char *head, const char *path)
{
char *delim = "?";
html("<a");
if (title) {
html(" title='");
@@ -237,14 +237,15 @@ static char *repolink(char *title, char *class, char *page, char *head,
html_url_arg(head);
delim = "&amp;";
}
return fmt("%s", delim);
}
-static void reporevlink(char *page, char *name, char *title, char *class,
- char *head, char *rev, char *path)
+static void reporevlink(const char *page, const char *name, const char *title,
+ const char *class, const char *head, const char *rev,
+ const char *path)
{
char *delim;
delim = repolink(title, class, page, head, path);
if (rev && ctx.qry.head != NULL && strcmp(rev, ctx.qry.head)) {
html(delim);
@@ -253,38 +254,39 @@ static void reporevlink(char *page, char *name, char *title, char *class,
}
html("'>");
html_txt(name);
html("</a>");
}
-void cgit_summary_link(char *name, char *title, char *class, char *head)
+void cgit_summary_link(const char *name, const char *title, const char *class,
+ const char *head)
{
reporevlink(NULL, name, title, class, head, NULL, NULL);
}
-void cgit_tag_link(char *name, char *title, char *class, char *head,
- char *rev)
+void cgit_tag_link(const char *name, const char *title, const char *class,
+ const char *head, const char *rev)
{
reporevlink("tag", name, title, class, head, rev, NULL);
}
-void cgit_tree_link(char *name, char *title, char *class, char *head,
- char *rev, char *path)
+void cgit_tree_link(const char *name, const char *title, const char *class,
+ const char *head, const char *rev, const char *path)
{
reporevlink("tree", name, title, class, head, rev, path);
}
-void cgit_plain_link(char *name, char *title, char *class, char *head,
- char *rev, char *path)
+void cgit_plain_link(const char *name, const char *title, const char *class,
+ const char *head, const char *rev, const char *path)
{
reporevlink("plain", name, title, class, head, rev, path);
}
-void cgit_log_link(char *name, char *title, char *class, char *head,
- char *rev, char *path, int ofs, char *grep, char *pattern,
- int showmsg)
+void cgit_log_link(const char *name, const char *title, const char *class,
+ const char *head, const char *rev, const char *path,
+ int ofs, const char *grep, const char *pattern, int showmsg)
{
char *delim;
delim = repolink(title, class, "log", head, path);
if (rev && strcmp(rev, ctx.qry.head)) {
html(delim);
@@ -313,14 +315,14 @@ void cgit_log_link(char *name, char *title, char *class, char *head,
}
html("'>");
html_txt(name);
html("</a>");
}
-void cgit_commit_link(char *name, char *title, char *class, char *head,
- char *rev, int toggle_ssdiff)
+void cgit_commit_link(char *name, const char *title, const char *class,
+ const char *head, const char *rev, int toggle_ssdiff)
{
if (strlen(name) > ctx.cfg.max_msg_len && ctx.cfg.max_msg_len >= 15) {
name[ctx.cfg.max_msg_len] = '\0';
name[ctx.cfg.max_msg_len - 1] = '.';
name[ctx.cfg.max_msg_len - 2] = '.';
name[ctx.cfg.max_msg_len - 3] = '.';
@@ -341,27 +343,28 @@ void cgit_commit_link(char *name, char *title, char *class, char *head,
}
html("'>");
html_txt(name);
html("</a>");
}
-void cgit_refs_link(char *name, char *title, char *class, char *head,
- char *rev, char *path)
+void cgit_refs_link(const char *name, const char *title, const char *class,
+ const char *head, const char *rev, const char *path)
{
reporevlink("refs", name, title, class, head, rev, path);
}
-void cgit_snapshot_link(char *name, char *title, char *class, char *head,
- char *rev, char *archivename)
+void cgit_snapshot_link(const char *name, const char *title, const char *class,
+ const char *head, const char *rev,
+ const char *archivename)
{
reporevlink("snapshot", name, title, class, head, rev, archivename);
}
-void cgit_diff_link(char *name, char *title, char *class, char *head,
- char *new_rev, char *old_rev, char *path,
- int toggle_ssdiff)
+void cgit_diff_link(const char *name, const char *title, const char *class,
+ const char *head, const char *new_rev, const char *old_rev,
+ const char *path, int toggle_ssdiff)
{
char *delim;
delim = repolink(title, class, "diff", head, path);
if (new_rev && ctx.qry.head != NULL && strcmp(new_rev, ctx.qry.head)) {
html(delim);
@@ -381,20 +384,20 @@ void cgit_diff_link(char *name, char *title, char *class, char *head,
}
html("'>");
html_txt(name);
html("</a>");
}
-void cgit_patch_link(char *name, char *title, char *class, char *head,
- char *rev)
+void cgit_patch_link(const char *name, const char *title, const char *class,
+ const char *head, const char *rev)
{
reporevlink("patch", name, title, class, head, rev, NULL);
}
-void cgit_stats_link(char *name, char *title, char *class, char *head,
- char *path)
+void cgit_stats_link(const char *name, const char *title, const char *class,
+ const char *head, const char *path)
{
reporevlink("stats", name, title, class, head, NULL, path);
}
void cgit_object_link(struct object *obj)
{
@@ -414,13 +417,13 @@ void cgit_object_link(struct object *obj)
else
page = "blob";
name = fmt("%s %s...", typename(obj->type), shortrev);
reporevlink(page, name, NULL, NULL, ctx.qry.head, fullrev, NULL);
}
-void cgit_print_date(time_t secs, char *format, int local_time)
+void cgit_print_date(time_t secs, const char *format, int local_time)
{
char buf[64];
struct tm *time;
if (!secs)
return;
@@ -429,13 +432,13 @@ void cgit_print_date(time_t secs, char *format, int local_time)
else
time = gmtime(&secs);
strftime(buf, sizeof(buf)-1, format, time);
html_txt(buf);
}
-void cgit_print_age(time_t t, time_t max_relative, char *format)
+void cgit_print_age(time_t t, time_t max_relative, const char *format)
{
time_t now, secs;
if (!t)
return;
time(&now);
@@ -608,13 +611,14 @@ int print_archive_ref(const char *refname, const unsigned char *sha1,
html_link_open(url, NULL, "menu");
html_txt(strlpart(buf, 20));
html_link_close();
return 0;
}
-void cgit_add_hidden_formfields(int incl_head, int incl_search, char *page)
+void cgit_add_hidden_formfields(int incl_head, int incl_search,
+ const char *page)
{
char *url;
if (!ctx.cfg.virtual_root) {
url = fmt("%s/%s", ctx.qry.repo, page);
if (ctx.qry.path)