aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/append.c2
-rw-r--r--examples/cookie.c2
-rw-r--r--examples/echo.c2
-rw-r--r--examples/fcgi.c11
-rw-r--r--examples/upload.c7
5 files changed, 15 insertions, 9 deletions
diff --git a/examples/append.c b/examples/append.c
index e51745a..30060fa 100644
--- a/examples/append.c
+++ b/examples/append.c
@@ -32,7 +32,7 @@ void response_request(struct magi_request * req, struct magi_response * res)
int main(int argc, char const * argv[])
{
struct magi_request request;
- if (magi_cgi(&request, 0, 0)) {
+ if (magi_cgi(&request, 0, 0, 0)) {
struct magi_response response;
response_request(&request, &response);
magi_cgi_response(&response);
diff --git a/examples/cookie.c b/examples/cookie.c
index 47929cb..f99f07f 100644
--- a/examples/cookie.c
+++ b/examples/cookie.c
@@ -30,7 +30,7 @@ void response_request(struct magi_request * req, struct magi_response * res)
int main(int argc, char const * argv[])
{
struct magi_request request;
- if (magi_cgi(&request, 0, 0)) {
+ if (magi_cgi(&request, 0, 0, 0)) {
struct magi_response response;
response_request(&request, &response);
magi_cgi_response(&response);
diff --git a/examples/echo.c b/examples/echo.c
index 6901b71..16e9d56 100644
--- a/examples/echo.c
+++ b/examples/echo.c
@@ -112,7 +112,7 @@ void response_request(struct magi_request * req, struct magi_response * res)
int main(int argc, char const * argv[])
{
struct magi_request request;
- if (magi_cgi(&request, 0, 0)) {
+ if (magi_cgi(&request, 0, 0, 0)) {
struct magi_response response;
response_request(&request, &response);
magi_cgi_response(&response);
diff --git a/examples/fcgi.c b/examples/fcgi.c
index 9cdbe90..d6cc478 100644
--- a/examples/fcgi.c
+++ b/examples/fcgi.c
@@ -21,21 +21,24 @@ void response_request(struct magi_request * req, struct magi_resopnse * res)
int main(int argc, char const * argv[])
{
struct magi_session session;
- if (magi_fcgi(&session)) {
+ int sock = magi_socket_inet("localhost", 9973);
+ /* E.g. also magi_socket_file("fcgi.sock") can be used. */
+ if (magi_fcgi(&session, sock)) {
struct magi_request request;
while (magi_fcgi_accept(&request, &session)) {
if (!request.error) {
struct magi_response response;
response_request(&request, &response);
- magi_fcgi_response(response);
- magi_reponse_destroy(response);
+ magi_fcgi_response(&response, &session);
+ magi_response_destroy(&response);
} else {
magi_fcgi_error(request.error, &session);
}
magi_request_destroy(&request);
}
}
- puts(session.error->message);
+ puts(magi_error_message(session.error));
magi_session_destroy(&session);
+ magi_socket_close(sock);
return 0;
}
diff --git a/examples/upload.c b/examples/upload.c
index 5fe3338..95c7f87 100644
--- a/examples/upload.c
+++ b/examples/upload.c
@@ -6,7 +6,10 @@
#include <string.h>
-void tempfile_callback(struct magi_field * field, char * buffer, int len)
+void tempfile_callback(struct magi_file * file,
+ char * buffer,
+ int len,
+ void * _)
{
static FILE * file = 0;
if (!strcmp(field->name, "data")) {
@@ -57,7 +60,7 @@ void response_request(struct magi_request * req, struct magi_response * res)
int main(int argc, char const * argv[])
{
struct magi_request request;
- if (magi_cgi(&request, tempfile_callback, 0)) {
+ if (magi_cgi(&request, tempfile_callback, 0, 0)) {
struct magi_response response;
response_request(&request, &response);
magi_cgi_response(&response);