diff --git a/lib/libwebsockets.c b/lib/libwebsockets.c index 9eb5568e..118a28a7 100644 --- a/lib/libwebsockets.c +++ b/lib/libwebsockets.c @@ -2954,8 +2954,8 @@ lws_cmdline_option(int argc, const char **argv, const char *val) int n = strlen(val), c = argc; while (--c > 0) - if (!strncmp(argv[c], val, n) && !*(argv[c] + n)) { - if (c != argc - 1) + if (!strncmp(argv[c], val, n)) { + if (!*(argv[c] + n) && c != argc - 1) return argv[c + 1]; return argv[c] + n; diff --git a/minimal-examples/client-server/minimal-ws-proxy/minimal-ws-proxy.c b/minimal-examples/client-server/minimal-ws-proxy/minimal-ws-proxy.c index 6ca0052b..6c9eaab8 100644 --- a/minimal-examples/client-server/minimal-ws-proxy/minimal-ws-proxy.c +++ b/minimal-examples/client-server/minimal-ws-proxy/minimal-ws-proxy.c @@ -56,30 +56,33 @@ void sigint_handler(int sig) interrupted = 1; } -int main(int argc, char **argv) +int main(int argc, const char **argv) { struct lws_context_creation_info info; struct lws_context *context; - int n = 0; + const char *p; + int n = 0, logs = LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE + /* for LLL_ verbosity above NOTICE to be built into lws, + * lws must have been configured and built with + * -DCMAKE_BUILD_TYPE=DEBUG instead of =RELEASE */ + /* | LLL_INFO */ /* | LLL_PARSER */ /* | LLL_HEADER */ + /* | LLL_EXT */ /* | LLL_CLIENT */ /* | LLL_LATENCY */ + /* | LLL_DEBUG */; signal(SIGINT, sigint_handler); + if ((p = lws_cmdline_option(argc, argv, "-d"))) + logs = atoi(p); + + lws_set_log_level(logs, NULL); + lwsl_user("LWS minimal ws proxy | visit http://localhost:7681\n"); + memset(&info, 0, sizeof info); /* otherwise uninitialized garbage */ info.options = LWS_SERVER_OPTION_DO_SSL_GLOBAL_INIT; info.port = 7681; info.mounts = &mount; info.protocols = protocols; - lws_set_log_level(LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE - /* for LLL_ verbosity above NOTICE to be built into lws, - * lws must have been configured and built with - * -DCMAKE_BUILD_TYPE=DEBUG instead of =RELEASE */ - /* | LLL_INFO */ /* | LLL_PARSER */ /* | LLL_HEADER */ - /* | LLL_EXT */ /* | LLL_CLIENT */ /* | LLL_LATENCY */ - /* | LLL_DEBUG */, NULL); - - lwsl_user("LWS minimal ws proxy | visit http://localhost:7681\n"); - context = lws_create_context(&info); if (!context) { lwsl_err("lws init failed\n"); diff --git a/minimal-examples/http-client/minimal-http-client-certinfo/README.md b/minimal-examples/http-client/minimal-http-client-certinfo/README.md index e5971c99..ff6ada4b 100644 --- a/minimal-examples/http-client/minimal-http-client-certinfo/README.md +++ b/minimal-examples/http-client/minimal-http-client-certinfo/README.md @@ -3,14 +3,6 @@ This demonstrates how to dump information from the peer certificate largely independent of the tls backend. -## build - -``` - $ cmake . && make -``` - -## usage - The application goes to https://warmcat.com and receives the page data. Before receiving the page it dumps information on the server's cert. @@ -20,6 +12,20 @@ This works independently of the tls backend being OpenSSL or mbedTLS. However the public keys cannot be compared between the two tls backends, since they produce different representations. +## build + +``` + $ cmake . && make +``` + +## usage + +Commandline option|Meaning +---|--- +-d |Debug verbosity in decimal, eg, -d15 +-l| Connect to https://localhost:7681 and accept selfsigned cert +--h1|Specify http/1.1 only using ALPN, rejects h2 even if server supports it + ``` $ ./lws-minimal-http-client-certinfo [2018/04/05 21:39:26:5882] USER: LWS minimal http client diff --git a/minimal-examples/http-client/minimal-http-client-certinfo/minimal-http-client-certinfo.c b/minimal-examples/http-client/minimal-http-client-certinfo/minimal-http-client-certinfo.c index ed02898c..f96b1d5a 100644 --- a/minimal-examples/http-client/minimal-http-client-certinfo/minimal-http-client-certinfo.c +++ b/minimal-examples/http-client/minimal-http-client-certinfo/minimal-http-client-certinfo.c @@ -16,7 +16,7 @@ #include #include -static int interrupted; +static int interrupted, bad = 1, status; static struct lws *client_wsi; static int @@ -37,8 +37,8 @@ callback_http(struct lws *wsi, enum lws_callback_reasons reason, break; case LWS_CALLBACK_ESTABLISHED_CLIENT_HTTP: - lwsl_notice("lws_http_client_http_response %d\n", - lws_http_client_http_response(wsi)); + status = lws_http_client_http_response(wsi); + lwsl_notice("lws_http_client_http_response %d\n", status); if (!lws_tls_peer_cert_info(wsi, LWS_TLS_CERT_INFO_COMMON_NAME, ci, sizeof(buf) - sizeof(*ci))) @@ -97,6 +97,8 @@ callback_http(struct lws *wsi, enum lws_callback_reasons reason, case LWS_CALLBACK_COMPLETED_CLIENT_HTTP: lwsl_user("LWS_CALLBACK_COMPLETED_CLIENT_HTTP\n"); client_wsi = NULL; + bad = status != 200; + lws_cancel_service(lws_get_context(wsi)); /* abort poll wait */ break; default: @@ -122,22 +124,13 @@ sigint_handler(int sig) interrupted = 1; } -static int findswitch(int argc, char **argv, const char *val) -{ - while (--argc > 0) { - if (!strcmp(argv[argc], val)) - return argc; - } - - return 0; -} - -int main(int argc, char **argv) +int main(int argc, const char **argv) { struct lws_context_creation_info info; struct lws_client_connect_info i; struct lws_context *context; - int logs = LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE + const char *p; + int n = 0, logs = LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE /* * For LLL_ verbosity above NOTICE to be built into lws, * lws must have been configured and built with @@ -146,16 +139,14 @@ int main(int argc, char **argv) * | LLL_INFO | LLL_PARSER | LLL_HEADER | LLL_EXT | * LLL_CLIENT | LLL_LATENCY | LLL_DEBUG */ ; - int n = 0, m; signal(SIGINT, sigint_handler); - /* you can set the log level on commandline with, eg, -d 15 */ - m = findswitch(argc, argv, "-d"); - if (m && m + 1 < argc) - logs = atoi(argv[m + 1]); + + if ((p = lws_cmdline_option(argc, argv, "-d"))) + logs = atoi(p); lws_set_log_level(logs, NULL); - lwsl_user("LWS minimal http client\n"); + lwsl_user("LWS minimal http client [<-d ] [-l] [--h1]\n"); memset(&info, 0, sizeof info); /* otherwise uninitialized garbage */ info.options = LWS_SERVER_OPTION_DO_SSL_GLOBAL_INIT; @@ -178,13 +169,24 @@ int main(int argc, char **argv) memset(&i, 0, sizeof i); /* otherwise uninitialized garbage */ i.context = context; + i.ssl_connection = LCCSCF_USE_SSL; - i.port = 443; - i.address = "warmcat.com"; + if (lws_cmdline_option(argc, argv, "-l")) { + i.port = 7681; + i.address = "localhost"; + i.ssl_connection |= LCCSCF_ALLOW_SELFSIGNED; + } else { + i.port = 443; + i.address = "warmcat.com"; + } i.path = "/"; i.host = i.address; i.origin = i.address; - i.ssl_connection = /* LCCSCF_NOT_H2 | */ LCCSCF_USE_SSL; + + /* force h1 even if h2 available */ + if (lws_cmdline_option(argc, argv, "--h1")) + i.alpn = "http/1.1"; + i.method = "GET"; i.protocol = protocols[0].name; @@ -195,7 +197,7 @@ int main(int argc, char **argv) n = lws_service(context, 1000); lws_context_destroy(context); - lwsl_user("Completed\n"); + lwsl_user("Completed: %s\n", bad ? "failed" : "OK"); - return 0; + return bad; } diff --git a/minimal-examples/http-client/minimal-http-client-hugeurl/minimal-http-client-hugeurl.c b/minimal-examples/http-client/minimal-http-client-hugeurl/minimal-http-client-hugeurl.c index d989966b..c50c0d6d 100644 --- a/minimal-examples/http-client/minimal-http-client-hugeurl/minimal-http-client-hugeurl.c +++ b/minimal-examples/http-client/minimal-http-client-hugeurl/minimal-http-client-hugeurl.c @@ -8,19 +8,19 @@ * * This demonstrates the a minimal http client using lws. * - * It visits https://warmcat.com/?fakeparam=<2KB> and receives the html page there. You - * can dump the page data by changing the #if 0 below. + * It visits https://warmcat.com/?fakeparam=<2KB> and receives the html + * page there. You can dump the page data by changing the #if 0 below. */ #include #include #include -static int interrupted; +static int interrupted, bad = 1, status; static struct lws *client_wsi; static const char * const uri = - "/index.html?fakeparam=" + "/?fakeparam=" "00000000000000000000000000000000000000000000000000" "00000000000000000000000000000000000000000000000000" "00000000000000000000000000000000000000000000000000" @@ -76,6 +76,11 @@ callback_http(struct lws *wsi, enum lws_callback_reasons reason, client_wsi = NULL; break; + case LWS_CALLBACK_ESTABLISHED_CLIENT_HTTP: + status = lws_http_client_http_response(wsi); + lwsl_user("Connected with server response: %d\n", status); + break; + /* chunks of chunked content, with header removed */ case LWS_CALLBACK_RECEIVE_CLIENT_HTTP_READ: lwsl_user("RECEIVE_CLIENT_HTTP_READ: read %d\n", (int)len); @@ -106,6 +111,8 @@ callback_http(struct lws *wsi, enum lws_callback_reasons reason, case LWS_CALLBACK_COMPLETED_CLIENT_HTTP: client_wsi = NULL; + bad = status != 200; + lws_cancel_service(lws_get_context(wsi)); /* abort poll wait */ break; default: @@ -131,23 +138,26 @@ sigint_handler(int sig) interrupted = 1; } -int main(int argc, char **argv) +int main(int argc, const char **argv) { struct lws_context_creation_info info; struct lws_client_connect_info i; struct lws_context *context; - int n = 0; - - signal(SIGINT, sigint_handler); - lws_set_log_level(LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE + const char *p; + int n = 0, logs = LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE /* for LLL_ verbosity above NOTICE to be built into lws, * lws must have been configured and built with * -DCMAKE_BUILD_TYPE=DEBUG instead of =RELEASE */ /* | LLL_INFO */ /* | LLL_PARSER */ /* | LLL_HEADER */ /* | LLL_EXT */ /* | LLL_CLIENT */ /* | LLL_LATENCY */ - /* | LLL_DEBUG */, NULL); + /* | LLL_DEBUG */; - lwsl_user("LWS minimal http client hugeurl\n"); + if ((p = lws_cmdline_option(argc, argv, "-d"))) + logs = atoi(p); + + signal(SIGINT, sigint_handler); + lws_set_log_level(logs, NULL); + lwsl_user("LWS minimal http client hugeurl [-d [-l]\n"); memset(&info, 0, sizeof info); /* otherwise uninitialized garbage */ info.options = LWS_SERVER_OPTION_DO_SSL_GLOBAL_INIT; @@ -170,24 +180,30 @@ int main(int argc, char **argv) memset(&i, 0, sizeof i); /* otherwise uninitialized garbage */ i.context = context; + i.ssl_connection = LCCSCF_USE_SSL; - i.port = 443; - i.address = "warmcat.com"; + if (lws_cmdline_option(argc, argv, "-l")) { + i.port = 7681; + i.address = "localhost"; + i.ssl_connection |= LCCSCF_ALLOW_SELFSIGNED; + } else { + i.port = 443; + i.address = "warmcat.com"; + } i.path = uri; i.host = i.address; i.origin = i.address; - i.ssl_connection = 1; i.method = "GET"; - i.protocol = protocols[0].name; i.pwsi = &client_wsi; + lws_client_connect_via_info(&i); while (n >= 0 && client_wsi && !interrupted) n = lws_service(context, 1000); lws_context_destroy(context); - lwsl_user("Completed\n"); + lwsl_user("Completed: %s\n", bad? "failed": "OK"); - return 0; + return bad; } diff --git a/minimal-examples/http-client/minimal-http-client-hugeurl/selftest.sh b/minimal-examples/http-client/minimal-http-client-hugeurl/selftest.sh new file mode 100755 index 00000000..9be3a8a7 --- /dev/null +++ b/minimal-examples/http-client/minimal-http-client-hugeurl/selftest.sh @@ -0,0 +1,23 @@ +#!/bin/bash +# +# $1: path to minimal example binaries... +# if lws is built with -DLWS_WITH_MINIMAL_EXAMPLES=1 +# that will be ./bin from your build dir +# +# $2: path for logs and results. The results will go +# in a subdir named after the directory this script +# is in + +if [ -z "$1" -o -z "$2" ] ; then + echo "required args missing" + exit 1 +fi + +MYTEST=`echo $0 | sed "s/\/[^\/]*\$//g" |sed "s/.*\///g"` +mkdir -p $2/$MYTEST +rm -f $2/$MYTEST/*.log $2/$MYTEST/*.result +$1/lws-$MYTEST > $2/$MYTEST/1.log 2> $2/$MYTEST/1.log +echo $? > $2/$MYTEST/1.result + +exit 0 + diff --git a/minimal-examples/http-client/minimal-http-client-multi/minimal-http-client-multi.c b/minimal-examples/http-client/minimal-http-client-multi/minimal-http-client-multi.c index 7e87780d..4508fb46 100644 --- a/minimal-examples/http-client/minimal-http-client-multi/minimal-http-client-multi.c +++ b/minimal-examples/http-client/minimal-http-client-multi/minimal-http-client-multi.c @@ -230,7 +230,7 @@ int main(int argc, const char **argv) if (!staggered) /* * just pile on all the connections at once, testing the - * pipeline queueing before the first is connected + * pipeline queuing before the first is connected */ for (m = 0; m < (int)LWS_ARRAY_SIZE(client_wsi); m++) lws_try_client_connection(&i, m); @@ -242,7 +242,7 @@ int main(int argc, const char **argv) if (staggered) { /* * open the connections at 100ms intervals, with the - * last one being after 1s, testing both queueing, and + * last one being after 1s, testing both queuing, and * direct H2 stream addition stability */ if (us() > next && m < (int)LWS_ARRAY_SIZE(client_wsi)) { diff --git a/minimal-examples/http-client/minimal-http-client-post/minimal-http-client-post.c b/minimal-examples/http-client/minimal-http-client-post/minimal-http-client-post.c index 66e578b2..d2406892 100644 --- a/minimal-examples/http-client/minimal-http-client-post/minimal-http-client-post.c +++ b/minimal-examples/http-client/minimal-http-client-post/minimal-http-client-post.c @@ -17,7 +17,7 @@ #include #include -static int interrupted; +static int interrupted, bad = 1, status; static struct lws *client_wsi; struct pss { @@ -48,8 +48,8 @@ callback_http(struct lws *wsi, enum lws_callback_reasons reason, /* ...callbacks related to receiving the result... */ case LWS_CALLBACK_ESTABLISHED_CLIENT_HTTP: - lwsl_user("LWS_CALLBACK_ESTABLISHED_CLIENT_HTTP: response %d\n", - lws_http_client_http_response(wsi)); + status = lws_http_client_http_response(wsi); + lwsl_user("Connected with server response: %d\n", status); break; case LWS_CALLBACK_RECEIVE_CLIENT_HTTP_READ: @@ -67,6 +67,7 @@ callback_http(struct lws *wsi, enum lws_callback_reasons reason, case LWS_CALLBACK_COMPLETED_CLIENT_HTTP: lwsl_user("LWS_CALLBACK_COMPLETED_CLIENT_HTTP\n"); client_wsi = NULL; + bad = status != 200; break; /* ...callbacks related to generating the POST... */ @@ -182,23 +183,29 @@ sigint_handler(int sig) interrupted = 1; } -int main(int argc, char **argv) +int main(int argc, const char **argv) { struct lws_context_creation_info info; struct lws_client_connect_info i; struct lws_context *context; - int n = 0; + const char *p; + int n = 0, logs = LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE + /* + * For LLL_ verbosity above NOTICE to be built into lws, + * lws must have been configured and built with + * -DCMAKE_BUILD_TYPE=DEBUG instead of =RELEASE + * + * | LLL_INFO | LLL_PARSER | LLL_HEADER | LLL_EXT | + * LLL_CLIENT | LLL_LATENCY | LLL_DEBUG + */ ; signal(SIGINT, sigint_handler); - lws_set_log_level(LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE - /* for LLL_ verbosity above NOTICE to be built into lws, - * lws must have been configured and built with - * -DCMAKE_BUILD_TYPE=DEBUG instead of =RELEASE */ - /* | LLL_INFO */ /* | LLL_PARSER */ /* | LLL_HEADER */ - /* | LLL_EXT */ /* | LLL_CLIENT */ /* | LLL_LATENCY */ - /* | LLL_DEBUG */, NULL); - lwsl_user("LWS minimal http client - POST\n"); + if ((p = lws_cmdline_option(argc, argv, "-d"))) + logs = atoi(p); + + lws_set_log_level(logs, NULL); + lwsl_user("LWS minimal http client - POST [-d] [-l] [--h1]\n"); memset(&info, 0, sizeof info); /* otherwise uninitialized garbage */ info.options = LWS_SERVER_OPTION_DO_SSL_GLOBAL_INIT; @@ -221,15 +228,27 @@ int main(int argc, char **argv) memset(&i, 0, sizeof i); /* otherwise uninitialized garbage */ i.context = context; + i.ssl_connection = LCCSCF_USE_SSL; + + if (lws_cmdline_option(argc, argv, "-l")) { + i.port = 7681; + i.address = "localhost"; + i.ssl_connection |= LCCSCF_ALLOW_SELFSIGNED; + i.path = "/formtest"; + } else { + i.port = 443; + i.address = "libwebsockets.org"; + i.path = "/testserver/formtest"; + } - i.port = 443; - i.address = "libwebsockets.org"; - i.path = "/testserver/formtest"; - i.ssl_connection = /* LCCSCF_NOT_H2 | */ LCCSCF_USE_SSL; i.host = i.address; i.origin = i.address; i.method = "POST"; + /* force h1 even if h2 available */ + if (lws_cmdline_option(argc, argv, "--h1")) + i.alpn = "http/1.1"; + i.protocol = protocols[0].name; i.pwsi = &client_wsi; lws_client_connect_via_info(&i); @@ -238,7 +257,7 @@ int main(int argc, char **argv) n = lws_service(context, 1000); lws_context_destroy(context); - lwsl_user("Completed\n"); + lwsl_user("Completed: %s\n", bad ? "failed" : "OK"); - return 0; + return bad; } diff --git a/minimal-examples/http-client/minimal-http-client/README.md b/minimal-examples/http-client/minimal-http-client/README.md index 9d279557..a3ac8d68 100644 --- a/minimal-examples/http-client/minimal-http-client/README.md +++ b/minimal-examples/http-client/minimal-http-client/README.md @@ -1,5 +1,8 @@ # lws minimal http client +The application goes to either https://warmcat.com or +https://localhost:7681 (with `-l` option) and receives the page data. + ## build ``` @@ -8,7 +11,11 @@ ## usage -The application goes to https://warmcat.com and receives the page data. +Commandline option|Meaning +---|--- +-d |Debug verbosity in decimal, eg, -d15 +-l| Connect to https://localhost:7681 and accept selfsigned cert +--h1|Specify http/1.1 only using ALPN, rejects h2 even if server supports it ``` $ ./lws-minimal-http-client diff --git a/minimal-examples/http-client/minimal-http-client/minimal-http-client.c b/minimal-examples/http-client/minimal-http-client/minimal-http-client.c index 30562833..a0efb647 100644 --- a/minimal-examples/http-client/minimal-http-client/minimal-http-client.c +++ b/minimal-examples/http-client/minimal-http-client/minimal-http-client.c @@ -16,7 +16,7 @@ #include #include -static int interrupted; +static int interrupted, bad = 1, status; static struct lws *client_wsi; static int @@ -32,6 +32,11 @@ callback_http(struct lws *wsi, enum lws_callback_reasons reason, client_wsi = NULL; break; + case LWS_CALLBACK_ESTABLISHED_CLIENT_HTTP: + status = lws_http_client_http_response(wsi); + lwsl_user("Connected with server response: %d\n", status); + break; + /* chunks of chunked content, with header removed */ case LWS_CALLBACK_RECEIVE_CLIENT_HTTP_READ: lwsl_user("RECEIVE_CLIENT_HTTP_READ: read %d\n", (int)len); @@ -63,6 +68,8 @@ callback_http(struct lws *wsi, enum lws_callback_reasons reason, case LWS_CALLBACK_COMPLETED_CLIENT_HTTP: lwsl_user("LWS_CALLBACK_COMPLETED_CLIENT_HTTP\n"); client_wsi = NULL; + bad = status != 200; + lws_cancel_service(lws_get_context(wsi)); /* abort poll wait */ break; default: @@ -88,22 +95,13 @@ sigint_handler(int sig) interrupted = 1; } -static int findswitch(int argc, char **argv, const char *val) -{ - while (--argc > 0) { - if (!strcmp(argv[argc], val)) - return argc; - } - - return 0; -} - -int main(int argc, char **argv) +int main(int argc, const char **argv) { struct lws_context_creation_info info; struct lws_client_connect_info i; struct lws_context *context; - int logs = LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE + const char *p; + int n = 0, logs = LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE /* * For LLL_ verbosity above NOTICE to be built into lws, * lws must have been configured and built with @@ -112,16 +110,14 @@ int main(int argc, char **argv) * | LLL_INFO | LLL_PARSER | LLL_HEADER | LLL_EXT | * LLL_CLIENT | LLL_LATENCY | LLL_DEBUG */ ; - int n = 0, m; signal(SIGINT, sigint_handler); - /* you can set the log level on commandline with, eg, -d 15 */ - m = findswitch(argc, argv, "-d"); - if (m && m + 1 < argc) - logs = atoi(argv[m + 1]); + + if ((p = lws_cmdline_option(argc, argv, "-d"))) + logs = atoi(p); lws_set_log_level(logs, NULL); - lwsl_user("LWS minimal http client\n"); + lwsl_user("LWS minimal http client [-d] [-l] [--h1]\n"); memset(&info, 0, sizeof info); /* otherwise uninitialized garbage */ info.options = LWS_SERVER_OPTION_DO_SSL_GLOBAL_INIT; @@ -144,13 +140,23 @@ int main(int argc, char **argv) memset(&i, 0, sizeof i); /* otherwise uninitialized garbage */ i.context = context; + i.ssl_connection = LCCSCF_USE_SSL; + + if (lws_cmdline_option(argc, argv, "-l")) { + i.port = 7681; + i.address = "localhost"; + i.ssl_connection |= LCCSCF_ALLOW_SELFSIGNED; + } else { + i.port = 443; + i.address = "warmcat.com"; + } + + if (lws_cmdline_option(argc, argv, "--h1")) + i.alpn = "http/1.1"; - i.port = 443; - i.address = "warmcat.com"; i.path = "/"; i.host = i.address; i.origin = i.address; - i.ssl_connection = /* LCCSCF_NOT_H2 | */ LCCSCF_USE_SSL; i.method = "GET"; i.protocol = protocols[0].name; @@ -161,7 +167,7 @@ int main(int argc, char **argv) n = lws_service(context, 1000); lws_context_destroy(context); - lwsl_user("Completed\n"); + lwsl_user("Completed: %s\n", bad ? "failed" : "OK"); - return 0; + return bad; } diff --git a/minimal-examples/http-client/minimal-http-client/selftest.sh b/minimal-examples/http-client/minimal-http-client/selftest.sh new file mode 100755 index 00000000..9be3a8a7 --- /dev/null +++ b/minimal-examples/http-client/minimal-http-client/selftest.sh @@ -0,0 +1,23 @@ +#!/bin/bash +# +# $1: path to minimal example binaries... +# if lws is built with -DLWS_WITH_MINIMAL_EXAMPLES=1 +# that will be ./bin from your build dir +# +# $2: path for logs and results. The results will go +# in a subdir named after the directory this script +# is in + +if [ -z "$1" -o -z "$2" ] ; then + echo "required args missing" + exit 1 +fi + +MYTEST=`echo $0 | sed "s/\/[^\/]*\$//g" |sed "s/.*\///g"` +mkdir -p $2/$MYTEST +rm -f $2/$MYTEST/*.log $2/$MYTEST/*.result +$1/lws-$MYTEST > $2/$MYTEST/1.log 2> $2/$MYTEST/1.log +echo $? > $2/$MYTEST/1.result + +exit 0 + diff --git a/minimal-examples/http-server/minimal-http-server-dynamic/minimal-http-server-dynamic.c b/minimal-examples/http-server/minimal-http-server-dynamic/minimal-http-server-dynamic.c index 088fab83..2b7fa4cc 100644 --- a/minimal-examples/http-server/minimal-http-server-dynamic/minimal-http-server-dynamic.c +++ b/minimal-examples/http-server/minimal-http-server-dynamic/minimal-http-server-dynamic.c @@ -151,29 +151,32 @@ void sigint_handler(int sig) interrupted = 1; } -int main(int argc, char **argv) +int main(int argc, const char **argv) { struct lws_context_creation_info info; struct lws_context *context; - int n = 0; - - signal(SIGINT, sigint_handler); - - memset(&info, 0, sizeof info); /* otherwise uninitialized garbage */ - info.port = 7681; - info.protocols = protocols; - info.mounts = &mount; - - lws_set_log_level(LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE + const char *p; + int n = 0, logs = LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE /* for LLL_ verbosity above NOTICE to be built into lws, * lws must have been configured and built with * -DCMAKE_BUILD_TYPE=DEBUG instead of =RELEASE */ /* | LLL_INFO */ /* | LLL_PARSER */ /* | LLL_HEADER */ /* | LLL_EXT */ /* | LLL_CLIENT */ /* | LLL_LATENCY */ - /* | LLL_DEBUG */, NULL); + /* | LLL_DEBUG */; + signal(SIGINT, sigint_handler); + + if ((p = lws_cmdline_option(argc, argv, "-d"))) + logs = atoi(p); + + lws_set_log_level(logs, NULL); lwsl_user("LWS minimal http server dynamic | visit http://localhost:7681\n"); + memset(&info, 0, sizeof info); /* otherwise uninitialized garbage */ + info.port = 7681; + info.protocols = protocols; + info.mounts = &mount; + context = lws_create_context(&info); if (!context) { lwsl_err("lws init failed\n"); diff --git a/minimal-examples/http-server/minimal-http-server-form-get/minimal-http-server-form-get.c b/minimal-examples/http-server/minimal-http-server-form-get/minimal-http-server-form-get.c index 64cb1aac..4a5a4a40 100644 --- a/minimal-examples/http-server/minimal-http-server-form-get/minimal-http-server-form-get.c +++ b/minimal-examples/http-server/minimal-http-server-form-get/minimal-http-server-form-get.c @@ -115,29 +115,32 @@ void sigint_handler(int sig) interrupted = 1; } -int main(int argc, char **argv) +int main(int argc, const char **argv) { struct lws_context_creation_info info; struct lws_context *context; - int n = 0; - - signal(SIGINT, sigint_handler); - - memset(&info, 0, sizeof info); /* otherwise uninitialized garbage */ - info.port = 7681; - info.protocols = protocols; - info.mounts = &mount; - - lws_set_log_level(LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE + const char *p; + int n = 0, logs = LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE /* for LLL_ verbosity above NOTICE to be built into lws, * lws must have been configured and built with * -DCMAKE_BUILD_TYPE=DEBUG instead of =RELEASE */ /* | LLL_INFO */ /* | LLL_PARSER */ /* | LLL_HEADER */ /* | LLL_EXT */ /* | LLL_CLIENT */ /* | LLL_LATENCY */ - /* | LLL_DEBUG */, NULL); + /* | LLL_DEBUG */; + signal(SIGINT, sigint_handler); + + if ((p = lws_cmdline_option(argc, argv, "-d"))) + logs = atoi(p); + + lws_set_log_level(logs, NULL); lwsl_user("LWS minimal http server GET | visit http://localhost:7681\n"); + memset(&info, 0, sizeof info); /* otherwise uninitialized garbage */ + info.port = 7681; + info.protocols = protocols; + info.mounts = &mount; + context = lws_create_context(&info); if (!context) { lwsl_err("lws init failed\n"); diff --git a/minimal-examples/http-server/minimal-http-server-form-post-file/minimal-http-server-form-post-file.c b/minimal-examples/http-server/minimal-http-server-form-post-file/minimal-http-server-form-post-file.c index d335af7f..e974821b 100644 --- a/minimal-examples/http-server/minimal-http-server-form-post-file/minimal-http-server-form-post-file.c +++ b/minimal-examples/http-server/minimal-http-server-form-post-file/minimal-http-server-form-post-file.c @@ -225,29 +225,32 @@ void sigint_handler(int sig) interrupted = 1; } -int main(int argc, char **argv) +int main(int argc, const char **argv) { struct lws_context_creation_info info; struct lws_context *context; - int n = 0; - - signal(SIGINT, sigint_handler); - - memset(&info, 0, sizeof info); /* otherwise uninitialized garbage */ - info.port = 7681; - info.protocols = protocols; - info.mounts = &mount; - - lws_set_log_level(LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE + const char *p; + int n = 0, logs = LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE /* for LLL_ verbosity above NOTICE to be built into lws, * lws must have been configured and built with * -DCMAKE_BUILD_TYPE=DEBUG instead of =RELEASE */ /* | LLL_INFO */ /* | LLL_PARSER */ /* | LLL_HEADER */ /* | LLL_EXT */ /* | LLL_CLIENT */ /* | LLL_LATENCY */ - /* | LLL_DEBUG */, NULL); + /* | LLL_DEBUG */; + signal(SIGINT, sigint_handler); + + if ((p = lws_cmdline_option(argc, argv, "-d"))) + logs = atoi(p); + + lws_set_log_level(logs, NULL); lwsl_user("LWS minimal http server POST file | visit http://localhost:7681\n"); + memset(&info, 0, sizeof info); /* otherwise uninitialized garbage */ + info.port = 7681; + info.protocols = protocols; + info.mounts = &mount; + context = lws_create_context(&info); if (!context) { lwsl_err("lws init failed\n"); diff --git a/minimal-examples/http-server/minimal-http-server-form-post/minimal-http-server-form-post.c b/minimal-examples/http-server/minimal-http-server-form-post/minimal-http-server-form-post.c index ea5760e7..10c73e90 100644 --- a/minimal-examples/http-server/minimal-http-server-form-post/minimal-http-server-form-post.c +++ b/minimal-examples/http-server/minimal-http-server-form-post/minimal-http-server-form-post.c @@ -169,29 +169,32 @@ void sigint_handler(int sig) interrupted = 1; } -int main(int argc, char **argv) +int main(int argc, const char **argv) { struct lws_context_creation_info info; struct lws_context *context; - int n = 0; - - signal(SIGINT, sigint_handler); - - memset(&info, 0, sizeof info); /* otherwise uninitialized garbage */ - info.port = 7681; - info.protocols = protocols; - info.mounts = &mount; - - lws_set_log_level(LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE + const char *p; + int n = 0, logs = LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE /* for LLL_ verbosity above NOTICE to be built into lws, * lws must have been configured and built with * -DCMAKE_BUILD_TYPE=DEBUG instead of =RELEASE */ /* | LLL_INFO */ /* | LLL_PARSER */ /* | LLL_HEADER */ /* | LLL_EXT */ /* | LLL_CLIENT */ /* | LLL_LATENCY */ - /* | LLL_DEBUG */, NULL); + /* | LLL_DEBUG */; + signal(SIGINT, sigint_handler); + + if ((p = lws_cmdline_option(argc, argv, "-d"))) + logs = atoi(p); + + lws_set_log_level(logs, NULL); lwsl_user("LWS minimal http server POST | visit http://localhost:7681\n"); + memset(&info, 0, sizeof info); /* otherwise uninitialized garbage */ + info.port = 7681; + info.protocols = protocols; + info.mounts = &mount; + context = lws_create_context(&info); if (!context) { lwsl_err("lws init failed\n"); diff --git a/minimal-examples/http-server/minimal-http-server-libuv-foreign/minimal-http-server-libuv-foreign.c b/minimal-examples/http-server/minimal-http-server-libuv-foreign/minimal-http-server-libuv-foreign.c index 3da9d0cb..b27763b5 100644 --- a/minimal-examples/http-server/minimal-http-server-libuv-foreign/minimal-http-server-libuv-foreign.c +++ b/minimal-examples/http-server/minimal-http-server-libuv-foreign/minimal-http-server-libuv-foreign.c @@ -75,11 +75,26 @@ static void lws_uv_walk_cb(uv_handle_t *handle, void *arg) uv_close(handle, lws_uv_close_cb); } -int main(int argc, char **argv) +int main(int argc, const char **argv) { struct lws_context_creation_info info; uv_timer_t timer_outer; uv_loop_t loop; + const char *p; + int logs = LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE + /* for LLL_ verbosity above NOTICE to be built into lws, + * lws must have been configured and built with + * -DCMAKE_BUILD_TYPE=DEBUG instead of =RELEASE */ + /* | LLL_INFO */ /* | LLL_PARSER */ /* | LLL_HEADER */ + /* | LLL_EXT */ /* | LLL_CLIENT */ /* | LLL_LATENCY */ + /* | LLL_DEBUG */; + + if ((p = lws_cmdline_option(argc, argv, "-d"))) + logs = atoi(p); + + lws_set_log_level(logs, NULL); + lwsl_user("LWS minimal http server libuv + foreign loop |" + " visit http://localhost:7681\n"); memset(&info, 0, sizeof info); /* otherwise uninitialized garbage */ info.port = 7681; @@ -87,17 +102,6 @@ int main(int argc, char **argv) info.error_document_404 = "/404.html"; info.options = LWS_SERVER_OPTION_LIBUV; - lws_set_log_level(LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE - /* for LLL_ verbosity above NOTICE to be built into lws, - * lws must have been configured and built with - * -DCMAKE_BUILD_TYPE=DEBUG instead of =RELEASE */ - /* | LLL_INFO */ /* | LLL_PARSER */ /* | LLL_HEADER */ - /* | LLL_EXT */ /* | LLL_CLIENT */ /* | LLL_LATENCY */ - /* | LLL_DEBUG */, NULL); - - lwsl_user("LWS minimal http server libuv + foreign loop |" - " visit http://localhost:7681\n"); - uv_loop_init(&loop); uv_timer_init(&loop, &timer_outer); diff --git a/minimal-examples/http-server/minimal-http-server-libuv/minimal-http-server.c b/minimal-examples/http-server/minimal-http-server-libuv/minimal-http-server.c index 81a2d1f1..f93e651a 100644 --- a/minimal-examples/http-server/minimal-http-server-libuv/minimal-http-server.c +++ b/minimal-examples/http-server/minimal-http-server-libuv/minimal-http-server.c @@ -55,9 +55,23 @@ void signal_cb(uv_signal_t *watcher, int signum) lws_libuv_stop(context); } -int main(int argc, char **argv) +int main(int argc, const char **argv) { struct lws_context_creation_info info; + const char *p; + int logs = LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE + /* for LLL_ verbosity above NOTICE to be built into lws, + * lws must have been configured and built with + * -DCMAKE_BUILD_TYPE=DEBUG instead of =RELEASE */ + /* | LLL_INFO */ /* | LLL_PARSER */ /* | LLL_HEADER */ + /* | LLL_EXT */ /* | LLL_CLIENT */ /* | LLL_LATENCY */ + /* | LLL_DEBUG */; + + if ((p = lws_cmdline_option(argc, argv, "-d"))) + logs = atoi(p); + + lws_set_log_level(logs, NULL); + lwsl_user("LWS minimal http server libuv | visit http://localhost:7681\n"); memset(&info, 0, sizeof info); /* otherwise uninitialized garbage */ info.port = 7681; @@ -65,16 +79,6 @@ int main(int argc, char **argv) info.error_document_404 = "/404.html"; info.options = LWS_SERVER_OPTION_LIBUV; - lws_set_log_level(LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE - /* for LLL_ verbosity above NOTICE to be built into lws, - * lws must have been configured and built with - * -DCMAKE_BUILD_TYPE=DEBUG instead of =RELEASE */ - /* | LLL_INFO */ /* | LLL_PARSER */ /* | LLL_HEADER */ - /* | LLL_EXT */ /* | LLL_CLIENT */ /* | LLL_LATENCY */ - /* | LLL_DEBUG */, NULL); - - lwsl_user("LWS minimal http server libuv | visit http://localhost:7681\n"); - context = lws_create_context(&info); if (!context) { lwsl_err("lws init failed\n"); diff --git a/minimal-examples/http-server/minimal-http-server-multivhost/minimal-http-server.c b/minimal-examples/http-server/minimal-http-server-multivhost/minimal-http-server.c index 3507ede7..57e07541 100644 --- a/minimal-examples/http-server/minimal-http-server-multivhost/minimal-http-server.c +++ b/minimal-examples/http-server/minimal-http-server-multivhost/minimal-http-server.c @@ -80,27 +80,30 @@ void sigint_handler(int sig) interrupted = 1; } -int main(int argc, char **argv) +int main(int argc, const char **argv) { struct lws_context_creation_info info; struct lws_context *context; - int n = 0; - - signal(SIGINT, sigint_handler); - - memset(&info, 0, sizeof info); /* otherwise uninitialized garbage */ - info.options = LWS_SERVER_OPTION_EXPLICIT_VHOSTS; - - lws_set_log_level(LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE + const char *p; + int n = 0, logs = LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE /* for LLL_ verbosity above NOTICE to be built into lws, * lws must have been configured and built with * -DCMAKE_BUILD_TYPE=DEBUG instead of =RELEASE */ /* | LLL_INFO */ /* | LLL_PARSER */ /* | LLL_HEADER */ /* | LLL_EXT */ /* | LLL_CLIENT */ /* | LLL_LATENCY */ - /* | LLL_DEBUG */, NULL); + /* | LLL_DEBUG */; + if ((p = lws_cmdline_option(argc, argv, "-d"))) + logs = atoi(p); + + lws_set_log_level(logs, NULL); lwsl_user("LWS minimal http server-multivhost | visit http://localhost:7681 / 7682\n"); + signal(SIGINT, sigint_handler); + + memset(&info, 0, sizeof info); /* otherwise uninitialized garbage */ + info.options = LWS_SERVER_OPTION_EXPLICIT_VHOSTS; + /* * Because of LWS_SERVER_OPTION_EXPLICIT_VHOSTS, this only creates * the context and no longer creates a default vhost diff --git a/minimal-examples/http-server/minimal-http-server-smp/minimal-http-server-smp.c b/minimal-examples/http-server/minimal-http-server-smp/minimal-http-server-smp.c index d38c5d48..fcd008b5 100644 --- a/minimal-examples/http-server/minimal-http-server-smp/minimal-http-server-smp.c +++ b/minimal-examples/http-server/minimal-http-server-smp/minimal-http-server-smp.c @@ -64,12 +64,25 @@ void sigint_handler(int sig) lws_cancel_service(context); } -int main(int argc, char **argv) +int main(int argc, const char **argv) { pthread_t pthread_service[COUNT_THREADS]; struct lws_context_creation_info info; void *retval; - int n = 0; + const char *p; + int n = 0, logs = LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE + /* for LLL_ verbosity above NOTICE to be built into lws, + * lws must have been configured and built with + * -DCMAKE_BUILD_TYPE=DEBUG instead of =RELEASE */ + /* | LLL_INFO */ /* | LLL_PARSER */ /* | LLL_HEADER */ + /* | LLL_EXT */ /* | LLL_CLIENT */ /* | LLL_LATENCY */ + /* | LLL_DEBUG */; + + if ((p = lws_cmdline_option(argc, argv, "-d"))) + logs = atoi(p); + + lws_set_log_level(logs, NULL); + lwsl_user("LWS minimal http server SMP | visit http://127.0.0.1:7681\n"); signal(SIGINT, sigint_handler); @@ -79,16 +92,6 @@ int main(int argc, char **argv) // info.max_http_header_pool = 10; info.count_threads = COUNT_THREADS; - lws_set_log_level(LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE - /* for LLL_ verbosity above NOTICE to be built into lws, - * lws must have been configured and built with - * -DCMAKE_BUILD_TYPE=DEBUG instead of =RELEASE */ - /* | LLL_INFO */ /* | LLL_PARSER */ /* | LLL_HEADER */ - /* | LLL_EXT */ /* | LLL_CLIENT */ /* | LLL_LATENCY */ - /* | LLL_DEBUG */, NULL); - - lwsl_user("LWS minimal http server SMP | visit http://127.0.0.1:7681\n"); - context = lws_create_context(&info); if (!context) { lwsl_err("lws init failed\n"); diff --git a/minimal-examples/http-server/minimal-http-server-tls/minimal-http-server-tls.c b/minimal-examples/http-server/minimal-http-server-tls/minimal-http-server-tls.c index 96dc19c7..7af4db8c 100644 --- a/minimal-examples/http-server/minimal-http-server-tls/minimal-http-server-tls.c +++ b/minimal-examples/http-server/minimal-http-server-tls/minimal-http-server-tls.c @@ -47,11 +47,24 @@ void sigint_handler(int sig) interrupted = 1; } -int main(int argc, char **argv) +int main(int argc, const char **argv) { struct lws_context_creation_info info; struct lws_context *context; - int n = 0; + const char *p; + int n = 0, logs = LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE + /* for LLL_ verbosity above NOTICE to be built into lws, + * lws must have been configured and built with + * -DCMAKE_BUILD_TYPE=DEBUG instead of =RELEASE */ + /* | LLL_INFO */ /* | LLL_PARSER */ /* | LLL_HEADER */ + /* | LLL_EXT */ /* | LLL_CLIENT */ /* | LLL_LATENCY */ + /* | LLL_DEBUG */; + + if ((p = lws_cmdline_option(argc, argv, "-d"))) + logs = atoi(p); + + lws_set_log_level(logs, NULL); + lwsl_user("LWS minimal http server TLS | visit https://localhost:7681\n"); signal(SIGINT, sigint_handler); @@ -64,16 +77,6 @@ int main(int argc, char **argv) info.ssl_cert_filepath = "localhost-100y.cert"; info.ssl_private_key_filepath = "localhost-100y.key"; - lws_set_log_level(LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE - /* for LLL_ verbosity above NOTICE to be built into lws, - * lws must have been configured and built with - * -DCMAKE_BUILD_TYPE=DEBUG instead of =RELEASE */ - /* | LLL_INFO */ /* | LLL_PARSER */ /* | LLL_HEADER */ - /* | LLL_EXT */ /* | LLL_CLIENT */ /* | LLL_LATENCY */ - /* | LLL_DEBUG */, NULL); - - lwsl_user("LWS minimal http server TLS | visit https://localhost:7681\n"); - context = lws_create_context(&info); if (!context) { lwsl_err("lws init failed\n"); diff --git a/minimal-examples/http-server/minimal-http-server/minimal-http-server.c b/minimal-examples/http-server/minimal-http-server/minimal-http-server.c index 5ad28fd5..20b59e8b 100644 --- a/minimal-examples/http-server/minimal-http-server/minimal-http-server.c +++ b/minimal-examples/http-server/minimal-http-server/minimal-http-server.c @@ -22,7 +22,7 @@ static int interrupted; static const struct lws_http_mount mount = { /* .mount_next */ NULL, /* linked-list "next" */ /* .mountpoint */ "/", /* mountpoint URL */ - /* .origin */ "./mount-origin", /* serve from dir */ + /* .origin */ "./mount-origin", /* serve from dir */ /* .def */ "index.html", /* default filename */ /* .protocol */ NULL, /* .cgienv */ NULL, @@ -44,29 +44,32 @@ void sigint_handler(int sig) interrupted = 1; } -int main(int argc, char **argv) +int main(int argc, const char **argv) { struct lws_context_creation_info info; struct lws_context *context; - int n = 0; - - signal(SIGINT, sigint_handler); - - memset(&info, 0, sizeof info); /* otherwise uninitialized garbage */ - info.port = 7681; - info.mounts = &mount; - info.error_document_404 = "/404.html"; - - lws_set_log_level(LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE + const char *p; + int n = 0, logs = LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE /* for LLL_ verbosity above NOTICE to be built into lws, * lws must have been configured and built with * -DCMAKE_BUILD_TYPE=DEBUG instead of =RELEASE */ /* | LLL_INFO */ /* | LLL_PARSER */ /* | LLL_HEADER */ /* | LLL_EXT */ /* | LLL_CLIENT */ /* | LLL_LATENCY */ - /* | LLL_INFO */ /* | LLL_DEBUG */, NULL); + /* | LLL_DEBUG */; + signal(SIGINT, sigint_handler); + + if ((p = lws_cmdline_option(argc, argv, "-d"))) + logs = atoi(p); + + lws_set_log_level(logs, NULL); lwsl_user("LWS minimal http server | visit http://localhost:7681\n"); + memset(&info, 0, sizeof info); /* otherwise uninitialized garbage */ + info.port = 7681; + info.mounts = &mount; + info.error_document_404 = "/404.html"; + context = lws_create_context(&info); if (!context) { lwsl_err("lws init failed\n"); diff --git a/minimal-examples/raw/minimal-raw-adopt-tcp/minimal-raw-adopt-tcp.c b/minimal-examples/raw/minimal-raw-adopt-tcp/minimal-raw-adopt-tcp.c index b975662a..6344fd6d 100644 --- a/minimal-examples/raw/minimal-raw-adopt-tcp/minimal-raw-adopt-tcp.c +++ b/minimal-examples/raw/minimal-raw-adopt-tcp/minimal-raw-adopt-tcp.c @@ -83,28 +83,33 @@ void sigint_handler(int sig) interrupted = 1; } -int main(int argc, char **argv) +int main(int argc, const char **argv) { struct lws_context_creation_info info; struct lws_context *context; lws_sock_file_fd_type sock; struct addrinfo h, *r, *rp; struct lws_vhost *vhost; - int n = 0; - - lws_set_log_level(LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE + const char *p; + int n = 0, logs = LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE /* for LLL_ verbosity above NOTICE to be built into lws, * lws must have been configured and built with * -DCMAKE_BUILD_TYPE=DEBUG instead of =RELEASE */ /* | LLL_INFO */ /* | LLL_PARSER */ /* | LLL_HEADER */ /* | LLL_EXT */ /* | LLL_CLIENT */ /* | LLL_LATENCY */ - /* | LLL_DEBUG */, NULL); + /* | LLL_DEBUG */; + + signal(SIGINT, sigint_handler); + + if ((p = lws_cmdline_option(argc, argv, "-d"))) + logs = atoi(p); + + lws_set_log_level(logs, NULL); + lwsl_user("LWS minimal raw adopt tcp\n"); memset(&info, 0, sizeof info); /* otherwise uninitialized garbage */ info.options = LWS_SERVER_OPTION_EXPLICIT_VHOSTS; - lwsl_user("LWS minimal raw adopt tcp\n"); - context = lws_create_context(&info); if (!context) { lwsl_err("lws init failed\n"); diff --git a/minimal-examples/raw/minimal-raw-adopt-udp/minimal-raw-adopt-udp.c b/minimal-examples/raw/minimal-raw-adopt-udp/minimal-raw-adopt-udp.c index d67d8da8..23a9c5a6 100644 --- a/minimal-examples/raw/minimal-raw-adopt-udp/minimal-raw-adopt-udp.c +++ b/minimal-examples/raw/minimal-raw-adopt-udp/minimal-raw-adopt-udp.c @@ -120,28 +120,31 @@ void sigint_handler(int sig) interrupted = 1; } -int main(int argc, char **argv) +int main(int argc, const char **argv) { struct lws_context_creation_info info; struct lws_context *context; struct lws_vhost *vhost; - int n = 0; - - lws_set_log_level(LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE + const char *p; + int n = 0, logs = LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE /* for LLL_ verbosity above NOTICE to be built into lws, * lws must have been configured and built with * -DCMAKE_BUILD_TYPE=DEBUG instead of =RELEASE */ /* | LLL_INFO */ /* | LLL_PARSER */ /* | LLL_HEADER */ /* | LLL_EXT */ /* | LLL_CLIENT */ /* | LLL_LATENCY */ - /* | LLL_DEBUG */, NULL); + /* | LLL_DEBUG */; + + signal(SIGINT, sigint_handler); + + if ((p = lws_cmdline_option(argc, argv, "-d"))) + logs = atoi(p); + + lws_set_log_level(logs, NULL); + lwsl_user("LWS minimal raw adopt udp | nc -u 127.0.0.1 7681\n"); memset(&info, 0, sizeof info); /* otherwise uninitialized garbage */ info.options = LWS_SERVER_OPTION_EXPLICIT_VHOSTS; - lwsl_user("LWS minimal raw adopt udp | nc -u 127.0.0.1 7681\n"); - - signal(SIGINT, sigint_handler); - context = lws_create_context(&info); if (!context) { lwsl_err("lws init failed\n"); diff --git a/minimal-examples/raw/minimal-raw-file/minimal-raw-file.c b/minimal-examples/raw/minimal-raw-file/minimal-raw-file.c index 98199572..74b0c422 100644 --- a/minimal-examples/raw/minimal-raw-file/minimal-raw-file.c +++ b/minimal-examples/raw/minimal-raw-file/minimal-raw-file.c @@ -106,26 +106,25 @@ void sigint_handler(int sig) interrupted = 1; } -int main(int argc, char **argv) +int main(int argc, const char **argv) { struct lws_context_creation_info info; struct lws_context *context; - int n = 0; - - signal(SIGINT, sigint_handler); - - memset(&info, 0, sizeof info); /* otherwise uninitialized garbage */ - info.port = CONTEXT_PORT_NO_LISTEN_SERVER; /* no listen socket for demo */ - info.protocols = protocols; - - lws_set_log_level(LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE + const char *p; + int n = 0, logs = LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE /* for LLL_ verbosity above NOTICE to be built into lws, * lws must have been configured and built with * -DCMAKE_BUILD_TYPE=DEBUG instead of =RELEASE */ /* | LLL_INFO */ /* | LLL_PARSER */ /* | LLL_HEADER */ /* | LLL_EXT */ /* | LLL_CLIENT */ /* | LLL_LATENCY */ - /* | LLL_DEBUG */, NULL); + /* | LLL_DEBUG */; + signal(SIGINT, sigint_handler); + + if ((p = lws_cmdline_option(argc, argv, "-d"))) + logs = atoi(p); + + lws_set_log_level(logs, NULL); lwsl_user("LWS minimal raw file\n"); if (argc < 2) { lwsl_user("Usage: %s " @@ -135,6 +134,12 @@ int main(int argc, char **argv) return 1; } + signal(SIGINT, sigint_handler); + + memset(&info, 0, sizeof info); /* otherwise uninitialized garbage */ + info.port = CONTEXT_PORT_NO_LISTEN_SERVER; /* no listen socket for demo */ + info.protocols = protocols; + lws_strncpy(filepath, argv[1], sizeof(filepath)); context = lws_create_context(&info); diff --git a/minimal-examples/raw/minimal-raw-vhost/minimal-raw-vhost.c b/minimal-examples/raw/minimal-raw-vhost/minimal-raw-vhost.c index 7989c2c4..05043d08 100644 --- a/minimal-examples/raw/minimal-raw-vhost/minimal-raw-vhost.c +++ b/minimal-examples/raw/minimal-raw-vhost/minimal-raw-vhost.c @@ -110,29 +110,32 @@ void sigint_handler(int sig) interrupted = 1; } -int main(int argc, char **argv) +int main(int argc, const char **argv) { struct lws_context_creation_info info; struct lws_context *context; - int n = 0; - - signal(SIGINT, sigint_handler); - - memset(&info, 0, sizeof info); /* otherwise uninitialized garbage */ - info.port = 7681; - info.protocols = protocols; - info.options = LWS_SERVER_OPTION_ONLY_RAW; /* vhost accepts RAW */ - - lws_set_log_level(LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE + const char *p; + int n = 0, logs = LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE /* for LLL_ verbosity above NOTICE to be built into lws, * lws must have been configured and built with * -DCMAKE_BUILD_TYPE=DEBUG instead of =RELEASE */ /* | LLL_INFO */ /* | LLL_PARSER */ /* | LLL_HEADER */ /* | LLL_EXT */ /* | LLL_CLIENT */ /* | LLL_LATENCY */ - /* | LLL_DEBUG */, NULL); + /* | LLL_DEBUG */; + signal(SIGINT, sigint_handler); + + if ((p = lws_cmdline_option(argc, argv, "-d"))) + logs = atoi(p); + + lws_set_log_level(logs, NULL); lwsl_user("LWS minimal raw vhost | nc localhost 7681\n"); + memset(&info, 0, sizeof info); /* otherwise uninitialized garbage */ + info.port = 7681; + info.protocols = protocols; + info.options = LWS_SERVER_OPTION_ONLY_RAW; /* vhost accepts RAW */ + context = lws_create_context(&info); if (!context) { lwsl_err("lws init failed\n"); diff --git a/minimal-examples/ws-client/minimal-ws-client-pmd-bulk/minimal-ws-client-pmd-bulk.c b/minimal-examples/ws-client/minimal-ws-client-pmd-bulk/minimal-ws-client-pmd-bulk.c index 2f3c331c..fd49dc62 100644 --- a/minimal-examples/ws-client/minimal-ws-client-pmd-bulk/minimal-ws-client-pmd-bulk.c +++ b/minimal-examples/ws-client/minimal-ws-client-pmd-bulk/minimal-ws-client-pmd-bulk.c @@ -72,46 +72,40 @@ void sigint_handler(int sig) interrupted = 1; } -static int findswitch(int argc, char **argv, const char *val) -{ - while (--argc > 0) { - if (!strcmp(argv[argc], val)) - return argc; - } - - return 0; -} - -int main(int argc, char **argv) +int main(int argc, const char **argv) { struct lws_context_creation_info info; struct lws_context *context; - int n = 0; - - signal(SIGINT, sigint_handler); - - memset(&info, 0, sizeof info); /* otherwise uninitialized garbage */ - info.port = CONTEXT_PORT_NO_LISTEN; - info.protocols = protocols; - info.pvo = &pvo; - if (!findswitch(argc, argv, "-n")) - info.extensions = extensions; - info.pt_serv_buf_size = 32 * 1024; - - if (!findswitch(argc, argv, "-c")) - options |= 1; - - lws_set_log_level(LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE + const char *p; + int n = 0, logs = LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE /* for LLL_ verbosity above NOTICE to be built into lws, * lws must have been configured and built with * -DCMAKE_BUILD_TYPE=DEBUG instead of =RELEASE */ /* | LLL_INFO */ /* | LLL_PARSER */ /* | LLL_HEADER */ /* | LLL_EXT */ /* | LLL_CLIENT */ /* | LLL_LATENCY */ - /* | LLL_DEBUG */, NULL); + /* | LLL_DEBUG */; + signal(SIGINT, sigint_handler); + + if ((p = lws_cmdline_option(argc, argv, "-d"))) + logs = atoi(p); + + lws_set_log_level(logs, NULL); lwsl_user("LWS minimal ws client + permessage-deflate + multifragment bulk message\n"); lwsl_user(" needs minimal-ws-server-pmd-bulk running to communicate with\n"); lwsl_user(" %s [-n (no exts)] [-c (compressible)]\n", argv[0]); + + memset(&info, 0, sizeof info); /* otherwise uninitialized garbage */ + info.port = CONTEXT_PORT_NO_LISTEN; + info.protocols = protocols; + info.pvo = &pvo; + if (!lws_cmdline_option(argc, argv, "-n")) + info.extensions = extensions; + info.pt_serv_buf_size = 32 * 1024; + + if (!lws_cmdline_option(argc, argv, "-c")) + options |= 1; + context = lws_create_context(&info); if (!context) { lwsl_err("lws init failed\n"); diff --git a/minimal-examples/ws-client/minimal-ws-client-tx/minimal-ws-client.c b/minimal-examples/ws-client/minimal-ws-client-tx/minimal-ws-client.c index 98a16bee..9d2a0138 100644 --- a/minimal-examples/ws-client/minimal-ws-client-tx/minimal-ws-client.c +++ b/minimal-examples/ws-client/minimal-ws-client-tx/minimal-ws-client.c @@ -286,22 +286,25 @@ sigint_handler(int sig) interrupted = 1; } -int main(int argc, char **argv) +int main(int argc, const char **argv) { struct lws_context_creation_info info; struct lws_context *context; - int n = 0; - - signal(SIGINT, sigint_handler); - - lws_set_log_level(LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE + const char *p; + int n = 0, logs = LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE /* for LLL_ verbosity above NOTICE to be built into lws, * lws must have been configured and built with * -DCMAKE_BUILD_TYPE=DEBUG instead of =RELEASE */ /* | LLL_INFO */ /* | LLL_PARSER */ /* | LLL_HEADER */ /* | LLL_EXT */ /* | LLL_CLIENT */ /* | LLL_LATENCY */ - /* | LLL_DEBUG */, NULL); + /* | LLL_DEBUG */; + signal(SIGINT, sigint_handler); + + if ((p = lws_cmdline_option(argc, argv, "-d"))) + logs = atoi(p); + + lws_set_log_level(logs, NULL); lwsl_user("LWS minimal ws client tx\n"); lwsl_user(" Run minimal-ws-broker and browse to that\n"); diff --git a/minimal-examples/ws-server/minimal-ws-broker/minimal-ws-broker.c b/minimal-examples/ws-server/minimal-ws-broker/minimal-ws-broker.c index 18ac0ba6..5e6de4a1 100644 --- a/minimal-examples/ws-server/minimal-ws-broker/minimal-ws-broker.c +++ b/minimal-examples/ws-server/minimal-ws-broker/minimal-ws-broker.c @@ -54,29 +54,32 @@ void sigint_handler(int sig) interrupted = 1; } -int main(int argc, char **argv) +int main(int argc, const char **argv) { struct lws_context_creation_info info; struct lws_context *context; - int n = 0; - - signal(SIGINT, sigint_handler); - - memset(&info, 0, sizeof info); /* otherwise uninitialized garbage */ - info.port = 7681; - info.mounts = &mount; - info.protocols = protocols; - - lws_set_log_level(LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE + const char *p; + int n = 0, logs = LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE /* for LLL_ verbosity above NOTICE to be built into lws, * lws must have been configured and built with * -DCMAKE_BUILD_TYPE=DEBUG instead of =RELEASE */ /* | LLL_INFO */ /* | LLL_PARSER */ /* | LLL_HEADER */ /* | LLL_EXT */ /* | LLL_CLIENT */ /* | LLL_LATENCY */ - /* | LLL_DEBUG */, NULL); + /* | LLL_DEBUG */; + signal(SIGINT, sigint_handler); + + if ((p = lws_cmdline_option(argc, argv, "-d"))) + logs = atoi(p); + + lws_set_log_level(logs, NULL); lwsl_user("LWS minimal ws broker | visit http://localhost:7681\n"); + memset(&info, 0, sizeof info); /* otherwise uninitialized garbage */ + info.port = 7681; + info.mounts = &mount; + info.protocols = protocols; + context = lws_create_context(&info); if (!context) { lwsl_err("lws init failed\n"); diff --git a/minimal-examples/ws-server/minimal-ws-server-pmd-bulk/minimal-ws-server-pmd-bulk.c b/minimal-examples/ws-server/minimal-ws-server-pmd-bulk/minimal-ws-server-pmd-bulk.c index 301ab8d1..daa6fc7e 100644 --- a/minimal-examples/ws-server/minimal-ws-server-pmd-bulk/minimal-ws-server-pmd-bulk.c +++ b/minimal-examples/ws-server/minimal-ws-server-pmd-bulk/minimal-ws-server-pmd-bulk.c @@ -87,48 +87,42 @@ void sigint_handler(int sig) interrupted = 1; } -static int findswitch(int argc, char **argv, const char *val) -{ - while (--argc > 0) { - if (!strcmp(argv[argc], val)) - return 1; - } - - return 0; -} - -int main(int argc, char **argv) +int main(int argc, const char **argv) { struct lws_context_creation_info info; struct lws_context *context; - int n = 0; + const char *p; + int n = 0, logs = LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE + /* for LLL_ verbosity above NOTICE to be built into lws, + * lws must have been configured and built with + * -DCMAKE_BUILD_TYPE=DEBUG instead of =RELEASE */ + /* | LLL_INFO */ /* | LLL_PARSER */ /* | LLL_HEADER */ + /* | LLL_EXT */ /* | LLL_CLIENT */ /* | LLL_LATENCY */ + /* | LLL_DEBUG */; signal(SIGINT, sigint_handler); + if ((p = lws_cmdline_option(argc, argv, "-d"))) + logs = atoi(p); + + lws_set_log_level(logs, NULL); + lwsl_user("LWS minimal ws server + permessage-deflate | visit http://localhost:7681\n"); + lwsl_user(" %s [-n (no exts)] [-c (compressible)]\n", argv[0]); + memset(&info, 0, sizeof info); /* otherwise uninitialized garbage */ info.port = 7681; info.mounts = &mount; info.protocols = protocols; info.pvo = &pvo; - if (!findswitch(argc, argv, "-n")) + if (!lws_cmdline_option(argc, argv, "-n")) info.extensions = extensions; - if (!findswitch(argc, argv, "-c")) + if (!lws_cmdline_option(argc, argv, "-c")) options |= 1; info.pt_serv_buf_size = 32 * 1024; - lws_set_log_level(LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE - /* for LLL_ verbosity above NOTICE to be built into lws, - * lws must have been configured and built with - * -DCMAKE_BUILD_TYPE=DEBUG instead of =RELEASE */ - /* | LLL_INFO */ /* | LLL_PARSER */ /* | LLL_HEADER */ - /* | LLL_EXT */ /* | LLL_CLIENT */ /* | LLL_LATENCY */ - /* | LLL_DEBUG */, NULL); - - lwsl_user("LWS minimal ws server + permessage-deflate | visit http://localhost:7681\n"); - lwsl_user(" %s [-n (no exts)] [-c (compressible)]\n", argv[0]); context = lws_create_context(&info); if (!context) { lwsl_err("lws init failed\n"); diff --git a/minimal-examples/ws-server/minimal-ws-server-pmd/minimal-ws-server-pmd.c b/minimal-examples/ws-server/minimal-ws-server-pmd/minimal-ws-server-pmd.c index a36343d1..25cded37 100644 --- a/minimal-examples/ws-server/minimal-ws-server-pmd/minimal-ws-server-pmd.c +++ b/minimal-examples/ws-server/minimal-ws-server-pmd/minimal-ws-server-pmd.c @@ -64,30 +64,33 @@ void sigint_handler(int sig) interrupted = 1; } -int main(int argc, char **argv) +int main(int argc, const char **argv) { struct lws_context_creation_info info; struct lws_context *context; - int n = 0; + const char *p; + int n = 0, logs = LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE + /* for LLL_ verbosity above NOTICE to be built into lws, + * lws must have been configured and built with + * -DCMAKE_BUILD_TYPE=DEBUG instead of =RELEASE */ + /* | LLL_INFO */ /* | LLL_PARSER */ /* | LLL_HEADER */ + /* | LLL_EXT */ /* | LLL_CLIENT */ /* | LLL_LATENCY */ + /* | LLL_DEBUG */; signal(SIGINT, sigint_handler); + if ((p = lws_cmdline_option(argc, argv, "-d"))) + logs = atoi(p); + + lws_set_log_level(logs, NULL); + lwsl_user("LWS minimal ws server + permessage-deflate | visit http://localhost:7681\n"); + memset(&info, 0, sizeof info); /* otherwise uninitialized garbage */ info.port = 7681; info.mounts = &mount; info.protocols = protocols; info.extensions = extensions; - lws_set_log_level(LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE - /* for LLL_ verbosity above NOTICE to be built into lws, - * lws must have been configured and built with - * -DCMAKE_BUILD_TYPE=DEBUG instead of =RELEASE */ - /* | LLL_INFO */ /* | LLL_PARSER */ /* | LLL_HEADER */ - /* | LLL_EXT */ /* | LLL_CLIENT */ /* | LLL_LATENCY */ - /* | LLL_DEBUG */, NULL); - - lwsl_user("LWS minimal ws server + permessage-deflate | visit http://localhost:7681\n"); - context = lws_create_context(&info); if (!context) { lwsl_err("lws init failed\n"); diff --git a/minimal-examples/ws-server/minimal-ws-server-ring/minimal-ws-server.c b/minimal-examples/ws-server/minimal-ws-server-ring/minimal-ws-server.c index 2762739b..1da75383 100644 --- a/minimal-examples/ws-server/minimal-ws-server-ring/minimal-ws-server.c +++ b/minimal-examples/ws-server/minimal-ws-server-ring/minimal-ws-server.c @@ -54,29 +54,32 @@ void sigint_handler(int sig) interrupted = 1; } -int main(int argc, char **argv) +int main(int argc, const char **argv) { struct lws_context_creation_info info; struct lws_context *context; - int n = 0; - - signal(SIGINT, sigint_handler); - - memset(&info, 0, sizeof info); /* otherwise uninitialized garbage */ - info.port = 7681; - info.mounts = &mount; - info.protocols = protocols; - - lws_set_log_level(LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE + const char *p; + int n = 0, logs = LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE /* for LLL_ verbosity above NOTICE to be built into lws, * lws must have been configured and built with * -DCMAKE_BUILD_TYPE=DEBUG instead of =RELEASE */ /* | LLL_INFO */ /* | LLL_PARSER */ /* | LLL_HEADER */ /* | LLL_EXT */ /* | LLL_CLIENT */ /* | LLL_LATENCY */ - /* | LLL_DEBUG */, NULL); + /* | LLL_DEBUG */; + signal(SIGINT, sigint_handler); + + if ((p = lws_cmdline_option(argc, argv, "-d"))) + logs = atoi(p); + + lws_set_log_level(logs, NULL); lwsl_user("LWS minimal ws server (lws_ring) | visit http://localhost:7681\n"); + memset(&info, 0, sizeof info); /* otherwise uninitialized garbage */ + info.port = 7681; + info.mounts = &mount; + info.protocols = protocols; + context = lws_create_context(&info); if (!context) { lwsl_err("lws init failed\n"); diff --git a/minimal-examples/ws-server/minimal-ws-server-threads/minimal-ws-server.c b/minimal-examples/ws-server/minimal-ws-server-threads/minimal-ws-server.c index 0da7e386..1632626a 100644 --- a/minimal-examples/ws-server/minimal-ws-server-threads/minimal-ws-server.c +++ b/minimal-examples/ws-server/minimal-ws-server-threads/minimal-ws-server.c @@ -82,29 +82,33 @@ void sigint_handler(int sig) interrupted = 1; } -int main(int argc, char **argv) +int main(int argc, const char **argv) { struct lws_context_creation_info info; struct lws_context *context; + const char *p; + int logs = LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE + /* for LLL_ verbosity above NOTICE to be built into lws, + * lws must have been configured and built with + * -DCMAKE_BUILD_TYPE=DEBUG instead of =RELEASE */ + /* | LLL_INFO */ /* | LLL_PARSER */ /* | LLL_HEADER */ + /* | LLL_EXT */ /* | LLL_CLIENT */ /* | LLL_LATENCY */ + /* | LLL_DEBUG */; signal(SIGINT, sigint_handler); + if ((p = lws_cmdline_option(argc, argv, "-d"))) + logs = atoi(p); + + lws_set_log_level(logs, NULL); + lwsl_user("LWS minimal ws server + threads | visit http://localhost:7681\n"); + memset(&info, 0, sizeof info); /* otherwise uninitialized garbage */ info.port = 7681; info.mounts = &mount; info.protocols = protocols; info.pvo = &pvo; /* per-vhost options */ - lws_set_log_level(LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE - /* for LLL_ verbosity above NOTICE to be built into lws, - * lws must have been configured and built with - * -DCMAKE_BUILD_TYPE=DEBUG instead of =RELEASE */ - /* | LLL_INFO */ /* | LLL_PARSER */ /* | LLL_HEADER */ - /* | LLL_EXT */ /* | LLL_CLIENT */ /* | LLL_LATENCY */ - /* | LLL_DEBUG */, NULL); - - lwsl_user("LWS minimal ws server + threads | visit http://localhost:7681\n"); - context = lws_create_context(&info); if (!context) { lwsl_err("lws init failed\n"); diff --git a/minimal-examples/ws-server/minimal-ws-server/minimal-ws-server.c b/minimal-examples/ws-server/minimal-ws-server/minimal-ws-server.c index d22a7d7c..8b67503d 100644 --- a/minimal-examples/ws-server/minimal-ws-server/minimal-ws-server.c +++ b/minimal-examples/ws-server/minimal-ws-server/minimal-ws-server.c @@ -54,29 +54,32 @@ void sigint_handler(int sig) interrupted = 1; } -int main(int argc, char **argv) +int main(int argc, const char **argv) { struct lws_context_creation_info info; struct lws_context *context; - int n = 0; - - signal(SIGINT, sigint_handler); - - memset(&info, 0, sizeof info); /* otherwise uninitialized garbage */ - info.port = 7681; - info.mounts = &mount; - info.protocols = protocols; - - lws_set_log_level(LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE + const char *p; + int n = 0, logs = LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE /* for LLL_ verbosity above NOTICE to be built into lws, * lws must have been configured and built with * -DCMAKE_BUILD_TYPE=DEBUG instead of =RELEASE */ /* | LLL_INFO */ /* | LLL_PARSER */ /* | LLL_HEADER */ /* | LLL_EXT */ /* | LLL_CLIENT */ /* | LLL_LATENCY */ - /* | LLL_DEBUG */, NULL); + /* | LLL_DEBUG */; + signal(SIGINT, sigint_handler); + + if ((p = lws_cmdline_option(argc, argv, "-d"))) + logs = atoi(p); + + lws_set_log_level(logs, NULL); lwsl_user("LWS minimal ws server | visit http://localhost:7681\n"); + memset(&info, 0, sizeof info); /* otherwise uninitialized garbage */ + info.port = 7681; + info.mounts = &mount; + info.protocols = protocols; + context = lws_create_context(&info); if (!context) { lwsl_err("lws init failed\n");