diff --git a/src/audio.c b/src/audio.c index 3e61a6548..c5f0fa9bc 100644 --- a/src/audio.c +++ b/src/audio.c @@ -49,7 +49,7 @@ void initAudioDriver() { if (*test!='\0') { ERROR("\"%s\" is not a valid write size", (getConf())[CONF_AUDIO_WRITE_SIZE]); - exit(-1); + exit(EXIT_FAILURE); } audio_ao_options = NULL; @@ -62,13 +62,13 @@ void initAudioDriver() { ao_driver_id((getConf())[CONF_AO_DRIVER]))<0) { ERROR("\"%s\" is not a valid ao driver\n", (getConf())[CONF_AO_DRIVER]); - exit(-1); + exit(EXIT_FAILURE); } if((ai = ao_driver_info(audio_ao_driver_id))==NULL) { ERROR("problems getting ao_driver_info\n"); ERROR("you may not have permission to the audio device\n"); - exit(-1); + exit(EXIT_FAILURE); } dup = strdup((getConf())[CONF_AO_DRIVER_OPTIONS]); @@ -81,7 +81,7 @@ void initAudioDriver() { if(!key) { ERROR("problems parsing " "ao_driver_options \"%s\"\n", n1); - exit(-1); + exit(EXIT_FAILURE); } /*found = 0; for(i=0;ioption_count;i++) { @@ -94,13 +94,13 @@ void initAudioDriver() { ERROR("\"%s\" is not an option for " "\"%s\" ao driver\n",key, ai->short_name); - exit(-1); + exit(EXIT_FAILURE); }*/ value = strtok_r(NULL,"",&stk2); if(!value) { ERROR("problems parsing " "ao_driver_options \"%s\"\n", n1); - exit(-1); + exit(EXIT_FAILURE); } ao_append_option(&audio_ao_options,key,value); n1 = strtok_r(NULL,";",&stk1); diff --git a/src/conf.c b/src/conf.c index ce7e8a123..c79156e4f 100644 --- a/src/conf.c +++ b/src/conf.c @@ -160,7 +160,7 @@ char ** readConf(char * file) { if(!(fp=fopen(file,"r"))) { ERROR("problems opening file %s for reading\n",file); - exit(-1); + exit(EXIT_FAILURE); } while(myFgets(string,sizeof(string),fp)) { @@ -169,13 +169,13 @@ char ** readConf(char * file) { if(numberOfArgs==0) continue; if(2!=numberOfArgs) { ERROR("improperly formated config line: %s\n",string); - exit(-1); + exit(EXIT_FAILURE); } i = 0; while(i=CONF_NUMBER_OF_PARAMS) { ERROR("unrecognized line in conf: %s\n",string); - exit(-1); + exit(EXIT_FAILURE); } if(conf_params[i]!=NULL) { if(allowCat[i]) { @@ -203,7 +203,7 @@ char ** readConf(char * file) { if(conf_params[conf_required[i]] == NULL) { ERROR("%s is unassigned in conf file\n", conf_strings[conf_required[i]]); - exit(-1); + exit(EXIT_FAILURE); } } @@ -214,7 +214,7 @@ char ** readConf(char * file) { { ERROR("\"%s\" is not an absolute path\n", conf_params[conf_absolutePaths[i]]); - exit(-1); + exit(EXIT_FAILURE); } /* Parse ~ in path */ else if(conf_params[conf_absolutePaths[i]] && @@ -230,7 +230,7 @@ char ** readConf(char * file) { if((pwd = getpwuid(uid)) == NULL) { ERROR("problems getting passwd entry " "for current user\n"); - exit(-1); + exit(EXIT_FAILURE); } } else { @@ -249,7 +249,7 @@ char ** readConf(char * file) { ERROR("user \"%s\" not found\n", &(conf_params[ conf_absolutePaths[i]][1])); - exit(-1); + exit(EXIT_FAILURE); } if(foundSlash) *ch = '/'; } diff --git a/src/decode.c b/src/decode.c index a849b738d..ae5e2fcb4 100644 --- a/src/decode.c +++ b/src/decode.c @@ -70,7 +70,7 @@ void decodeSigHandler(int sig) { int pid = *decode_pid; if(pid>0) kill(pid,SIGTERM); } - exit(0); + exit(EXIT_SUCCESS); } } @@ -275,7 +275,7 @@ int decoderInit(PlayerControl * pc, Buffer * cb, AudioFormat *af, else my_usleep(10000); } - exit(0); + exit(EXIT_SUCCESS); /* END OF CHILD */ } else if(pid<0) { diff --git a/src/directory.c b/src/directory.c index 2d672afce..3da1a0517 100644 --- a/src/directory.c +++ b/src/directory.c @@ -444,21 +444,21 @@ void readDirectoryInfo(FILE * fp,Directory * directory) { key = strdup(&(buffer[strlen(DIRECTORY_DIR)])); if(myFgets(buffer,bufferSize,fp)<0) { ERROR("Error reading db\n"); - exit(-1); + exit(EXIT_FAILURE); } if(strncmp(DIRECTORY_MTIME,buffer,strlen(DIRECTORY_MTIME))) { ERROR("Error reading db\n"); ERROR("%s\n",buffer); - exit(-1); + exit(EXIT_FAILURE); } mtime = atoi(&(buffer[strlen(DIRECTORY_BEGIN)])); if(myFgets(buffer,bufferSize,fp)<0) { ERROR("Error reading db\n"); - exit(-1); + exit(EXIT_FAILURE); } if(strncmp(DIRECTORY_BEGIN,buffer,strlen(DIRECTORY_BEGIN))) { ERROR("Error reading db\n"); - exit(-1); + exit(EXIT_FAILURE); } name = strdup(&(buffer[strlen(DIRECTORY_BEGIN)])); subDirectory = newDirectory(directory,name,mtime); @@ -472,7 +472,7 @@ void readDirectoryInfo(FILE * fp,Directory * directory) { } else { ERROR("Unknown line in db: %s\n",buffer); - exit(-1); + exit(EXIT_FAILURE); } } } @@ -529,7 +529,7 @@ int readDirectoryDB() { if(myFgets(buffer,bufferSize,fp)<0) { ERROR("Error reading db\n"); - exit(-1); + exit(EXIT_FAILURE); } if(0==strcmp(DIRECTORY_INFO_BEGIN,buffer)) { while(myFgets(buffer,bufferSize,fp) && @@ -541,7 +541,7 @@ int readDirectoryDB() { if(foundVersion) { ERROR("already found " "version in db\n"); - exit(-1); + exit(EXIT_FAILURE); } foundVersion = 1; } @@ -554,7 +554,7 @@ int readDirectoryDB() { if(foundFsCharset) { ERROR("already found " "fs charset in db\n"); - exit(-1); + exit(EXIT_FAILURE); } foundFsCharset = 1; @@ -577,7 +577,7 @@ int readDirectoryDB() { else { ERROR("directory: unknown line in db info: %s\n", buffer); - exit(-1); + exit(EXIT_FAILURE); } } } diff --git a/src/interface.c b/src/interface.c index 79445c380..0689e9319 100644 --- a/src/interface.c +++ b/src/interface.c @@ -418,25 +418,25 @@ void initInterfaces() { interface_timeout = strtol((getConf())[CONF_CONNECTION_TIMEOUT],&test,10); if(*test!='\0' || interface_timeout<=0) { ERROR("connection timeout \"%s\" is not a positive integer\n",(getConf())[CONF_CONNECTION_TIMEOUT]); - exit(-1); + exit(EXIT_FAILURE); } interface_max_connections = strtol((getConf())[CONF_MAX_CONNECTIONS],&test,10); if(*test!='\0' || interface_max_connections<=0) { ERROR("max connections \"%s\" is not a positive integer\n",(getConf())[CONF_MAX_CONNECTIONS]); - exit(-1); + exit(EXIT_FAILURE); } interface_max_command_list_size = strtoll((getConf())[CONF_MAX_COMMAND_LIST_SIZE],&test,10); if(*test!='\0' || interface_max_command_list_size<=0) { ERROR("max command list size \"%s\" is not a positive integer\n",(getConf())[CONF_MAX_COMMAND_LIST_SIZE]); - exit(-1); + exit(EXIT_FAILURE); } interface_max_output_buffer_size = strtoll((getConf())[CONF_MAX_OUTPUT_BUFFER_SIZE],&test,10); if(*test!='\0' || interface_max_output_buffer_size<=0) { ERROR("max output buffer size \"%s\" is not a positive integer\n",(getConf())[CONF_MAX_OUTPUT_BUFFER_SIZE]); - exit(-1); + exit(EXIT_FAILURE); } interface_max_command_list_size*=1024; diff --git a/src/listen.c b/src/listen.c index 374d547b8..5fd07a9b4 100644 --- a/src/listen.c +++ b/src/listen.c @@ -90,7 +90,7 @@ int establish(unsigned short port) { if(!(he = gethostbyname((getConf())[CONF_BIND_TO_ADDRESS]))) { ERROR("can't lookup host \"%s\"\n", (getConf())[CONF_BIND_TO_ADDRESS]); - exit(-1); + exit(EXIT_FAILURE); } switch(he->h_addrtype) { #ifdef HAVE_IPV6 @@ -99,7 +99,7 @@ int establish(unsigned short port) { ERROR("no IPv6 support, but a IPv6 address " "found for \"%s\"\n", (getConf())[CONF_BIND_TO_ADDRESS]); - exit(-1); + exit(EXIT_FAILURE); } bcopy((char *)he->h_addr,(char *) &sin6.sin6_addr.s6_addr,he->h_length); @@ -116,7 +116,7 @@ int establish(unsigned short port) { default: ERROR("address type for \"%s\" is not IPv4 or IPv6\n", (getConf())[CONF_BIND_TO_ADDRESS]); - exit(-1); + exit(EXIT_FAILURE); } } diff --git a/src/main.c b/src/main.c index ef6cf3a5e..cac40b68f 100644 --- a/src/main.c +++ b/src/main.c @@ -99,7 +99,7 @@ void parseOptions(int argc, char ** argv, Options * options) { if(strncmp(argv[i],"--",2)==0) { if(strcmp(argv[i],"--help")==0) { usage(argv); - exit(0); + exit(EXIT_SUCCESS); } else if(strcmp(argv[i],"--no-daemon")==0) { options->daemon = 0; @@ -119,11 +119,11 @@ void parseOptions(int argc, char ** argv, Options * options) { } else if(strcmp(argv[i],"--version")==0) { version(); - exit(0); + exit(EXIT_SUCCESS); } else { myfprintf(stderr,"unknown command line option: %s\n",argv[i]); - exit(-1); + exit(EXIT_FAILURE); } } else break; @@ -176,7 +176,7 @@ void parseOptions(int argc, char ** argv, Options * options) { } usage(argv); - exit(-1); + exit(EXIT_FAILURE); } int main(int argc, char * argv[]) { @@ -207,12 +207,12 @@ int main(int argc, char * argv[]) { if((port = atoi(options.portStr))<0) { ERROR("problem with port number\n"); - return -1; + return EXIT_FAILURE; } if((listenSocket = establish(port))<0) { ERROR("error binding port\n"); - return -1; + return EXIT_FAILURE; } /* @@ -229,7 +229,7 @@ int main(int argc, char * argv[]) { struct passwd * userpwd; if ((userpwd = getpwnam(options.usr)) == NULL) { ERROR("no such user: %s\n", options.usr); - return -1; + return EXIT_FAILURE; } uid = userpwd->pw_uid; gid = userpwd->pw_gid; @@ -237,7 +237,7 @@ int main(int argc, char * argv[]) { if(setgid(gid) == -1) { ERROR("cannot setgid of user %s: %s\n", options.usr, strerror(errno)); - return -1; + return EXIT_FAILURE; } #ifdef _BSD_SOURCE @@ -253,13 +253,13 @@ int main(int argc, char * argv[]) { ERROR("cannot get groups " "of user %s: %s\n", options.usr, strerror(errno)); - return -1; + return EXIT_FAILURE; } else if(setgroups(NGROUPS_MAX, gid_list) == -1) { ERROR("cannot set groups " "of user %s: %s\n", options.usr, strerror(errno)); - return -1; + return EXIT_FAILURE; } #endif @@ -268,7 +268,7 @@ int main(int argc, char * argv[]) { ERROR("cannot change to uid of user " "%s: %s\n", options.usr, strerror(errno)); - return -1; + return EXIT_FAILURE; } } @@ -276,13 +276,13 @@ int main(int argc, char * argv[]) { if(NULL==(out=fopen(options.logFile,"a"))) { ERROR("problem opening file \"%s\" for writing\n", options.logFile); - return -1; + return EXIT_FAILURE; } if(NULL==(err=fopen(options.errorFile,"a"))) { ERROR("problem opening file \"%s\" for writing\n", options.errorFile); - return -1; + return EXIT_FAILURE; } initPaths(); @@ -303,11 +303,11 @@ int main(int argc, char * argv[]) { } if((stat(playlistDir,&st))<0) { ERROR("problem stat'ing \"%s\"\n",options.playlistDirArg); - return -1; + return EXIT_FAILURE; } if(!S_ISDIR(st.st_mode)) { ERROR("\"%s\" is not a directory\n",options.playlistDirArg); - return -1; + return EXIT_FAILURE; } if(options.musicDirArg[0]=='/') { @@ -321,11 +321,11 @@ int main(int argc, char * argv[]) { if(musicDir[strlen(musicDir)-1]!='/') strcat(musicDir,"/"); if((stat(musicDir,&st))<0) { ERROR("problem stat'ing \"%s\"\n",options.musicDirArg); - return -1; + return EXIT_FAILURE; } if(!S_ISDIR(st.st_mode)) { ERROR("\"%s\" is not a directory\n",options.musicDirArg); - return -1; + return EXIT_FAILURE; } initTables(); @@ -344,12 +344,12 @@ int main(int argc, char * argv[]) { if(options.createDB<0) { ERROR("can't open db file and using \"--no-create-db\"" " command line option\n"); - exit(-1); + exit(EXIT_FAILURE); } initMp3Directory(); if(writeDirectoryDB()<0) { ERROR("problem opening db for reading or writing\n"); - exit(-1); + exit(EXIT_FAILURE); } } @@ -365,54 +365,54 @@ int main(int argc, char * argv[]) { fflush(NULL); pid = fork(); - if(pid>0) _exit(0); + if(pid>0) _exit(EXIT_SUCCESS); else if(pid<0) { ERROR("problems fork'ing for daemon!\n"); - exit(-1); + exit(EXIT_FAILURE); } if(chdir("/")<0) { ERROR("problems changing to root directory\n"); - exit(-1); + exit(EXIT_FAILURE); } if(setsid()<0) { ERROR("problems setsid'ing\n"); - exit(-1); + exit(EXIT_FAILURE); } if(close(STDOUT_FILENO)) { fprintf(err,"problems closing stdout : %s\n", strerror(errno)); - exit(-1); + exit(EXIT_FAILURE); } if(close(STDERR_FILENO)) { fprintf(err,"problems closing stderr : %s\n", strerror(errno)); - exit(-1); + exit(EXIT_FAILURE); } if(dup2(fileno(out),STDOUT_FILENO)<0) { fprintf(err,"problems dup2 stdout : %s\n", strerror(errno)); - exit(-1); + exit(EXIT_FAILURE); } if(dup2(fileno(err),STDERR_FILENO)<0) { fprintf(err,"problems dup2 stderr : %s\n", strerror(errno)); - exit(-1); + exit(EXIT_FAILURE); } myfprintfStdLogMode(out,err); fflush(NULL); pid = fork(); - if(pid>0) _exit(0); + if(pid>0) _exit(EXIT_SUCCESS); else if(pid<0) { ERROR("problems fork'ing for daemon!\n"); - exit(-1); + exit(EXIT_FAILURE); } } else { @@ -426,12 +426,12 @@ int main(int argc, char * argv[]) { if(fd<0) { ERROR("not able to open /dev/null to redirect stdin: " "%s\n",strerror(errno)); - exit(-1); + exit(EXIT_FAILURE); } if(dup2(fd,STDIN_FILENO)<0) { ERROR("problems dup2's stdin for redirection: " "%s\n",strerror(errno)); - exit(-1); + exit(EXIT_FAILURE); } } @@ -461,5 +461,5 @@ int main(int argc, char * argv[]) { finishPermissions(); finishCommands(); - return 0; + return EXIT_SUCCESS; } diff --git a/src/pcm_utils.c b/src/pcm_utils.c index 9cfb9efc3..3bb900508 100644 --- a/src/pcm_utils.c +++ b/src/pcm_utils.c @@ -80,7 +80,7 @@ void pcm_volumeChange(char * buffer, int bufferSize, AudioFormat * format, default: ERROR("%i bits not supported by pcm_volumeChange!\n", format->bits); - exit(-1); + exit(EXIT_FAILURE); } } @@ -120,7 +120,7 @@ void pcm_add(char * buffer1, char * buffer2, size_t bufferSize1, break; default: ERROR("%i bits not supported by pcm_add!\n",format->bits); - exit(-1); + exit(EXIT_FAILURE); } } diff --git a/src/permission.c b/src/permission.c index 36c9a39c1..da319325f 100644 --- a/src/permission.c +++ b/src/permission.c @@ -59,7 +59,7 @@ unsigned int parsePermissions(char * string) { } else { ERROR("uknown permission \"%s\"\n",temp); - exit(-1); + exit(EXIT_FAILURE); } temp = strtok_r(NULL,PERMISSION_SEPERATOR,&tok); @@ -99,12 +99,12 @@ void initPermissions() { ERROR("\"%s\" not found in password string \"%s\"\n", PERMISSION_PASSWORD_CHAR, nextSet); - exit(-1); + exit(EXIT_FAILURE); } if(!(temp = strtok_r(nextSet,PERMISSION_PASSWORD_CHAR,&cp2))) { ERROR("something weird just happend in permission.c\n"); - exit(-1); + exit(EXIT_FAILURE); } password = temp; diff --git a/src/player.c b/src/player.c index e0628de6c..e74abaa3d 100644 --- a/src/player.c +++ b/src/player.c @@ -137,7 +137,7 @@ int playerInit() { else my_usleep(10000); } - exit(0); + exit(EXIT_SUCCESS); } else if(player_pid<0) { ERROR("player Problems fork()'ing\n"); diff --git a/src/playerData.c b/src/playerData.c index 07b0dfb3c..f86a86cb9 100644 --- a/src/playerData.c +++ b/src/playerData.c @@ -45,7 +45,7 @@ void initPlayerData() { if(*test!='\0' || bufferSize<=0) { ERROR("buffer size \"%s\" is not a positive integer\n", getConf()[CONF_BUFFER_SIZE]); - exit(-1); + exit(EXIT_FAILURE); } bufferSize*=1024; @@ -53,7 +53,7 @@ void initPlayerData() { if(buffered_chunks >= 1<<15) { ERROR("buffer size \"%i\" is too big\n",bufferSize); - exit(-1); + exit(EXIT_FAILURE); } perc = strtod((getConf())[CONF_BUFFER_BEFORE_PLAY],&test); @@ -61,7 +61,7 @@ void initPlayerData() { ERROR("buffered before play \"%s\" is not a positive " "percentage and less than 100 percent\n", (getConf())[CONF_BUFFER_BEFORE_PLAY]); - exit(-1); + exit(EXIT_FAILURE); } buffered_before_play = (perc/100)*buffered_chunks; if(buffered_before_play>buffered_chunks) { @@ -77,15 +77,15 @@ void initPlayerData() { if((shmid = shmget(IPC_PRIVATE,allocationSize,IPC_CREAT|0600))<0) { ERROR("problems shmget'ing\n"); - exit(-1); + exit(EXIT_FAILURE); } if((playerData_pd = shmat(shmid,NULL,0))<0) { ERROR("problems shmat'ing\n"); - exit(-1); + exit(EXIT_FAILURE); } if (shmctl(shmid, IPC_RMID, 0)<0) { ERROR("problems shmctl'ing\n"); - exit(-1); + exit(EXIT_FAILURE); } buffer = &(playerData_pd->buffer); diff --git a/src/playlist.c b/src/playlist.c index 62482a9df..957a4a748 100644 --- a/src/playlist.c +++ b/src/playlist.c @@ -108,7 +108,7 @@ void initPlaylist() { if(*test!='\0') { ERROR("max playlist length \"%s\" is not an integer\n", (getConf())[CONF_MAX_PLAYLIST_LENGTH]); - exit(-1); + exit(EXIT_FAILURE); } if(strcmp("yes",(getConf())[CONF_SAVE_ABSOLUTE_PATHS_IN_PLAYLISTS]) @@ -123,7 +123,7 @@ void initPlaylist() { ERROR("save_absolute_paths_in_playlist \"%s\" is not yes or " "no\n", (getConf())[CONF_SAVE_ABSOLUTE_PATHS_IN_PLAYLISTS]); - exit(-1); + exit(EXIT_FAILURE); } playlist.songs = malloc(sizeof(Song *)*playlist_max_length); @@ -228,14 +228,14 @@ void loadPlaylistFromStateFile(FILE * fp, char * buffer, int state, int current, if(!myFgets(buffer,PLAYLIST_BUFFER_SIZE,fp)) { ERROR("error parsing state file \"%s\"\n",playlist_stateFile); - exit(-1); + exit(EXIT_FAILURE); } while(strcmp(buffer,PLAYLIST_STATE_FILE_PLAYLIST_END)) { song = atoi(strtok(buffer,":")); if(!(temp = strtok(NULL,""))) { ERROR("error parsing state file \"%s\"\n", playlist_stateFile); - exit(-1); + exit(EXIT_FAILURE); } if(addToPlaylist(stderr,temp)==0 && current==song) { if(state!=PLAYER_STATE_STOP) { @@ -252,7 +252,7 @@ void loadPlaylistFromStateFile(FILE * fp, char * buffer, int state, int current, if(!myFgets(buffer,PLAYLIST_BUFFER_SIZE,fp)) { ERROR("error parsing state file \"%s\"\n", playlist_stateFile); - exit(-1); + exit(EXIT_FAILURE); } } } @@ -270,14 +270,14 @@ void readPlaylistState() { if(!S_ISREG(st.st_mode)) { ERROR("state file \"%s\" is not a regular " "file\n",playlist_stateFile); - exit(-1); + exit(EXIT_FAILURE); } fp = fopen(playlist_stateFile,"r"); if(!fp) { ERROR("problems opening state file \"%s\" for " "reading\n",playlist_stateFile); - exit(-1); + exit(EXIT_FAILURE); } while(myFgets(buffer,PLAYLIST_BUFFER_SIZE,fp)) { @@ -329,7 +329,7 @@ void readPlaylistState() { ERROR("error parsing state " "file \"%s\"\n", playlist_stateFile); - exit(-1); + exit(EXIT_FAILURE); } current = atoi(&(buffer [strlen(PLAYLIST_STATE_FILE_CURRENT)])); diff --git a/src/sig_handlers.c b/src/sig_handlers.c index 896ea0b31..4baf060f0 100644 --- a/src/sig_handlers.c +++ b/src/sig_handlers.c @@ -28,7 +28,7 @@ void termSigHandler(int signal) { if(signal==SIGTERM) { savePlaylistState(); playerKill(); - exit(0); + exit(EXIT_SUCCESS); } } diff --git a/src/song.c b/src/song.c index c7186d1e0..826fbceb8 100644 --- a/src/song.c +++ b/src/song.c @@ -179,7 +179,7 @@ void readSongInfoIntoList(FILE * fp, SongList * list) { else if(0==strncmp(SONG_FILE,buffer,strlen(SONG_FILE))) { if(!song || song->utf8file) { ERROR("Problems reading song info\n"); - exit(-1); + exit(EXIT_FAILURE); } song->utf8file = strdup(&(buffer[strlen(SONG_FILE)])); } @@ -208,7 +208,7 @@ void readSongInfoIntoList(FILE * fp, SongList * list) { } else { ERROR("songinfo: unknown line in db: %s\n",buffer); - exit(-1); + exit(EXIT_FAILURE); } } diff --git a/src/volume.c b/src/volume.c index da320c57f..b55cd1e17 100644 --- a/src/volume.c +++ b/src/volume.c @@ -358,7 +358,7 @@ void initVolume() { } else { ERROR("unknown mixer type: %s\n",(getConf())[CONF_MIXER_TYPE]); - exit(-1); + exit(EXIT_FAILURE); } if(strlen((getConf())[CONF_MIXER_DEVICE])) { volume_mixerDevice = (getConf())[CONF_MIXER_DEVICE];