mirror of
https://github.com/owntone/owntone-server.git
synced 2025-01-27 06:33:21 -05:00
Cleanup options and add long options
This commit is contained in:
parent
6e64e54429
commit
f39c48b989
80
src/main.c
80
src/main.c
@ -250,35 +250,65 @@ int
|
|||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int option;
|
int option;
|
||||||
char *configfile = CONFFILE;
|
char *configfile;
|
||||||
int reload = 0;
|
|
||||||
int background;
|
int background;
|
||||||
int force_non_root = 0;
|
int mdns_no_rsp;
|
||||||
int skip_initial = 1;
|
int mdns_no_daap;
|
||||||
|
int loglevel;
|
||||||
|
char *logdomains;
|
||||||
|
char *logfile;
|
||||||
cfg_t *lib;
|
cfg_t *lib;
|
||||||
char *runas, *tmp;
|
char *runas, *tmp;
|
||||||
int port;
|
int port;
|
||||||
char *servername;
|
char *servername;
|
||||||
char *ffid = NULL;
|
char *ffid;
|
||||||
char *perr = NULL;
|
char *perr;
|
||||||
char *txtrecord[10];
|
char *txtrecord[10];
|
||||||
char *pidfile = PIDFILE;
|
char *pidfile;
|
||||||
sigset_t sigs;
|
sigset_t sigs;
|
||||||
int sigfd;
|
int sigfd;
|
||||||
struct event sig_event;
|
struct event sig_event;
|
||||||
int ret;
|
int ret;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
int loglevel = -1;
|
struct option option_map[] =
|
||||||
char *logdomains = NULL;
|
{
|
||||||
char *logfile = NULL;
|
{ "ffid", 1, NULL, 'b' },
|
||||||
|
{ "debug", 1, NULL, 'd' },
|
||||||
|
{ "logdomains", 1, NULL, 'D' },
|
||||||
|
{ "foreground", 0, NULL, 'f' },
|
||||||
|
{ "config", 1, NULL, 'c' },
|
||||||
|
{ "pidfile", 1, NULL, 'P' },
|
||||||
|
{ "version", 0, NULL, 'v' },
|
||||||
|
|
||||||
|
{ "mdns-no-rsp", 0, NULL, 512 },
|
||||||
|
{ "mdns-no-daap", 0, NULL, 513 },
|
||||||
|
|
||||||
|
{ NULL, 0, NULL, 0 }
|
||||||
|
};
|
||||||
|
|
||||||
|
configfile = CONFFILE;
|
||||||
|
pidfile = PIDFILE;
|
||||||
|
loglevel = -1;
|
||||||
|
logdomains = NULL;
|
||||||
|
logfile = NULL;
|
||||||
background = 1;
|
background = 1;
|
||||||
|
ffid = NULL;
|
||||||
|
mdns_no_rsp = 0;
|
||||||
|
mdns_no_daap = 0;
|
||||||
|
|
||||||
while ((option = getopt(argc, argv, "D:d:c:P:frysiub:v")) != -1)
|
while ((option = getopt_long(argc, argv, "D:d:c:P:fb:v", option_map, NULL)) != -1)
|
||||||
{
|
{
|
||||||
switch (option)
|
switch (option)
|
||||||
{
|
{
|
||||||
|
case 512:
|
||||||
|
mdns_no_rsp = 1;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 513:
|
||||||
|
mdns_no_daap = 1;
|
||||||
|
break;
|
||||||
|
|
||||||
case 'b':
|
case 'b':
|
||||||
ffid = optarg;
|
ffid = optarg;
|
||||||
break;
|
break;
|
||||||
@ -307,18 +337,6 @@ main(int argc, char **argv)
|
|||||||
pidfile = optarg;
|
pidfile = optarg;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'r':
|
|
||||||
reload = 1;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 's':
|
|
||||||
skip_initial = 0;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'y':
|
|
||||||
force_non_root = 1;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'v':
|
case 'v':
|
||||||
fprintf(stdout, "Firefly Media Server: Version %s\n",VERSION);
|
fprintf(stdout, "Firefly Media Server: Version %s\n",VERSION);
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
@ -331,14 +349,6 @@ main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((getuid() != 0) && (!force_non_root))
|
|
||||||
{
|
|
||||||
fprintf(stderr, "You are not root. This is almost certainly wrong. "
|
|
||||||
"If you are\nsure you want to do this, use the -y "
|
|
||||||
"command-line switch\n");
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = logger_init(NULL, NULL, (loglevel < 0) ? E_LOG : loglevel);
|
ret = logger_init(NULL, NULL, (loglevel < 0) ? E_LOG : loglevel);
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
{
|
{
|
||||||
@ -440,7 +450,7 @@ main(int argc, char **argv)
|
|||||||
|
|
||||||
/* Initialize the database before starting */
|
/* Initialize the database before starting */
|
||||||
DPRINTF(E_INFO, L_MAIN, "Initializing database\n");
|
DPRINTF(E_INFO, L_MAIN, "Initializing database\n");
|
||||||
if (db_init(reload))
|
if (db_init(0))
|
||||||
{
|
{
|
||||||
DPRINTF(E_FATAL, L_MAIN, "Error in db_init: %s\n", strerror(errno));
|
DPRINTF(E_FATAL, L_MAIN, "Error in db_init: %s\n", strerror(errno));
|
||||||
}
|
}
|
||||||
@ -523,9 +533,11 @@ main(int argc, char **argv)
|
|||||||
/* Register web server service */
|
/* Register web server service */
|
||||||
mdns_register(servername, "_http._tcp", port, txtrecord);
|
mdns_register(servername, "_http._tcp", port, txtrecord);
|
||||||
/* Register RSP service */
|
/* Register RSP service */
|
||||||
mdns_register(servername, "_rsp._tcp", port, txtrecord);
|
if (!mdns_no_rsp)
|
||||||
|
mdns_register(servername, "_rsp._tcp", port, txtrecord);
|
||||||
/* Register DAAP service */
|
/* Register DAAP service */
|
||||||
mdns_register(servername, "_daap._tcp", port, txtrecord);
|
if (!mdns_no_daap)
|
||||||
|
mdns_register(servername, "_daap._tcp", port, txtrecord);
|
||||||
|
|
||||||
for (i = 0; i < (sizeof(txtrecord) / sizeof(*txtrecord) - 1); i++)
|
for (i = 0; i < (sizeof(txtrecord) / sizeof(*txtrecord) - 1); i++)
|
||||||
free(txtrecord[i]);
|
free(txtrecord[i]);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user