finish ack error codes
git-svn-id: https://svn.musicpd.org/mpd/trunk@1325 09075e82-0dd4-0310-85a5-a0d7c8717e4f
This commit is contained in:
parent
f958e0a4c5
commit
630d33b234
4
TODO
4
TODO
|
@ -1,8 +1,6 @@
|
||||||
1) put some sort of error reporting for streaming/inputStream!
|
1) put some sort of error reporting for streaming/inputStream!
|
||||||
|
|
||||||
2) ACK error codes
|
2) Fix charset errors so they don't goto stderr/out
|
||||||
|
|
||||||
3) Fix charset errors so they don't goto stderr/out
|
|
||||||
|
|
||||||
|
|
||||||
Post-1.0
|
Post-1.0
|
||||||
|
|
|
@ -154,7 +154,8 @@ int handlePlay(FILE * fp, unsigned int * permission, int argArrayLength,
|
||||||
if(argArrayLength==2) {
|
if(argArrayLength==2) {
|
||||||
song = strtol(argArray[1],&test,10);
|
song = strtol(argArray[1],&test,10);
|
||||||
if(*test!='\0') {
|
if(*test!='\0') {
|
||||||
commandError(fp, "need a positive integer");
|
commandError(fp, ACK_ERROR_ARG,
|
||||||
|
"need a positive integer");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -174,7 +175,7 @@ int handlePause(FILE * fp, unsigned int * permission,
|
||||||
char * test;
|
char * test;
|
||||||
int pause = strtol(argArray[1],&test,10);
|
int pause = strtol(argArray[1],&test,10);
|
||||||
if(*test!='\0' || (pause!=0 && pause!=1)) {
|
if(*test!='\0' || (pause!=0 && pause!=1)) {
|
||||||
commandError(fp, "\%s\" is not 0 or 1", argArray[1]);
|
commandError(fp, ACK_ERROR_ARG, "\%s\" is not 0 or 1", argArray[1]);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return playerSetPause(fp,pause);
|
return playerSetPause(fp,pause);
|
||||||
|
@ -265,7 +266,8 @@ int handleDelete(FILE * fp, unsigned int * permission, int argArrayLength,
|
||||||
|
|
||||||
song = strtol(argArray[1],&test,10);
|
song = strtol(argArray[1],&test,10);
|
||||||
if(*test!='\0') {
|
if(*test!='\0') {
|
||||||
commandError(fp, "need a positive integer");
|
commandError(fp, ACK_ERROR_ARG,
|
||||||
|
"need a positive integer");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return deleteFromPlaylist(fp,song);
|
return deleteFromPlaylist(fp,song);
|
||||||
|
@ -329,7 +331,8 @@ int handlePlaylistInfo(FILE * fp, unsigned int * permission,
|
||||||
if(argArrayLength == 2) {
|
if(argArrayLength == 2) {
|
||||||
song = strtol(argArray[1],&test,10);
|
song = strtol(argArray[1],&test,10);
|
||||||
if(*test!='\0') {
|
if(*test!='\0') {
|
||||||
commandError(fp, "%s need a positive integer");
|
commandError(fp, ACK_ERROR_ARG,
|
||||||
|
"%s need a positive integer");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -418,7 +421,7 @@ int handleVolume(FILE * fp, unsigned int * permission, int argArrayLength,
|
||||||
|
|
||||||
change = strtol(argArray[1],&test,10);
|
change = strtol(argArray[1],&test,10);
|
||||||
if(*test!='\0') {
|
if(*test!='\0') {
|
||||||
commandError(fp, "need an integer");
|
commandError(fp, ACK_ERROR_ARG, "need an integer");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return changeVolumeLevel(fp,change,1);
|
return changeVolumeLevel(fp,change,1);
|
||||||
|
@ -432,7 +435,7 @@ int handleSetVol(FILE * fp, unsigned int * permission, int argArrayLength,
|
||||||
|
|
||||||
level = strtol(argArray[1],&test,10);
|
level = strtol(argArray[1],&test,10);
|
||||||
if(*test!='\0') {
|
if(*test!='\0') {
|
||||||
commandError(fp, "need an integer");
|
commandError(fp, ACK_ERROR_ARG, "need an integer");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return changeVolumeLevel(fp,level,0);
|
return changeVolumeLevel(fp,level,0);
|
||||||
|
@ -446,7 +449,7 @@ int handleRepeat(FILE * fp, unsigned int * permission, int argArrayLength,
|
||||||
|
|
||||||
status = strtol(argArray[1],&test,10);
|
status = strtol(argArray[1],&test,10);
|
||||||
if(*test!='\0') {
|
if(*test!='\0') {
|
||||||
commandError(fp, "need an integer");
|
commandError(fp, ACK_ERROR_ARG, "need an integer");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return setPlaylistRepeatStatus(fp,status);
|
return setPlaylistRepeatStatus(fp,status);
|
||||||
|
@ -460,7 +463,7 @@ int handleRandom(FILE * fp, unsigned int * permission, int argArrayLength,
|
||||||
|
|
||||||
status = strtol(argArray[1],&test,10);
|
status = strtol(argArray[1],&test,10);
|
||||||
if(*test!='\0') {
|
if(*test!='\0') {
|
||||||
commandError(fp, "need an integer");
|
commandError(fp, ACK_ERROR_ARG, "need an integer");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return setPlaylistRandomStatus(fp,status);
|
return setPlaylistRandomStatus(fp,status);
|
||||||
|
@ -497,12 +500,14 @@ int handleMove(FILE * fp, unsigned int * permission, int argArrayLength,
|
||||||
|
|
||||||
from = strtol(argArray[1],&test,10);
|
from = strtol(argArray[1],&test,10);
|
||||||
if(*test!='\0') {
|
if(*test!='\0') {
|
||||||
commandError(fp, "\"%s\" is not a integer", argArray[1]);
|
commandError(fp, ACK_ERROR_ARG,
|
||||||
|
"\"%s\" is not a integer", argArray[1]);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
to = strtol(argArray[2],&test,10);
|
to = strtol(argArray[2],&test,10);
|
||||||
if(*test!='\0') {
|
if(*test!='\0') {
|
||||||
commandError(fp, "\"%s\" is not a integer", argArray[2]);
|
commandError(fp, ACK_ERROR_ARG,
|
||||||
|
"\"%s\" is not a integer", argArray[2]);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return moveSongInPlaylist(fp,from,to);
|
return moveSongInPlaylist(fp,from,to);
|
||||||
|
@ -517,12 +522,14 @@ int handleSwap(FILE * fp, unsigned int * permission, int argArrayLength,
|
||||||
|
|
||||||
song1 = strtol(argArray[1],&test,10);
|
song1 = strtol(argArray[1],&test,10);
|
||||||
if(*test!='\0') {
|
if(*test!='\0') {
|
||||||
commandError(fp, "\"%s\" is not a integer", argArray[1]);
|
commandError(fp, ACK_ERROR_ARG,
|
||||||
|
"\"%s\" is not a integer", argArray[1]);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
song2 = strtol(argArray[2],&test,10);
|
song2 = strtol(argArray[2],&test,10);
|
||||||
if(*test!='\0') {
|
if(*test!='\0') {
|
||||||
commandError(fp, "\"%s\" is not a integer", argArray[2]);
|
commandError(fp, ACK_ERROR_ARG, "\"%s\" is not a integer",
|
||||||
|
argArray[2]);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return swapSongsInPlaylist(fp,song1,song2);
|
return swapSongsInPlaylist(fp,song1,song2);
|
||||||
|
@ -537,12 +544,14 @@ int handleSeek(FILE * fp, unsigned int * permission, int argArrayLength,
|
||||||
|
|
||||||
song = strtol(argArray[1],&test,10);
|
song = strtol(argArray[1],&test,10);
|
||||||
if(*test!='\0') {
|
if(*test!='\0') {
|
||||||
commandError(fp, "\"%s\" is not a integer", argArray[1]);
|
commandError(fp, ACK_ERROR_ARG,
|
||||||
|
"\"%s\" is not a integer", argArray[1]);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
time = strtol(argArray[2],&test,10);
|
time = strtol(argArray[2],&test,10);
|
||||||
if(*test!='\0') {
|
if(*test!='\0') {
|
||||||
commandError(fp, "\"%s\" is not a integer", argArray[2]);
|
commandError(fp, ACK_ERROR_ARG,
|
||||||
|
"\"%s\" is not a integer", argArray[2]);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return seekSongInPlaylist(fp,song,time);
|
return seekSongInPlaylist(fp,song,time);
|
||||||
|
@ -567,7 +576,7 @@ int handlePassword(FILE * fp, unsigned int * permission, int argArrayLength,
|
||||||
char ** argArray)
|
char ** argArray)
|
||||||
{
|
{
|
||||||
if(getPermissionFromPassword(argArray[1],permission)<0) {
|
if(getPermissionFromPassword(argArray[1],permission)<0) {
|
||||||
commandError(fp, "incorrect password");
|
commandError(fp, ACK_ERROR_PASSWORD, "incorrect password");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -582,7 +591,8 @@ int handleCrossfade(FILE * fp, unsigned int * permission, int argArrayLength,
|
||||||
|
|
||||||
time = strtol(argArray[1],&test,10);
|
time = strtol(argArray[1],&test,10);
|
||||||
if(*test!='\0' || time<0) {
|
if(*test!='\0' || time<0) {
|
||||||
commandError(fp, "\"%s\" is not a integer >= 0", argArray[1]);
|
commandError(fp, ACK_ERROR_ARG,
|
||||||
|
"\"%s\" is not a integer >= 0", argArray[1]);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -647,7 +657,8 @@ int checkArgcAndPermission(CommandEntry * cmd, FILE *fp,
|
||||||
|
|
||||||
if (cmd->reqPermission != (permission & cmd->reqPermission)) {
|
if (cmd->reqPermission != (permission & cmd->reqPermission)) {
|
||||||
if(fp) {
|
if(fp) {
|
||||||
commandError(fp, "you don't have permission for \"%s\"",
|
commandError(fp, ACK_ERROR_PERMISSION,
|
||||||
|
"you don't have permission for \"%s\"",
|
||||||
cmd->cmd);
|
cmd->cmd);
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -657,21 +668,24 @@ int checkArgcAndPermission(CommandEntry * cmd, FILE *fp,
|
||||||
|
|
||||||
if (min == max && max != argc) {
|
if (min == max && max != argc) {
|
||||||
if(fp) {
|
if(fp) {
|
||||||
commandError(fp, "wrong number of arguments for \"%s\"",
|
commandError(fp, ACK_ERROR_ARG,
|
||||||
|
"wrong number of arguments for \"%s\"",
|
||||||
argArray[0]);
|
argArray[0]);
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
else if (argc < min) {
|
else if (argc < min) {
|
||||||
if(fp) {
|
if(fp) {
|
||||||
commandError(fp, "too few arguments for \"%s\"",
|
commandError(fp, ACK_ERROR_ARG,
|
||||||
|
"too few arguments for \"%s\"",
|
||||||
argArray[0]);
|
argArray[0]);
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
else if (argc > max && max /* != 0 */) {
|
else if (argc > max && max /* != 0 */) {
|
||||||
if(fp) {
|
if(fp) {
|
||||||
commandError(fp, "too many arguments for \"%s\"",
|
commandError(fp, ACK_ERROR_ARG,
|
||||||
|
"too many arguments for \"%s\"",
|
||||||
argArray[0]);
|
argArray[0]);
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -690,7 +704,10 @@ CommandEntry * getCommandEntryAndCheckArgcAndPermission(FILE * fp,
|
||||||
if(argArrayLength == 0) return NULL;
|
if(argArrayLength == 0) return NULL;
|
||||||
|
|
||||||
if(!findInList(commandList, argArray[0],(void *)&cmd)) {
|
if(!findInList(commandList, argArray[0],(void *)&cmd)) {
|
||||||
if(fp) commandError(fp, "unknown command \"%s\"", argArray[0]);
|
if(fp) {
|
||||||
|
commandError(fp, ACK_ERROR_UNKNOWN,
|
||||||
|
"unknown command \"%s\"", argArray[0]);
|
||||||
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,8 @@
|
||||||
|
|
||||||
#include "list.h"
|
#include "list.h"
|
||||||
#include "myfprintf.h"
|
#include "myfprintf.h"
|
||||||
|
#include "log.h"
|
||||||
|
#include "ack.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
@ -43,17 +45,18 @@ void finishCommands();
|
||||||
|
|
||||||
#define commandSuccess(fp) myfprintf(fp, "OK\n")
|
#define commandSuccess(fp) myfprintf(fp, "OK\n")
|
||||||
|
|
||||||
#define commandError(fp, format, ... ) \
|
#define commandError(fp, error, format, ... ) \
|
||||||
{\
|
{\
|
||||||
if(current_command) { \
|
if(current_command) { \
|
||||||
myfprintf(fp, "ACK [%s:%i] " format "\n", \
|
myfprintf(fp, "ACK [%s:%i:%i] " format "\n", \
|
||||||
current_command, command_listNum, \
|
current_command, command_listNum, \
|
||||||
##__VA_ARGS__); \
|
(int)error, ##__VA_ARGS__); \
|
||||||
current_command = NULL; \
|
current_command = NULL; \
|
||||||
} \
|
} \
|
||||||
else { \
|
else { \
|
||||||
myfprintf(fp, "ACK [:%i] " format "\n", \
|
myfprintf(fp, "ACK [:%i:%i] " format "\n", \
|
||||||
command_listNum, ##__VA_ARGS__); \
|
command_listNum, (int)error, \
|
||||||
|
##__VA_ARGS__); \
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -166,7 +166,7 @@ void readDirectoryDBIfUpdateIsFinished() {
|
||||||
|
|
||||||
int updateInit(FILE * fp, List * pathList) {
|
int updateInit(FILE * fp, List * pathList) {
|
||||||
if(directory_updatePid > 0) {
|
if(directory_updatePid > 0) {
|
||||||
commandError(fp, "already updating");
|
commandError(fp, ACK_ERROR_UPDATE_ALREADY, "already updating");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -223,7 +223,8 @@ int updateInit(FILE * fp, List * pathList) {
|
||||||
else if(directory_updatePid < 0) {
|
else if(directory_updatePid < 0) {
|
||||||
unblockSignals();
|
unblockSignals();
|
||||||
ERROR("updateInit: Problems forking()'ing\n");
|
ERROR("updateInit: Problems forking()'ing\n");
|
||||||
commandError(fp, "problems trying to update");
|
commandError(fp, ACK_ERROR_SYSTEM,
|
||||||
|
"problems trying to update");
|
||||||
directory_updatePid = 0;
|
directory_updatePid = 0;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -744,7 +745,7 @@ int printDirectoryInfo(FILE * fp, char * name) {
|
||||||
Directory * directory;
|
Directory * directory;
|
||||||
|
|
||||||
if((directory = getDirectory(name))==NULL) {
|
if((directory = getDirectory(name))==NULL) {
|
||||||
commandError(fp, "directory not found");
|
commandError(fp, ACK_ERROR_NO_EXIST, "directory not found");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -977,27 +978,25 @@ int readDirectoryDB() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int updateMp3Directory(FILE * fp) {
|
void updateMp3Directory() {
|
||||||
switch(updateDirectory(mp3rootDirectory)) {
|
switch(updateDirectory(mp3rootDirectory)) {
|
||||||
case 0:
|
case 0:
|
||||||
/* nothing updated */
|
/* nothing updated */
|
||||||
return 0;
|
return;
|
||||||
case 1:
|
case 1:
|
||||||
|
if(writeDirectoryDB()<0) {
|
||||||
|
ERROR("problems writing music db file, \"%s\"\n",
|
||||||
|
directory_db);
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
/* something was updated and db should be written */
|
/* something was updated and db should be written */
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ERROR("problems updating music db\n");
|
ERROR("problems updating music db\n");
|
||||||
commandError(fp, "problems updating music db");
|
exit(EXIT_FAILURE);
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(writeDirectoryDB()<0) {
|
return;
|
||||||
ERROR("problems writing music db file, \"%s\"\n",directory_db);
|
|
||||||
commandError(fp, "problems writing music db");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int traverseAllInSubDirectory(FILE * fp, Directory * directory,
|
int traverseAllInSubDirectory(FILE * fp, Directory * directory,
|
||||||
|
@ -1047,7 +1046,8 @@ int traverseAllIn(FILE * fp, char * name,
|
||||||
if((song = getSongFromDB(name)) && forEachSong) {
|
if((song = getSongFromDB(name)) && forEachSong) {
|
||||||
return forEachSong(fp, song, data);
|
return forEachSong(fp, song, data);
|
||||||
}
|
}
|
||||||
commandError(fp, "directory or file not found");
|
commandError(fp, ACK_ERROR_NO_EXIST,
|
||||||
|
"directory or file not found");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1129,7 +1129,7 @@ int searchForSongsIn(FILE * fp, char * name, char * item, char * string) {
|
||||||
ret = traverseAllIn(fp,name,searchForFilenameInDirectory,NULL,
|
ret = traverseAllIn(fp,name,searchForFilenameInDirectory,NULL,
|
||||||
(void *)dup);
|
(void *)dup);
|
||||||
}
|
}
|
||||||
else commandError(fp, "unknown table");
|
else commandError(fp, ACK_ERROR_ARG, "unknown table");
|
||||||
|
|
||||||
free(dup);
|
free(dup);
|
||||||
|
|
||||||
|
@ -1166,7 +1166,7 @@ int findSongsIn(FILE * fp, char * name, char * item, char * string) {
|
||||||
(void *)string);
|
(void *)string);
|
||||||
}
|
}
|
||||||
|
|
||||||
commandError(fp, "unknown table");
|
commandError(fp, ACK_ERROR_ARG, "unknown table");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ int writeDirectoryDB();
|
||||||
|
|
||||||
int readDirectoryDB();
|
int readDirectoryDB();
|
||||||
|
|
||||||
int updateMp3Directory(FILE * fp);
|
void updateMp3Directory();
|
||||||
|
|
||||||
int printAllIn(FILE * fp, char * name);
|
int printAllIn(FILE * fp, char * name);
|
||||||
|
|
||||||
|
|
|
@ -289,6 +289,7 @@ int interfaceReadInput(Interface * interface) {
|
||||||
==0)
|
==0)
|
||||||
{
|
{
|
||||||
commandError(interface->fp,
|
commandError(interface->fp,
|
||||||
|
ACK_ERROR_NOT_LIST,
|
||||||
"not in command list mode");
|
"not in command list mode");
|
||||||
ret = -1;
|
ret = -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -324,7 +324,7 @@ void openDB(Options * options, char * argv0) {
|
||||||
if(options->createDB) exit(EXIT_SUCCESS);
|
if(options->createDB) exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
if(options->updateDB) {
|
if(options->updateDB) {
|
||||||
if(updateMp3Directory(stderr)<0) exit(EXIT_FAILURE);
|
updateMp3Directory();
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -386,7 +386,8 @@ int playerSeek(FILE * fp, Song * song, float time) {
|
||||||
PlayerControl * pc = &(getPlayerData()->playerControl);
|
PlayerControl * pc = &(getPlayerData()->playerControl);
|
||||||
|
|
||||||
if(pc->state==PLAYER_STATE_STOP) {
|
if(pc->state==PLAYER_STATE_STOP) {
|
||||||
commandError(fp, "player not currently playing");
|
commandError(fp, ACK_ERROR_PLAYER_SYNC,
|
||||||
|
"player not currently playing");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -375,7 +375,8 @@ int playlistInfo(FILE * fp,int song) {
|
||||||
end = song+1;
|
end = song+1;
|
||||||
}
|
}
|
||||||
if(song>=playlist.length) {
|
if(song>=playlist.length) {
|
||||||
commandError(fp, "song doesn't exist: \"%i\"", song);
|
commandError(fp, ACK_ERROR_NO_EXIST,
|
||||||
|
"song doesn't exist: \"%i\"", song);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -486,7 +487,8 @@ int addToPlaylist(FILE * fp, char * url) {
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
commandError(fp, "\"%s\" is not in the music db or is"
|
commandError(fp, ACK_ERROR_NO_EXIST,
|
||||||
|
"\"%s\" is not in the music db or is"
|
||||||
"not a valid url\n", url);
|
"not a valid url\n", url);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -496,7 +498,8 @@ int addToPlaylist(FILE * fp, char * url) {
|
||||||
|
|
||||||
int addSongToPlaylist(FILE * fp, Song * song) {
|
int addSongToPlaylist(FILE * fp, Song * song) {
|
||||||
if(playlist.length==playlist_max_length) {
|
if(playlist.length==playlist_max_length) {
|
||||||
commandError(fp, "playlist is at the max size");
|
commandError(fp, ACK_ERROR_PLAYLIST_MAX,
|
||||||
|
"playlist is at the max size");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -535,11 +538,13 @@ int swapSongsInPlaylist(FILE * fp, int song1, int song2) {
|
||||||
int currentSong = -1;
|
int currentSong = -1;
|
||||||
|
|
||||||
if(song1<0 || song1>=playlist.length) {
|
if(song1<0 || song1>=playlist.length) {
|
||||||
commandError(fp, "song doesn't exist: \"%i\"", song1);
|
commandError(fp, ACK_ERROR_NO_EXIST,
|
||||||
|
"song doesn't exist: \"%i\"", song1);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if(song2<0 || song2>=playlist.length) {
|
if(song2<0 || song2>=playlist.length) {
|
||||||
commandError(fp, "song doesn't exist: \"%i\"", song2);
|
commandError(fp, ACK_ERROR_NO_EXIST,
|
||||||
|
"song doesn't exist: \"%i\"", song2);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -586,7 +591,8 @@ int deleteFromPlaylist(FILE * fp, int song) {
|
||||||
int songOrder;
|
int songOrder;
|
||||||
|
|
||||||
if(song<0 || song>=playlist.length) {
|
if(song<0 || song>=playlist.length) {
|
||||||
commandError(fp, "song doesn't exist: \"%i\"", song);
|
commandError(fp, ACK_ERROR_NO_EXIST,
|
||||||
|
"song doesn't exist: \"%i\"", song);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -710,7 +716,8 @@ int playPlaylist(FILE * fp, int song, int stopOnError) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(song<0 || song>=playlist.length) {
|
else if(song<0 || song>=playlist.length) {
|
||||||
commandError(fp, "song doesn't exist: \"%i\"", song);
|
commandError(fp, ACK_ERROR_NO_EXIST,
|
||||||
|
"song doesn't exist: \"%i\"", song);
|
||||||
playlist_state = PLAYLIST_STATE_STOP;
|
playlist_state = PLAYLIST_STATE_STOP;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -831,7 +838,7 @@ int getPlaylistRandomStatus() {
|
||||||
|
|
||||||
int setPlaylistRepeatStatus(FILE * fp, int status) {
|
int setPlaylistRepeatStatus(FILE * fp, int status) {
|
||||||
if(status!=0 && status!=1) {
|
if(status!=0 && status!=1) {
|
||||||
commandError(fp, "\"%i\" is not 0 or 1", status);
|
commandError(fp, ACK_ERROR_ARG, "\"%i\" is not 0 or 1", status);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -855,12 +862,14 @@ int moveSongInPlaylist(FILE * fp, int from, int to) {
|
||||||
int currentSong = -1;
|
int currentSong = -1;
|
||||||
|
|
||||||
if(from<0 || from>=playlist.length) {
|
if(from<0 || from>=playlist.length) {
|
||||||
commandError(fp, "song doesn't exist: \"%i\"", from);
|
commandError(fp, ACK_ERROR_NO_EXIST,
|
||||||
|
"song doesn't exist: \"%i\"", from);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(to<0 || to>=playlist.length) {
|
if(to<0 || to>=playlist.length) {
|
||||||
commandError(fp, "song doesn't exist: \"%i\"", to);
|
commandError(fp, ACK_ERROR_NO_EXIST,
|
||||||
|
"song doesn't exist: \"%i\"", to);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -966,7 +975,7 @@ int setPlaylistRandomStatus(FILE * fp, int status) {
|
||||||
int statusWas = playlist.random;
|
int statusWas = playlist.random;
|
||||||
|
|
||||||
if(status!=0 && status!=1) {
|
if(status!=0 && status!=1) {
|
||||||
commandError(fp, "\"%i\" is not 0 or 1", status);
|
commandError(fp, ACK_ERROR_ARG, "\"%i\" is not 0 or 1", status);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1060,12 +1069,14 @@ int deletePlaylist(FILE * fp, char * utf8file) {
|
||||||
if((actualFile = rpp2app(rfile)) && isPlaylist(actualFile)) free(rfile);
|
if((actualFile = rpp2app(rfile)) && isPlaylist(actualFile)) free(rfile);
|
||||||
else {
|
else {
|
||||||
free(rfile);
|
free(rfile);
|
||||||
commandError(fp, "playlist \"%s\" not found", utf8file);
|
commandError(fp, ACK_ERROR_NO_EXIST,
|
||||||
|
"playlist \"%s\" not found", utf8file);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(unlink(actualFile)<0) {
|
if(unlink(actualFile)<0) {
|
||||||
commandError(fp, "problems deleting file");
|
commandError(fp, ACK_ERROR_SYSTEM,
|
||||||
|
"problems deleting file");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1081,7 +1092,8 @@ int savePlaylist(FILE * fp, char * utf8file) {
|
||||||
char * actualFile;
|
char * actualFile;
|
||||||
|
|
||||||
if(strstr(utf8file,"/")) {
|
if(strstr(utf8file,"/")) {
|
||||||
commandError(fp, "cannot save \"%s\", saving playlists to "
|
commandError(fp, ACK_ERROR_ARG,
|
||||||
|
"cannot save \"%s\", saving playlists to "
|
||||||
"subdirectories is not supported", utf8file);
|
"subdirectories is not supported", utf8file);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -1109,7 +1121,7 @@ int savePlaylist(FILE * fp, char * utf8file) {
|
||||||
|
|
||||||
while(!(fileP = fopen(actualFile,"w")) && errno==EINTR);
|
while(!(fileP = fopen(actualFile,"w")) && errno==EINTR);
|
||||||
if(fileP==NULL) {
|
if(fileP==NULL) {
|
||||||
commandError(fp, "problems opening file");
|
commandError(fp, ACK_ERROR_SYSTEM, "problems opening file");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1151,13 +1163,15 @@ int loadPlaylist(FILE * fp, char * utf8file) {
|
||||||
if((actualFile = rpp2app(rfile)) && isPlaylist(actualFile)) free(rfile);
|
if((actualFile = rpp2app(rfile)) && isPlaylist(actualFile)) free(rfile);
|
||||||
else {
|
else {
|
||||||
free(rfile);
|
free(rfile);
|
||||||
commandError(fp, "playlist \"%s\" not found", utf8file);
|
commandError(fp, ACK_ERROR_NO_EXIST,
|
||||||
|
"playlist \"%s\" not found", utf8file);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
while(!(fileP = fopen(actualFile,"r")) && errno==EINTR);
|
while(!(fileP = fopen(actualFile,"r")) && errno==EINTR);
|
||||||
if(fileP==NULL) {
|
if(fileP==NULL) {
|
||||||
commandError(fp, "problems opening file \"%s\"", utf8file);
|
commandError(fp, ACK_ERROR_SYSTEM,
|
||||||
|
"problems opening file \"%s\"", utf8file);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1175,7 +1189,9 @@ int loadPlaylist(FILE * fp, char * utf8file) {
|
||||||
strncat(s,"/",MAXPATHLEN-parentlen);
|
strncat(s,"/",MAXPATHLEN-parentlen);
|
||||||
strncat(s,temp,MAXPATHLEN-parentlen-1);
|
strncat(s,temp,MAXPATHLEN-parentlen-1);
|
||||||
if(strlen(s)>=MAXPATHLEN) {
|
if(strlen(s)>=MAXPATHLEN) {
|
||||||
commandError(fp, "\"%s\" too long",
|
commandError(fp,
|
||||||
|
ACK_ERROR_PLAYLIST_LOAD,
|
||||||
|
"\"%s\" too long",
|
||||||
temp);
|
temp);
|
||||||
free(temp);
|
free(temp);
|
||||||
while(fclose(fileP) && errno==EINTR);
|
while(fclose(fileP) && errno==EINTR);
|
||||||
|
@ -1201,7 +1217,8 @@ int loadPlaylist(FILE * fp, char * utf8file) {
|
||||||
}
|
}
|
||||||
else if(slength==MAXPATHLEN) {
|
else if(slength==MAXPATHLEN) {
|
||||||
s[slength] = '\0';
|
s[slength] = '\0';
|
||||||
commandError(fp, "\"%s\" too long", s);
|
commandError(fp, ACK_ERROR_PLAYLIST_LOAD,
|
||||||
|
"\"%s\" too long", s);
|
||||||
while(fclose(fileP) && errno==EINTR);
|
while(fclose(fileP) && errno==EINTR);
|
||||||
if(erroredFile) free(erroredFile);
|
if(erroredFile) free(erroredFile);
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -1212,7 +1229,8 @@ int loadPlaylist(FILE * fp, char * utf8file) {
|
||||||
while(fclose(fileP) && errno==EINTR);
|
while(fclose(fileP) && errno==EINTR);
|
||||||
|
|
||||||
if(erroredFile) {
|
if(erroredFile) {
|
||||||
commandError(fp, "can't add file \"%s\"", erroredFile);
|
commandError(fp, ACK_ERROR_PLAYLIST_LOAD,
|
||||||
|
"can't add file \"%s\"", erroredFile);
|
||||||
free(erroredFile);
|
free(erroredFile);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -1240,7 +1258,8 @@ int seekSongInPlaylist(FILE * fp, int song, float time) {
|
||||||
int i = song;
|
int i = song;
|
||||||
|
|
||||||
if(song<0 || song>=playlist.length) {
|
if(song<0 || song>=playlist.length) {
|
||||||
commandError(fp, "song doesn't exist: \"%i\"", song);
|
commandError(fp, ACK_ERROR_NO_EXIST,
|
||||||
|
"song doesn't exist: \"%i\"", song);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1265,4 +1284,3 @@ int seekSongInPlaylist(FILE * fp, int song, float time) {
|
||||||
|
|
||||||
return playerSeek(fp, playlist.songs[playlist.order[i]], time);
|
return playerSeek(fp, playlist.songs[playlist.order[i]], time);
|
||||||
}
|
}
|
||||||
/* vim:set shiftwidth=4 tabstop=8 expandtab: */
|
|
||||||
|
|
|
@ -172,7 +172,8 @@ int printAllAlbums(FILE * fp, char * artist) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
commandError(fp, "artist \"%s\" not found", artist);
|
commandError(fp, ACK_ERROR_NO_EXIST,
|
||||||
|
"artist \"%s\" not found", artist);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -183,7 +184,8 @@ int printAllAlbums(FILE * fp, char * artist) {
|
||||||
int printAllKeysOfTable(FILE * fp, char * table, char * arg1) {
|
int printAllKeysOfTable(FILE * fp, char * table, char * arg1) {
|
||||||
if(strcmp(table,TABLES_ARTIST)==0) {
|
if(strcmp(table,TABLES_ARTIST)==0) {
|
||||||
if(arg1!=NULL) {
|
if(arg1!=NULL) {
|
||||||
commandError(fp, "%s table takes no args", table);
|
commandError(fp, ACK_ERROR_ARG,
|
||||||
|
"%s table takes no args", table);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return printAllArtists(fp);
|
return printAllArtists(fp);
|
||||||
|
@ -192,7 +194,7 @@ int printAllKeysOfTable(FILE * fp, char * table, char * arg1) {
|
||||||
return printAllAlbums(fp,arg1);
|
return printAllAlbums(fp,arg1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
commandError(fp, "table \"%s\" does not exist", table);
|
commandError(fp, ACK_ERROR_ARG, "unknown table", table);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
13
src/volume.c
13
src/volume.c
|
@ -144,7 +144,8 @@ int changeOssVolumeLevel(FILE * fp, int change, int rel) {
|
||||||
|
|
||||||
if (rel) {
|
if (rel) {
|
||||||
if((current = getOssVolumeLevel()) < 0) {
|
if((current = getOssVolumeLevel()) < 0) {
|
||||||
commandError(fp, "problem getting current volume");
|
commandError(fp, ACK_ERROR_SYSTEM,
|
||||||
|
"problem getting current volume");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,7 +159,7 @@ int changeOssVolumeLevel(FILE * fp, int change, int rel) {
|
||||||
level = (new << 8) + new;
|
level = (new << 8) + new;
|
||||||
|
|
||||||
if(ioctl(volume_ossFd,MIXER_WRITE(volume_ossControl),&level) < 0) {
|
if(ioctl(volume_ossFd,MIXER_WRITE(volume_ossControl),&level) < 0) {
|
||||||
commandError(fp, "problems setting volume");
|
commandError(fp, ACK_ERROR_SYSTEM, "problems setting volume");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -270,7 +271,7 @@ int changeAlsaVolumeLevel(FILE * fp, int change, int rel) {
|
||||||
|
|
||||||
if((err = snd_mixer_selem_get_playback_volume(volume_alsaElem,
|
if((err = snd_mixer_selem_get_playback_volume(volume_alsaElem,
|
||||||
SND_MIXER_SCHN_FRONT_LEFT,&level))<0) {
|
SND_MIXER_SCHN_FRONT_LEFT,&level))<0) {
|
||||||
commandError(fp, "problems getting volume");
|
commandError(fp, ACK_ERROR_SYSTEM, "problems getting volume");
|
||||||
ERROR("problems getting alsa volume: %s\n",snd_strerror(err));
|
ERROR("problems getting alsa volume: %s\n",snd_strerror(err));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -296,7 +297,7 @@ int changeAlsaVolumeLevel(FILE * fp, int change, int rel) {
|
||||||
|
|
||||||
if((err = snd_mixer_selem_set_playback_volume_all(
|
if((err = snd_mixer_selem_set_playback_volume_all(
|
||||||
volume_alsaElem,level))<0) {
|
volume_alsaElem,level))<0) {
|
||||||
commandError(fp, "problems setting volume");
|
commandError(fp, ACK_ERROR_SYSTEM, "problems setting volume");
|
||||||
ERROR("problems setting alsa volume: %s\n",snd_strerror(err));
|
ERROR("problems setting alsa volume: %s\n",snd_strerror(err));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -423,8 +424,8 @@ int changeVolumeLevel(FILE * fp, int change, int rel) {
|
||||||
case VOLUME_MIXER_TYPE_SOFTWARE:
|
case VOLUME_MIXER_TYPE_SOFTWARE:
|
||||||
return changeSoftwareVolume(fp,change,rel);
|
return changeSoftwareVolume(fp,change,rel);
|
||||||
default:
|
default:
|
||||||
commandError(fp, "no volume support");
|
return 0;
|
||||||
return -1;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* vim:set shiftwidth=4 tabstop=8 expandtab: */
|
/* vim:set shiftwidth=4 tabstop=8 expandtab: */
|
||||||
|
|
Loading…
Reference in New Issue