summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--ui-shared.c76
-rw-r--r--ui-shared.h69
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
@@ -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)
diff --git a/ui-shared.h b/ui-shared.h
index 9ebc1f9..308c982 100644
--- a/ui-shared.h
+++ b/ui-shared.h
@@ -7,46 +7,57 @@ extern char *cgit_rooturl();
extern char *cgit_repourl(const char *reponame);
extern char *cgit_fileurl(const char *reponame, const char *pagename,
const char *filename, const char *query);
extern char *cgit_pageurl(const char *reponame, const char *pagename,
const char *query);
-extern void cgit_index_link(char *name, char *title, char *class,
- char *pattern, int ofs);
-extern void cgit_summary_link(char *name, char *title, char *class, char *head);
-extern void cgit_tag_link(char *name, char *title, char *class, char *head,
- char *rev);
-extern void cgit_tree_link(char *name, char *title, char *class, char *head,
- char *rev, char *path);
-extern void cgit_plain_link(char *name, char *title, char *class, char *head,
- char *rev, char *path);
-extern void cgit_log_link(char *name, char *title, char *class, char *head,
- char *rev, char *path, int ofs, char *grep,
- char *pattern, int showmsg);
-extern void cgit_commit_link(char *name, char *title, char *class, char *head,
- char *rev, int toggle_ssdiff);
-extern void cgit_patch_link(char *name, char *title, char *class, char *head,
- char *rev);
-extern void cgit_refs_link(char *name, char *title, char *class, char *head,
- char *rev, char *path);
-extern void cgit_snapshot_link(char *name, char *title, char *class,
- char *head, char *rev, char *archivename);
-extern void cgit_diff_link(char *name, char *title, char *class, char *head,
- char *new_rev, char *old_rev, char *path,
- int toggle_ssdiff);
-extern void cgit_stats_link(char *name, char *title, char *class, char *head,
- char *path);
+extern void cgit_index_link(const char *name, const char *title,
+ const char *class, const char *pattern, int ofs);
+extern void cgit_summary_link(const char *name, const char *title,
+ const char *class, const char *head);
+extern void cgit_tag_link(const char *name, const char *title,
+ const char *class, const char *head,
+ const char *rev);
+extern void cgit_tree_link(const char *name, const char *title,
+ const char *class, const char *head,
+ const char *rev, const char *path);
+extern void cgit_plain_link(const char *name, const char *title,
+ const char *class, const char *head,
+ const char *rev, const char *path);
+extern 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);
+extern void cgit_commit_link(char *name, const char *title,
+ const char *class, const char *head,
+ const char *rev, int toggle_ssdiff);
+extern void cgit_patch_link(const char *name, const char *title,
+ const char *class, const char *head,
+ const char *rev);
+extern void cgit_refs_link(const char *name, const char *title,
+ const char *class, const char *head,
+ const char *rev, const char *path);
+extern void cgit_snapshot_link(const char *name, const char *title,
+ const char *class, const char *head,
+ const char *rev, const char *archivename);
+extern 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);
+extern void cgit_stats_link(const char *name, const char *title,
+ const char *class, const char *head,
+ const char *path);
extern void cgit_object_link(struct object *obj);
-extern void cgit_print_error(char *msg);
-extern void cgit_print_date(time_t secs, char *format, int local_time);
-extern void cgit_print_age(time_t t, time_t max_relative, char *format);
+extern void cgit_print_error(const char *msg);
+extern void cgit_print_date(time_t secs, const char *format, int local_time);
+extern void cgit_print_age(time_t t, time_t max_relative, const char *format);
extern void cgit_print_http_headers(struct cgit_context *ctx);
extern void cgit_print_docstart(struct cgit_context *ctx);
extern void cgit_print_docend();
extern void cgit_print_pageheader(struct cgit_context *ctx);
extern void cgit_print_filemode(unsigned short mode);
extern void cgit_print_snapshot_links(const char *repo, const char *head,
const char *hex, int snapshots);
extern void cgit_add_hidden_formfields(int incl_head, int incl_search,
- char *page);
+ const char *page);
#endif /* UI_SHARED_H */