From 8f1e6faa7f548c9a8bcbcac71c8f239a6540b926 Mon Sep 17 00:00:00 2001 From: Aleksey Veresov Date: Wed, 11 Mar 2020 17:54:19 +0300 Subject: [magi] --- examples/Makefile | 2 +- examples/append.c | 2 +- examples/cookie.c | 2 +- examples/echo.c | 44 ++++++++++++++++++++------------------------ examples/upload.c | 11 +++++------ 5 files changed, 28 insertions(+), 33 deletions(-) (limited to 'examples') diff --git a/examples/Makefile b/examples/Makefile index 991f936..88af46d 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -3,7 +3,7 @@ # Debug mode (allowing to debug the examples via gdb): # DEBUG = yes # Examples to build by default: -EXAMPLES = append cookie echo upload fastcgi +EXAMPLES = append cookie echo upload # Specify your favourite C compiler here (e.g. tcc): CC = gcc diff --git a/examples/append.c b/examples/append.c index 3a32287..c6cfb2b 100644 --- a/examples/append.c +++ b/examples/append.c @@ -26,7 +26,7 @@ void response(magi_request *r) ""); } -int main(int argc, char const *argv[]) +int main() { magi_request request; magi_request_init(&request); diff --git a/examples/cookie.c b/examples/cookie.c index 7c55ba8..601c901 100644 --- a/examples/cookie.c +++ b/examples/cookie.c @@ -24,7 +24,7 @@ void response(magi_request *r) magi_response(r, "

"); } -int main(int argc, char const *argv[]) +int main() { magi_request request; magi_request_init(&request); diff --git a/examples/echo.c b/examples/echo.c index e3b90c7..7c840e2 100644 --- a/examples/echo.c +++ b/examples/echo.c @@ -38,33 +38,29 @@ void list_files(magi_request *r) for (current = r->files; current; current = current->next) { magi_file *f = ¤t->item; magi_response_format(r, "[%s] was [%s] on clientside
", - f->param_name, f->file_name); + f->field, f->filename); } } void show_meta(magi_request *r) { - magi_response(r, "I was called with method ["); - magi_response(r, r->method); - if (r->uri) { - magi_response(r, "] with URL ["); - magi_response(r, r->uri); - } - if (r->server_name) { - magi_response(r, "] for server ["); - magi_response(r, r->server_name); + magi_response(r, "I was called "); + if (r->is_secure) { + magi_response(r, "securely "); } - if (r->server_port) { - magi_response(r, "] on port ["); - magi_response(r, r->server_port); + magi_response(r, "with method ["); + magi_response(r, r->method); + if (r->host) { + magi_response(r, "] on server ["); + magi_response(r, r->host); } - if (r->server_protocol) { - magi_response(r, "] with protocol ["); - magi_response(r, r->server_protocol); + if (r->script) { + magi_response(r, "] being script on ["); + magi_response(r, r->script); } - if (r->server_software) { - magi_response(r, "] and I am running on software ["); - magi_response(r, r->server_software); + if (r->path) { + magi_response(r, "] with requested path ["); + magi_response(r, r->path); } magi_response(r, "]
"); } @@ -85,13 +81,13 @@ void response(magi_request *r) list_cookies(r); magi_response(r, "

Parameters:

"); - list_params(r, r->params); + list_params(r, r->meta); magi_response(r, "

URL Parameters:

"); - list_params(r, r->url_params); + list_params(r, r->head); - magi_response(r, "

HTTP Parameters:

"); - list_params(r, r->http_params); + magi_response(r, "

Body Parameters:

"); + list_params(r, r->body); magi_response(r, "

Files:

"); list_files(r); @@ -99,7 +95,7 @@ void response(magi_request *r) magi_response(r, ""); } -int main(int argc, char const *argv[]) +int main() { magi_request request; magi_request_init(&request); diff --git a/examples/upload.c b/examples/upload.c index 54d3a48..a8503ea 100644 --- a/examples/upload.c +++ b/examples/upload.c @@ -29,18 +29,17 @@ void response(magi_request *r) void get(magi_request *r) { - magi_loadfiles rules; - magi_loadfiles_init(&rules); + magi_loadfiles rules = { 0, 0 }; magi_loadfiles_add(&rules, "data", "data", 0); - magi_loadfiles_set(&r, &rules); - magi_cgi(&r); + magi_loadfiles_set(r, &rules); + magi_cgi(r); magi_loadfiles_free(&rules); } -int main(int argc, char const *argv[]) +int main() { magi_request request; - magi_request_init(request); + magi_request_init(&request); get(&request); if (request.error) { magi_response_error(&request); -- cgit v1.2.3