Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
jami-daemon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
jami-daemon
Commits
1c9d7cab
Commit
1c9d7cab
authored
13 years ago
by
Tristan Matthews
Browse files
Options
Downloads
Patches
Plain Diff
* #9736: restored command line options to daemon
Also added -v/--version flag
parent
0d661418
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
daemon/configure.ac
+2
-1
2 additions, 1 deletion
daemon/configure.ac
daemon/src/dbus/dbusmanager.cpp
+2
-2
2 additions, 2 deletions
daemon/src/dbus/dbusmanager.cpp
daemon/src/main.cpp
+88
-39
88 additions, 39 deletions
daemon/src/main.cpp
with
92 additions
and
42 deletions
daemon/configure.ac
+
2
−
1
View file @
1c9d7cab
...
@@ -50,7 +50,8 @@ AC_FUNC_ALLOCA
...
@@ -50,7 +50,8 @@ AC_FUNC_ALLOCA
AC_HEADER_STDC
AC_HEADER_STDC
AC_CHECK_HEADERS([arpa/inet.h fcntl.h libintl.h limits.h malloc.h memory.h \
AC_CHECK_HEADERS([arpa/inet.h fcntl.h libintl.h limits.h malloc.h memory.h \
netdb.h netinet/in.h stdlib.h string.h strings.h \
netdb.h netinet/in.h stdlib.h string.h strings.h \
sys/ioctl.h sys/socket.h sys/time.h unistd.h utime.h ostream])
sys/ioctl.h sys/socket.h sys/time.h unistd.h utime.h \
ostream getopt.h])
dnl Check for typedefs, structures, and compiler characteristics
dnl Check for typedefs, structures, and compiler characteristics
AC_HEADER_STAT
AC_HEADER_STAT
...
...
This diff is collapsed.
Click to expand it.
daemon/src/dbus/dbusmanager.cpp
+
2
−
2
View file @
1c9d7cab
...
@@ -86,7 +86,7 @@ void DBusManager::exec()
...
@@ -86,7 +86,7 @@ void DBusManager::exec()
ERROR
(
"%s: %s, exiting
\n
"
,
err
.
name
(),
err
.
what
());
ERROR
(
"%s: %s, exiting
\n
"
,
err
.
name
(),
err
.
what
());
::
exit
(
EXIT_FAILURE
);
::
exit
(
EXIT_FAILURE
);
}
catch
(
const
std
::
exception
&
err
)
{
}
catch
(
const
std
::
exception
&
err
)
{
ERROR
(
"%s:
%s,
exiting
\n
"
,
err
.
what
());
ERROR
(
"%s: exiting
\n
"
,
err
.
what
());
::
exit
(
EXIT_FAILURE
);
::
exit
(
EXIT_FAILURE
);
}
}
}
}
...
@@ -100,7 +100,7 @@ DBusManager::exit()
...
@@ -100,7 +100,7 @@ DBusManager::exit()
ERROR
(
"%s: %s, exiting
\n
"
,
err
.
name
(),
err
.
what
());
ERROR
(
"%s: %s, exiting
\n
"
,
err
.
name
(),
err
.
what
());
::
exit
(
EXIT_FAILURE
);
::
exit
(
EXIT_FAILURE
);
}
catch
(
const
std
::
exception
&
err
)
{
}
catch
(
const
std
::
exception
&
err
)
{
ERROR
(
"%s:
%s,
exiting
\n
"
,
err
.
what
());
ERROR
(
"%s: exiting
\n
"
,
err
.
what
());
::
exit
(
EXIT_FAILURE
);
::
exit
(
EXIT_FAILURE
);
}
}
}
}
This diff is collapsed.
Click to expand it.
daemon/src/main.cpp
+
88
−
39
View file @
1c9d7cab
...
@@ -35,50 +35,98 @@
...
@@ -35,50 +35,98 @@
#endif
#endif
#include
<iostream>
#include
<iostream>
#include
<memory>
// for auto_ptr
#include
<getopt.h>
#include
<string>
// #include <commoncpp/common.h>
#include
"fileutils.h"
#include
"fileutils.h"
#include
"dbus/dbusmanager.h"
#include
"dbus/dbusmanager.h"
#include
"manager.h"
#include
"manager.h"
/*
ost::CommandOptionNoArg console(
"console", "c", "Log in console (instead of syslog)"
);
ost::CommandOptionNoArg debug(
namespace
{
"debug", "d", "Debug mode (more verbose)"
void
print_title
()
);
{
std
::
cout
<<
"SFLphone Daemon "
<<
VERSION
<<
", by Savoir-Faire Linux 2004-2012"
<<
std
::
endl
<<
"http://www.sflphone.org/"
<<
std
::
endl
;
}
ost::CommandOptionNoArg help(
void
print_usage
()
"help", "h", "Print help"
);
*/
int
main
(
int
/*argc*/
,
char
**
argv
)
{
{
fileutils
::
set_program_dir
(
argv
[
0
]);
std
::
cout
<<
std
::
endl
<<
// makeCommandOptionParse allocates the object with operator new, so
"-c, --console
\t
- Log in console (instead of syslog)"
<<
std
::
endl
<<
// auto_ptr is fine in this context.
"-d, --debug
\t
- Debug mode (more verbose)"
<<
std
::
endl
<<
// TODO: This should eventually be replaced with std::unique_ptr for C++0x
"-h, --help
\t
- Print help"
<<
std
::
endl
;
// std::auto_ptr<ost::CommandOptionParse> args(ost::makeCommandOptionParse(argc, argv, ""));
}
printf
(
"SFLphone Daemon "
VERSION
", by Savoir-Faire Linux 2004-2012
\n
"
\
// Parse command line arguments, setting debug options or printing a help
"http://www.sflphone.org/
\n
"
);
// message accordingly.
/*
// returns true if we should quit (i.e. help was printed), false otherwise
if (help.numSet) {
bool
parse_args
(
int
argc
,
char
*
argv
[])
std::cerr << args->printUsage();
{
return 0;
int
consoleFlag
=
false
;
} else if (args->argsHaveError()) {
int
debugFlag
=
false
;
std::cerr << args->printErrors();
int
helpFlag
=
false
;
std::cerr << args->printUsage();
int
versionFlag
=
false
;
return 1;
static
const
struct
option
long_options
[]
=
{
/* These options set a flag. */
{
"debug"
,
no_argument
,
NULL
,
'd'
},
{
"console"
,
no_argument
,
NULL
,
'c'
},
{
"help"
,
no_argument
,
NULL
,
'h'
},
{
"version"
,
no_argument
,
NULL
,
'v'
},
{
0
,
0
,
0
,
0
}
/* Sentinel */
};
while
(
true
)
{
/* getopt_long stores the option index here. */
int
option_index
=
0
;
int
c
=
getopt_long
(
argc
,
argv
,
"dchv"
,
long_options
,
&
option_index
);
/* Detect the end of the options. */
if
(
c
==
-
1
)
break
;
switch
(
c
)
{
case
'd'
:
debugFlag
=
true
;
break
;
case
'c'
:
consoleFlag
=
true
;
break
;
case
'h'
:
case
'?'
:
helpFlag
=
true
;
break
;
case
'v'
:
versionFlag
=
true
;
break
;
default:
break
;
}
}
*/
}
// Logger::setConsoleLog(console.numSet);
// Logger::setDebugMode(debug.numSet);
bool
quit
=
false
;
Logger
::
setConsoleLog
(
1
);
if
(
helpFlag
)
{
Logger
::
setDebugMode
(
1
);
print_usage
();
quit
=
true
;
}
else
if
(
versionFlag
)
{
// We've always print the title/version, so we can just exit
quit
=
true
;
}
else
{
Logger
::
setConsoleLog
(
consoleFlag
);
Logger
::
setDebugMode
(
debugFlag
);
}
return
quit
;
}
}
int
main
(
int
argc
,
char
*
argv
[])
{
fileutils
::
set_program_dir
(
argv
[
0
]);
print_title
();
if
(
parse_args
(
argc
,
argv
))
return
0
;
if
(
!
fileutils
::
create_pidfile
())
if
(
!
fileutils
::
create_pidfile
())
return
1
;
return
1
;
...
@@ -89,7 +137,8 @@ int main(int /*argc*/, char **argv)
...
@@ -89,7 +137,8 @@ int main(int /*argc*/, char **argv)
std
::
cerr
<<
e
.
what
()
<<
std
::
endl
;
std
::
cerr
<<
e
.
what
()
<<
std
::
endl
;
return
1
;
return
1
;
}
catch
(...)
{
}
catch
(...)
{
std
::
cerr
<<
"An exception occured when initializing the system."
<<
std
::
endl
;
std
::
cerr
<<
"An exception occured when initializing "
PACKAGE
<<
std
::
endl
;
return
1
;
return
1
;
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment