aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorng0@n0.is <ng0@n0.is>2019-07-22 10:09:37 +0000
committerng0@n0.is <ng0@n0.is>2019-07-22 10:09:37 +0000
commitefc746de551880d0b67563e755d12591ae1ef0df (patch)
tree5aaf160eec4c76d84ff52f0ea457d56312f6d95c
parent861f4534ef12ec16d28c0bce1711da9e1640ea24 (diff)
downloadlibmicrohttpd-gsoc2019-efc746de551880d0b67563e755d12591ae1ef0df.tar.gz
libmicrohttpd-gsoc2019-efc746de551880d0b67563e755d12591ae1ef0df.zip
verbose adding everything I have, even though it might not be useful.
-rw-r--r--inc.c.netbsd.txt3
-rw-r--r--inc.c.patch71
-rw-r--r--newtest.c32
-rw-r--r--quicklegend.txt9
-rw-r--r--wrapperfunc.c33
5 files changed, 148 insertions, 0 deletions
diff --git a/inc.c.netbsd.txt b/inc.c.netbsd.txt
new file mode 100644
index 0000000..6d86dd0
--- /dev/null
+++ b/inc.c.netbsd.txt
@@ -0,0 +1,3 @@
1export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/home/ng0/code/dev/prefix/lib/pkgconfig ; clang `pkgconf --cflags libmicrohttpd` inc.c `pkgconf --libs libmicrohttpd` -Wall -Wl,-R/home/ng0/code/dev/prefix/lib
2
3A run of ktruss -p $OURPID results in the logfile here.
diff --git a/inc.c.patch b/inc.c.patch
new file mode 100644
index 0000000..e7d4ec3
--- /dev/null
+++ b/inc.c.patch
@@ -0,0 +1,71 @@
1diff -r 0cc341b44642 inc.c
2--- a/inc.c Tue Jun 04 11:07:47 2019 +0000
3+++ b/inc.c Tue Jun 04 22:40:57 2019 +0000
4@@ -1,7 +1,30 @@
5 #include <microhttpd.h>
6 #include <stdlib.h>
7 #include <stdio.h>
8+#include <curl/curl.h>
9
10+struct CBC
11+{
12+ char *buf;
13+ size_t pos;
14+ size_t size;
15+};
16+
17+static size_t
18+copyBuffer (void *ptr,
19+ size_t size,
20+ size_t nmemb,
21+ void *ctx)
22+{
23+ struct CBC *cbc = ctx;
24+ if (cbc->pos + size * nmemb > cbc->size)
25+ return 0; /* overflow */
26+ memcpy (&cbc->buf[cbc->pos], ptr, size *nmemb);
27+ cbc->pos += size * nmemb;
28+ return size * nmemb;
29+}
30+
31+// crc - content reader callback
32 static ssize_t
33 crc (void *cls, uint64_t pos, char *buf, size_t size_max)
34 {
35@@ -37,16 +60,34 @@
36 }
37
38 int
39-main ()
40+main (void)
41 {
42+ int port;
43+ port = 8888;
44+ CURL *c;
45+ snprintf(buf, sizeof(buf), "http://127.0.0.1:%d/", port);
46 struct MHD_Daemon *daemon =
47 MHD_start_daemon (MHD_USE_AUTO | MHD_USE_INTERNAL_POLLING_THREAD,
48- 8888,
49+ port,
50 NULL,
51 NULL,
52 &answer_to_connection,
53 NULL,
54 MHD_OPTION_END);
55+ c = curl_easy_init ();
56+ curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/");
57+ curl_easy_setopt (c, CURLOPT_URL, (long)port);
58+ curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
59+ curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc);
60+ curl_easy_setopt (c, CURLOPT_FAILONERROR, 1);
61+ curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
62+ curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L);
63+ curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 150L);
64+ /* NOTE: use of CONNECTTIMEOUT without also
65+ * setting NOSIGNAL results in really weird
66+ * crashes on my system! */
67+ curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1);
68+
69 if (NULL == daemon)
70 return 1;
71 (void) getchar ();
diff --git a/newtest.c b/newtest.c
new file mode 100644
index 0000000..4bc5504
--- /dev/null
+++ b/newtest.c
@@ -0,0 +1,32 @@
1#include <microhttpd.h>
2#include <stdlib.h>
3#include <stdio.h>
4#include <string.h>
5
6/*
7 *
8 */
9
10int
11main (void)
12{
13 struct MHD_Daemon *daemon;
14 // initialize the daemon
15 daemon =
16 MHD_start_daemon (MHD_USE_AUTO | MHD_USE_INTERNAL_POLLING_THREAD |
17 MHD_USE_ERROR_LOG,
18 80,
19 NULL,
20 NULL,
21 &answer_to_connection,
22 NULL,
23 NULL,
24 MHD_OPTION_END);
25 // call the daemon
26 if (NULL == daemon)
27 return 1;
28 (void) getchar ();
29 // stop the daemon (never reached?)
30 MHD_stop_daemon (daemon);
31 return 0;
32}
diff --git a/quicklegend.txt b/quicklegend.txt
new file mode 100644
index 0000000..4238e75
--- /dev/null
+++ b/quicklegend.txt
@@ -0,0 +1,9 @@
1Reoccuring entries, translated.
2Based on netbsd's sys/socket.h.
3
40xffff -> SOL_SOCKET
5
6
7Based on netbsd's netinet/tcp.h.
8
9TCP_NODELAY -> 1 -> 0x1
diff --git a/wrapperfunc.c b/wrapperfunc.c
new file mode 100644
index 0000000..48efd76
--- /dev/null
+++ b/wrapperfunc.c
@@ -0,0 +1,33 @@
1/*
2 * starting point: NetBSD's <netinet/tcp.h>
3 */
4enum MHD_socket_options
5{
6 MHD_TCP_NODELAY = 1, /* don't delay send to coalesce packets */
7 MHD_TCP_MAXSEG = 2, /* set maximum segment size */
8 MHD_TCP_KEEPIDLE = 3,
9 MHD_TCP_NOPUSH = 4, /* reserved for FreeBSD compat */
10 MHD_TCP_KEEPINTVL = 5,
11 MHD_TCP_KEEPCNT = 6,
12 MHD_TCP_KEEPINIT = 7,
13 MHD_TCP_NOOPT = 8, /* reserved for FreeBSD compat */
14 MHD_TCP_INFO = 9, /* retrieve tcp_info structure */
15 MHD_TCP_MD5SIG = 10, /* use MD5 digests (RFC2385) */
16 MHD_TCP_CONGCTL = 11, /* selected congestion control */
17 MHD_TCPI_OPT_TIMESTAMPS = 12,
18 MHD_TCPI_OPT_SACK = 13,
19 MHD_TCPI_OPT_WSCALE = 14,
20 MHD_TCPI_OPT_ECN = 15,
21 MHD_TCPI_OPT_TOE = 16
22};
23
24/*
25 * prototype for setsocket etc wrapper
26 */
27void
28MHD_socketoption (struct MHD_Connnection *connection,
29 char *buffer,
30 size_t buffersize,
31 enum MHD_socket_options);
32
33/* EOF wrapperfunc.c */