From 1ae51ff94d0f1f27a4e4cc657371578db13c3ca1 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Fri, 8 Feb 2019 20:26:14 +0100 Subject: Make code compile again (fix bitrot dating back from 2013). --- src/muniad.cc | 138 +++++++++++++++++++++++++++++++--------------------------- 1 file changed, 75 insertions(+), 63 deletions(-) (limited to 'src/muniad.cc') diff --git a/src/muniad.cc b/src/muniad.cc index b478484..b5685c2 100644 --- a/src/muniad.cc +++ b/src/muniad.cc @@ -40,71 +40,76 @@ #include "hugin.hpp" #include "taskmanager.h" -static struct libwebsocket_protocols protocols[] = { +static struct lws_protocols protocols[] = +{ // first protocol must always be HTTP handler { "http-only", callback_http, 0 }, - { "lws-task-protocol", callback_lws_task, - sizeof(struct per_session_data__lws_task) - }, - { NULL, NULL, 0 } // End of list + { "lws-task-protocol", callback_lws_task, sizeof(struct per_session_data__lws_task) }, + { nullptr, nullptr, 0 } // End of list }; static struct option options[] = { - { "help", no_argument, NULL, 'h' }, - { "port", required_argument, NULL, 'p' }, - { "file", required_argument, NULL, 'f' }, - { "ssl", no_argument, NULL, 's' }, - { "killmask", no_argument, NULL, 'k' }, - { "interface", required_argument, NULL, 'i' }, -// { "dumpfile", required_argument, NULL, 'd'}, - { NULL, 0, 0, 0 } + { "help", no_argument, nullptr, 'h' }, + { "port", required_argument, nullptr, 'p' }, + { "file", required_argument, nullptr, 'f' }, + { "ssl", no_argument, nullptr, 's' }, + { "killmask", no_argument, nullptr, 'k' }, + { "interface", required_argument, nullptr, 'i' }, +// { "dumpfile", required_argument, nullptr, 'd'}, + { nullptr, 0, 0, 0 } }; int main(int argc, char **argv) { - const char *db_filename = "/tmp/munia.xml"; + const char *db_filename = "/tmp/munia.xml"; int n = 0; const char *cert_path = - LOCAL_RESOURCE_PATH"/libwebsockets-test-server.pem"; + LOCAL_RESOURCE_PATH"/libwebsockets-test-server.pem"; const char *key_path = - LOCAL_RESOURCE_PATH"/libwebsockets-test-server.key.pem"; + LOCAL_RESOURCE_PATH"/libwebsockets-test-server.key.pem"; int port = 7681; int use_ssl = 0; - struct libwebsocket_context *context; + struct lws_context *context; int opts = 0; char interface_name[128] = ""; - const char * interface = NULL; + const char * interface = nullptr; // std::string dumpfile; fprintf(stderr, "Munia test server\n" - "(C) Copyright 2012 Bent Bisballe Nyeng (deva@aasimon.org)\n" - " & Jonas Suhr Christensen (jsc@umbraculum.org)\n" - "License GPLv3+: GNU GPL version 3 or later " - "\n" - "\n" - "This is free software; you are free to change and redistribute it.\n" - "There is NO WARRANTY, to the extent permitted by law.\n"); - - while(n >= 0) { - n = getopt_long(argc, argv, "ci:khsp:f:", options, NULL); - if(n < 0) continue; - switch(n) { + "(C) Copyright 2012-2019 Bent Bisballe Nyeng (deva@aasimon.org)\n" + " & Jonas Suhr Christensen (jsc@umbraculum.org)\n" + "License GPLv3+: GNU GPL version 3 or later " + "\n" + "\n" + "This is free software; you are free to change and redistribute it.\n" + "There is NO WARRANTY, to the extent permitted by law.\n"); + + while(n >= 0) + { + n = getopt_long(argc, argv, "ci:khsp:f:", options, nullptr); + if(n < 0) + { + continue; + } + + switch(n) + { case 's': use_ssl = 1; break; -// case 'd': -// dumpfile = optarg; +// case 'd': +// dumpfile = optarg; case 'k': //opts = LWS_SERVER_OPTION_DEFEAT_CLIENT_MASK; break; case 'p': port = atoi(optarg); break; - case 'f': - db_filename = strdup(optarg); - break; - case 'i': + case 'f': + db_filename = strdup(optarg); + break; + case 'i': strncpy(interface_name, optarg, sizeof interface_name); interface_name[(sizeof interface_name) - 1] = '\0'; interface = interface_name; @@ -115,44 +120,51 @@ int main(int argc, char **argv) } } - //_parse("+all"); + //_parse("+all"); - task_manager.init(db_filename); + task_manager.init(db_filename); - if(!use_ssl) cert_path = key_path = NULL; + if(!use_ssl) + { + cert_path = key_path = nullptr; + } - struct lws_context_creation_info info; - memset(&info, 0, sizeof info); - info.port = port; - info.iface = interface; - info.protocols = protocols; - info.extensions = libwebsocket_get_internal_extensions(); + struct lws_context_creation_info info{}; + info.port = port; + info.iface = interface; + info.protocols = protocols; + //info.extensions = lws_get_internal_extensions(); // DEPRECATED - if (!use_ssl) { - info.ssl_cert_filepath = cert_path; - info.ssl_private_key_filepath = NULL; - } else { - info.ssl_cert_filepath = - LOCAL_RESOURCE_PATH"/libwebsockets-test-server.pem"; - info.ssl_private_key_filepath = - LOCAL_RESOURCE_PATH"/libwebsockets-test-server.key.pem"; - } + if(!use_ssl) + { + info.ssl_cert_filepath = cert_path; + info.ssl_private_key_filepath = nullptr; + } + else + { + info.ssl_cert_filepath = + LOCAL_RESOURCE_PATH"/libwebsockets-test-server.pem"; + info.ssl_private_key_filepath = + LOCAL_RESOURCE_PATH"/libwebsockets-test-server.key.pem"; + } - info.gid = -1; - info.uid = -1; - info.options = opts; + info.gid = -1; + info.uid = -1; + info.options = opts; - context = libwebsocket_create_context(&info); - if (context == NULL) { + context = lws_create_context(&info); + if(context == nullptr) + { fprintf(stderr, "libwebsocket init failed\n"); return -1; } - while (1) { - libwebsocket_service(context, 50); - } + while(1) + { + lws_service(context, 50); + } - libwebsocket_context_destroy(context); + lws_context_destroy(context); return 0; } -- cgit v1.2.3