aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorng0@n0.is <ng0@n0.is>2019-06-07 09:56:31 +0000
committerng0@n0.is <ng0@n0.is>2019-06-07 09:56:31 +0000
commit4f1b2ecaf2b9d2f5dc5ae28f6e7e5a20addbb5a6 (patch)
tree7cbbe67d479bd050eaacf21f59b4be08b988845a
parenta8d89462cb391ee1688aa85b30d1ccb55ca0bc26 (diff)
downloadlibmicrohttpd-gsoc2019-4f1b2ecaf2b9d2f5dc5ae28f6e7e5a20addbb5a6.tar.gz
libmicrohttpd-gsoc2019-4f1b2ecaf2b9d2f5dc5ae28f6e7e5a20addbb5a6.zip
add mrg.c
-rw-r--r--mrg.c55
1 files changed, 55 insertions, 0 deletions
diff --git a/mrg.c b/mrg.c
new file mode 100644
index 0000000..e7b5bea
--- /dev/null
+++ b/mrg.c
@@ -0,0 +1,55 @@
1#include <microhttpd.h>
2#include <stdlib.h>
3#include <stdio.h>
4#include <string.h>
5
6static int
7answer_to_connection (void *cls,
8 struct MHD_Connection *connection,
9 const char *url,
10 const char *method,
11 const char *version,
12 const char *upload_data,
13 size_t *upload_data_size,
14 void **con_cls)
15{
16 const char *body = "<html><body>\
17 <p>\
18 Hello, ick bins eins HTML body!<br>\
19 Ia! Ia! Cthulhu fhtagn! Ph'nglui mglw'nfah Cthulhu R'lyeh wgah'nagl fhtagn!\
20 Ia! Ia! Cthulhu fhtagn! Ph'nglui mglw'nfah Cthulhu R'lyeh wgah'nagl fhtagn!\
21 Ia! Ia! Cthulhu fhtagn! Ph'nglui mglw'nfah Cthulhu R'lyeh wgah'nagl fhtagn!\
22 Ia! Ia! Cthulhu fhtagn! Ph'nglui mglw'nfah Cthulhu R'lyeh wgah'nagl fhtagn!\
23 Ia! Ia! Cthulhu fhtagn! Ph'nglui mglw'nfah Cthulhu R'lyeh wgah'nagl fhtagn!\
24 Ia! Ia! Cthulhu fhtagn! Ph'nglui mglw'nfah Cthulhu R'lyeh wgah'nagl fhtagn!\
25 Ia! Ia! Cthulhu fhtagn! Ph'nglui mglw'nfah Cthulhu R'lyeh wgah'nagl fhtagn!\
26 Ia! Ia! Cthulhu fhtagn! Ph'nglui mglw'nfah Cthulhu R'lyeh wgah'nagl fhtagn!\
27 </p>\
28 </body></html>";
29 int ret;
30 struct MHD_Response *response =
31 MHD_create_response_from_buffer (strlen (body),
32 (void *) body,
33 MHD_RESPMEM_PERSISTENT);
34 ret = MHD_queue_response (connection, MHD_HTTP_OK, response);
35 MHD_destroy_response (response);
36 return ret;
37}
38
39int
40main ()
41{
42 struct MHD_Daemon *daemon =
43 MHD_start_daemon (MHD_USE_AUTO | MHD_USE_INTERNAL_POLLING_THREAD,
44 8888,
45 NULL,
46 NULL,
47 &answer_to_connection,
48 NULL,
49 MHD_OPTION_END);
50 if (NULL == daemon)
51 return 1;
52 (void) getchar ();
53 MHD_stop_daemon (daemon);
54 return 0;
55}