From 9d0fb8156d6122730c6007393d49a6d76a114c60 Mon Sep 17 00:00:00 2001 From: Aleksey Veresov Date: Mon, 2 Mar 2020 20:10:16 +0300 Subject: [magi] --- examples/append.c | 6 +++--- examples/cookie.c | 6 +++--- examples/echo.c | 60 +++++++++++++++++++++++++++--------------------------- examples/fastcgi.c | 2 +- examples/upload.c | 6 +++--- 5 files changed, 40 insertions(+), 40 deletions(-) (limited to 'examples') diff --git a/examples/append.c b/examples/append.c index cafdf9c..3a32287 100644 --- a/examples/append.c +++ b/examples/append.c @@ -5,7 +5,7 @@ void response(magi_request *r) { char *data = magi_request_param(r, "addon"); - magi_response_add(r, + magi_response(r, "" "" @@ -15,9 +15,9 @@ void response(magi_request *r) FILE *file = fopen("file_to_append", "a"); fputs(data, file); fclose(file); - magi_response_add(r, "

Appended!

"); + magi_response(r, "

Appended!

"); } - magi_response_add(r, + magi_response(r, "
" "" "" diff --git a/examples/cookie.c b/examples/cookie.c index 5bbade1..7c55ba8 100644 --- a/examples/cookie.c +++ b/examples/cookie.c @@ -4,7 +4,7 @@ void list_cookies(magi_request *r) { magi_cookies *current; - magi_response_add(r, "Cookies:"); + magi_response(r, "Cookies:"); for (current = r->cookies; current; current = current->next) { magi_cookie *c = ¤t->item; magi_response_format(r, "
[%s] = [%s]", c->name, c->data); @@ -14,14 +14,14 @@ void list_cookies(magi_request *r) void response(magi_request *r) { magi_response_cookie(r, "cookie", "monster"); - magi_response_add(r, + magi_response(r, "" "" "Cookie Listing and Setting" "

"); list_cookies(r); - magi_response_add(r, "

"); + magi_response(r, "

"); } int main(int argc, char const *argv[]) diff --git a/examples/echo.c b/examples/echo.c index 89230de..e3b90c7 100644 --- a/examples/echo.c +++ b/examples/echo.c @@ -6,21 +6,21 @@ void list_cookies(magi_request *r) magi_cookies *current = r->cookies; for (current = r->cookies; current; current = current->next) { magi_cookie *c = ¤t->item; - magi_response_add(r, "Cookie with name ["); - magi_response_add(r, c->name); + magi_response(r, "Cookie with name ["); + magi_response(r, c->name); if (c->data) { - magi_response_add(r, "] is ["); - magi_response_add(r, c->data); + magi_response(r, "] is ["); + magi_response(r, c->data); } if (c->domain) { - magi_response_add(r, "] for domain ["); - magi_response_add(r, c->domain); + magi_response(r, "] for domain ["); + magi_response(r, c->domain); } if (c->path) { - magi_response_add(r, "] for path ["); - magi_response_add(r, c->path); + magi_response(r, "] for path ["); + magi_response(r, c->path); } - magi_response_add(r, "]
"); + magi_response(r, "]
"); } } @@ -44,59 +44,59 @@ void list_files(magi_request *r) void show_meta(magi_request *r) { - magi_response_add(r, "I was called with method ["); - magi_response_add(r, r->method); + magi_response(r, "I was called with method ["); + magi_response(r, r->method); if (r->uri) { - magi_response_add(r, "] with URL ["); - magi_response_add(r, r->uri); + magi_response(r, "] with URL ["); + magi_response(r, r->uri); } if (r->server_name) { - magi_response_add(r, "] for server ["); - magi_response_add(r, r->server_name); + magi_response(r, "] for server ["); + magi_response(r, r->server_name); } if (r->server_port) { - magi_response_add(r, "] on port ["); - magi_response_add(r, r->server_port); + magi_response(r, "] on port ["); + magi_response(r, r->server_port); } if (r->server_protocol) { - magi_response_add(r, "] with protocol ["); - magi_response_add(r, r->server_protocol); + magi_response(r, "] with protocol ["); + magi_response(r, r->server_protocol); } if (r->server_software) { - magi_response_add(r, "] and I am running on software ["); - magi_response_add(r, r->server_software); + magi_response(r, "] and I am running on software ["); + magi_response(r, r->server_software); } - magi_response_add(r, "]
"); + magi_response(r, "]
"); } void response(magi_request *r) { - magi_response_add(r, + magi_response(r, "" "" "Echo" ""); - magi_response_add(r, "

Echo CGI Script

"); + magi_response(r, "

Echo CGI Script

"); show_meta(r); - magi_response_add(r, "

Cookies:

"); + magi_response(r, "

Cookies:

"); list_cookies(r); - magi_response_add(r, "

Parameters:

"); + magi_response(r, "

Parameters:

"); list_params(r, r->params); - magi_response_add(r, "

URL Parameters:

"); + magi_response(r, "

URL Parameters:

"); list_params(r, r->url_params); - magi_response_add(r, "

HTTP Parameters:

"); + magi_response(r, "

HTTP Parameters:

"); list_params(r, r->http_params); - magi_response_add(r, "

Files:

"); + magi_response(r, "

Files:

"); list_files(r); - magi_response_add(r, ""); + magi_response(r, ""); } int main(int argc, char const *argv[]) diff --git a/examples/fastcgi.c b/examples/fastcgi.c index 2d68a3b..5d3c4b1 100644 --- a/examples/fastcgi.c +++ b/examples/fastcgi.c @@ -3,7 +3,7 @@ void response(magi_request *r) { - magi_response_add(r, + magi_response(r, "" "" diff --git a/examples/upload.c b/examples/upload.c index 158dcad..54d3a48 100644 --- a/examples/upload.c +++ b/examples/upload.c @@ -6,7 +6,7 @@ void response(magi_request *r) { char *name = magi_request_param(r, "name"); magi_file *data = magi_request_file(r, "data"); - magi_response_add(r, + magi_response(r, "" "" @@ -14,9 +14,9 @@ void response(magi_request *r) ""); if (name && data) { rename("data", name); - magi_response_add(r, "

Uploaded!

"); + magi_response(r, "

Uploaded!

"); } - magi_response_add(r, + magi_response(r, "
" "" -- cgit v1.2.3