From 4d77e4bb69a47daf23ad4a902b300bf1aa7d5597 Mon Sep 17 00:00:00 2001 From: Aleksey Veresov Date: Mon, 13 Jul 2020 10:21:47 +0300 Subject: typedef struct removed to support C++98. --- examples/append.c | 6 +++--- examples/cookie.c | 12 ++++++------ examples/echo.c | 22 +++++++++++----------- examples/upload.c | 14 +++++++------- 4 files changed, 27 insertions(+), 27 deletions(-) (limited to 'examples') 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 -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(" -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("
[%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 -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("

"); /* 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("

"); } -void list_params(magi_params *current) +void list_params(struct magi_params *current) { printf("

"); /* 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]
", p->name, p->data); } printf("

"); } -void list_files(magi_request *r) +void list_files(struct magi_request *r) { - magi_files *current; + struct magi_files *current; printf("

"); /* 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
", f->field, f->filename); } printf("

"); } -void show_meta(magi_request *r) +void show_meta(struct magi_request *r) { printf("

I was called "); if (r->is_secure) { @@ -68,7 +68,7 @@ void show_meta(magi_request *r) printf("]

"); } -void response(magi_request *r) +void response(struct magi_request *r) { magi_response_default(); /* Pass default headers and send body: */ printf(" -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("

Uploaded!

"); /* 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(""); } -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: */ -- cgit v1.2.3