diff options
Diffstat (limited to 'browse.c')
-rw-r--r-- | browse.c | 36 |
1 files changed, 18 insertions, 18 deletions
@@ -35,15 +35,16 @@ #include <string.h> #include "browse.h" +#include "cgi.h" #include "config.h" -#include "error.h" #include "http.h" #include "url.h" #define URL_LENGTH_MAX 8192 /* - * Checks that the path can be safely processed. Namely, it should not contain "..", which denotes an attempt to get out of the DATA_DIR root folder. + * Checks that the path can be safely processed. Namely, it should not contain + * "..", which denotes an attempt to get out of the DATA_DIR root folder. */ static bool check_request_path(char *path) @@ -105,20 +106,19 @@ browse(struct kreq * r) } http_open(r, KHTTP_200); - if (KCGI_OK != khtml_open(&html, r, 0)) - return VAULT_CGI_ERROR; + K_OK(khtml_open(&html, r, 0)); /* build basic html page */ - khtml_elem(&html, KELEM_DOCTYPE); - khtml_elem(&html, KELEM_HEAD); - khtml_attr(&html, KELEM_META, KATTR_CHARSET, "utf-8", KATTR__MAX); - khtml_elem(&html, KELEM_HTML); - khtml_elem(&html, KELEM_BODY); - khtml_elem(&html, KELEM_P); - khtml_puts(&html, "/"); - khtml_closeelem(&html, 1); + K_OK(khtml_elem(&html, KELEM_DOCTYPE)); + K_OK(khtml_elem(&html, KELEM_HEAD)); + K_OK(khtml_attr(&html, KELEM_META, KATTR_CHARSET, "utf-8", KATTR__MAX)); + K_OK(khtml_elem(&html, KELEM_HTML)); + K_OK(khtml_elem(&html, KELEM_BODY)); + K_OK(khtml_elem(&html, KELEM_P)); + K_OK(khtml_puts(&html, "/")); + K_OK(khtml_closeelem(&html, 1)); - khtml_elem(&html, KELEM_UL); + K_OK(khtml_elem(&html, KELEM_UL)); while ((dir = readdir(data_dir)) != NULL) { /* ignore special . and .. folders */ file_name = dir->d_name; @@ -127,12 +127,12 @@ browse(struct kreq * r) url_size = build_browse_url(r, url, URL_LENGTH_MAX, file_name); if (url_size == 0 || url_size >= URL_LENGTH_MAX) continue; - khtml_elem(&html, KELEM_LI); - khtml_attr(&html, KELEM_A, KATTR_HREF, url, KATTR__MAX); - khtml_puts(&html, dir->d_name); - khtml_closeelem(&html, 2); + K_OK(khtml_elem(&html, KELEM_LI)); + K_OK(khtml_attr(&html, KELEM_A, KATTR_HREF, url, KATTR__MAX)); + K_OK(khtml_puts(&html, dir->d_name)); + K_OK(khtml_closeelem(&html, 2)); } - khtml_close(&html); + K_OK(khtml_close(&html)); closedir(data_dir); return VAULT_SUCCESS; |