From 23f3f8592c21ee58b0ac040736b5b766d52de193 Mon Sep 17 00:00:00 2001 From: Aleksey Veresov Date: Wed, 13 Nov 2019 19:16:21 +0300 Subject: Cosmetical changes. --- examples/append.c | 30 ++++++++++++++---------------- examples/cookie.c | 34 ++++++++++++---------------------- examples/echo.c | 22 ++++++++++------------ examples/upload.c | 44 +++++++++++++++++++++----------------------- 4 files changed, 57 insertions(+), 73 deletions(-) (limited to 'examples') diff --git a/examples/append.c b/examples/append.c index b8aa1cf..b6ee217 100644 --- a/examples/append.c +++ b/examples/append.c @@ -8,9 +8,9 @@ void handle_request() { struct magi_request request; if (magi_cgi(&request, 0, 0)) { - struct magi_field *a = magi_field_list_get(request.fields, "addon"); + struct magi_field * a = magi_field_list_get(request.fields, "addon"); if (a && a->data) { - FILE *file = fopen("file_to_append", "a"); + FILE * file = fopen("file_to_append", "a"); fputs(a->data, file); fclose(file); } @@ -25,22 +25,20 @@ void print_preamble() void print_webpage() { - puts( - "" - "" - "Append to File" - "" - "
" - "" - "" - "
" - "" - "" - ); + puts("" + "" + "Append to File" + "" + "
" + "" + "" + "
" + "" + ""); } -int main(int argc, char const *argv[]) +int main(int argc, char const * argv[]) { handle_request(); print_preamble(); diff --git a/examples/cookie.c b/examples/cookie.c index dd18cc6..5ef56ac 100644 --- a/examples/cookie.c +++ b/examples/cookie.c @@ -7,34 +7,26 @@ void print_preamble() { - puts( - "Set-Cookie:cookie=monstre\r\n" /* Important to set cookies before: */ - "Content-Type: application/xhtml+xml\r\n\r\n" - ); + puts("Set-Cookie:cookie=monstre\r\n" /* Important to set cookies before: */ + "Content-Type: application/xhtml+xml\r\n\r\n"); } void print_webpage_top() { - puts( - "" - "" - "Cookie Listing and Setting" - "" - ); + puts("" + "" + "Cookie Listing and Setting" + ""); } void read_and_print_cookies() { struct magi_request request; if (magi_cgi(&request, 0, 0)) { - struct magi_cookie_list *cookie; + struct magi_cookie_list * cookie; for (cookie = request.cookies; cookie; cookie = cookie->next) { - printf( - "[%s] = [%s]
", - cookie->item.name, - cookie->item.data - ); + printf("[%s] = [%s]
", cookie->item.name, cookie->item.data); } magi_request_destroy(&request); } @@ -42,13 +34,11 @@ void read_and_print_cookies() void print_webpage_bottom() { - puts( - "" - "" - ); + puts("" + ""); } -int main(int argc, char const *argv[]) +int main(int argc, char const * argv[]) { print_preamble(); /* Following probably will be much more pleasant with use of templates. */ diff --git a/examples/echo.c b/examples/echo.c index ff037a6..0345b8c 100644 --- a/examples/echo.c +++ b/examples/echo.c @@ -8,17 +8,15 @@ void print_preamble() { - puts( - "Content-type: application/xhtml+xml\r\n\r\n" - "" - "" - "Echo" - "" - ); + puts("Content-type: application/xhtml+xml\r\n\r\n" + "" + "" + "Echo" + ""); } -void proceed_cookies(struct magi_cookie_list *cookies) +void proceed_cookies(struct magi_cookie_list * cookies) { puts("

Cookies:

"); while (cookies) { @@ -46,7 +44,7 @@ void proceed_cookies(struct magi_cookie_list *cookies) puts("
"); } -void proceed_fields(struct magi_field_list *fields) +void proceed_fields(struct magi_field_list * fields) { puts("

Feilds:

"); while (fields) { @@ -60,7 +58,7 @@ void proceed_fields(struct magi_field_list *fields) puts("
"); } -void proceed_params(struct magi_param_list *params) +void proceed_params(struct magi_param_list * params) { puts("

HTTP Parameters:

"); while (params) { @@ -114,7 +112,7 @@ void print_footer() puts(""); } -int main(int argc, char const *argv[]) +int main(int argc, char const * argv[]) { print_preamble(); handle_request(); 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 +#include +#include #include #include #include -#include -#include -#include -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( - "" - "" - "Upload File" - "" - "
" - "" - "" - "" - "
" - "" - "" - ); + puts("" + "" + "Upload File" + "" + "
" + "" + "" + "" + "
" + "" + ""); } -int main(int argc, char const *argv[]) +int main(int argc, char const * argv[]) { handle_request(); print_preamble(); -- cgit v1.2.3