aboutsummaryrefslogtreecommitdiffstats
path: root/ui-snapshot.c
diff options
context:
space:
mode:
Diffstat (limited to 'ui-snapshot.c')
-rw-r--r--ui-snapshot.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/ui-snapshot.c b/ui-snapshot.c
index 9be5dbe..a47884e 100644
--- a/ui-snapshot.c
+++ b/ui-snapshot.c
@@ -100,11 +100,11 @@ static int make_snapshot(const struct cgit_snapshot_format *format,
100 unsigned char sha1[20]; 100 unsigned char sha1[20];
101 101
102 if (get_sha1(hex, sha1)) { 102 if (get_sha1(hex, sha1)) {
103 cgit_print_error(fmt("Bad object id: %s", hex)); 103 cgit_print_error("Bad object id: %s", hex);
104 return 1; 104 return 1;
105 } 105 }
106 if (!lookup_commit_reference(sha1)) { 106 if (!lookup_commit_reference(sha1)) {
107 cgit_print_error(fmt("Not a commit reference: %s", hex)); 107 cgit_print_error("Not a commit reference: %s", hex);
108 return 1; 108 return 1;
109 } 109 }
110 ctx.page.mimetype = xstrdup(format->mimetype); 110 ctx.page.mimetype = xstrdup(format->mimetype);
@@ -154,13 +154,18 @@ static const char *get_ref_from_filename(const char *url, const char *filename,
154 return NULL; 154 return NULL;
155} 155}
156 156
157static void show_error(char *msg) 157__attribute__((format (printf, 1, 2)))
158static void show_error(char *fmt, ...)
158{ 159{
160 va_list ap;
161
159 ctx.page.mimetype = "text/html"; 162 ctx.page.mimetype = "text/html";
160 cgit_print_http_headers(&ctx); 163 cgit_print_http_headers(&ctx);
161 cgit_print_docstart(&ctx); 164 cgit_print_docstart(&ctx);
162 cgit_print_pageheader(&ctx); 165 cgit_print_pageheader(&ctx);
163 cgit_print_error(msg); 166 va_start(ap, fmt);
167 cgit_vprint_error(fmt, ap);
168 va_end(ap);
164 cgit_print_docend(); 169 cgit_print_docend();
165} 170}
166 171
@@ -177,8 +182,7 @@ void cgit_print_snapshot(const char *head, const char *hex,
177 182
178 f = get_format(filename); 183 f = get_format(filename);
179 if (!f) { 184 if (!f) {
180 show_error(xstrdup(fmt("Unsupported snapshot format: %s", 185 show_error("Unsupported snapshot format: %s", filename);
181 filename)));
182 return; 186 return;
183 } 187 }
184 188