aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorAleksey Veresov <aleksey@veresov.pro>2020-03-18 00:46:01 +0300
committerAleksey Veresov <aleksey@veresov.pro>2020-03-18 00:46:01 +0300
commitfcffb003f36a4357b6ba88e6b5e2239d7d111a6a (patch)
treea1fbe4bc96b8669c131f3f704c8aaa607d836134 /examples
parent321a942995fed6133298c1ca6779cfca9eb0d065 (diff)
downloadmagi-fcffb003f36a4357b6ba88e6b5e2239d7d111a6a.tar
magi-fcffb003f36a4357b6ba88e6b5e2239d7d111a6a.tar.xz
magi-fcffb003f36a4357b6ba88e6b5e2239d7d111a6a.zip
[magi]
Diffstat (limited to 'examples')
-rw-r--r--examples/append.c4
-rw-r--r--examples/cookie.c6
-rw-r--r--examples/echo.c37
-rw-r--r--examples/upload.c6
4 files changed, 22 insertions, 31 deletions
diff --git a/examples/append.c b/examples/append.c
index c6cfb2b..8417796 100644
--- a/examples/append.c
+++ b/examples/append.c
@@ -19,8 +19,8 @@ void response(magi_request *r)
}
magi_response(r,
"<form action='/cgi-bin/append' method='post'><fieldset>"
- "<input type='text' name='addon' value='Whatever you want to add.'/>"
- "<input type='submit' value='Append'/>"
+ "<input type='text' name='addon' value='Whatever you want to add.' />"
+ "<input type='submit' value='Append' />"
"</fieldset></form>"
"</body>"
"</html>");
diff --git a/examples/cookie.c b/examples/cookie.c
index 0492e1b..e18c100 100644
--- a/examples/cookie.c
+++ b/examples/cookie.c
@@ -7,11 +7,7 @@ void list_cookies(magi_request *r)
magi_response(r, "Cookies:");
for (current = r->cookies; current; current = current->next) {
magi_cookie *c = &current->item;
- magi_response(r, "<br/>[");
- magi_response(r, c->name);
- magi_response(r, "] = [");
- magi_response(r, c->data);
- magi_response(r, "]");
+ magi_response_format(r, "<br />[%s]=[%s]", c->name, c->data);
}
}
diff --git a/examples/echo.c b/examples/echo.c
index 52089d9..7cb4a3b 100644
--- a/examples/echo.c
+++ b/examples/echo.c
@@ -4,6 +4,7 @@
void list_cookies(magi_request *r)
{
magi_cookies *current = r->cookies;
+ magi_response(r, "<p>");
for (current = r->cookies; current; current = current->next) {
magi_cookie *c = &current->item;
magi_response(r, "Cookie with name [");
@@ -20,56 +21,50 @@ void list_cookies(magi_request *r)
magi_response(r, "] for path [");
magi_response(r, c->path);
}
- magi_response(r, "]<br/>");
+ magi_response(r, "]<br />");
}
+ magi_response(r, "</p>");
}
void list_params(magi_request *r, magi_params *current)
{
+ magi_response(r, "<p>");
for (; current; current = current->next) {
magi_param *p = &current->item;
- magi_response(r, "[");
- magi_response(r, p->name);
- magi_response(r, "] is [");
- magi_response(r, p->data);
- magi_response(r, "]<br/>");
+ magi_response_format(r, "[%s] is [%s]<br />", p->name, p->data);
}
+ magi_response(r, "</p>");
}
void list_files(magi_request *r)
{
magi_files *current;
+ magi_response(r, "<p>");
for (current = r->files; current; current = current->next) {
magi_file *f = &current->item;
- magi_response(r, "[");
- magi_response(r, f->field);
- magi_response(r, "] was [");
- magi_response(r, f->filename);
- magi_response(r, "] on clientside<br/>");
+ magi_response_format(r, "[%s] was [%s] on clientside<br />",
+ f->field, f->filename);
}
+ magi_response(r, "</p>");
}
void show_meta(magi_request *r)
{
- magi_response(r, "I was called ");
+ magi_response(r, "<p>I was called ");
if (r->is_secure) {
magi_response(r, "securely ");
}
- magi_response(r, "with method [");
- magi_response(r, r->method);
+ magi_response_format(r, "with method [%s", r->method);
if (r->host) {
- magi_response(r, "] on server [");
- magi_response(r, r->host);
+ magi_response_format(r, "] on server [%s", r->host);
}
if (r->script) {
- magi_response(r, "] being script on [");
- magi_response(r, r->script);
+ magi_response_format(r, "] being script on [%s", r->script);
}
if (r->path) {
- magi_response(r, "] with requested path [");
- magi_response(r, r->path);
+ magi_response_format(r, "] with requested path [%s", r->path);
}
- magi_response(r, "]<br/>");
+ magi_response(r, "]</p>");
}
void response(magi_request *r)
diff --git a/examples/upload.c b/examples/upload.c
index a8503ea..9a16dd1 100644
--- a/examples/upload.c
+++ b/examples/upload.c
@@ -19,9 +19,9 @@ void response(magi_request *r)
magi_response(r,
"<form action='/cgi-bin/upload' method='post' "
"enctype='multipart/form-data'><fieldset>"
- "<input type='text' name='name' value='filename'/>"
- "<input type='file' name='data'/>"
- "<input type='submit' value='Upload'/>"
+ "<input type='text' name='name' value='filename' />"
+ "<input type='file' name='data' />"
+ "<input type='submit' value='Upload' />"
"</fieldset></form>"
"</body>"
"</html>");