aboutsummaryrefslogtreecommitdiff
path: root/doc/examples/simplepost.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2010-07-26 16:57:47 +0000
committerChristian Grothoff <christian@grothoff.org>2010-07-26 16:57:47 +0000
commit761267757c03f8c05c21d377a7fd24a70d7a0363 (patch)
treebbcc625f95dd672beba3f789ee799f15104a0753 /doc/examples/simplepost.c
parent8157744d45ee018ab325ff5a16be1212cd7e8f58 (diff)
downloadlibmicrohttpd-761267757c03f8c05c21d377a7fd24a70d7a0363.tar.gz
libmicrohttpd-761267757c03f8c05c21d377a7fd24a70d7a0363.zip
ready for 0.9.0
Diffstat (limited to 'doc/examples/simplepost.c')
-rw-r--r--doc/examples/simplepost.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/doc/examples/simplepost.c b/doc/examples/simplepost.c
index 83c2f3cd..0aa93511 100644
--- a/doc/examples/simplepost.c
+++ b/doc/examples/simplepost.c
@@ -1,4 +1,6 @@
1#include <platform.h> 1#include <sys/types.h>
2#include <sys/select.h>
3#include <sys/socket.h>
2#include <microhttpd.h> 4#include <microhttpd.h>
3 5
4#define PORT 8888 6#define PORT 8888
@@ -30,7 +32,7 @@ const char *errorpage =
30 "<html><body>This doesn't seem to be right.</body></html>"; 32 "<html><body>This doesn't seem to be right.</body></html>";
31 33
32 34
33int 35static int
34send_page (struct MHD_Connection *connection, const char *page) 36send_page (struct MHD_Connection *connection, const char *page)
35{ 37{
36 int ret; 38 int ret;
@@ -50,15 +52,13 @@ send_page (struct MHD_Connection *connection, const char *page)
50} 52}
51 53
52 54
53int 55static int
54iterate_post (void *coninfo_cls, enum MHD_ValueKind kind, const char *key, 56iterate_post (void *coninfo_cls, enum MHD_ValueKind kind, const char *key,
55 const char *filename, const char *content_type, 57 const char *filename, const char *content_type,
56 const char *transfer_encoding, const char *data, uint64_t off, 58 const char *transfer_encoding, const char *data, uint64_t off,
57 size_t size) 59 size_t size)
58{ 60{
59 struct connection_info_struct *con_info = 61 struct connection_info_struct *con_info = coninfo_cls;
60 (struct connection_info_struct *) coninfo_cls;
61
62 62
63 if (0 == strcmp (key, "name")) 63 if (0 == strcmp (key, "name"))
64 { 64 {
@@ -81,13 +81,11 @@ iterate_post (void *coninfo_cls, enum MHD_ValueKind kind, const char *key,
81 return MHD_YES; 81 return MHD_YES;
82} 82}
83 83
84void 84static void
85request_completed (void *cls, struct MHD_Connection *connection, 85request_completed (void *cls, struct MHD_Connection *connection,
86 void **con_cls, enum MHD_RequestTerminationCode toe) 86 void **con_cls, enum MHD_RequestTerminationCode toe)
87{ 87{
88 struct connection_info_struct *con_info = 88 struct connection_info_struct *con_info = *con_cls;
89 (struct connection_info_struct *) *con_cls;
90
91 89
92 if (NULL == con_info) 90 if (NULL == con_info)
93 return; 91 return;
@@ -104,7 +102,7 @@ request_completed (void *cls, struct MHD_Connection *connection,
104} 102}
105 103
106 104
107int 105static int
108answer_to_connection (void *cls, struct MHD_Connection *connection, 106answer_to_connection (void *cls, struct MHD_Connection *connection,
109 const char *url, const char *method, 107 const char *url, const char *method,
110 const char *version, const char *upload_data, 108 const char *version, const char *upload_data,
@@ -170,7 +168,6 @@ main ()
170{ 168{
171 struct MHD_Daemon *daemon; 169 struct MHD_Daemon *daemon;
172 170
173
174 daemon = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY, PORT, NULL, NULL, 171 daemon = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY, PORT, NULL, NULL,
175 &answer_to_connection, NULL, 172 &answer_to_connection, NULL,
176 MHD_OPTION_NOTIFY_COMPLETED, request_completed, 173 MHD_OPTION_NOTIFY_COMPLETED, request_completed,