From aec1204a54e3baa12c76db75c2f67696def05eb0 Mon Sep 17 00:00:00 2001 From: John Keeping Date: Fri, 14 Aug 2015 12:47:01 +0100 Subject: 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 --- ui-shared.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'ui-shared.c') 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) html("\n\n"); } +void cgit_print_error_page(int code, const char *msg, const char *fmt, ...) +{ + va_list ap; + ctx.page.status = code; + ctx.page.statusmsg = msg; + cgit_print_http_headers(); + cgit_print_docstart(); + cgit_print_pageheader(); + va_start(ap, fmt); + cgit_vprint_error(fmt, ap); + va_end(ap); + cgit_print_docend(); +} + static void add_clone_urls(void (*fn)(const char *), char *txt, char *suffix) { struct strbuf **url_list = strbuf_split_str(txt, ' ', 0); -- cgit v1.2.3-59-g8ed1b