aboutsummaryrefslogtreecommitdiff
path: root/src/examples/refuse_post_example.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2019-10-17 16:56:41 +0200
committerChristian Grothoff <christian@grothoff.org>2019-10-17 16:56:41 +0200
commit972103dc288e2a2396e060018e7c3733f29a940d (patch)
treeaeb0b3a182d5168f12752928d3204342c9581e91 /src/examples/refuse_post_example.c
parentcbbfd0591fc639ddd21a5850f54f403fb7394174 (diff)
downloadlibmicrohttpd-972103dc288e2a2396e060018e7c3733f29a940d.tar.gz
libmicrohttpd-972103dc288e2a2396e060018e7c3733f29a940d.zip
applying uncrustify to ensure uniform indentation
Diffstat (limited to 'src/examples/refuse_post_example.c')
-rw-r--r--src/examples/refuse_post_example.c59
1 files changed, 31 insertions, 28 deletions
diff --git a/src/examples/refuse_post_example.c b/src/examples/refuse_post_example.c
index dad3beb1..9241ce43 100644
--- a/src/examples/refuse_post_example.c
+++ b/src/examples/refuse_post_example.c
@@ -24,14 +24,16 @@
24#include "platform.h" 24#include "platform.h"
25#include <microhttpd.h> 25#include <microhttpd.h>
26 26
27const char *askpage = "<html><body>\n\ 27const char *askpage =
28 "<html><body>\n\
28 Upload a file, please!<br>\n\ 29 Upload a file, please!<br>\n\
29 <form action=\"/filepost\" method=\"post\" enctype=\"multipart/form-data\">\n\ 30 <form action=\"/filepost\" method=\"post\" enctype=\"multipart/form-data\">\n\
30 <input name=\"file\" type=\"file\">\n\ 31 <input name=\"file\" type=\"file\">\n\
31 <input type=\"submit\" value=\" Send \"></form>\n\ 32 <input type=\"submit\" value=\" Send \"></form>\n\
32 </body></html>"; 33 </body></html>";
33 34
34#define BUSYPAGE "<html><head><title>Webserver busy</title></head><body>We are too busy to process POSTs right now.</body></html>" 35#define BUSYPAGE \
36 "<html><head><title>Webserver busy</title></head><body>We are too busy to process POSTs right now.</body></html>"
35 37
36static int 38static int
37ahc_echo (void *cls, 39ahc_echo (void *cls,
@@ -45,37 +47,37 @@ ahc_echo (void *cls,
45 const char *me = cls; 47 const char *me = cls;
46 struct MHD_Response *response; 48 struct MHD_Response *response;
47 int ret; 49 int ret;
48 (void)cls; /* Unused. Silent compiler warning. */ 50 (void) cls; /* Unused. Silent compiler warning. */
49 (void)url; /* Unused. Silent compiler warning. */ 51 (void) url; /* Unused. Silent compiler warning. */
50 (void)version; /* Unused. Silent compiler warning. */ 52 (void) version; /* Unused. Silent compiler warning. */
51 (void)upload_data; /* Unused. Silent compiler warning. */ 53 (void) upload_data; /* Unused. Silent compiler warning. */
52 (void)upload_data_size; /* Unused. Silent compiler warning. */ 54 (void) upload_data_size; /* Unused. Silent compiler warning. */
53 55
54 if ((0 != strcmp (method, "GET")) && (0 != strcmp (method, "POST"))) 56 if ((0 != strcmp (method, "GET")) && (0 != strcmp (method, "POST")))
55 return MHD_NO; /* unexpected method */ 57 return MHD_NO; /* unexpected method */
56 58
57 if (&aptr != *ptr) 59 if (&aptr != *ptr)
58 { 60 {
59 *ptr = &aptr; 61 *ptr = &aptr;
60 62
61 /* always to busy for POST requests */ 63 /* always to busy for POST requests */
62 if (0 == strcmp (method, "POST")) 64 if (0 == strcmp (method, "POST"))
63 { 65 {
64 response = MHD_create_response_from_buffer (strlen (BUSYPAGE), 66 response = MHD_create_response_from_buffer (strlen (BUSYPAGE),
65 (void *) BUSYPAGE, 67 (void *) BUSYPAGE,
66 MHD_RESPMEM_PERSISTENT); 68 MHD_RESPMEM_PERSISTENT);
67 ret = 69 ret =
68 MHD_queue_response (connection, MHD_HTTP_SERVICE_UNAVAILABLE, 70 MHD_queue_response (connection, MHD_HTTP_SERVICE_UNAVAILABLE,
69 response); 71 response);
70 MHD_destroy_response (response); 72 MHD_destroy_response (response);
71 return ret; 73 return ret;
72 }
73 } 74 }
75 }
74 76
75 *ptr = NULL; /* reset when done */ 77 *ptr = NULL; /* reset when done */
76 response = MHD_create_response_from_buffer (strlen (me), 78 response = MHD_create_response_from_buffer (strlen (me),
77 (void *) me, 79 (void *) me,
78 MHD_RESPMEM_PERSISTENT); 80 MHD_RESPMEM_PERSISTENT);
79 ret = MHD_queue_response (connection, MHD_HTTP_OK, response); 81 ret = MHD_queue_response (connection, MHD_HTTP_OK, response);
80 MHD_destroy_response (response); 82 MHD_destroy_response (response);
81 return ret; 83 return ret;
@@ -87,11 +89,12 @@ main (int argc, char *const *argv)
87 struct MHD_Daemon *d; 89 struct MHD_Daemon *d;
88 90
89 if (argc != 2) 91 if (argc != 2)
90 { 92 {
91 printf ("%s PORT\n", argv[0]); 93 printf ("%s PORT\n", argv[0]);
92 return 1; 94 return 1;
93 } 95 }
94 d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, 96 d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION
97 | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG,
95 atoi (argv[1]), 98 atoi (argv[1]),
96 NULL, NULL, &ahc_echo, (void *) askpage, 99 NULL, NULL, &ahc_echo, (void *) askpage,
97 MHD_OPTION_END); 100 MHD_OPTION_END);