diff options
author | Warren Dukes <warren.dukes@gmail.com> | 2004-10-28 05:14:55 +0000 |
---|---|---|
committer | Warren Dukes <warren.dukes@gmail.com> | 2004-10-28 05:14:55 +0000 |
commit | 58dbe4bb5d974c34335d6906a9ce930f07cd1db4 (patch) | |
tree | 9a6aee08b21100cb74e809f0620d81466f6067df /src/main.c | |
parent | 8f40569aeeafe4a36e3d719c1df97de42606ea76 (diff) | |
download | mpd-58dbe4bb5d974c34335d6906a9ce930f07cd1db4.tar.gz mpd-58dbe4bb5d974c34335d6906a9ce930f07cd1db4.tar.xz mpd-58dbe4bb5d974c34335d6906a9ce930f07cd1db4.zip |
merge shank-rewrite-config changes
git-svn-id: https://svn.musicpd.org/mpd/trunk@2375 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/src/main.c b/src/main.c index ddde281a7..f56d74939 100644 --- a/src/main.c +++ b/src/main.c @@ -165,9 +165,12 @@ void parseOptions(int argc, char ** argv, Options * options) { return; } else if(argcLeft<=2) { - char ** conf = NULL; - if(argcLeft==2) conf = readConf(argv[argc-1]); - if(argcLeft==1) { + int conf = 0; + if(argcLeft==2) { + readConf(argv[argc-1]); + conf = 1; + } + else if(argcLeft==1) { FILE * fp; char * homedir = getenv("HOME"); char userfile[MAXPATHLEN+1] = ""; @@ -179,23 +182,27 @@ void parseOptions(int argc, char ** argv, Options * options) { } if(strlen(userfile) && (fp=fopen(userfile,"r"))) { fclose(fp); - conf = readConf(userfile); + readConf(userfile); + conf = 1; } else if((fp=fopen(SYSTEM_CONFIG_FILE_LOCATION,"r"))) { fclose(fp); - conf = readConf(SYSTEM_CONFIG_FILE_LOCATION); + readConf(SYSTEM_CONFIG_FILE_LOCATION); + conf = 1; } } if(conf) { - options->portStr = conf[CONF_PORT]; - options->musicDirArg = conf[CONF_MUSIC_DIRECTORY]; - options->playlistDirArg = conf[CONF_PLAYLIST_DIRECTORY]; - options->logFile = conf[CONF_LOG_FILE]; - options->errorFile = conf[CONF_ERROR_FILE]; - options->usr = conf[CONF_USER]; - if(conf[CONF_DB_FILE]) { - options->dbFile = conf[CONF_DB_FILE]; - } + options->portStr = forceAndGetConfigParamValue( + CONF_PORT); + options->musicDirArg = + parseConfigFilePath(CONF_MUSIC_DIR, 1); + options->playlistDirArg = + parseConfigFilePath(CONF_PLAYLIST_DIR, 1); + options->logFile = parseConfigFilePath(CONF_LOG_FILE,1); + options->errorFile = + parseConfigFilePath(CONF_ERROR_FILE, 1); + options->usr = parseConfigFilePath(CONF_USER, 0); + options->dbFile = parseConfigFilePath(CONF_DB_FILE, 0); return; } } |