diff options
author | Aleksey Veresov <aleksey@veresov.pro> | 2020-07-13 10:21:47 +0300 |
---|---|---|
committer | Aleksey Veresov <aleksey@veresov.pro> | 2020-07-13 10:21:47 +0300 |
commit | 4d77e4bb69a47daf23ad4a902b300bf1aa7d5597 (patch) | |
tree | b3c21c9bb01cf84d07e3b9e51b707e24e2afabd2 /examples | |
parent | 915f37b5ad202dfeb51999faba5a2849318ebea2 (diff) | |
download | magi-4d77e4bb69a47daf23ad4a902b300bf1aa7d5597.tar magi-4d77e4bb69a47daf23ad4a902b300bf1aa7d5597.tar.xz magi-4d77e4bb69a47daf23ad4a902b300bf1aa7d5597.zip |
typedef struct removed to support C++98.
Diffstat (limited to 'examples')
-rw-r--r-- | examples/append.c | 6 | ||||
-rw-r--r-- | examples/cookie.c | 12 | ||||
-rw-r--r-- | examples/echo.c | 22 | ||||
-rw-r--r-- | examples/upload.c | 14 |
4 files changed, 27 insertions, 27 deletions
diff --git a/examples/append.c b/examples/append.c index f1b8f96..65662b5 100644 --- a/examples/append.c +++ b/examples/append.c @@ -5,7 +5,7 @@ #include <stdio.h> -void append(magi_request *r) +void append(struct magi_request *r) { char *data = magi_request_param(r, "addon"); if (data) { /* If field "addon" was in request: */ @@ -16,7 +16,7 @@ void append(magi_request *r) } } -void response(magi_request *r) +void response(struct magi_request *r) { magi_response_default(); /* Pass default headers and send body: */ printf("<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN' " @@ -34,7 +34,7 @@ void response(magi_request *r) int main() { - magi_request request; + struct magi_request request; magi_request_init(&request); /* Setting defaults. */ if (magi_parse(&request)) { /* If parsing was done successful */ response(&request); /* we need to response the request. */ diff --git a/examples/cookie.c b/examples/cookie.c index 7253185..e859faa 100644 --- a/examples/cookie.c +++ b/examples/cookie.c @@ -6,20 +6,20 @@ #include <stdio.h> -void list_cookies(magi_request *r) +void list_cookies(struct magi_request *r) { - magi_cookies *current; + struct magi_cookies *current; printf("Cookies:"); /* Iterate through all cookies in request to show them in body: */ for (current = r->cookies; current; current = current->next) { - magi_cookie *c = ¤t->item; + struct magi_cookie *c = ¤t->item; printf("<br />[%s]=[%s]", c->name, c->data); } } -void response(magi_request *r) +void response(struct magi_request *r) { - magi_response head; + struct magi_response head; magi_response_init(&head); /* Setting defaults. */ /* Set cookie "cookie" with value "monster" on clientside: */ magi_response_cookie(&head, "cookie", "monster"); @@ -36,7 +36,7 @@ void response(magi_request *r) int main() { - magi_request request; + struct magi_request request; magi_request_init(&request); /* Setting defaults. */ if (magi_parse(&request)) { /* If parsing was done successful */ response(&request); /* we need to response the request. */ diff --git a/examples/echo.c b/examples/echo.c index 3598986..c93a897 100644 --- a/examples/echo.c +++ b/examples/echo.c @@ -4,13 +4,13 @@ #include <stdio.h> -void list_cookies(magi_request *r) +void list_cookies(struct magi_request *r) { - magi_cookies *current = r->cookies; + struct magi_cookies *current = r->cookies; printf("<p>"); /* Iterate through all cookies in request to show them in body: */ for (current = r->cookies; current; current = current->next) { - magi_cookie *c = ¤t->item; + struct magi_cookie *c = ¤t->item; printf("Cookie with name [%s", c->name); if (c->data) { printf("] is [%s", c->data); @@ -26,30 +26,30 @@ void list_cookies(magi_request *r) printf("</p>"); } -void list_params(magi_params *current) +void list_params(struct magi_params *current) { printf("<p>"); /* Iterate through specified params to show them in body: */ for (; current; current = current->next) { - magi_param *p = ¤t->item; + struct magi_param *p = ¤t->item; printf("[%s] is [%s]<br />", p->name, p->data); } printf("</p>"); } -void list_files(magi_request *r) +void list_files(struct magi_request *r) { - magi_files *current; + struct magi_files *current; printf("<p>"); /* Iterate through all field files in request to show them in body: */ for (current = r->files; current; current = current->next) { - magi_file *f = ¤t->item; + struct magi_file *f = ¤t->item; printf("[%s] was [%s] on clientside<br />", f->field, f->filename); } printf("</p>"); } -void show_meta(magi_request *r) +void show_meta(struct magi_request *r) { printf("<p>I was called "); if (r->is_secure) { @@ -68,7 +68,7 @@ void show_meta(magi_request *r) printf("]</p>"); } -void response(magi_request *r) +void response(struct magi_request *r) { magi_response_default(); /* Pass default headers and send body: */ printf("<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN' " @@ -100,7 +100,7 @@ void response(magi_request *r) int main() { - magi_request request; + struct magi_request request; magi_request_init(&request); /* Setting defaults. */ if (magi_parse(&request)) { /* If parsing was done successful */ response(&request); /* we need to response the request. */ diff --git a/examples/upload.c b/examples/upload.c index d07db16..8efceb7 100644 --- a/examples/upload.c +++ b/examples/upload.c @@ -6,17 +6,17 @@ #include <stdio.h> -void upload(magi_request *r) +void upload(struct magi_request *r) { - char *name = magi_request_param(r, "name"); - const magi_file *data = magi_request_file(r, "data"); + char *name = magi_request_param(r, "name"); + const struct magi_file *data = magi_request_file(r, "data"); if (name && data) { /* If file to load and its name are in the request: */ rename("data", name); /* Rename loaded file to designated name. */ printf("<p>Uploaded!</p>"); /* And display success message. */ } } -void response(magi_request *r) +void response(struct magi_request *r) { magi_response_default(); /* Pass default headers and send body: */ printf("<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN' " @@ -34,9 +34,9 @@ void response(magi_request *r) "</body></html>"); } -void get(magi_request *r) +void get(struct magi_request *r) { - magi_loadfiles rules = { 0, 0 }; + struct magi_loadfiles rules = { 0, 0 }; /* Setup callback to load file from "data" field into file "data": */ magi_loadfiles_add(&rules, "data", "data", 0); magi_loadfiles_set(r, &rules); /* Setup request to use the callback. */ @@ -46,7 +46,7 @@ void get(magi_request *r) int main() { - magi_request request; + struct magi_request request; magi_request_init(&request); get(&request); /* Parse request. */ if (request.error) { /* If error occurred display error message: */ |