diff options
author | John Keeping | 2015-08-14 12:47:01 +0100 |
---|---|---|
committer | Jason A. Donenfeld | 2015-08-14 15:46:51 +0200 |
commit | aec1204a54e3baa12c76db75c2f67696def05eb0 (patch) | |
tree | 313974d5bc7e8c26178f266f632d993cca2b883b | |
parent | aa12084f9835783abbd1f1e4609f8de05e73cec4 (diff) | |
download | cgit-aec1204a54e3baa12c76db75c2f67696def05eb0.tar.gz cgit-aec1204a54e3baa12c76db75c2f67696def05eb0.tar.bz2 cgit-aec1204a54e3baa12c76db75c2f67696def05eb0.zip |
ui-shared: add cgit_print_error_page() function
This will allow us to generate error responses with the correct HTTP
response code without needing all of the layout boilerplate.
Signed-off-by: John Keeping <john@keeping.me.uk>
-rw-r--r-- | ui-shared.c | 14 | ||||
-rw-r--r-- | ui-shared.h | 2 |
2 files changed, 16 insertions, 0 deletions
diff --git a/ui-shared.c b/ui-shared.c index 36fcb21..06dd0a8 100644 --- a/ui-shared.c +++ b/ui-shared.c | |||
@@ -788,6 +788,20 @@ void cgit_print_docend(void) | |||
788 | html("</body>\n</html>\n"); | 788 | html("</body>\n</html>\n"); |
789 | } | 789 | } |
790 | 790 | ||
791 | void cgit_print_error_page(int code, const char *msg, const char *fmt, ...) | ||
792 | { | ||
793 | va_list ap; | ||
794 | ctx.page.status = code; | ||
795 | ctx.page.statusmsg = msg; | ||
796 | cgit_print_http_headers(); | ||
797 | cgit_print_docstart(); | ||
798 | cgit_print_pageheader(); | ||
799 | va_start(ap, fmt); | ||
800 | cgit_vprint_error(fmt, ap); | ||
801 | va_end(ap); | ||
802 | cgit_print_docend(); | ||
803 | } | ||
804 | |||
791 | static void add_clone_urls(void (*fn)(const char *), char *txt, char *suffix) | 805 | static void add_clone_urls(void (*fn)(const char *), char *txt, char *suffix) |
792 | { | 806 | { |
793 | struct strbuf **url_list = strbuf_split_str(txt, ' ', 0); | 807 | struct strbuf **url_list = strbuf_split_str(txt, ' ', 0); |
diff --git a/ui-shared.h b/ui-shared.h index d8a3551..652685e 100644 --- a/ui-shared.h +++ b/ui-shared.h | |||
@@ -64,6 +64,8 @@ extern void cgit_print_http_headers(void); | |||
64 | extern void cgit_redirect(const char *url, bool permanent); | 64 | extern void cgit_redirect(const char *url, bool permanent); |
65 | extern void cgit_print_docstart(void); | 65 | extern void cgit_print_docstart(void); |
66 | extern void cgit_print_docend(); | 66 | extern void cgit_print_docend(); |
67 | __attribute__((format (printf,3,4))) | ||
68 | extern void cgit_print_error_page(int code, const char *msg, const char *fmt, ...); | ||
67 | extern void cgit_print_pageheader(void); | 69 | extern void cgit_print_pageheader(void); |
68 | extern void cgit_print_filemode(unsigned short mode); | 70 | extern void cgit_print_filemode(unsigned short mode); |
69 | extern void cgit_print_snapshot_links(const char *repo, const char *head, | 71 | extern void cgit_print_snapshot_links(const char *repo, const char *head, |