/* the Music Player Daemon (MPD) * (c)2003-2004 by Warren Dukes (shank@mercury.chem.pitt.edu) * This project's homepage is: http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "conf.h" #include "log.h" #include "utils.h" #include "buffer2array.h" #include "audio.h" #include "volume.h" #include #include #include #include #include #include #include #define MAX_STRING_SIZE MAXPATHLEN+80 #define CONF_COMMENT '#' #define CONF_NUMBER_OF_PARAMS 35 #define CONF_NUMBER_OF_PATHS 6 #define CONF_NUMBER_OF_REQUIRED 5 #define CONF_NUMBER_OF_ALLOW_CATS 1 #define CONF_CONNECTION_TIMEOUT_DEFAULT "60" #define CONF_MAX_CONNECTIONS_DEFAULT "5" #define CONF_MAX_PLAYLIST_LENGTH_DEFAULT "16384" #define CONF_BUFFER_BEFORE_PLAY_DEFAULT "25%" #define CONF_MAX_COMMAND_LIST_SIZE_DEFAULT "2048" #define CONF_MAX_OUTPUT_BUFFER_SIZE_DEFAULT "2048" #define CONF_AO_DRIVER_DEFAULT AUDIO_AO_DRIVER_DEFAULT #define CONF_AO_DRIVER_OPTIONS_DEFAULT "" #define CONF_SAVE_ABSOLUTE_PATHS_IN_PLAYLISTS_DEFAULT "no" #define CONF_BIND_TO_ADDRESS_DEFAULT "any" #define CONF_USER_DEFAULT "" #define CONF_LOG_LEVEL_DEFAULT "default" #define CONF_AUDIO_WRITE_SIZE_DEFAULT "1024" #define CONF_BUFFER_SIZE_DEFAULT "2048" #ifndef NO_OSS_MIXER #define CONF_MIXER_TYPE_DEFAULT VOLUME_MIXER_OSS #define CONF_MIXER_DEVICE_DEFAULT "" #else #ifdef HAVE_ALSA #define CONF_MIXER_TYPE_DEFAULT VOLUME_MIXER_ALSA #define CONF_MIXER_DEVICE_DEFAULT "" #else #define CONF_MIXER_TYPE_DEFAULT VOLUME_MIXER_SOFTWARE #define CONF_MIXER_DEVICE_DEFAULT "" #endif #endif static char * conf_params[CONF_NUMBER_OF_PARAMS]; void initConf() { int i; for(i=0;i=CONF_NUMBER_OF_PARAMS) { ERROR("unrecognized paramater in conf at line %i: %s\n",count,string); exit(EXIT_FAILURE); } if(conf_params[i]!=NULL) { if(allowCat[i]) { conf_params[i] = realloc(conf_params[i], strlen(conf_params[i])+ strlen(CONF_CAT_CHAR)+ strlen(array[1])+1); strcat(conf_params[i],CONF_CAT_CHAR); strcat(conf_params[i],array[1]); } else { free(conf_params[i]); conf_params[i] = strdup(array[1]); } } else conf_params[i] = strdup(array[1]); free(array[0]); free(array[1]); free(array); } fclose(fp); for(i=0;ipw_dir)+strlen( &(conf_params[conf_absolutePaths[i]][pos]))+1); strcpy(path,pwd->pw_dir); strcat(path,&(conf_params[conf_absolutePaths[i]][pos])); free(conf_params[conf_absolutePaths[i]]); conf_params[conf_absolutePaths[i]] = path; } } return conf_params; } char ** getConf() { return conf_params; }