diff options
author | Christian Grothoff <christian@grothoff.org> | 2019-08-25 21:13:27 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2019-08-25 21:13:27 +0200 |
commit | 5d7265871c653ebe72d59bb153ca07590b2ca5a7 (patch) | |
tree | 224e74d71581aad89d5be2837aa7917a7e645537 | |
parent | 91530f21e982350b98d9f6aa17379ad8af9f3158 (diff) | |
download | libmicrohttpd-5d7265871c653ebe72d59bb153ca07590b2ca5a7.tar.gz libmicrohttpd-5d7265871c653ebe72d59bb153ca07590b2ca5a7.zip |
reindenting
-rw-r--r-- | src/examples/minimal_example.c | 64 |
1 files changed, 36 insertions, 28 deletions
diff --git a/src/examples/minimal_example.c b/src/examples/minimal_example.c index dbafda77..d6589cf9 100644 --- a/src/examples/minimal_example.c +++ b/src/examples/minimal_example.c | |||
@@ -25,7 +25,8 @@ | |||
25 | #include "platform.h" | 25 | #include "platform.h" |
26 | #include <microhttpd.h> | 26 | #include <microhttpd.h> |
27 | 27 | ||
28 | #define PAGE "<html><head><title>libmicrohttpd demo</title></head><body>libmicrohttpd demo</body></html>" | 28 | #define PAGE \ |
29 | "<html><head><title>libmicrohttpd demo</title></head><body>libmicrohttpd demo</body></html>" | ||
29 | 30 | ||
30 | static int | 31 | static int |
31 | ahc_echo (void *cls, | 32 | ahc_echo (void *cls, |
@@ -33,54 +34,61 @@ ahc_echo (void *cls, | |||
33 | const char *url, | 34 | const char *url, |
34 | const char *method, | 35 | const char *method, |
35 | const char *version, | 36 | const char *version, |
36 | const char *upload_data, size_t *upload_data_size, void **ptr) | 37 | const char *upload_data, |
38 | size_t *upload_data_size, | ||
39 | void **ptr) | ||
37 | { | 40 | { |
38 | static int aptr; | 41 | static int aptr; |
39 | const char *me = cls; | 42 | const char *me = cls; |
40 | struct MHD_Response *response; | 43 | struct MHD_Response *response; |
41 | int ret; | 44 | int ret; |
42 | (void)url; /* Unused. Silent compiler warning. */ | 45 | |
43 | (void)version; /* Unused. Silent compiler warning. */ | 46 | (void) url; /* Unused. Silent compiler warning. */ |
44 | (void)upload_data; /* Unused. Silent compiler warning. */ | 47 | (void) version; /* Unused. Silent compiler warning. */ |
45 | (void)upload_data_size; /* Unused. Silent compiler warning. */ | 48 | (void) upload_data; /* Unused. Silent compiler warning. */ |
49 | (void) upload_data_size; /* Unused. Silent compiler warning. */ | ||
46 | 50 | ||
47 | if (0 != strcmp (method, "GET")) | 51 | if (0 != strcmp (method, "GET")) |
48 | return MHD_NO; /* unexpected method */ | 52 | return MHD_NO; /* unexpected method */ |
49 | if (&aptr != *ptr) | 53 | if (&aptr != *ptr) |
50 | { | 54 | { |
51 | /* do never respond on first call */ | 55 | /* do never respond on first call */ |
52 | *ptr = &aptr; | 56 | *ptr = &aptr; |
53 | return MHD_YES; | 57 | return MHD_YES; |
54 | } | 58 | } |
55 | *ptr = NULL; /* reset when done */ | 59 | *ptr = NULL; /* reset when done */ |
56 | response = MHD_create_response_from_buffer (strlen (me), | 60 | response = MHD_create_response_from_buffer (strlen (me), |
57 | (void *) me, | 61 | (void *) me, |
58 | MHD_RESPMEM_PERSISTENT); | 62 | MHD_RESPMEM_PERSISTENT); |
59 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); | 63 | ret = MHD_queue_response (connection, |
64 | MHD_HTTP_OK, | ||
65 | response); | ||
60 | MHD_destroy_response (response); | 66 | MHD_destroy_response (response); |
61 | return ret; | 67 | return ret; |
62 | } | 68 | } |
63 | 69 | ||
70 | |||
64 | int | 71 | int |
65 | main (int argc, char *const *argv) | 72 | main (int argc, |
73 | char *const *argv) | ||
66 | { | 74 | { |
67 | struct MHD_Daemon *d; | 75 | struct MHD_Daemon *d; |
68 | 76 | ||
69 | if (argc != 2) | 77 | if (argc != 2) |
70 | { | 78 | { |
71 | printf ("%s PORT\n", argv[0]); | 79 | printf ("%s PORT\n", argv[0]); |
72 | return 1; | 80 | return 1; |
73 | } | 81 | } |
74 | d = MHD_start_daemon (/* MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, */ | 82 | d = MHD_start_daemon (/* MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, */ |
75 | MHD_USE_AUTO | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, | 83 | MHD_USE_AUTO | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, |
76 | /* MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG | MHD_USE_POLL, */ | 84 | /* MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG | MHD_USE_POLL, */ |
77 | /* MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG | MHD_USE_POLL, */ | 85 | /* MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG | MHD_USE_POLL, */ |
78 | /* MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, */ | 86 | /* MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, */ |
79 | atoi (argv[1]), | 87 | atoi (argv[1]), |
80 | NULL, NULL, &ahc_echo, PAGE, | 88 | NULL, NULL, &ahc_echo, PAGE, |
81 | MHD_OPTION_CONNECTION_TIMEOUT, (unsigned int) 120, | 89 | MHD_OPTION_CONNECTION_TIMEOUT, (unsigned int) 120, |
82 | MHD_OPTION_STRICT_FOR_CLIENT, (int) 1, | 90 | MHD_OPTION_STRICT_FOR_CLIENT, (int) 1, |
83 | MHD_OPTION_END); | 91 | MHD_OPTION_END); |
84 | if (d == NULL) | 92 | if (d == NULL) |
85 | return 1; | 93 | return 1; |
86 | (void) getc (stdin); | 94 | (void) getc (stdin); |