diff options
author | Warren Dukes <warren.dukes@gmail.com> | 2004-06-04 00:49:33 +0000 |
---|---|---|
committer | Warren Dukes <warren.dukes@gmail.com> | 2004-06-04 00:49:33 +0000 |
commit | ef6c500edb7dc1a4eb9bff11b83b57dd60d37d4a (patch) | |
tree | 26e7b16fbeb8bef1b45a9a7a035d5a3309c0145a /src/command.c | |
parent | dafe92a9edd35ef805963d30e953bcadd78074d3 (diff) | |
download | mpd-ef6c500edb7dc1a4eb9bff11b83b57dd60d37d4a.tar.gz mpd-ef6c500edb7dc1a4eb9bff11b83b57dd60d37d4a.tar.xz mpd-ef6c500edb7dc1a4eb9bff11b83b57dd60d37d4a.zip |
clean up ACK error coding a little bit
git-svn-id: https://svn.musicpd.org/mpd/trunk@1321 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to 'src/command.c')
-rw-r--r-- | src/command.c | 59 |
1 files changed, 23 insertions, 36 deletions
diff --git a/src/command.c b/src/command.c index 13325e851..121c9358e 100644 --- a/src/command.c +++ b/src/command.c @@ -151,7 +151,7 @@ int handlePlay(FILE * fp, unsigned int * permission, int argArrayLength, if(argArrayLength==2) { song = strtol(argArray[1],&test,10); if(*test!='\0') { - myfprintf(fp,"%s need a positive integer\n",COMMAND_RESPOND_ERROR); + commandError(fp, "need a positive integer"); return -1; } } @@ -171,8 +171,7 @@ int handlePause(FILE * fp, unsigned int * permission, char * test; int pause = strtol(argArray[1],&test,10); if(*test!='\0' || (pause!=0 && pause!=1)) { - myfprintf(fp,"%s \%s\" is not 0 or 1\n", - COMMAND_RESPOND_ERROR,pause); + commandError(fp, "\%s\" is not 0 or 1", argArray[1]); return -1; } return playerSetPause(fp,pause); @@ -263,7 +262,7 @@ int handleDelete(FILE * fp, unsigned int * permission, int argArrayLength, song = strtol(argArray[1],&test,10); if(*test!='\0') { - myfprintf(fp,"%s need a positive integer\n",COMMAND_RESPOND_ERROR); + commandError(fp, "need a positive integer"); return -1; } return deleteFromPlaylist(fp,song); @@ -327,7 +326,7 @@ int handlePlaylistInfo(FILE * fp, unsigned int * permission, if(argArrayLength == 2) { song = strtol(argArray[1],&test,10); if(*test!='\0') { - myfprintf(fp,"%s need a positive integer\n",COMMAND_RESPOND_ERROR); + commandError(fp, "%s need a positive integer"); return -1; } } @@ -416,7 +415,7 @@ int handleVolume(FILE * fp, unsigned int * permission, int argArrayLength, change = strtol(argArray[1],&test,10); if(*test!='\0') { - myfprintf(fp,"%s need an integer\n",COMMAND_RESPOND_ERROR); + commandError(fp, "need an integer"); return -1; } return changeVolumeLevel(fp,change,1); @@ -430,7 +429,7 @@ int handleSetVol(FILE * fp, unsigned int * permission, int argArrayLength, level = strtol(argArray[1],&test,10); if(*test!='\0') { - myfprintf(fp,"%s need an integer\n",COMMAND_RESPOND_ERROR); + commandError(fp, "need an integer"); return -1; } return changeVolumeLevel(fp,level,0); @@ -444,7 +443,7 @@ int handleRepeat(FILE * fp, unsigned int * permission, int argArrayLength, status = strtol(argArray[1],&test,10); if(*test!='\0') { - myfprintf(fp,"%s need an integer\n",COMMAND_RESPOND_ERROR); + commandError(fp, "need an integer"); return -1; } return setPlaylistRepeatStatus(fp,status); @@ -458,7 +457,7 @@ int handleRandom(FILE * fp, unsigned int * permission, int argArrayLength, status = strtol(argArray[1],&test,10); if(*test!='\0') { - myfprintf(fp,"%s need an integer\n",COMMAND_RESPOND_ERROR); + commandError(fp, "need an integer"); return -1; } return setPlaylistRandomStatus(fp,status); @@ -495,14 +494,12 @@ int handleMove(FILE * fp, unsigned int * permission, int argArrayLength, from = strtol(argArray[1],&test,10); if(*test!='\0') { - myfprintf(fp,"%s \"%s\" is not a integer\n", - COMMAND_RESPOND_ERROR,argArray[1]); + commandError(fp, "\"%s\" is not a integer", argArray[1]); return -1; } to = strtol(argArray[2],&test,10); if(*test!='\0') { - myfprintf(fp,"%s \"%s\" is not a integer\n", - COMMAND_RESPOND_ERROR,argArray[2]); + commandError(fp, "\"%s\" is not a integer", argArray[2]); return -1; } return moveSongInPlaylist(fp,from,to); @@ -517,14 +514,12 @@ int handleSwap(FILE * fp, unsigned int * permission, int argArrayLength, song1 = strtol(argArray[1],&test,10); if(*test!='\0') { - myfprintf(fp,"%s \"%s\" is not a integer\n", - COMMAND_RESPOND_ERROR,argArray[1]); + commandError(fp, "\"%s\" is not a integer", argArray[1]); return -1; } song2 = strtol(argArray[2],&test,10); if(*test!='\0') { - myfprintf(fp,"%s \"%s\" is not a integer\n", - COMMAND_RESPOND_ERROR,argArray[2]); + commandError(fp, "\"%s\" is not a integer", argArray[2]); return -1; } return swapSongsInPlaylist(fp,song1,song2); @@ -539,14 +534,12 @@ int handleSeek(FILE * fp, unsigned int * permission, int argArrayLength, song = strtol(argArray[1],&test,10); if(*test!='\0') { - myfprintf(fp,"%s \"%s\" is not a integer\n", - COMMAND_RESPOND_ERROR,argArray[1]); + commandError(fp, "\"%s\" is not a integer", argArray[1]); return -1; } time = strtol(argArray[2],&test,10); if(*test!='\0') { - myfprintf(fp,"%s \"%s\" is not a integer\n", - COMMAND_RESPOND_ERROR,argArray[2]); + commandError(fp, "\"%s\" is not a integer", argArray[2]); return -1; } return seekSongInPlaylist(fp,song,time); @@ -571,7 +564,7 @@ int handlePassword(FILE * fp, unsigned int * permission, int argArrayLength, char ** argArray) { if(getPermissionFromPassword(argArray[1],permission)<0) { - myfprintf(fp,"%s incorrect password\n",COMMAND_RESPOND_ERROR); + commandError(fp, "incorrect password"); return -1; } @@ -586,8 +579,7 @@ int handleCrossfade(FILE * fp, unsigned int * permission, int argArrayLength, time = strtol(argArray[1],&test,10); if(*test!='\0' || time<0) { - myfprintf(fp,"%s \"%s\" is not a integer >= 0\n", - COMMAND_RESPOND_ERROR,argArray[1]); + commandError(fp, "\"%s\" is not a integer >= 0", argArray[1]); return -1; } @@ -652,8 +644,7 @@ int checkArgcAndPermission(CommandEntry * cmd, FILE *fp, if (cmd->reqPermission != (permission & cmd->reqPermission)) { if(fp) { - myfprintf(fp,"%s You don't have permission for " - "\"%s\"\n",COMMAND_RESPOND_ERROR, + commandError(fp, "you don't have permission for \"%s\"", cmd->cmd); } return -1; @@ -663,23 +654,22 @@ int checkArgcAndPermission(CommandEntry * cmd, FILE *fp, if (min == max && max != argc) { if(fp) { - myfprintf(fp,"%s Wrong number of arguments for " - "\"%s\"\n",COMMAND_RESPOND_ERROR, + commandError(fp, "wrong number of arguments for \"%s\"", argArray[0]); } return -1; } else if (argc < min) { if(fp) { - myfprintf(fp,"%s too few arguments for \"%s\"\n", - COMMAND_RESPOND_ERROR,argArray[0]); + commandError(fp, "too few arguments for \"%s\"", + argArray[0]); } return -1; } else if (argc > max && max /* != 0 */) { if(fp) { - myfprintf(fp,"%s too many arguments for \"%s\"\n", - COMMAND_RESPOND_ERROR,argArray[0]); + commandError(fp, "too many arguments for \"%s\"", + argArray[0]); } return -1; } @@ -694,10 +684,7 @@ CommandEntry * getCommandEntryAndCheckArgcAndPermission(FILE * fp, if(argArrayLength == 0) return NULL; if(!findInList(commandList, argArray[0],(void *)&cmd)) { - if(fp) { - myfprintf(fp,"%s Unknown command \"%s\"\n", - COMMAND_RESPOND_ERROR,argArray[0]); - } + if(fp) commandError(fp, "unknown command \"%s\"", argArray[0]); return NULL; } |