Commit 541c8a79 authored by Geithner, Thomas's avatar Geithner, Thomas
Browse files

added command line argument parsing and daemonize option

parent 12d3ff2a
......@@ -12,23 +12,72 @@
#include <iostream>
#include <cstdint>
#include <getopt.h>
using namespace std;
using namespace desk;
void print_help(void){
}
int main(int argc, char** argv){
char c;
uint16_t coap_port;
int opt_idx;
bool daemonize(false);
string config_file("/etc/desk.conf");
static struct option l_opts[] = {
{"config", 1, 0, 'c'},
{"daemon", 0, 0, 'd'},
{"help", 0, 0, 'h'},
{0, 0, 0, 0}
};
while(true){
c = getopt_long(argc, argv, "c:dh", l_opts, &opt_idx);
Config conf("/etc/desk.conf");
if(c == -1){
break;
}
switch(c){
case 'c':
// config
config_file = optarg;
break;
case 'd':
daemonize=true;
// daemon
break;
case 'h':
// help
cout << "\t-c / --config <config_file> : config file" << endl;
cout << "\t-d / --daemon : daemonize" << endl;
cout << "\t-h / --help : print help" << endl;
return 0;
break;
}
}
Config conf(config_file);
LinakDesk desk(conf);
CmdFrontend cf(desk);
if(!daemonize){
CmdFrontend cf(desk);
}
coap_port = conf.get("coap_port", 5678);
CoapFrontend cof(desk, coap_port);
desk.doDeskControl();
if(daemonize){
daemon(0, 0);
}
return 0;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment