aboutsummaryrefslogtreecommitdiff
path: root/src/examples/authorization_example.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/examples/authorization_example.c')
-rw-r--r--src/examples/authorization_example.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/examples/authorization_example.c b/src/examples/authorization_example.c
index 796ad072..eb478104 100644
--- a/src/examples/authorization_example.c
+++ b/src/examples/authorization_example.c
@@ -90,22 +90,29 @@ ahc_echo (void *cls,
90 return ret; 90 return ret;
91} 91}
92 92
93
93int 94int
94main (int argc, char *const *argv) 95main (int argc, char *const *argv)
95{ 96{
96 struct MHD_Daemon *d; 97 struct MHD_Daemon *d;
98 unsigned int port;
97 99
98 if (argc != 3) 100 if ( (argc != 2) ||
101 (1 != sscanf (argv[1], "%u", &port)) ||
102 (UINT16_MAX < port) )
99 { 103 {
100 printf ("%s PORT SECONDS-TO-RUN\n", argv[0]); 104 fprintf (stderr,
105 "%s PORT\n", argv[0]);
101 return 1; 106 return 1;
102 } 107 }
108
103 d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_DEBUG, 109 d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_DEBUG,
104 atoi (argv[1]), 110 atoi (argv[1]),
105 NULL, NULL, &ahc_echo, PAGE, MHD_OPTION_END); 111 NULL, NULL, &ahc_echo, PAGE, MHD_OPTION_END);
106 if (d == NULL) 112 if (d == NULL)
107 return 1; 113 return 1;
108 sleep (atoi (argv[2])); 114 fprintf (stderr, "HTTP server running. Press ENTER to stop the server\n");
115 (void) getc (stdin);
109 MHD_stop_daemon (d); 116 MHD_stop_daemon (d);
110 return 0; 117 return 0;
111} 118}