diff options
Diffstat (limited to 'examples/upload.c')
-rw-r--r-- | examples/upload.c | 44 |
1 files changed, 21 insertions, 23 deletions
diff --git a/examples/upload.c b/examples/upload.c index 59dd020..1cf6f5f 100644 --- a/examples/upload.c +++ b/examples/upload.c @@ -1,13 +1,13 @@ +#include <cgi.h> +#include <multipart.h> +#include <request.h> #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <request.h> -#include <multipart.h> -#include <cgi.h> -void tempfile_callback(struct magi_field *field, char *buffer, int len) +void tempfile_callback(struct magi_field * field, char * buffer, int len) { - static FILE *file = 0; + static FILE * file = 0; if (!strcmp(field->name, "data")) { if (!file) { remove(field->name); @@ -32,8 +32,8 @@ void handle_request() { struct magi_request request; if (magi_cgi(&request, tempfile_callback, 0)) { - struct magi_field *name = magi_field_list_get(request.fields, "name"); - struct magi_field *data = magi_field_list_get(request.fields, "data"); + struct magi_field * name = magi_field_list_get(request.fields, "name"); + struct magi_field * data = magi_field_list_get(request.fields, "data"); if (name && name->data && data) { rename("data", name->data); } @@ -48,24 +48,22 @@ void print_preamble() void print_webpage() { - puts( - "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN' " - "'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>" - "<html xmlns='http://www.w3.org/1999/xhtml'>" - "<head><title>Upload File</title></head>" - "<body>" - "<form action='/cgi-bin/upload' method='post' " - "enctype='multipart/form-data'><fieldset>" - "<input type='text' name='name' value='filename'/>" - "<input type='file' name='data'/>" - "<input type='submit' value='Upload'/>" - "</fieldset></form>" - "</body>" - "</html>" - ); + puts("<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN' " + "'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>" + "<html xmlns='http://www.w3.org/1999/xhtml'>" + "<head><title>Upload File</title></head>" + "<body>" + "<form action='/cgi-bin/upload' method='post' " + "enctype='multipart/form-data'><fieldset>" + "<input type='text' name='name' value='filename'/>" + "<input type='file' name='data'/>" + "<input type='submit' value='Upload'/>" + "</fieldset></form>" + "</body>" + "</html>"); } -int main(int argc, char const *argv[]) +int main(int argc, char const * argv[]) { handle_request(); print_preamble(); |