diff options
author | Aleksey Veresov <aleksey@veresov.pro> | 2020-03-11 17:54:19 +0300 |
---|---|---|
committer | Aleksey Veresov <aleksey@veresov.pro> | 2020-03-11 17:54:19 +0300 |
commit | 8f1e6faa7f548c9a8bcbcac71c8f239a6540b926 (patch) | |
tree | dd5dfec60de8e52472fe8db2b5ae66010d5dc1d3 /examples | |
parent | 5cfe6cdf6af2d630d21871f9193fc1b4a7db24ff (diff) | |
download | magi-8f1e6faa7f548c9a8bcbcac71c8f239a6540b926.tar magi-8f1e6faa7f548c9a8bcbcac71c8f239a6540b926.tar.xz magi-8f1e6faa7f548c9a8bcbcac71c8f239a6540b926.zip |
[magi]
Diffstat (limited to 'examples')
-rw-r--r-- | examples/Makefile | 2 | ||||
-rw-r--r-- | examples/append.c | 2 | ||||
-rw-r--r-- | examples/cookie.c | 2 | ||||
-rw-r--r-- | examples/echo.c | 44 | ||||
-rw-r--r-- | examples/upload.c | 11 |
5 files changed, 28 insertions, 33 deletions
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) "</html>"); } -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, "</p></body></html>"); } -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<br/>", - 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, "]<br/>"); } @@ -85,13 +81,13 @@ void response(magi_request *r) list_cookies(r); magi_response(r, "<h2>Parameters:</h2>"); - list_params(r, r->params); + list_params(r, r->meta); magi_response(r, "<h2>URL Parameters:</h2>"); - list_params(r, r->url_params); + list_params(r, r->head); - magi_response(r, "<h2>HTTP Parameters:</h2>"); - list_params(r, r->http_params); + magi_response(r, "<h2>Body Parameters:</h2>"); + list_params(r, r->body); magi_response(r, "<h2>Files:</h2>"); list_files(r); @@ -99,7 +95,7 @@ void response(magi_request *r) magi_response(r, "</body></html>"); } -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); |