diff options
| author | Xavier Del Campo Romero <xavi92@disroot.org> | 2025-09-22 17:32:44 +0200 |
|---|---|---|
| committer | Xavier Del Campo Romero <xavi92@disroot.org> | 2026-02-13 09:57:39 +0100 |
| commit | 78bf2fe4a5bf37514f6dfd203ef969da0bf40c2e (patch) | |
| tree | 33f9440b8ee0fa7a3b3ad033616d722d2101bb4d /form_unauthorized.c | |
| parent | 107a2e43d54f9a42fb85b00b83cb0d9abb194680 (diff) | |
Diffstat (limited to 'form_unauthorized.c')
| -rw-r--r-- | form_unauthorized.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/form_unauthorized.c b/form_unauthorized.c new file mode 100644 index 0000000..3d699f2 --- /dev/null +++ b/form_unauthorized.c @@ -0,0 +1,29 @@ +#include "form.h" +#include "defs.h" +#include <dynstr.h> +#include <libweb/http.h> +#include <stdio.h> +#include <stdlib.h> + +int form_unauthorized(const char *const msg, struct http_response *const r) +{ + struct dynstr d; + + dynstr_init(&d); + + if (dynstr_append(&d, "%s\n<html>%s</html>", DOCTYPE_TAG, msg)) + { + fprintf(stderr, "%s: dynstr_append failed\n", __func__); + return -1; + } + + *r = (const struct http_response) + { + .status = HTTP_STATUS_UNAUTHORIZED, + .buf.ro = d.str, + .n = d.len, + .free = free + }; + + return 0; +} |
