Mercurial > sci
comparison 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 |
comparison
equal
deleted
inserted
replaced
39:27f039a790f4 | 40:752bb1cd2dd8 |
---|---|
39 } | 39 } |
40 | 40 |
41 khttp_free(req); | 41 khttp_free(req); |
42 } | 42 } |
43 | 43 |
44 static const int statustab[] = { | |
45 [KHTTP_200] = 200, | |
46 [KHTTP_400] = 400, | |
47 [KHTTP_404] = 404, | |
48 [KHTTP_500] = 500 | |
49 }; | |
50 | |
51 static const char * const statusmsg[] = { | |
52 [KHTTP_200] = "OK", | |
53 [KHTTP_400] = "Bad Request", | |
54 [KHTTP_404] = "Not Found", | |
55 [KHTTP_500] = "Internal Server Error" | |
56 }; | |
57 | |
44 void | 58 void |
45 pageutil_status(struct kreq *req, enum khttp status) | 59 pageutil_status(struct kreq *req, enum khttp status) |
46 { | 60 { |
47 assert(req); | 61 assert(req); |
48 | 62 |
49 char *body; | 63 char *body; |
50 | 64 |
51 body = theme_page_status(status); | 65 /* |
66 * KHTTP_ are numbered like a standard enum, the Javascript code must | |
67 * get the appropriate HTTP code instead. | |
68 */ | |
69 body = theme_page_status(statustab[status], statusmsg[status]); | |
52 pageutil_render(req, status, KMIME_TEXT_HTML, body); | 70 pageutil_render(req, status, KMIME_TEXT_HTML, body); |
53 free(body); | 71 free(body); |
54 } | 72 } |
55 | 73 |
56 void | 74 void |