aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorWarren Dukes <warren.dukes@gmail.com>2004-06-04 00:49:33 +0000
committerWarren Dukes <warren.dukes@gmail.com>2004-06-04 00:49:33 +0000
commitef6c500edb7dc1a4eb9bff11b83b57dd60d37d4a (patch)
tree26e7b16fbeb8bef1b45a9a7a035d5a3309c0145a /src
parentdafe92a9edd35ef805963d30e953bcadd78074d3 (diff)
downloadmpd-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')
-rw-r--r--src/command.c59
-rw-r--r--src/command.h9
-rw-r--r--src/directory.c17
-rw-r--r--src/interface.c14
-rw-r--r--src/player.c3
-rw-r--r--src/playlist.c70
-rw-r--r--src/tables.c9
-rw-r--r--src/volume.c13
8 files changed, 83 insertions, 111 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;
}
diff --git a/src/command.h b/src/command.h
index a2733ed6e..3aad04dca 100644
--- a/src/command.h
+++ b/src/command.h
@@ -22,15 +22,13 @@
#include "../config.h"
#include "list.h"
+#include "myfprintf.h"
#include <stdio.h>
#define COMMAND_RETURN_KILL 10
#define COMMAND_RETURN_CLOSE 20
-#define COMMAND_RESPOND_ERROR "ACK"
-#define COMMAND_RESPOND_OK "OK"
-
int proccessListOfCommands(FILE * fp, int * permission, int * expired,
List * list);
@@ -40,5 +38,8 @@ void initCommands();
void finishCommands();
+#define commandSuccess(fp) myfprintf(fp, "OK\n")
+
+#define commandError(fp, format, ... ) myfprintf(fp, "ACK " format "\n", ##__VA_ARGS__)
+
#endif
-/* vim:set shiftwidth=4 tabstop=8 expandtab: */
diff --git a/src/directory.c b/src/directory.c
index 79b3b1bb9..f73a4f14c 100644
--- a/src/directory.c
+++ b/src/directory.c
@@ -166,7 +166,7 @@ void readDirectoryDBIfUpdateIsFinished() {
int updateInit(FILE * fp, List * pathList) {
if(directory_updatePid > 0) {
- myfprintf(fp,"%s already updating\n",COMMAND_RESPOND_ERROR);
+ commandError(fp, "already updating");
return -1;
}
@@ -223,8 +223,7 @@ int updateInit(FILE * fp, List * pathList) {
else if(directory_updatePid < 0) {
unblockSignals();
ERROR("updateInit: Problems forking()'ing\n");
- myfprintf(fp,"%s problems trying to update\n",
- COMMAND_RESPOND_ERROR);
+ commandError(fp, "problems trying to update");
directory_updatePid = 0;
return -1;
}
@@ -745,7 +744,7 @@ int printDirectoryInfo(FILE * fp, char * name) {
Directory * directory;
if((directory = getDirectory(name))==NULL) {
- myfprintf(fp,"%s: directory not found\n",COMMAND_RESPOND_ERROR);
+ commandError(fp, "directory not found");
return -1;
}
@@ -988,13 +987,13 @@ int updateMp3Directory(FILE * fp) {
break;
default:
ERROR("problems updating music db\n");
- myfprintf(fp,"%s problems updating music db\n",COMMAND_RESPOND_ERROR);
+ commandError(fp, "problems updating music db");
return -1;
}
if(writeDirectoryDB()<0) {
ERROR("problems writing music db file, \"%s\"\n",directory_db);
- myfprintf(fp,"%s problems writing music db\n",COMMAND_RESPOND_ERROR);
+ commandError(fp, "problems writing music db");
return -1;
}
@@ -1048,7 +1047,7 @@ int traverseAllIn(FILE * fp, char * name,
if((song = getSongFromDB(name)) && forEachSong) {
return forEachSong(fp, song, data);
}
- myfprintf(fp,"%s: directory or file not found\n",COMMAND_RESPOND_ERROR);
+ commandError(fp, "directory or file not found");
return -1;
}
@@ -1130,7 +1129,7 @@ int searchForSongsIn(FILE * fp, char * name, char * item, char * string) {
ret = traverseAllIn(fp,name,searchForFilenameInDirectory,NULL,
(void *)dup);
}
- else myfprintf(fp,"%s unknown table\n",COMMAND_RESPOND_ERROR);
+ else commandError(fp, "unknown table");
free(dup);
@@ -1167,7 +1166,7 @@ int findSongsIn(FILE * fp, char * name, char * item, char * string) {
(void *)string);
}
- myfprintf(fp,"%s unknown table\n",COMMAND_RESPOND_ERROR);
+ commandError(fp, "unknown table");
return -1;
}
diff --git a/src/interface.c b/src/interface.c
index 2fb95ae1c..4abbc8c4f 100644
--- a/src/interface.c
+++ b/src/interface.c
@@ -41,7 +41,7 @@
#include <errno.h>
#include <signal.h>
-#define GREETING "MPD"
+#define GREETING "OK MPD"
#define INTERFACE_MAX_BUFFER_LENGTH MAXPATHLEN+1024
#define INTERFACE_LIST_MODE_BEGIN "command_list_begin"
@@ -120,8 +120,7 @@ void openInterface(Interface * interface, int fd) {
#endif
interface->outBuffer = malloc(interface->outBufSize);
- myfprintf(interface->fp,"%s %s %s\n",COMMAND_RESPOND_OK,GREETING,
- VERSION);
+ myfprintf(interface->fp, "%s %s\n", GREETING, VERSION);
printInterfaceOutBuffer(interface);
}
@@ -237,9 +236,7 @@ int interfaceReadInput(Interface * interface) {
interface->num,
ret);
if(ret==0) {
- myfprintf(interface->fp,
- "%s\n",
- COMMAND_RESPOND_OK);
+ commandSuccess(interface->fp);
}
else if(ret==COMMAND_RETURN_CLOSE ||
interface->expired) {
@@ -291,7 +288,8 @@ int interfaceReadInput(Interface * interface) {
INTERFACE_LIST_MODE_END)
==0)
{
- myfprintf(interface->fp,"%s not in command list mode\n",COMMAND_RESPOND_ERROR);
+ commandError(interface->fp,
+ "not in command list mode");
ret = -1;
}
else {
@@ -304,7 +302,7 @@ int interfaceReadInput(Interface * interface) {
DEBUG("interface %i: command returned %i\n",interface->num,ret);
}
if(ret==0) {
- myfprintf(interface->fp,"%s\n",COMMAND_RESPOND_OK);
+ commandSuccess(interface->fp);
}
else if(ret==COMMAND_RETURN_CLOSE ||
interface->expired) {
diff --git a/src/player.c b/src/player.c
index 4b96f8584..b4b4e8b74 100644
--- a/src/player.c
+++ b/src/player.c
@@ -386,8 +386,7 @@ int playerSeek(FILE * fp, Song * song, float time) {
PlayerControl * pc = &(getPlayerData()->playerControl);
if(pc->state==PLAYER_STATE_STOP) {
- myfprintf(fp,"%s player not currently playing\n",
- COMMAND_RESPOND_ERROR);
+ commandError(fp, "player not currently playing");
return -1;
}
diff --git a/src/playlist.c b/src/playlist.c
index 75b812338..d1691b5ed 100644
--- a/src/playlist.c
+++ b/src/playlist.c
@@ -375,7 +375,7 @@ int playlistInfo(FILE * fp,int song) {
end = song+1;
}
if(song>=playlist.length) {
- myfprintf(fp,"%s song doesn't exist\n",COMMAND_RESPOND_ERROR);
+ commandError(fp, "song doesn't exist");
return -1;
}
@@ -486,9 +486,8 @@ int addToPlaylist(FILE * fp, char * url) {
{
}
else {
- myfprintf(fp,"%s \"%s\" is not in the music db or is"
- "not a valid url\n",
- COMMAND_RESPOND_ERROR,url);
+ commandError(fp, "\"%s\" is not in the music db or is"
+ "not a valid url\n", url);
return -1;
}
@@ -497,7 +496,7 @@ int addToPlaylist(FILE * fp, char * url) {
int addSongToPlaylist(FILE * fp, Song * song) {
if(playlist.length==playlist_max_length) {
- myfprintf(fp,"%s playlist is at the max size\n",COMMAND_RESPOND_ERROR);
+ commandError(fp, "playlist is at the max size");
return -1;
}
@@ -536,13 +535,11 @@ int swapSongsInPlaylist(FILE * fp, int song1, int song2) {
int currentSong = -1;
if(song1<0 || song1>=playlist.length) {
- myfprintf(fp,"%s \"%i\" is not in the playlist\n",
- COMMAND_RESPOND_ERROR,song1);
+ commandError(fp,"\"%i\" is not in the playlist", song1);
return -1;
}
if(song2<0 || song2>=playlist.length) {
- myfprintf(fp,"%s \"%i\" is not in the playlist\n",
- COMMAND_RESPOND_ERROR,song2);
+ commandError(fp, "\"%i\" is not in the playlist", song2);
return -1;
}
@@ -589,11 +586,11 @@ int deleteFromPlaylist(FILE * fp, int song) {
int songOrder;
if(song<0) {
- myfprintf(fp,"%s need a positive integer\n",COMMAND_RESPOND_ERROR);
+ commandError(fp, "need a positive integer");
return -1;
}
if(song>=playlist.length) {
- myfprintf(fp,"%s song doesn't exist\n",COMMAND_RESPOND_ERROR);
+ commandError(fp, "song doesn't exist");
return -1;
}
@@ -717,17 +714,17 @@ int playPlaylist(FILE * fp, int song, int stopOnError) {
}
}
else if(song<0) {
- myfprintf(fp,"%s need integer >= -1\n",COMMAND_RESPOND_ERROR);
+ commandError(fp, "need integer >= -1");
playlist_state = PLAYLIST_STATE_STOP;
return -1;
}
if(!playlist.length) {
- myfprintf(fp,"%s playlist is empty\n",COMMAND_RESPOND_ERROR);
+ commandError(fp, "playlist is empty");
playlist_state = PLAYLIST_STATE_STOP;
return -1;
}
else if(song>=playlist.length) {
- myfprintf(fp,"%s song doesn't exist\n",COMMAND_RESPOND_ERROR);
+ commandError(fp, "song doesn't exist");
playlist_state = PLAYLIST_STATE_STOP;
return -1;
}
@@ -848,7 +845,7 @@ int getPlaylistRandomStatus() {
int setPlaylistRepeatStatus(FILE * fp, int status) {
if(status!=0 && status!=1) {
- myfprintf(fp,"%s \"%i\" is not 0 or 1\n",COMMAND_RESPOND_ERROR,status);
+ commandError(fp, "\"%i\" is not 0 or 1", status);
return -1;
}
@@ -872,14 +869,12 @@ int moveSongInPlaylist(FILE * fp, int from, int to) {
int currentSong = -1;
if(from<0 || from>=playlist.length) {
- myfprintf(fp,"%s \"%i\" is not a song in the playlist\n",
- COMMAND_RESPOND_ERROR,from);
+ commandError(fp, "\"%i\" is not a song in the playlist", from);
return -1;
}
if(to<0 || to>=playlist.length) {
- myfprintf(fp,"%s \"%i\" is not a song in the playlist\n",
- COMMAND_RESPOND_ERROR,to);
+ commandError(fp, "\"%i\" is not a song in the playlist", to);
return -1;
}
@@ -985,7 +980,7 @@ int setPlaylistRandomStatus(FILE * fp, int status) {
int statusWas = playlist.random;
if(status!=0 && status!=1) {
- myfprintf(fp,"%s \"%i\" is not 0 or 1\n",COMMAND_RESPOND_ERROR,status);
+ commandError(fp, "\"%i\" is not 0 or 1", status);
return -1;
}
@@ -1079,13 +1074,12 @@ int deletePlaylist(FILE * fp, char * utf8file) {
if((actualFile = rpp2app(rfile)) && isPlaylist(actualFile)) free(rfile);
else {
free(rfile);
- myfprintf(fp,"%s playlist \"%s\" not found\n",
- COMMAND_RESPOND_ERROR,utf8file);
+ commandError(fp, "playlist \"%s\" not found", utf8file);
return -1;
}
if(unlink(actualFile)<0) {
- myfprintf(fp,"%s problems deleting file\n",COMMAND_RESPOND_ERROR);
+ commandError(fp, "problems deleting file");
return -1;
}
@@ -1101,9 +1095,8 @@ int savePlaylist(FILE * fp, char * utf8file) {
char * actualFile;
if(strstr(utf8file,"/")) {
- myfprintf(fp,"%s cannot save \"%s\", saving playlists to "
- "subdirectories is not supported\n",
- COMMAND_RESPOND_ERROR,utf8file);
+ commandError(fp, "cannot save \"%s\", saving playlists to "
+ "subdirectories is not supported", utf8file);
return -1;
}
@@ -1123,13 +1116,14 @@ int savePlaylist(FILE * fp, char * utf8file) {
free(rfile);
if(0==stat(actualFile,&st)) {
- myfprintf(fp,"%s A file or directory already exists with the name \"%s\"\n",COMMAND_RESPOND_ERROR,utf8file);
+ myfprintf(fp, "a file or directory already exists with the name"
+ " \"%s\"", utf8file);
return -1;
}
while(!(fileP = fopen(actualFile,"w")) && errno==EINTR);
if(fileP==NULL) {
- myfprintf(fp,"%s Problems opening file\n",COMMAND_RESPOND_ERROR);
+ commandError(fp, "problems opening file");
return -1;
}
@@ -1171,15 +1165,13 @@ int loadPlaylist(FILE * fp, char * utf8file) {
if((actualFile = rpp2app(rfile)) && isPlaylist(actualFile)) free(rfile);
else {
free(rfile);
- myfprintf(fp,"%s playlist \"%s\" not found\n",
- COMMAND_RESPOND_ERROR,utf8file);
+ commandError(fp, "playlist \"%s\" not found", utf8file);
return -1;
}
while(!(fileP = fopen(actualFile,"r")) && errno==EINTR);
if(fileP==NULL) {
- myfprintf(fp,"%s Problems opening file \"%s\"\n",
- COMMAND_RESPOND_ERROR,utf8file);
+ commandError(fp, "problems opening file \"%s\"", utf8file);
return -1;
}
@@ -1197,7 +1189,8 @@ int loadPlaylist(FILE * fp, char * utf8file) {
strncat(s,"/",MAXPATHLEN-parentlen);
strncat(s,temp,MAXPATHLEN-parentlen-1);
if(strlen(s)>=MAXPATHLEN) {
- myfprintf(fp,"%s \"%s\" too long\n",COMMAND_RESPOND_ERROR,temp);
+ commandError(fp, "\"%s\" too long",
+ temp);
free(temp);
while(fclose(fileP) && errno==EINTR);
if(erroredFile) free(erroredFile);
@@ -1222,7 +1215,7 @@ int loadPlaylist(FILE * fp, char * utf8file) {
}
else if(slength==MAXPATHLEN) {
s[slength] = '\0';
- myfprintf(fp,"%s \"%s\" too long\n",COMMAND_RESPOND_ERROR,s);
+ commandError(fp, "\"%s\" too long", s);
while(fclose(fileP) && errno==EINTR);
if(erroredFile) free(erroredFile);
return -1;
@@ -1233,8 +1226,7 @@ int loadPlaylist(FILE * fp, char * utf8file) {
while(fclose(fileP) && errno==EINTR);
if(erroredFile) {
- myfprintf(fp,"%s can't add file \"%s\"\n",COMMAND_RESPOND_ERROR,
- erroredFile);
+ commandError(fp, "can't add file \"%s\"", erroredFile);
free(erroredFile);
return -1;
}
@@ -1262,15 +1254,15 @@ int seekSongInPlaylist(FILE * fp, int song, float time) {
int i = song;
if(song<0) {
- myfprintf(fp,"%s need integer >= -1\n",COMMAND_RESPOND_ERROR);
+ commandError(fp, "need integer >= -1");
return -1;
}
if(!playlist.length) {
- myfprintf(fp,"%s playlist is empty\n",COMMAND_RESPOND_ERROR);
+ commandError(fp, "playlist is empty");
return -1;
}
else if(song>=playlist.length) {
- myfprintf(fp,"%s song doesn't exist\n",COMMAND_RESPOND_ERROR);
+ commandError(fp, "song doesn't exist");
return -1;
}
diff --git a/src/tables.c b/src/tables.c
index 4129c1d29..114f71d15 100644
--- a/src/tables.c
+++ b/src/tables.c
@@ -172,8 +172,7 @@ int printAllAlbums(FILE * fp, char * artist) {
}
}
else {
- myfprintf(fp,"%s artist \"%s\" not found\n",
- COMMAND_RESPOND_ERROR,artist);
+ commandError(fp, "artist \"%s\" not found", artist);
return -1;
}
}
@@ -184,7 +183,7 @@ int printAllAlbums(FILE * fp, char * artist) {
int printAllKeysOfTable(FILE * fp, char * table, char * arg1) {
if(strcmp(table,TABLES_ARTIST)==0) {
if(arg1!=NULL) {
- myfprintf(fp,"%s %s table takes no args\n",COMMAND_RESPOND_ERROR,table);
+ commandError(fp, "%s table takes no args", table);
return -1;
}
return printAllArtists(fp);
@@ -193,8 +192,8 @@ int printAllKeysOfTable(FILE * fp, char * table, char * arg1) {
return printAllAlbums(fp,arg1);
}
else {
- myfprintf(fp,"%s table \"%s\" does not exist or not available for listing\n",COMMAND_RESPOND_ERROR,table);
+ commandError(fp, "table \"%s\" does not exist or not available "
+ "for listing", table);
return -1;
}
}
-/* vim:set shiftwidth=4 tabstop=8 expandtab: */
diff --git a/src/volume.c b/src/volume.c
index 49d7483cd..bf367ab75 100644
--- a/src/volume.c
+++ b/src/volume.c
@@ -144,8 +144,7 @@ int changeOssVolumeLevel(FILE * fp, int change, int rel) {
if (rel) {
if((current = getOssVolumeLevel()) < 0) {
- myfprintf(fp,"%s problem getting current volume\n",
- COMMAND_RESPOND_ERROR);
+ commandError(fp, "problem getting current volume");
return -1;
}
@@ -159,7 +158,7 @@ int changeOssVolumeLevel(FILE * fp, int change, int rel) {
level = (new << 8) + new;
if(ioctl(volume_ossFd,MIXER_WRITE(volume_ossControl),&level) < 0) {
- myfprintf(fp,"%s problems setting volume\n",COMMAND_RESPOND_ERROR);
+ commandError(fp, "problems setting volume");
return -1;
}
@@ -271,8 +270,7 @@ 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) {
- myfprintf(fp,"%s problems getting volume\n",
- COMMAND_RESPOND_ERROR);
+ commandError(fp, "problems getting volume");
ERROR("problems getting alsa volume: %s\n",snd_strerror(err));
return -1;
}
@@ -298,8 +296,7 @@ int changeAlsaVolumeLevel(FILE * fp, int change, int rel) {
if((err = snd_mixer_selem_set_playback_volume_all(
volume_alsaElem,level))<0) {
- myfprintf(fp,"%s problems setting volume\n",
- COMMAND_RESPOND_ERROR);
+ commandError(fp, "problems setting volume");
ERROR("problems setting alsa volume: %s\n",snd_strerror(err));
return -1;
}
@@ -426,7 +423,7 @@ int changeVolumeLevel(FILE * fp, int change, int rel) {
case VOLUME_MIXER_TYPE_SOFTWARE:
return changeSoftwareVolume(fp,change,rel);
default:
- myfprintf(fp,"%s no volume support!\n",COMMAND_RESPOND_ERROR);
+ commandError(fp, "no volume support");
return -1;
}
}