From 8faeeeebf08bd9fdef16c44da0b150c9285024f8 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Fri, 18 May 2012 13:47:37 +0200 Subject: Ugly hack to feed filename from cli. --- src/muniad.cc | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src/muniad.cc') diff --git a/src/muniad.cc b/src/muniad.cc index 741241a..b9651dd 100644 --- a/src/muniad.cc +++ b/src/muniad.cc @@ -38,6 +38,8 @@ #include "http.h" #include "munia_proto.h" #include "debug.h" +#include "taskmanager.h" +extern TaskManager task_manager; static struct libwebsocket_protocols protocols[] = { // first protocol must always be HTTP handler @@ -51,6 +53,7 @@ static struct libwebsocket_protocols protocols[] = { 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' }, @@ -60,6 +63,7 @@ static struct option options[] = { int main(int argc, char **argv) { + const char *db_filename = "/tmp/munia.xml"; int n = 0; const char *cert_path = LOCAL_RESOURCE_PATH"/libwebsockets-test-server.pem"; @@ -84,7 +88,7 @@ int main(int argc, char **argv) "There is NO WARRANTY, to the extent permitted by law.\n"); while(n >= 0) { - n = getopt_long(argc, argv, "ci:khsp:", options, NULL); + n = getopt_long(argc, argv, "ci:khsp:f:", options, NULL); if(n < 0) continue; switch(n) { case 's': @@ -98,19 +102,24 @@ int main(int argc, char **argv) case 'p': port = atoi(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; break; case 'h': - fprintf(stderr, "Usage: muniad [--port=

] [--ssl]\n"); + fprintf(stderr, "Usage: muniad [--port=

] [--ssl] [--file=]\n"); exit(1); } } debug_parse("+all"); + task_manager.init(db_filename); + if(!use_ssl) cert_path = key_path = NULL; context = libwebsocket_create_context(port, interface, protocols, -- cgit v1.2.3