Mercurial > sci
diff scid/pageutil.c @ 40:752bb1cd2dd8
themes: improve status page
author | David Demelier <markand@malikania.fr> |
---|---|
date | Sun, 07 Aug 2022 08:43:32 +0200 |
parents | 081e1c258e64 |
children | 576f4b1ec79f |
line wrap: on
line diff
--- a/scid/pageutil.c Sun Aug 07 08:42:04 2022 +0200 +++ b/scid/pageutil.c Sun Aug 07 08:43:32 2022 +0200 @@ -41,6 +41,20 @@ khttp_free(req); } +static const int statustab[] = { + [KHTTP_200] = 200, + [KHTTP_400] = 400, + [KHTTP_404] = 404, + [KHTTP_500] = 500 +}; + +static const char * const statusmsg[] = { + [KHTTP_200] = "OK", + [KHTTP_400] = "Bad Request", + [KHTTP_404] = "Not Found", + [KHTTP_500] = "Internal Server Error" +}; + void pageutil_status(struct kreq *req, enum khttp status) { @@ -48,7 +62,11 @@ char *body; - body = theme_page_status(status); + /* + * KHTTP_ are numbered like a standard enum, the Javascript code must + * get the appropriate HTTP code instead. + */ + body = theme_page_status(statustab[status], statusmsg[status]); pageutil_render(req, status, KMIME_TEXT_HTML, body); free(body); }