From 80dd76db7f927be1b6a967f43f36d705b701f153 Mon Sep 17 00:00:00 2001 From: Warren Dukes Date: Tue, 15 Jun 2004 18:06:21 +0000 Subject: fix C99 stuff for commandError also some slight optimizations to interfacePrintWithFD() and myfprintf() git-svn-id: https://svn.musicpd.org/mpd/trunk@1503 09075e82-0dd4-0310-85a5-a0d7c8717e4f --- src/command.c | 25 +++++++++++++------------ src/command.h | 4 ++-- src/directory.c | 14 ++++++++------ src/interface.c | 17 +++++++++-------- src/interface.h | 2 +- src/myfprintf.c | 19 ++++++++----------- src/player.c | 2 +- src/playlist.c | 7 ++++--- src/volume.c | 11 +++++++---- 9 files changed, 53 insertions(+), 48 deletions(-) diff --git a/src/command.c b/src/command.c index 81398ebaf..03899cb17 100644 --- a/src/command.c +++ b/src/command.c @@ -164,7 +164,7 @@ int handlePlay(FILE * fp, unsigned int * permission, int argArrayLength, song = strtol(argArray[1],&test,10); if(*test!='\0') { commandError(fp, ACK_ERROR_ARG, - "need a positive integer"); + "need a positive integer", NULL); return -1; } } @@ -181,7 +181,7 @@ int handlePlayId(FILE * fp, unsigned int * permission, int argArrayLength, id = strtol(argArray[1],&test,10); if(*test!='\0') { commandError(fp, ACK_ERROR_ARG, - "need a positive integer"); + "need a positive integer", NULL); return -1; } } @@ -309,7 +309,7 @@ int handleDelete(FILE * fp, unsigned int * permission, int argArrayLength, song = strtol(argArray[1],&test,10); if(*test!='\0') { commandError(fp, ACK_ERROR_ARG, - "need a positive integer"); + "need a positive integer", NULL); return -1; } return deleteFromPlaylist(fp,song); @@ -324,7 +324,7 @@ int handleDeleteId(FILE * fp, unsigned int * permission, int argArrayLength, id = strtol(argArray[1],&test,10); if(*test!='\0') { commandError(fp, ACK_ERROR_ARG, - "need a positive integer"); + "need a positive integer", NULL); return -1; } return deleteFromPlaylistById(fp, id); @@ -387,7 +387,8 @@ int handlePlaylistChanges(FILE * fp, unsigned int * permission, version = strtoul(argArray[1], &test, 10); if(*test!='\0') { - commandError(fp, ACK_ERROR_ARG, "need a positive integer"); + commandError(fp, ACK_ERROR_ARG, "need a positive integer", + NULL); return -1; } return playlistChanges(fp, version); @@ -403,7 +404,7 @@ int handlePlaylistInfo(FILE * fp, unsigned int * permission, song = strtol(argArray[1],&test,10); if(*test!='\0') { commandError(fp, ACK_ERROR_ARG, - "%s need a positive integer"); + "need a positive integer", NULL); return -1; } } @@ -420,7 +421,7 @@ int handlePlaylistId(FILE * fp, unsigned int * permission, id = strtol(argArray[1],&test,10); if(*test!='\0') { commandError(fp, ACK_ERROR_ARG, - "%s need a positive integer"); + "need a positive integer", NULL); return -1; } } @@ -509,7 +510,7 @@ int handleVolume(FILE * fp, unsigned int * permission, int argArrayLength, change = strtol(argArray[1],&test,10); if(*test!='\0') { - commandError(fp, ACK_ERROR_ARG, "need an integer"); + commandError(fp, ACK_ERROR_ARG, "need an integer", NULL); return -1; } return changeVolumeLevel(fp,change,1); @@ -523,7 +524,7 @@ int handleSetVol(FILE * fp, unsigned int * permission, int argArrayLength, level = strtol(argArray[1],&test,10); if(*test!='\0') { - commandError(fp, ACK_ERROR_ARG, "need an integer"); + commandError(fp, ACK_ERROR_ARG, "need an integer", NULL); return -1; } return changeVolumeLevel(fp,level,0); @@ -537,7 +538,7 @@ int handleRepeat(FILE * fp, unsigned int * permission, int argArrayLength, status = strtol(argArray[1],&test,10); if(*test!='\0') { - commandError(fp, ACK_ERROR_ARG, "need an integer"); + commandError(fp, ACK_ERROR_ARG, "need an integer", NULL); return -1; } return setPlaylistRepeatStatus(fp,status); @@ -551,7 +552,7 @@ int handleRandom(FILE * fp, unsigned int * permission, int argArrayLength, status = strtol(argArray[1],&test,10); if(*test!='\0') { - commandError(fp, ACK_ERROR_ARG, "need an integer"); + commandError(fp, ACK_ERROR_ARG, "need an integer", NULL); return -1; } return setPlaylistRandomStatus(fp,status); @@ -730,7 +731,7 @@ int handlePassword(FILE * fp, unsigned int * permission, int argArrayLength, char ** argArray) { if(getPermissionFromPassword(argArray[1],permission)<0) { - commandError(fp, ACK_ERROR_PASSWORD, "incorrect password"); + commandError(fp, ACK_ERROR_PASSWORD, "incorrect password", NULL); return -1; } diff --git a/src/command.h b/src/command.h index f08ebb16a..cf8874a17 100644 --- a/src/command.h +++ b/src/command.h @@ -50,13 +50,13 @@ void finishCommands(); if(current_command) { \ myfprintf(fp, "ACK [%i@%i] {%s} " format "\n", \ (int)error, command_listNum, \ - current_command, ##__VA_ARGS__); \ + current_command, __VA_ARGS__); \ current_command = NULL; \ } \ else { \ myfprintf(stderr, "ACK [%i@%i] " format "\n", \ (int)error, command_listNum, \ - ##__VA_ARGS__); \ + __VA_ARGS__); \ } \ } diff --git a/src/directory.c b/src/directory.c index 0d1b0ee2b..a05553dd6 100644 --- a/src/directory.c +++ b/src/directory.c @@ -166,7 +166,8 @@ void readDirectoryDBIfUpdateIsFinished() { int updateInit(FILE * fp, List * pathList) { if(directory_updatePid > 0) { - commandError(fp, ACK_ERROR_UPDATE_ALREADY, "already updating"); + commandError(fp, ACK_ERROR_UPDATE_ALREADY, "already updating", + NULL); return -1; } @@ -224,7 +225,7 @@ int updateInit(FILE * fp, List * pathList) { unblockSignals(); ERROR("updateInit: Problems forking()'ing\n"); commandError(fp, ACK_ERROR_SYSTEM, - "problems trying to update"); + "problems trying to update", NULL); directory_updatePid = 0; return -1; } @@ -745,7 +746,8 @@ int printDirectoryInfo(FILE * fp, char * name) { Directory * directory; if((directory = getDirectory(name))==NULL) { - commandError(fp, ACK_ERROR_NO_EXIST, "directory not found"); + commandError(fp, ACK_ERROR_NO_EXIST, "directory not found", + NULL); return -1; } @@ -1047,7 +1049,7 @@ int traverseAllIn(FILE * fp, char * name, return forEachSong(fp, song, data); } commandError(fp, ACK_ERROR_NO_EXIST, - "directory or file not found"); + "directory or file not found", NULL); return -1; } @@ -1129,7 +1131,7 @@ int searchForSongsIn(FILE * fp, char * name, char * item, char * string) { ret = traverseAllIn(fp,name,searchForFilenameInDirectory,NULL, (void *)dup); } - else commandError(fp, ACK_ERROR_ARG, "unknown table"); + else commandError(fp, ACK_ERROR_ARG, "unknown table", NULL); free(dup); @@ -1166,7 +1168,7 @@ int findSongsIn(FILE * fp, char * name, char * item, char * string) { (void *)string); } - commandError(fp, ACK_ERROR_ARG, "unknown table"); + commandError(fp, ACK_ERROR_ARG, "unknown table", NULL); return -1; } diff --git a/src/interface.c b/src/interface.c index 89229050d..29e372a5e 100644 --- a/src/interface.c +++ b/src/interface.c @@ -542,20 +542,21 @@ void flushAllInterfaceBuffers() { } } -int interfacePrintWithFD(int fd,char * buffer) { - int i; - int buflen; +int interfacePrintWithFD(int fd, char * buffer, int buflen) { + static int i = 0; int copylen; Interface * interface; - if(!(buflen = strlen(buffer))) return -1; - - for(i=0;i=interface_max_connections || + !interfaces[i].open || interfaces[i].fd!=fd) + { + for(i=0;istate==PLAYER_STATE_STOP) { commandError(fp, ACK_ERROR_PLAYER_SYNC, - "player not currently playing"); + "player not currently playing", NULL); return -1; } diff --git a/src/playlist.c b/src/playlist.c index 3da74754a..7c5410c66 100644 --- a/src/playlist.c +++ b/src/playlist.c @@ -609,7 +609,7 @@ int addToPlaylist(FILE * fp, char * url) { int addSongToPlaylist(FILE * fp, Song * song) { if(playlist.length==playlist_max_length) { commandError(fp, ACK_ERROR_PLAYLIST_MAX, - "playlist is at the max size"); + "playlist is at the max size", NULL); return -1; } @@ -1248,7 +1248,7 @@ int deletePlaylist(FILE * fp, char * utf8file) { if(unlink(actualFile)<0) { commandError(fp, ACK_ERROR_SYSTEM, - "problems deleting file"); + "problems deleting file", NULL); return -1; } @@ -1293,7 +1293,8 @@ int savePlaylist(FILE * fp, char * utf8file) { while(!(fileP = fopen(actualFile,"w")) && errno==EINTR); if(fileP==NULL) { - commandError(fp, ACK_ERROR_SYSTEM, "problems opening file"); + commandError(fp, ACK_ERROR_SYSTEM, "problems opening file", + NULL); return -1; } diff --git a/src/volume.c b/src/volume.c index 4a1370b2f..fa2f8aaa9 100644 --- a/src/volume.c +++ b/src/volume.c @@ -145,7 +145,7 @@ int changeOssVolumeLevel(FILE * fp, int change, int rel) { if (rel) { if((current = getOssVolumeLevel()) < 0) { commandError(fp, ACK_ERROR_SYSTEM, - "problem getting current volume"); + "problem getting current volume", NULL); return -1; } @@ -159,7 +159,8 @@ int changeOssVolumeLevel(FILE * fp, int change, int rel) { level = (new << 8) + new; if(ioctl(volume_ossFd,MIXER_WRITE(volume_ossControl),&level) < 0) { - commandError(fp, ACK_ERROR_SYSTEM, "problems setting volume"); + commandError(fp, ACK_ERROR_SYSTEM, "problems setting volume", + NULL); return -1; } @@ -271,7 +272,8 @@ int changeAlsaVolumeLevel(FILE * fp, int change, int rel) { if((err = snd_mixer_selem_get_playback_volume(volume_alsaElem, SND_MIXER_SCHN_FRONT_LEFT,&level))<0) { - commandError(fp, ACK_ERROR_SYSTEM, "problems getting volume"); + commandError(fp, ACK_ERROR_SYSTEM, "problems getting volume", + NULL); WARNING("problems getting alsa volume: %s\n",snd_strerror(err)); return -1; } @@ -297,7 +299,8 @@ int changeAlsaVolumeLevel(FILE * fp, int change, int rel) { if((err = snd_mixer_selem_set_playback_volume_all( volume_alsaElem,level))<0) { - commandError(fp, ACK_ERROR_SYSTEM, "problems setting volume"); + commandError(fp, ACK_ERROR_SYSTEM, "problems setting volume", + NULL); WARNING("problems setting alsa volume: %s\n",snd_strerror(err)); return -1; } -- cgit v1.2.3