blob: 0492e1bf90e0e4d5f379d12b91fb05616ac9f625 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
#include <magi.h>
void list_cookies(magi_request *r)
{
magi_cookies *current;
magi_response(r, "Cookies:");
for (current = r->cookies; current; current = current->next) {
magi_cookie *c = ¤t->item;
magi_response(r, "<br/>[");
magi_response(r, c->name);
magi_response(r, "] = [");
magi_response(r, c->data);
magi_response(r, "]");
}
}
void response(magi_request *r)
{
magi_response_cookie(r, "cookie", "monster");
magi_response(r,
"<!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><p>");
list_cookies(r);
magi_response(r, "</p></body></html>");
}
int main()
{
magi_request request;
magi_request_init(&request);
if (magi_cgi(&request)) {
response(&request);
} else {
magi_response_error(&request);
}
magi_request_free(&request);
return 0;
}
|