aboutsummaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorLRN <lrn1986@gmail.com>2013-04-23 11:38:09 +0000
committerLRN <lrn1986@gmail.com>2013-04-23 11:38:09 +0000
commitaeaea9eda26ce82e1ea2d88e0847d1a79f1ae1a9 (patch)
tree4d2c95e9cc24b3e87e8cbc3ca12894221fc74667 /doc
parent05a6e239a353f9761bdfb37b7d87cfed1d7836fe (diff)
downloadlibmicrohttpd-aeaea9eda26ce82e1ea2d88e0847d1a79f1ae1a9.tar.gz
libmicrohttpd-aeaea9eda26ce82e1ea2d88e0847d1a79f1ae1a9.zip
W32 compatibility, also use ISO C instead of POSIX
Diffstat (limited to 'doc')
-rw-r--r--doc/examples/basicauthentication.c4
-rw-r--r--doc/examples/hellobrowser.c4
-rw-r--r--doc/examples/largepost.c4
-rw-r--r--doc/examples/logging.c4
-rw-r--r--doc/examples/responseheaders.c4
-rw-r--r--doc/examples/sessions.c51
-rw-r--r--doc/examples/simplepost.c4
-rw-r--r--doc/examples/tlsauthentication.c4
8 files changed, 73 insertions, 6 deletions
diff --git a/doc/examples/basicauthentication.c b/doc/examples/basicauthentication.c
index fa99dc37..81a59ac0 100644
--- a/doc/examples/basicauthentication.c
+++ b/doc/examples/basicauthentication.c
@@ -2,8 +2,12 @@
2 you see fit (Public Domain) */ 2 you see fit (Public Domain) */
3 3
4#include <sys/types.h> 4#include <sys/types.h>
5#ifndef _WIN32
5#include <sys/select.h> 6#include <sys/select.h>
6#include <sys/socket.h> 7#include <sys/socket.h>
8#else
9#include <winsock2.h>
10#endif
7#include <microhttpd.h> 11#include <microhttpd.h>
8#include <time.h> 12#include <time.h>
9#include <string.h> 13#include <string.h>
diff --git a/doc/examples/hellobrowser.c b/doc/examples/hellobrowser.c
index bbfc990f..baf049c5 100644
--- a/doc/examples/hellobrowser.c
+++ b/doc/examples/hellobrowser.c
@@ -2,8 +2,12 @@
2 you see fit (Public Domain) */ 2 you see fit (Public Domain) */
3 3
4#include <sys/types.h> 4#include <sys/types.h>
5#ifndef _WIN32
5#include <sys/select.h> 6#include <sys/select.h>
6#include <sys/socket.h> 7#include <sys/socket.h>
8#else
9#include <winsock2.h>
10#endif
7#include <string.h> 11#include <string.h>
8#include <microhttpd.h> 12#include <microhttpd.h>
9#include <stdio.h> 13#include <stdio.h>
diff --git a/doc/examples/largepost.c b/doc/examples/largepost.c
index 5bef59c4..64d1e3f9 100644
--- a/doc/examples/largepost.c
+++ b/doc/examples/largepost.c
@@ -2,8 +2,12 @@
2 you see fit (Public Domain) */ 2 you see fit (Public Domain) */
3 3
4#include <sys/types.h> 4#include <sys/types.h>
5#ifndef _WIN32
5#include <sys/select.h> 6#include <sys/select.h>
6#include <sys/socket.h> 7#include <sys/socket.h>
8#else
9#include <winsock2.h>
10#endif
7#include <stdio.h> 11#include <stdio.h>
8#include <stdlib.h> 12#include <stdlib.h>
9#include <string.h> 13#include <string.h>
diff --git a/doc/examples/logging.c b/doc/examples/logging.c
index b8d0341d..27545231 100644
--- a/doc/examples/logging.c
+++ b/doc/examples/logging.c
@@ -2,8 +2,12 @@
2 you see fit (Public Domain) */ 2 you see fit (Public Domain) */
3 3
4#include <sys/types.h> 4#include <sys/types.h>
5#ifndef _WIN32
5#include <sys/select.h> 6#include <sys/select.h>
6#include <sys/socket.h> 7#include <sys/socket.h>
8#else
9#include <winsock2.h>
10#endif
7#include <microhttpd.h> 11#include <microhttpd.h>
8#include <stdio.h> 12#include <stdio.h>
9 13
diff --git a/doc/examples/responseheaders.c b/doc/examples/responseheaders.c
index 2931c779..a56ccb21 100644
--- a/doc/examples/responseheaders.c
+++ b/doc/examples/responseheaders.c
@@ -2,8 +2,12 @@
2 you see fit (Public Domain) */ 2 you see fit (Public Domain) */
3 3
4#include <sys/types.h> 4#include <sys/types.h>
5#ifndef _WIN32
5#include <sys/select.h> 6#include <sys/select.h>
6#include <sys/socket.h> 7#include <sys/socket.h>
8#else
9#include <winsock2.h>
10#endif
7#include <microhttpd.h> 11#include <microhttpd.h>
8#include <time.h> 12#include <time.h>
9#include <sys/stat.h> 13#include <sys/stat.h>
diff --git a/doc/examples/sessions.c b/doc/examples/sessions.c
index 63abfc27..eff035df 100644
--- a/doc/examples/sessions.c
+++ b/doc/examples/sessions.c
@@ -4,7 +4,6 @@
4/* needed for asprintf */ 4/* needed for asprintf */
5#define _GNU_SOURCE 5#define _GNU_SOURCE
6 6
7
8#include <stdlib.h> 7#include <stdlib.h>
9#include <string.h> 8#include <string.h>
10#include <stdio.h> 9#include <stdio.h>
@@ -12,6 +11,46 @@
12#include <time.h> 11#include <time.h>
13#include <microhttpd.h> 12#include <microhttpd.h>
14 13
14#ifdef _WIN32
15int
16asprintf (char **resultp, const char *format, ...)
17{
18 va_list argptr;
19 char *result = NULL;
20 int len = 0;
21
22 if (format == NULL)
23 return -1;
24
25 va_start (argptr, format);
26
27 len = _vscprintf ((char *) format, argptr);
28 if (len >= 0)
29 {
30 len += 1;
31 result = (char *) malloc (sizeof (char *) * len);
32 if (result != NULL)
33 {
34 int len2 = _vscprintf ((char *) format, argptr);
35 if (len2 != len - 1 || len2 <= 0)
36 {
37 free (result);
38 result = NULL;
39 len = -1;
40 }
41 else
42 {
43 len = len2;
44 if (resultp)
45 *resultp = result;
46 }
47 }
48 }
49 va_end (argptr);
50 return len;
51}
52#endif
53
15/** 54/**
16 * Invalid method page. 55 * Invalid method page.
17 */ 56 */
@@ -163,10 +202,10 @@ get_session (struct MHD_Connection *connection)
163 snprintf (ret->sid, 202 snprintf (ret->sid,
164 sizeof (ret->sid), 203 sizeof (ret->sid),
165 "%X%X%X%X", 204 "%X%X%X%X",
166 (unsigned int) random (), 205 (unsigned int) rand (),
167 (unsigned int) random (), 206 (unsigned int) rand (),
168 (unsigned int) random (), 207 (unsigned int) rand (),
169 (unsigned int) random ()); 208 (unsigned int) rand ());
170 ret->rc++; 209 ret->rc++;
171 ret->start = time (NULL); 210 ret->start = time (NULL);
172 ret->next = sessions; 211 ret->next = sessions;
@@ -691,7 +730,7 @@ main (int argc, char *const *argv)
691 return 1; 730 return 1;
692 } 731 }
693 /* initialize PRNG */ 732 /* initialize PRNG */
694 srandom ((unsigned int) time (NULL)); 733 srand ((unsigned int) time (NULL));
695 d = MHD_start_daemon (MHD_USE_DEBUG, 734 d = MHD_start_daemon (MHD_USE_DEBUG,
696 atoi (argv[1]), 735 atoi (argv[1]),
697 NULL, NULL, 736 NULL, NULL,
diff --git a/doc/examples/simplepost.c b/doc/examples/simplepost.c
index 98a97624..11c8af54 100644
--- a/doc/examples/simplepost.c
+++ b/doc/examples/simplepost.c
@@ -2,8 +2,12 @@
2 you see fit (Public Domain) */ 2 you see fit (Public Domain) */
3 3
4#include <sys/types.h> 4#include <sys/types.h>
5#ifndef _WIN32
5#include <sys/select.h> 6#include <sys/select.h>
6#include <sys/socket.h> 7#include <sys/socket.h>
8#else
9#include <winsock2.h>
10#endif
7#include <microhttpd.h> 11#include <microhttpd.h>
8#include <stdio.h> 12#include <stdio.h>
9#include <string.h> 13#include <string.h>
diff --git a/doc/examples/tlsauthentication.c b/doc/examples/tlsauthentication.c
index 0127a40c..fd58505f 100644
--- a/doc/examples/tlsauthentication.c
+++ b/doc/examples/tlsauthentication.c
@@ -2,8 +2,12 @@
2 you see fit (Public Domain) */ 2 you see fit (Public Domain) */
3 3
4#include <sys/types.h> 4#include <sys/types.h>
5#ifndef _WIN32
5#include <sys/select.h> 6#include <sys/select.h>
6#include <sys/socket.h> 7#include <sys/socket.h>
8#else
9#include <winsock2.h>
10#endif
7#include <microhttpd.h> 11#include <microhttpd.h>
8#include <string.h> 12#include <string.h>
9#include <stdio.h> 13#include <stdio.h>