From b0a358a5f2ee27c052c163606a20135f37761884 Mon Sep 17 00:00:00 2001 From: Aleksey Veresov Date: Fri, 11 Oct 2019 14:35:34 +0300 Subject: . --- examples/append.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 examples/append.c (limited to 'examples/append.c') diff --git a/examples/append.c b/examples/append.c new file mode 100644 index 0000000..f0dfe2a --- /dev/null +++ b/examples/append.c @@ -0,0 +1,48 @@ +#include +#include +#include + + +void handle_request() +{ + struct magi_request request; + if (magi_request_build_cgi(&request, 0, 0)) { + struct magi_field *a = magi_field_list_get(request.fields, "addon"); + if (a && a->data) { + FILE *file = fopen("file_to_append", "a"); + fputs(a->data, file); + fclose(file); + } + magi_request_destroy(&request); + } +} + +void print_preamble() +{ + puts("Content-type: application/xhtml+xml\r\n\r\n"); +} + +void print_webpage() +{ + puts( + "" + "" + "Append to File" + "" + "
" + "" + "" + "
" + "" + "" + ); +} + +int main(int argc, char const *argv[]) +{ + handle_request(); + print_preamble(); + print_webpage(); + return 0; +} -- cgit v1.2.3