aboutsummaryrefslogtreecommitdiff
path: root/examples/cookie.c
diff options
context:
space:
mode:
authorAleksey Veresov <aleksey@veresov.pro>2020-02-04 18:14:54 +0300
committerAleksey Veresov <aleksey@veresov.pro>2020-02-04 18:14:54 +0300
commit8ef310a22a54dca7a80947f83f03bc296ab298dd (patch)
tree739df8f259747508176ecfcdb32f06d711d6c244 /examples/cookie.c
parent676f6520bf76867135f1af4fab5d69b3b212d198 (diff)
downloadmagi-8ef310a22a54dca7a80947f83f03bc296ab298dd.tar
magi-8ef310a22a54dca7a80947f83f03bc296ab298dd.tar.xz
magi-8ef310a22a54dca7a80947f83f03bc296ab298dd.zip
[magi]
Diffstat (limited to 'examples/cookie.c')
-rw-r--r--examples/cookie.c37
1 files changed, 16 insertions, 21 deletions
diff --git a/examples/cookie.c b/examples/cookie.c
index bb1e1d1..365f989 100644
--- a/examples/cookie.c
+++ b/examples/cookie.c
@@ -1,26 +1,22 @@
-#include <cgi.h>
-#include <cookie.h>
-#include <request.h>
-#include <response.h>
+#include <magi.h>
#include <stdio.h>
#include <stdlib.h>
-void response_request(struct magi_request * req, struct magi_response * res)
+void response_request(magi_request *req, magi_response *res)
{
- struct magi_cookie_list * current;
+ magi_cookie_list *current;
- magi_response_content_type(res, magi_xhtml);
- magi_response_add(
- res, "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN' "
- "'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>"
- "<html xmlns='http://www.w3.org/1999/xhtml'>"
- "<head><title>Cookie Listing and Setting</title></head>"
- "<body>");
+ magi_response_add(res,
+ "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN' "
+ "'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>"
+ "<html xmlns='http://www.w3.org/1999/xhtml'>"
+ "<head><title>Cookie Listing and Setting</title></head>"
+ "<body>");
for (current = req->cookies; current; current = current->next) {
- magi_response_add_format(res, "[%s] = [%s]<br/>", current->item.name,
- current->item.data);
+ magi_response_add_format(res,
+ "[%s] = [%s]<br/>", current->item.name, current->item.data);
}
magi_response_add(res, "</body></html>");
@@ -28,16 +24,15 @@ void response_request(struct magi_request * req, struct magi_response * res)
magi_response_cookie_easy(res, "cookie", "monster");
}
-int main(int argc, char const * argv[])
+int main(int argc, char const *argv[])
{
- struct magi_request request;
+ magi_request request;
magi_request_setup(&request);
- if (magi_request_cgi(&request) && magi_request_resume_cgi(&request)) {
- struct magi_response response;
+ if (magi_request_full_cgi(&request)) {
+ magi_response response;
magi_response_setup(&response);
response_request(&request, &response);
- magi_response_cgi(&response);
- magi_response_destroy(&response);
+ magi_response_cgi_clear(&response);
} else {
magi_error_cgi(request.error);
}