aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2016-01-18 20:37:15 +0000
committerChristian Grothoff <christian@grothoff.org>2016-01-18 20:37:15 +0000
commit9be469e2eeade6ccdbbd24f99cd37aa424e9afb9 (patch)
tree566f3675ee3ea69850bf1298992b096de82a3aae
parent24305c50dd976c24a4aab39c6d8b3ea24ff16aeb (diff)
downloadlibmicrohttpd-9be469e2eeade6ccdbbd24f99cd37aa424e9afb9.tar.gz
libmicrohttpd-9be469e2eeade6ccdbbd24f99cd37aa424e9afb9.zip
use getc() as in demo.c instead of sleep()
-rw-r--r--src/examples/authorization_example.c13
-rw-r--r--src/examples/demo.c4
2 files changed, 12 insertions, 5 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}
diff --git a/src/examples/demo.c b/src/examples/demo.c
index 6cf882cc..7d6d1bd8 100644
--- a/src/examples/demo.c
+++ b/src/examples/demo.c
@@ -856,9 +856,9 @@ main (int argc, char *const *argv)
856 "%s PORT\n", argv[0]); 856 "%s PORT\n", argv[0]);
857 return 1; 857 return 1;
858 } 858 }
859 #ifndef MINGW 859#ifndef MINGW
860 ignore_sigpipe (); 860 ignore_sigpipe ();
861 #endif 861#endif
862 magic = magic_open (MAGIC_MIME_TYPE); 862 magic = magic_open (MAGIC_MIME_TYPE);
863 (void) magic_load (magic, NULL); 863 (void) magic_load (magic, NULL);
864 864