neocgit

a more 'modern' version of cgit
Log | Files | Refs | Submodules | README | LICENSE | git clone https://git.ne02ptzero.me/git/neocgit

commit aec1204a54e3baa12c76db75c2f67696def05eb0
parent aa12084f9835783abbd1f1e4609f8de05e73cec4
Author: John Keeping <john@keeping.me.uk>
Date:   Fri, 14 Aug 2015 12:47:01 +0100

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>

Diffstat:
Mui-shared.c | 14++++++++++++++
Mui-shared.h | 2++
2 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/ui-shared.c b/ui-shared.c @@ -788,6 +788,20 @@ void cgit_print_docend(void) html("</body>\n</html>\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); diff --git a/ui-shared.h b/ui-shared.h @@ -64,6 +64,8 @@ extern void cgit_print_http_headers(void); extern void cgit_redirect(const char *url, bool permanent); extern void cgit_print_docstart(void); extern void cgit_print_docend(); +__attribute__((format (printf,3,4))) +extern void cgit_print_error_page(int code, const char *msg, const char *fmt, ...); extern void cgit_print_pageheader(void); extern void cgit_print_filemode(unsigned short mode); extern void cgit_print_snapshot_links(const char *repo, const char *head,