diff options
author | ng0@n0.is <ng0@n0.is> | 2019-06-03 17:05:27 +0000 |
---|---|---|
committer | ng0@n0.is <ng0@n0.is> | 2019-06-03 17:05:27 +0000 |
commit | 85f8cf4fde8c6cb56ce29ee5b52e2ab9b5bfc705 (patch) | |
tree | 878acb072cbcb81cb6c5e227b92f8eae0c1f276c /inc.c | |
parent | 5c923610f7dc5d90c259dd19fbd6f2b6d0c22463 (diff) | |
download | libmicrohttpd-gsoc2019-85f8cf4fde8c6cb56ce29ee5b52e2ab9b5bfc705.tar.gz libmicrohttpd-gsoc2019-85f8cf4fde8c6cb56ce29ee5b52e2ab9b5bfc705.zip |
clang format
Diffstat (limited to 'inc.c')
-rw-r--r-- | inc.c | 71 |
1 files changed, 38 insertions, 33 deletions
@@ -2,49 +2,54 @@ | |||
2 | #include <stdlib.h> | 2 | #include <stdlib.h> |
3 | #include <stdio.h> | 3 | #include <stdio.h> |
4 | 4 | ||
5 | static ssize_t crc (void *cls, uint64_t pos, | 5 | static ssize_t |
6 | char *buf, size_t size_max) { | 6 | crc (void *cls, uint64_t pos, char *buf, size_t size_max) |
7 | if (0 == size_max) return 0; | 7 | { |
8 | if (0 == rand() % 1024 * 1024) | 8 | if (0 == size_max) |
9 | return MHD_CONTENT_READER_END_OF_STREAM; | 9 | return 0; |
10 | *buf = 'b'; | 10 | if (0 == rand () % 1024 * 1024) |
11 | return 1; | 11 | return MHD_CONTENT_READER_END_OF_STREAM; |
12 | *buf = 'b'; | ||
13 | return 1; | ||
12 | } | 14 | } |
13 | 15 | ||
14 | 16 | ||
15 | static int | 17 | static int |
16 | answer_to_connection (void *cls, | 18 | answer_to_connection (void *cls, |
17 | struct MHD_Connection *connection, | 19 | struct MHD_Connection *connection, |
18 | const char *url, const char *method, | 20 | const char *url, |
21 | const char *method, | ||
19 | const char *version, | 22 | const char *version, |
20 | const char *upload_data, size_t *upload_data_size, | 23 | const char *upload_data, |
24 | size_t *upload_data_size, | ||
21 | void **con_cls) | 25 | void **con_cls) |
22 | { | 26 | { |
23 | int ret; | 27 | int ret; |
24 | struct MHD_Response *response | 28 | struct MHD_Response *response = |
25 | = MHD_create_response_from_callback | 29 | MHD_create_response_from_callback (MHD_SIZE_UNKNOWN, |
26 | (MHD_SIZE_UNKNOWN, | 30 | 1024, |
27 | 1024, | 31 | &crc, |
28 | &crc, NULL, NULL); | 32 | NULL, |
29 | ret = MHD_queue_response (connection, | 33 | NULL); |
30 | MHD_HTTP_OK, | 34 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); |
31 | response); | 35 | MHD_destroy_response (response); |
32 | MHD_destroy_response (response); | 36 | return ret; |
33 | return ret; | ||
34 | } | 37 | } |
35 | 38 | ||
36 | int main () | 39 | int |
40 | main () | ||
37 | { | 41 | { |
38 | struct MHD_Daemon *daemon | 42 | struct MHD_Daemon *daemon = |
39 | = MHD_start_daemon (MHD_USE_AUTO | \ | 43 | MHD_start_daemon (MHD_USE_AUTO | MHD_USE_INTERNAL_POLLING_THREAD, |
40 | MHD_USE_INTERNAL_POLLING_THREAD, | 44 | 8888, |
41 | 8888, | 45 | NULL, |
42 | NULL, NULL, | 46 | NULL, |
43 | &answer_to_connection, NULL, | 47 | &answer_to_connection, |
44 | MHD_OPTION_END); | 48 | NULL, |
45 | if (NULL == daemon) | 49 | MHD_OPTION_END); |
46 | return 1; | 50 | if (NULL == daemon) |
47 | (void) getchar (); | 51 | return 1; |
48 | MHD_stop_daemon (daemon); | 52 | (void) getchar (); |
49 | return 0; | 53 | MHD_stop_daemon (daemon); |
54 | return 0; | ||
50 | } | 55 | } |