aboutsummaryrefslogtreecommitdiff
path: root/form_badreq.c
diff options
context:
space:
mode:
authorXavier Del Campo Romero <xavi92@disroot.org>2025-09-22 17:32:44 +0200
committerXavier Del Campo Romero <xavi92@disroot.org>2026-02-13 09:57:39 +0100
commit78bf2fe4a5bf37514f6dfd203ef969da0bf40c2e (patch)
tree33f9440b8ee0fa7a3b3ad033616d722d2101bb4d /form_badreq.c
parent107a2e43d54f9a42fb85b00b83cb0d9abb194680 (diff)
Setup project skeletonHEADmaster
Diffstat (limited to 'form_badreq.c')
-rw-r--r--form_badreq.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/form_badreq.c b/form_badreq.c
new file mode 100644
index 0000000..e789259
--- /dev/null
+++ b/form_badreq.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_badreq(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_BAD_REQUEST,
+ .buf.ro = d.str,
+ .n = d.len,
+ .free = free
+ };
+
+ return 0;
+}