aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.c
diff options
context:
space:
mode:
authorWarren Dukes <warren.dukes@gmail.com>2004-04-11 00:52:05 +0000
committerWarren Dukes <warren.dukes@gmail.com>2004-04-11 00:52:05 +0000
commit171a7752a8fab0e1c55be1469a331ef20a7b3755 (patch)
tree33a74b690d0567116d4ab8d681d6499a232ecb9c /src/main.c
parent8c4bc2d2d499951107572b10e5a99ab2913f3aea (diff)
downloadmpd-171a7752a8fab0e1c55be1469a331ef20a7b3755.tar.gz
mpd-171a7752a8fab0e1c55be1469a331ef20a7b3755.tar.xz
mpd-171a7752a8fab0e1c55be1469a331ef20a7b3755.zip
add --only-create-db option from msells
have SIGHUP cause rereading db file git-svn-id: https://svn.musicpd.org/mpd/trunk@663 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to '')
-rw-r--r--src/main.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/main.c b/src/main.c
index cac40b68f..0f706a426 100644
--- a/src/main.c
+++ b/src/main.c
@@ -58,6 +58,7 @@ typedef struct _Options {
char * dbFile;
int daemon;
int createDB;
+ int onlyCreateDB;
} Options;
void usage(char * argv[]) {
@@ -72,6 +73,7 @@ void usage(char * argv[]) {
ERROR(" --help this usage statement\n");
ERROR(" --no-daemon don't detach from console\n");
ERROR(" --create-db force (re)creation database\n");
+ ERROR(" --only-create-db create database and exit\n");
ERROR(" --no-create-db don't create database\n");
ERROR(" --verbose verbose logging\n");
ERROR(" --version prints version information\n");
@@ -91,6 +93,7 @@ void parseOptions(int argc, char ** argv, Options * options) {
options->usr = NULL;
options->daemon = 1;
options->createDB = 0;
+ options->onlyCreateDB = 0;
options->dbFile = NULL;
if(argc>1) {
@@ -109,6 +112,10 @@ void parseOptions(int argc, char ** argv, Options * options) {
options->createDB = 1;
argcLeft--;
}
+ else if(strcmp(argv[i],"--only-create-db")==0) {
+ options->onlyCreateDB = 1;
+ argcLeft--;
+ }
else if(strcmp(argv[i],"--no-create-db")==0) {
options->createDB = -1;
argcLeft--;
@@ -210,7 +217,7 @@ int main(int argc, char * argv[]) {
return EXIT_FAILURE;
}
- if((listenSocket = establish(port))<0) {
+ if(!options.onlyCreateDB && (listenSocket = establish(port))<0) {
ERROR("error binding port\n");
return EXIT_FAILURE;
}
@@ -340,7 +347,8 @@ int main(int argc, char * argv[]) {
strncpy(directorydb,options.dbFile,MAXPATHLEN);
directorydb[MAXPATHLEN] = '\0';
}
- if(options.createDB>0 || readDirectoryDB()<0) {
+ if(options.createDB>0 || options.onlyCreateDB || readDirectoryDB()<0)
+ {
if(options.createDB<0) {
ERROR("can't open db file and using \"--no-create-db\""
" command line option\n");
@@ -351,6 +359,7 @@ int main(int argc, char * argv[]) {
ERROR("problem opening db for reading or writing\n");
exit(EXIT_FAILURE);
}
+ if(options.onlyCreateDB) exit(EXIT_SUCCESS);
}
initCommands();