blob: e789259f480746066adf233e93c93c87cff30e68 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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;
}
|