X-Git-Url: http://git.code-monkey.de/?a=blobdiff_plain;f=src%2Fmain.c;h=b7e5b1d1596470818670403d562f167284ac60a9;hb=76f6cc6fd2eecb29f265226e43408a0d9ad41174;hp=fce997a77a471f4201d3706e107f0e51ac1fee58;hpb=c989e4519ccdb068d0897e6255b9f3306e385bac;p=umurmur.git diff --git a/src/main.c b/src/main.c index fce997a..b7e5b1d 100644 --- a/src/main.c +++ b/src/main.c @@ -217,13 +217,14 @@ void setscheduler() void printhelp() { printf("uMurmur version %s. Mumble protocol %d.%d.%d\n", UMURMUR_VERSION, PROTVER_MAJOR, PROTVER_MINOR, PROTVER_PATCH); - printf("Usage: umurmurd [-d] [-p ] [-c ] [-h]\n"); - printf(" -d - Do not daemonize\n"); - printf(" -p - Write PID to this file\n"); - printf(" -c - Specify configuration file\n"); + printf("Usage: umurmurd [-d] [-r] [-h] [-p ] [-t] [-c ] [-a ] [-b ]\n"); + printf(" -d - Do not daemonize - run in foreground.\n"); #ifdef _POSIX_PRIORITY_SCHEDULING printf(" -r - Run with realtime priority\n"); #endif + printf(" -p - Write PID to this file\n"); + printf(" -c - Specify configuration file (default %s)\n", DEFAULT_CONFIG); + printf(" -t - Test config. Error message to stderr + non-zero exit code on error\n"); printf(" -a
- Bind to IP address\n"); printf(" -b - Bind to port\n"); printf(" -h - Print this help\n"); @@ -234,7 +235,7 @@ int main(int argc, char **argv) { bool_t nodaemon = false; #ifdef _POSIX_PRIORITY_SCHEDULING - bool_t realtime = false; + bool_t realtime = false, testconfig = false; #endif char *conffile = NULL, *pidfile = NULL; int c; @@ -242,9 +243,9 @@ int main(int argc, char **argv) /* Arguments */ #ifdef _POSIX_PRIORITY_SCHEDULING - while ((c = getopt(argc, argv, "drp:c:a:b:h")) != EOF) { + while ((c = getopt(argc, argv, "drp:c:a:b:ht")) != EOF) { #else - while ((c = getopt(argc, argv, "dp:c:a:b:h")) != EOF) { + while ((c = getopt(argc, argv, "dp:c:a:b:ht")) != EOF) { #endif switch(c) { case 'c': @@ -265,6 +266,9 @@ int main(int argc, char **argv) case 'h': printhelp(); break; + case 't': + testconfig = true; + break; #ifdef _POSIX_PRIORITY_SCHEDULING case 'r': realtime = true; @@ -276,7 +280,14 @@ int main(int argc, char **argv) break; } } - + + if (testconfig) { + if (!Conf_ok(conffile)) + exit(1); + else + exit(0); + } + /* Initialize the config subsystem early; * switch_user() will need to read some config variables as well as logging. */