aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorAleksey Veresov <aleksey@veresov.pro>2020-03-02 20:10:16 +0300
committerAleksey Veresov <aleksey@veresov.pro>2020-03-02 20:10:16 +0300
commit9d0fb8156d6122730c6007393d49a6d76a114c60 (patch)
tree4aff03474026772b7a0debb60d5a6f3bc5fd0beb /examples
parentc65fdedc7bedfc20da73cdbfc34c22bb80139896 (diff)
downloadmagi-9d0fb8156d6122730c6007393d49a6d76a114c60.tar
magi-9d0fb8156d6122730c6007393d49a6d76a114c60.tar.xz
magi-9d0fb8156d6122730c6007393d49a6d76a114c60.zip
[magi]
Diffstat (limited to 'examples')
-rw-r--r--examples/append.c6
-rw-r--r--examples/cookie.c6
-rw-r--r--examples/echo.c60
-rw-r--r--examples/fastcgi.c2
-rw-r--r--examples/upload.c6
5 files changed, 40 insertions, 40 deletions
diff --git a/examples/append.c b/examples/append.c
index cafdf9c..3a32287 100644
--- a/examples/append.c
+++ b/examples/append.c
@@ -5,7 +5,7 @@
void response(magi_request *r)
{
char *data = magi_request_param(r, "addon");
- magi_response_add(r,
+ 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'>"
@@ -15,9 +15,9 @@ void response(magi_request *r)
FILE *file = fopen("file_to_append", "a");
fputs(data, file);
fclose(file);
- magi_response_add(r, "<p>Appended!</p>");
+ magi_response(r, "<p>Appended!</p>");
}
- magi_response_add(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'/>"
diff --git a/examples/cookie.c b/examples/cookie.c
index 5bbade1..7c55ba8 100644
--- a/examples/cookie.c
+++ b/examples/cookie.c
@@ -4,7 +4,7 @@
void list_cookies(magi_request *r)
{
magi_cookies *current;
- magi_response_add(r, "Cookies:");
+ magi_response(r, "Cookies:");
for (current = r->cookies; current; current = current->next) {
magi_cookie *c = &current->item;
magi_response_format(r, "<br/>[%s] = [%s]", c->name, c->data);
@@ -14,14 +14,14 @@ void list_cookies(magi_request *r)
void response(magi_request *r)
{
magi_response_cookie(r, "cookie", "monster");
- magi_response_add(r,
+ 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_add(r, "</p></body></html>");
+ magi_response(r, "</p></body></html>");
}
int main(int argc, char const *argv[])
diff --git a/examples/echo.c b/examples/echo.c
index 89230de..e3b90c7 100644
--- a/examples/echo.c
+++ b/examples/echo.c
@@ -6,21 +6,21 @@ void list_cookies(magi_request *r)
magi_cookies *current = r->cookies;
for (current = r->cookies; current; current = current->next) {
magi_cookie *c = &current->item;
- magi_response_add(r, "Cookie with name [");
- magi_response_add(r, c->name);
+ magi_response(r, "Cookie with name [");
+ magi_response(r, c->name);
if (c->data) {
- magi_response_add(r, "] is [");
- magi_response_add(r, c->data);
+ magi_response(r, "] is [");
+ magi_response(r, c->data);
}
if (c->domain) {
- magi_response_add(r, "] for domain [");
- magi_response_add(r, c->domain);
+ magi_response(r, "] for domain [");
+ magi_response(r, c->domain);
}
if (c->path) {
- magi_response_add(r, "] for path [");
- magi_response_add(r, c->path);
+ magi_response(r, "] for path [");
+ magi_response(r, c->path);
}
- magi_response_add(r, "]<br/>");
+ magi_response(r, "]<br/>");
}
}
@@ -44,59 +44,59 @@ void list_files(magi_request *r)
void show_meta(magi_request *r)
{
- magi_response_add(r, "I was called with method [");
- magi_response_add(r, r->method);
+ magi_response(r, "I was called with method [");
+ magi_response(r, r->method);
if (r->uri) {
- magi_response_add(r, "] with URL [");
- magi_response_add(r, r->uri);
+ magi_response(r, "] with URL [");
+ magi_response(r, r->uri);
}
if (r->server_name) {
- magi_response_add(r, "] for server [");
- magi_response_add(r, r->server_name);
+ magi_response(r, "] for server [");
+ magi_response(r, r->server_name);
}
if (r->server_port) {
- magi_response_add(r, "] on port [");
- magi_response_add(r, r->server_port);
+ magi_response(r, "] on port [");
+ magi_response(r, r->server_port);
}
if (r->server_protocol) {
- magi_response_add(r, "] with protocol [");
- magi_response_add(r, r->server_protocol);
+ magi_response(r, "] with protocol [");
+ magi_response(r, r->server_protocol);
}
if (r->server_software) {
- magi_response_add(r, "] and I am running on software [");
- magi_response_add(r, r->server_software);
+ magi_response(r, "] and I am running on software [");
+ magi_response(r, r->server_software);
}
- magi_response_add(r, "]<br/>");
+ magi_response(r, "]<br/>");
}
void response(magi_request *r)
{
- magi_response_add(r,
+ 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>Echo</title></head>"
"<body>");
- magi_response_add(r, "<h1>Echo CGI Script</h1>");
+ magi_response(r, "<h1>Echo CGI Script</h1>");
show_meta(r);
- magi_response_add(r, "<h2>Cookies:</h2>");
+ magi_response(r, "<h2>Cookies:</h2>");
list_cookies(r);
- magi_response_add(r, "<h2>Parameters:</h2>");
+ magi_response(r, "<h2>Parameters:</h2>");
list_params(r, r->params);
- magi_response_add(r, "<h2>URL Parameters:</h2>");
+ magi_response(r, "<h2>URL Parameters:</h2>");
list_params(r, r->url_params);
- magi_response_add(r, "<h2>HTTP Parameters:</h2>");
+ magi_response(r, "<h2>HTTP Parameters:</h2>");
list_params(r, r->http_params);
- magi_response_add(r, "<h2>Files:</h2>");
+ magi_response(r, "<h2>Files:</h2>");
list_files(r);
- magi_response_add(r, "</body></html>");
+ magi_response(r, "</body></html>");
}
int main(int argc, char const *argv[])
diff --git a/examples/fastcgi.c b/examples/fastcgi.c
index 2d68a3b..5d3c4b1 100644
--- a/examples/fastcgi.c
+++ b/examples/fastcgi.c
@@ -3,7 +3,7 @@
void response(magi_request *r)
{
- magi_response_add(r,
+ 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'>"
diff --git a/examples/upload.c b/examples/upload.c
index 158dcad..54d3a48 100644
--- a/examples/upload.c
+++ b/examples/upload.c
@@ -6,7 +6,7 @@ void response(magi_request *r)
{
char *name = magi_request_param(r, "name");
magi_file *data = magi_request_file(r, "data");
- magi_response_add(r,
+ 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'>"
@@ -14,9 +14,9 @@ void response(magi_request *r)
"<body>");
if (name && data) {
rename("data", name);
- magi_response_add(r, "<p>Uploaded!</p>");
+ magi_response(r, "<p>Uploaded!</p>");
}
- magi_response_add(r,
+ magi_response(r,
"<form action='/cgi-bin/upload' method='post' "
"enctype='multipart/form-data'><fieldset>"
"<input type='text' name='name' value='filename'/>"