diff options
Diffstat (limited to 'server.h')
-rw-r--r-- | server.h | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/server.h b/server.h index 20d1803..4607d76 100644 --- a/server.h +++ b/server.h @@ -42,6 +42,8 @@ X(Search, "search") \ X(Stylesheet, "stylesheet") +extern const char *CSS; + enum { #define X(page, path) page, ENUM_PAGES @@ -57,7 +59,8 @@ extern const char *Pages[PagesLen]; X(Before, "before", kvalid_stringne) \ X(Tidy, "tidy", kvalid_int) \ X(Query, "query", kvalid_stringne) \ - X(Offset, "offset", kvalid_int) + X(Offset, "offset", kvalid_int) \ + X(Export, "export", NULL) enum Key { #define X(key, name, valid) key, @@ -166,19 +169,29 @@ struct Event { }; extern const char *htmlStylesheet; -enum kcgi_err htmlHead(struct khtmlreq *html, const char *title); +enum kcgi_err htmlHead( + struct khtmlreq *html, struct kreq *req, const char *title +); enum kcgi_err htmlHidden(struct khtmlreq *html, struct kreq *req, enum Key key); enum kcgi_err htmlNav(struct khtmlreq *html, struct kreq *req); enum kcgi_err htmlIRC(struct khtmlreq *html, const char *str); enum kcgi_err htmlEvent( struct khtmlreq *html, struct kreq *req, struct Event *event ); -enum kcgi_err htmlFooter(struct khtmlreq *html); +enum kcgi_err htmlFooter(struct khtmlreq *html, struct kreq *req); static inline enum kcgi_err httpHead(struct kreq *req, enum khttp http, enum kmime mime) { - return khttp_head(req, kresps[KRESP_STATUS], "%s", khttps[http]) + enum kcgi_err error = 0 + || khttp_head(req, kresps[KRESP_STATUS], "%s", khttps[http]) || khttp_head(req, kresps[KRESP_CONTENT_TYPE], "%s", kmimetypes[mime]); + if (req->fieldmap[Export]) { + error = error || khttp_head( + req, kresps[KRESP_CONTENT_DISPOSITION], + "attachment; filename=\"%s.%s\"", req->pagename, ksuffixes[mime] + ); + } + return error; } static inline enum kcgi_err |