Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Geithner, Thomas
desk-control
Commits
541c8a79
Commit
541c8a79
authored
Oct 11, 2017
by
Geithner, Thomas
Browse files
added command line argument parsing and daemonize option
parent
12d3ff2a
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/desk-main.cpp
View file @
541c8a79
...
...
@@ -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
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment