command.c: rerun mpd-indent.sh, no code changes
leave out initCommands to keep jat happy, and keep labels at the left hand side git-svn-id: https://svn.musicpd.org/mpd/trunk@4687 09075e82-0dd4-0310-85a5-a0d7c8717e4f
This commit is contained in:
parent
5b7c3c8707
commit
45f28394c0
212
src/command.c
212
src/command.c
@ -168,14 +168,12 @@ static void addCommand(char *name,
|
|||||||
insertInList(commandList, cmd->cmd, cmd);
|
insertInList(commandList, cmd->cmd, cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int handleUrlHandlers(int fd, int *permission, int argc,
|
static int handleUrlHandlers(int fd, int *permission, int argc, char *argv[])
|
||||||
char *argv[])
|
|
||||||
{
|
{
|
||||||
return printRemoteUrlHandlers(fd);
|
return printRemoteUrlHandlers(fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int handlePlay(int fd, int *permission, int argc,
|
static int handlePlay(int fd, int *permission, int argc, char *argv[])
|
||||||
char *argv[])
|
|
||||||
{
|
{
|
||||||
int song = -1;
|
int song = -1;
|
||||||
char *test;
|
char *test;
|
||||||
@ -191,8 +189,7 @@ static int handlePlay(int fd, int *permission, int argc,
|
|||||||
return playPlaylist(fd, song, 0);
|
return playPlaylist(fd, song, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int handlePlayId(int fd, int *permission, int argc,
|
static int handlePlayId(int fd, int *permission, int argc, char *argv[])
|
||||||
char *argv[])
|
|
||||||
{
|
{
|
||||||
int id = -1;
|
int id = -1;
|
||||||
char *test;
|
char *test;
|
||||||
@ -208,14 +205,12 @@ static int handlePlayId(int fd, int *permission, int argc,
|
|||||||
return playPlaylistById(fd, id, 0);
|
return playPlaylistById(fd, id, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int handleStop(int fd, int *permission, int argc,
|
static int handleStop(int fd, int *permission, int argc, char *argv[])
|
||||||
char *argv[])
|
|
||||||
{
|
{
|
||||||
return stopPlaylist(fd);
|
return stopPlaylist(fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int handleCurrentSong(int fd, int *permission, int argc,
|
static int handleCurrentSong(int fd, int *permission, int argc, char *argv[])
|
||||||
char *argv[])
|
|
||||||
{
|
{
|
||||||
int song = getPlaylistCurrentSong();
|
int song = getPlaylistCurrentSong();
|
||||||
|
|
||||||
@ -225,8 +220,7 @@ static int handleCurrentSong(int fd, int *permission, int argc,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int handlePause(int fd, int *permission,
|
static int handlePause(int fd, int *permission, int argc, char *argv[])
|
||||||
int argc, char *argv[])
|
|
||||||
{
|
{
|
||||||
if (argc == 2) {
|
if (argc == 2) {
|
||||||
char *test;
|
char *test;
|
||||||
@ -241,8 +235,7 @@ static int handlePause(int fd, int *permission,
|
|||||||
return playerPause(fd);
|
return playerPause(fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int commandStatus(int fd, int *permission, int argc,
|
static int commandStatus(int fd, int *permission, int argc, char *argv[])
|
||||||
char *argv[])
|
|
||||||
{
|
{
|
||||||
char *state = NULL;
|
char *state = NULL;
|
||||||
int updateJobId;
|
int updateJobId;
|
||||||
@ -264,15 +257,15 @@ static int commandStatus(int fd, int *permission, int argc,
|
|||||||
|
|
||||||
fdprintf(fd, "%s: %i\n", COMMAND_STATUS_VOLUME, getVolumeLevel());
|
fdprintf(fd, "%s: %i\n", COMMAND_STATUS_VOLUME, getVolumeLevel());
|
||||||
fdprintf(fd, "%s: %i\n", COMMAND_STATUS_REPEAT,
|
fdprintf(fd, "%s: %i\n", COMMAND_STATUS_REPEAT,
|
||||||
getPlaylistRepeatStatus());
|
getPlaylistRepeatStatus());
|
||||||
fdprintf(fd, "%s: %i\n", COMMAND_STATUS_RANDOM,
|
fdprintf(fd, "%s: %i\n", COMMAND_STATUS_RANDOM,
|
||||||
getPlaylistRandomStatus());
|
getPlaylistRandomStatus());
|
||||||
fdprintf(fd, "%s: %li\n", COMMAND_STATUS_PLAYLIST,
|
fdprintf(fd, "%s: %li\n", COMMAND_STATUS_PLAYLIST,
|
||||||
getPlaylistVersion());
|
getPlaylistVersion());
|
||||||
fdprintf(fd, "%s: %i\n", COMMAND_STATUS_PLAYLIST_LENGTH,
|
fdprintf(fd, "%s: %i\n", COMMAND_STATUS_PLAYLIST_LENGTH,
|
||||||
getPlaylistLength());
|
getPlaylistLength());
|
||||||
fdprintf(fd, "%s: %i\n", COMMAND_STATUS_CROSSFADE,
|
fdprintf(fd, "%s: %i\n", COMMAND_STATUS_CROSSFADE,
|
||||||
(int)(getPlayerCrossFade() + 0.5));
|
(int)(getPlayerCrossFade() + 0.5));
|
||||||
|
|
||||||
fdprintf(fd, "%s: %s\n", COMMAND_STATUS_STATE, state);
|
fdprintf(fd, "%s: %s\n", COMMAND_STATUS_STATE, state);
|
||||||
|
|
||||||
@ -280,45 +273,42 @@ static int commandStatus(int fd, int *permission, int argc,
|
|||||||
if (song >= 0) {
|
if (song >= 0) {
|
||||||
fdprintf(fd, "%s: %i\n", COMMAND_STATUS_SONG, song);
|
fdprintf(fd, "%s: %i\n", COMMAND_STATUS_SONG, song);
|
||||||
fdprintf(fd, "%s: %i\n", COMMAND_STATUS_SONGID,
|
fdprintf(fd, "%s: %i\n", COMMAND_STATUS_SONGID,
|
||||||
getPlaylistSongId(song));
|
getPlaylistSongId(song));
|
||||||
}
|
}
|
||||||
if (getPlayerState() != PLAYER_STATE_STOP) {
|
if (getPlayerState() != PLAYER_STATE_STOP) {
|
||||||
fdprintf(fd, "%s: %i:%i\n", COMMAND_STATUS_TIME,
|
fdprintf(fd, "%s: %i:%i\n", COMMAND_STATUS_TIME,
|
||||||
getPlayerElapsedTime(), getPlayerTotalTime());
|
getPlayerElapsedTime(), getPlayerTotalTime());
|
||||||
fdprintf(fd, "%s: %li\n", COMMAND_STATUS_BITRATE,
|
fdprintf(fd, "%s: %li\n", COMMAND_STATUS_BITRATE,
|
||||||
getPlayerBitRate());
|
getPlayerBitRate());
|
||||||
fdprintf(fd, "%s: %u:%i:%i\n", COMMAND_STATUS_AUDIO,
|
fdprintf(fd, "%s: %u:%i:%i\n", COMMAND_STATUS_AUDIO,
|
||||||
getPlayerSampleRate(), getPlayerBits(),
|
getPlayerSampleRate(), getPlayerBits(),
|
||||||
getPlayerChannels());
|
getPlayerChannels());
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((updateJobId = isUpdatingDB())) {
|
if ((updateJobId = isUpdatingDB())) {
|
||||||
fdprintf(fd, "%s: %i\n", COMMAND_STATUS_UPDATING_DB,
|
fdprintf(fd, "%s: %i\n", COMMAND_STATUS_UPDATING_DB,
|
||||||
updateJobId);
|
updateJobId);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getPlayerError() != PLAYER_ERROR_NOERROR) {
|
if (getPlayerError() != PLAYER_ERROR_NOERROR) {
|
||||||
fdprintf(fd, "%s: %s\n", COMMAND_STATUS_ERROR,
|
fdprintf(fd, "%s: %s\n", COMMAND_STATUS_ERROR,
|
||||||
getPlayerErrorStr());
|
getPlayerErrorStr());
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int handleKill(int fd, int *permission, int argc,
|
static int handleKill(int fd, int *permission, int argc, char *argv[])
|
||||||
char *argv[])
|
|
||||||
{
|
{
|
||||||
return COMMAND_RETURN_KILL;
|
return COMMAND_RETURN_KILL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int handleClose(int fd, int *permission, int argc,
|
static int handleClose(int fd, int *permission, int argc, char *argv[])
|
||||||
char *argv[])
|
|
||||||
{
|
{
|
||||||
return COMMAND_RETURN_CLOSE;
|
return COMMAND_RETURN_CLOSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int handleAdd(int fd, int *permission, int argc,
|
static int handleAdd(int fd, int *permission, int argc, char *argv[])
|
||||||
char *argv[])
|
|
||||||
{
|
{
|
||||||
char *path = argv[1];
|
char *path = argv[1];
|
||||||
|
|
||||||
@ -328,74 +318,63 @@ static int handleAdd(int fd, int *permission, int argc,
|
|||||||
return addAllIn(fd, path);
|
return addAllIn(fd, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int handleAddId(int fd, int *permission, int argc,
|
static int handleAddId(int fd, int *permission, int argc, char *argv[])
|
||||||
char *argv[])
|
|
||||||
{
|
{
|
||||||
return addToPlaylist(fd, argv[1], 1);
|
return addToPlaylist(fd, argv[1], 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int handleDelete(int fd, int *permission, int argc,
|
static int handleDelete(int fd, int *permission, int argc, char *argv[])
|
||||||
char *argv[])
|
|
||||||
{
|
{
|
||||||
int song;
|
int song;
|
||||||
char *test;
|
char *test;
|
||||||
|
|
||||||
song = strtol(argv[1], &test, 10);
|
song = strtol(argv[1], &test, 10);
|
||||||
if (*test != '\0') {
|
if (*test != '\0') {
|
||||||
commandError(fd, ACK_ERROR_ARG,
|
commandError(fd, ACK_ERROR_ARG, "need a positive integer");
|
||||||
"need a positive integer");
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return deleteFromPlaylist(fd, song);
|
return deleteFromPlaylist(fd, song);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int handleDeleteId(int fd, int *permission, int argc,
|
static int handleDeleteId(int fd, int *permission, int argc, char *argv[])
|
||||||
char *argv[])
|
|
||||||
{
|
{
|
||||||
int id;
|
int id;
|
||||||
char *test;
|
char *test;
|
||||||
|
|
||||||
id = strtol(argv[1], &test, 10);
|
id = strtol(argv[1], &test, 10);
|
||||||
if (*test != '\0') {
|
if (*test != '\0') {
|
||||||
commandError(fd, ACK_ERROR_ARG,
|
commandError(fd, ACK_ERROR_ARG, "need a positive integer");
|
||||||
"need a positive integer");
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return deleteFromPlaylistById(fd, id);
|
return deleteFromPlaylistById(fd, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int handlePlaylist(int fd, int *permission, int argc,
|
static int handlePlaylist(int fd, int *permission, int argc, char *argv[])
|
||||||
char *argv[])
|
|
||||||
{
|
{
|
||||||
return showPlaylist(fd);
|
return showPlaylist(fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int handleShuffle(int fd, int *permission, int argc,
|
static int handleShuffle(int fd, int *permission, int argc, char *argv[])
|
||||||
char *argv[])
|
|
||||||
{
|
{
|
||||||
return shufflePlaylist(fd);
|
return shufflePlaylist(fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int handleClear(int fd, int *permission, int argc,
|
static int handleClear(int fd, int *permission, int argc, char *argv[])
|
||||||
char *argv[])
|
|
||||||
{
|
{
|
||||||
return clearPlaylist(fd);
|
return clearPlaylist(fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int handleSave(int fd, int *permission, int argc,
|
static int handleSave(int fd, int *permission, int argc, char *argv[])
|
||||||
char *argv[])
|
|
||||||
{
|
{
|
||||||
return savePlaylist(fd, argv[1]);
|
return savePlaylist(fd, argv[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int handleLoad(int fd, int *permission, int argc,
|
static int handleLoad(int fd, int *permission, int argc, char *argv[])
|
||||||
char *argv[])
|
|
||||||
{
|
{
|
||||||
return loadPlaylist(fd, argv[1]);
|
return loadPlaylist(fd, argv[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int handleListPlaylist(int fd, int *permission, int argc,
|
static int handleListPlaylist(int fd, int *permission, int argc, char *argv[])
|
||||||
char *argv[])
|
|
||||||
{
|
{
|
||||||
return PlaylistInfo(fd, argv[1], 0);
|
return PlaylistInfo(fd, argv[1], 0);
|
||||||
}
|
}
|
||||||
@ -406,8 +385,7 @@ static int handleListPlaylistInfo(int fd, int *permission,
|
|||||||
return PlaylistInfo(fd, argv[1], 1);
|
return PlaylistInfo(fd, argv[1], 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int handleLsInfo(int fd, int *permission, int argc,
|
static int handleLsInfo(int fd, int *permission, int argc, char *argv[])
|
||||||
char *argv[])
|
|
||||||
{
|
{
|
||||||
if (argc == 1) {
|
if (argc == 1) {
|
||||||
if (printDirectoryInfo(fd, NULL) < 0)
|
if (printDirectoryInfo(fd, NULL) < 0)
|
||||||
@ -422,8 +400,7 @@ static int handleLsInfo(int fd, int *permission, int argc,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int handleRm(int fd, int *permission, int argc,
|
static int handleRm(int fd, int *permission, int argc, char *argv[])
|
||||||
char *argv[])
|
|
||||||
{
|
{
|
||||||
return deletePlaylist(fd, argv[1]);
|
return deletePlaylist(fd, argv[1]);
|
||||||
}
|
}
|
||||||
@ -456,8 +433,7 @@ static int handlePlaylistChangesPosId(int fd, int *permission,
|
|||||||
return playlistChangesPosId(fd, version);
|
return playlistChangesPosId(fd, version);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int handlePlaylistInfo(int fd, int *permission,
|
static int handlePlaylistInfo(int fd, int *permission, int argc, char *argv[])
|
||||||
int argc, char *argv[])
|
|
||||||
{
|
{
|
||||||
int song = -1;
|
int song = -1;
|
||||||
char *test;
|
char *test;
|
||||||
@ -473,8 +449,7 @@ static int handlePlaylistInfo(int fd, int *permission,
|
|||||||
return playlistInfo(fd, song);
|
return playlistInfo(fd, song);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int handlePlaylistId(int fd, int *permission,
|
static int handlePlaylistId(int fd, int *permission, int argc, char *argv[])
|
||||||
int argc, char *argv[])
|
|
||||||
{
|
{
|
||||||
int id = -1;
|
int id = -1;
|
||||||
char *test;
|
char *test;
|
||||||
@ -490,8 +465,7 @@ static int handlePlaylistId(int fd, int *permission,
|
|||||||
return playlistId(fd, id);
|
return playlistId(fd, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int handleFind(int fd, int *permission, int argc,
|
static int handleFind(int fd, int *permission, int argc, char *argv[])
|
||||||
char *argv[])
|
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
@ -512,8 +486,7 @@ static int handleFind(int fd, int *permission, int argc,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int handleSearch(int fd, int *permission, int argc,
|
static int handleSearch(int fd, int *permission, int argc, char *argv[])
|
||||||
char *argv[])
|
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
@ -538,7 +511,7 @@ static int listHandleUpdate(int fd,
|
|||||||
int *permission,
|
int *permission,
|
||||||
int argc,
|
int argc,
|
||||||
char *argv[],
|
char *argv[],
|
||||||
struct strnode *cmdnode, CommandEntry *cmd)
|
struct strnode *cmdnode, CommandEntry * cmd)
|
||||||
{
|
{
|
||||||
static List *pathList = NULL;
|
static List *pathList = NULL;
|
||||||
CommandEntry *nextCmd = NULL;
|
CommandEntry *nextCmd = NULL;
|
||||||
@ -552,7 +525,7 @@ static int listHandleUpdate(int fd,
|
|||||||
else
|
else
|
||||||
insertInList(pathList, "", NULL);
|
insertInList(pathList, "", NULL);
|
||||||
|
|
||||||
if(next)
|
if (next)
|
||||||
nextCmd = getCommandEntryFromString(next->data, permission);
|
nextCmd = getCommandEntryFromString(next->data, permission);
|
||||||
|
|
||||||
if (cmd != nextCmd) {
|
if (cmd != nextCmd) {
|
||||||
@ -565,8 +538,7 @@ static int listHandleUpdate(int fd,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int handleUpdate(int fd, int *permission, int argc,
|
static int handleUpdate(int fd, int *permission, int argc, char *argv[])
|
||||||
char *argv[])
|
|
||||||
{
|
{
|
||||||
if (argc == 2) {
|
if (argc == 2) {
|
||||||
int ret;
|
int ret;
|
||||||
@ -579,20 +551,17 @@ static int handleUpdate(int fd, int *permission, int argc,
|
|||||||
return updateInit(fd, NULL);
|
return updateInit(fd, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int handleNext(int fd, int *permission, int argc,
|
static int handleNext(int fd, int *permission, int argc, char *argv[])
|
||||||
char *argv[])
|
|
||||||
{
|
{
|
||||||
return nextSongInPlaylist(fd);
|
return nextSongInPlaylist(fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int handlePrevious(int fd, int *permission, int argc,
|
static int handlePrevious(int fd, int *permission, int argc, char *argv[])
|
||||||
char *argv[])
|
|
||||||
{
|
{
|
||||||
return previousSongInPlaylist(fd);
|
return previousSongInPlaylist(fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int handleListAll(int fd, int *permission, int argc,
|
static int handleListAll(int fd, int *permission, int argc, char *argv[])
|
||||||
char *argv[])
|
|
||||||
{
|
{
|
||||||
char *directory = NULL;
|
char *directory = NULL;
|
||||||
|
|
||||||
@ -601,8 +570,7 @@ static int handleListAll(int fd, int *permission, int argc,
|
|||||||
return printAllIn(fd, directory);
|
return printAllIn(fd, directory);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int handleVolume(int fd, int *permission, int argc,
|
static int handleVolume(int fd, int *permission, int argc, char *argv[])
|
||||||
char *argv[])
|
|
||||||
{
|
{
|
||||||
int change;
|
int change;
|
||||||
char *test;
|
char *test;
|
||||||
@ -615,8 +583,7 @@ static int handleVolume(int fd, int *permission, int argc,
|
|||||||
return changeVolumeLevel(fd, change, 1);
|
return changeVolumeLevel(fd, change, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int handleSetVol(int fd, int *permission, int argc,
|
static int handleSetVol(int fd, int *permission, int argc, char *argv[])
|
||||||
char *argv[])
|
|
||||||
{
|
{
|
||||||
int level;
|
int level;
|
||||||
char *test;
|
char *test;
|
||||||
@ -629,8 +596,7 @@ static int handleSetVol(int fd, int *permission, int argc,
|
|||||||
return changeVolumeLevel(fd, level, 0);
|
return changeVolumeLevel(fd, level, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int handleRepeat(int fd, int *permission, int argc,
|
static int handleRepeat(int fd, int *permission, int argc, char *argv[])
|
||||||
char *argv[])
|
|
||||||
{
|
{
|
||||||
int status;
|
int status;
|
||||||
char *test;
|
char *test;
|
||||||
@ -643,8 +609,7 @@ static int handleRepeat(int fd, int *permission, int argc,
|
|||||||
return setPlaylistRepeatStatus(fd, status);
|
return setPlaylistRepeatStatus(fd, status);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int handleRandom(int fd, int *permission, int argc,
|
static int handleRandom(int fd, int *permission, int argc, char *argv[])
|
||||||
char *argv[])
|
|
||||||
{
|
{
|
||||||
int status;
|
int status;
|
||||||
char *test;
|
char *test;
|
||||||
@ -657,21 +622,18 @@ static int handleRandom(int fd, int *permission, int argc,
|
|||||||
return setPlaylistRandomStatus(fd, status);
|
return setPlaylistRandomStatus(fd, status);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int handleStats(int fd, int *permission, int argc,
|
static int handleStats(int fd, int *permission, int argc, char *argv[])
|
||||||
char *argv[])
|
|
||||||
{
|
{
|
||||||
return printStats(fd);
|
return printStats(fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int handleClearError(int fd, int *permission, int argc,
|
static int handleClearError(int fd, int *permission, int argc, char *argv[])
|
||||||
char *argv[])
|
|
||||||
{
|
{
|
||||||
clearPlayerError();
|
clearPlayerError();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int handleList(int fd, int *permission, int argc,
|
static int handleList(int fd, int *permission, int argc, char *argv[])
|
||||||
char *argv[])
|
|
||||||
{
|
{
|
||||||
int numConditionals = 0;
|
int numConditionals = 0;
|
||||||
LocateTagItem *conditionals = NULL;
|
LocateTagItem *conditionals = NULL;
|
||||||
@ -679,8 +641,7 @@ static int handleList(int fd, int *permission, int argc,
|
|||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (tagType < 0) {
|
if (tagType < 0) {
|
||||||
commandError(fd, ACK_ERROR_ARG,
|
commandError(fd, ACK_ERROR_ARG, "\"%s\" is not known", argv[1]);
|
||||||
"\"%s\" is not known", argv[1]);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -698,8 +659,7 @@ static int handleList(int fd, int *permission, int argc,
|
|||||||
} else {
|
} else {
|
||||||
numConditionals =
|
numConditionals =
|
||||||
newLocateTagItemArrayFromArgArray(argv + 2,
|
newLocateTagItemArrayFromArgArray(argv + 2,
|
||||||
argc - 2,
|
argc - 2, &conditionals);
|
||||||
&conditionals);
|
|
||||||
|
|
||||||
if (numConditionals < 0) {
|
if (numConditionals < 0) {
|
||||||
commandError(fd, ACK_ERROR_ARG,
|
commandError(fd, ACK_ERROR_ARG,
|
||||||
@ -716,8 +676,7 @@ static int handleList(int fd, int *permission, int argc,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int handleMove(int fd, int *permission, int argc,
|
static int handleMove(int fd, int *permission, int argc, char *argv[])
|
||||||
char *argv[])
|
|
||||||
{
|
{
|
||||||
int from;
|
int from;
|
||||||
int to;
|
int to;
|
||||||
@ -738,8 +697,7 @@ static int handleMove(int fd, int *permission, int argc,
|
|||||||
return moveSongInPlaylist(fd, from, to);
|
return moveSongInPlaylist(fd, from, to);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int handleMoveId(int fd, int *permission, int argc,
|
static int handleMoveId(int fd, int *permission, int argc, char *argv[])
|
||||||
char *argv[])
|
|
||||||
{
|
{
|
||||||
int id;
|
int id;
|
||||||
int to;
|
int to;
|
||||||
@ -760,8 +718,7 @@ static int handleMoveId(int fd, int *permission, int argc,
|
|||||||
return moveSongInPlaylistById(fd, id, to);
|
return moveSongInPlaylistById(fd, id, to);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int handleSwap(int fd, int *permission, int argc,
|
static int handleSwap(int fd, int *permission, int argc, char *argv[])
|
||||||
char *argv[])
|
|
||||||
{
|
{
|
||||||
int song1;
|
int song1;
|
||||||
int song2;
|
int song2;
|
||||||
@ -782,8 +739,7 @@ static int handleSwap(int fd, int *permission, int argc,
|
|||||||
return swapSongsInPlaylist(fd, song1, song2);
|
return swapSongsInPlaylist(fd, song1, song2);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int handleSwapId(int fd, int *permission, int argc,
|
static int handleSwapId(int fd, int *permission, int argc, char *argv[])
|
||||||
char *argv[])
|
|
||||||
{
|
{
|
||||||
int id1;
|
int id1;
|
||||||
int id2;
|
int id2;
|
||||||
@ -804,8 +760,7 @@ static int handleSwapId(int fd, int *permission, int argc,
|
|||||||
return swapSongsInPlaylistById(fd, id1, id2);
|
return swapSongsInPlaylistById(fd, id1, id2);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int handleSeek(int fd, int *permission, int argc,
|
static int handleSeek(int fd, int *permission, int argc, char *argv[])
|
||||||
char *argv[])
|
|
||||||
{
|
{
|
||||||
int song;
|
int song;
|
||||||
int time;
|
int time;
|
||||||
@ -826,8 +781,7 @@ static int handleSeek(int fd, int *permission, int argc,
|
|||||||
return seekSongInPlaylist(fd, song, time);
|
return seekSongInPlaylist(fd, song, time);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int handleSeekId(int fd, int *permission, int argc,
|
static int handleSeekId(int fd, int *permission, int argc, char *argv[])
|
||||||
char *argv[])
|
|
||||||
{
|
{
|
||||||
int id;
|
int id;
|
||||||
int time;
|
int time;
|
||||||
@ -848,8 +802,7 @@ static int handleSeekId(int fd, int *permission, int argc,
|
|||||||
return seekSongInPlaylistById(fd, id, time);
|
return seekSongInPlaylistById(fd, id, time);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int handleListAllInfo(int fd, int *permission, int argc,
|
static int handleListAllInfo(int fd, int *permission, int argc, char *argv[])
|
||||||
char *argv[])
|
|
||||||
{
|
{
|
||||||
char *directory = NULL;
|
char *directory = NULL;
|
||||||
|
|
||||||
@ -858,14 +811,12 @@ static int handleListAllInfo(int fd, int *permission, int argc,
|
|||||||
return printInfoForAllIn(fd, directory);
|
return printInfoForAllIn(fd, directory);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int handlePing(int fd, int *permission, int argc,
|
static int handlePing(int fd, int *permission, int argc, char *argv[])
|
||||||
char *argv[])
|
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int handlePassword(int fd, int *permission, int argc,
|
static int handlePassword(int fd, int *permission, int argc, char *argv[])
|
||||||
char *argv[])
|
|
||||||
{
|
{
|
||||||
if (getPermissionFromPassword(argv[1], permission) < 0) {
|
if (getPermissionFromPassword(argv[1], permission) < 0) {
|
||||||
commandError(fd, ACK_ERROR_PASSWORD, "incorrect password");
|
commandError(fd, ACK_ERROR_PASSWORD, "incorrect password");
|
||||||
@ -875,8 +826,7 @@ static int handlePassword(int fd, int *permission, int argc,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int handleCrossfade(int fd, int *permission, int argc,
|
static int handleCrossfade(int fd, int *permission, int argc, char *argv[])
|
||||||
char *argv[])
|
|
||||||
{
|
{
|
||||||
int time;
|
int time;
|
||||||
char *test;
|
char *test;
|
||||||
@ -893,8 +843,7 @@ static int handleCrossfade(int fd, int *permission, int argc,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int handleEnableDevice(int fd, int *permission, int argc,
|
static int handleEnableDevice(int fd, int *permission, int argc, char *argv[])
|
||||||
char *argv[])
|
|
||||||
{
|
{
|
||||||
int device;
|
int device;
|
||||||
char *test;
|
char *test;
|
||||||
@ -909,8 +858,7 @@ static int handleEnableDevice(int fd, int *permission, int argc,
|
|||||||
return enableAudioDevice(fd, device);
|
return enableAudioDevice(fd, device);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int handleDisableDevice(int fd, int *permission,
|
static int handleDisableDevice(int fd, int *permission, int argc, char *argv[])
|
||||||
int argc, char *argv[])
|
|
||||||
{
|
{
|
||||||
int device;
|
int device;
|
||||||
char *test;
|
char *test;
|
||||||
@ -925,8 +873,7 @@ static int handleDisableDevice(int fd, int *permission,
|
|||||||
return disableAudioDevice(fd, device);
|
return disableAudioDevice(fd, device);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int handleDevices(int fd, int *permission, int argc,
|
static int handleDevices(int fd, int *permission, int argc, char *argv[])
|
||||||
char *argv[])
|
|
||||||
{
|
{
|
||||||
printAudioDevices(fd);
|
printAudioDevices(fd);
|
||||||
|
|
||||||
@ -934,8 +881,7 @@ static int handleDevices(int fd, int *permission, int argc,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* don't be fooled, this is the command handler for "commands" command */
|
/* don't be fooled, this is the command handler for "commands" command */
|
||||||
static int handleCommands(int fd, int *permission, int argc,
|
static int handleCommands(int fd, int *permission, int argc, char *argv[])
|
||||||
char *argv[])
|
|
||||||
{
|
{
|
||||||
ListNode *node = commandList->firstNode;
|
ListNode *node = commandList->firstNode;
|
||||||
CommandEntry *cmd;
|
CommandEntry *cmd;
|
||||||
@ -952,8 +898,7 @@ static int handleCommands(int fd, int *permission, int argc,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int handleNotcommands(int fd, int *permission, int argc,
|
static int handleNotcommands(int fd, int *permission, int argc, char *argv[])
|
||||||
char *argv[])
|
|
||||||
{
|
{
|
||||||
ListNode *node = commandList->firstNode;
|
ListNode *node = commandList->firstNode;
|
||||||
CommandEntry *cmd;
|
CommandEntry *cmd;
|
||||||
@ -1067,15 +1012,13 @@ static int checkArgcAndPermission(CommandEntry * cmd, int fd,
|
|||||||
} else if (argc < min) {
|
} else if (argc < min) {
|
||||||
if (fd) {
|
if (fd) {
|
||||||
commandError(fd, ACK_ERROR_ARG,
|
commandError(fd, ACK_ERROR_ARG,
|
||||||
"too few arguments for \"%s\"",
|
"too few arguments for \"%s\"", argv[0]);
|
||||||
argv[0]);
|
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
} else if (argc > max && max /* != 0 */ ) {
|
} else if (argc > max && max /* != 0 */ ) {
|
||||||
if (fd) {
|
if (fd) {
|
||||||
commandError(fd, ACK_ERROR_ARG,
|
commandError(fd, ACK_ERROR_ARG,
|
||||||
"too many arguments for \"%s\"",
|
"too many arguments for \"%s\"", argv[0]);
|
||||||
argv[0]);
|
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
} else
|
} else
|
||||||
@ -1105,8 +1048,7 @@ static CommandEntry *getCommandEntryAndCheckArgcAndPermission(int fd,
|
|||||||
|
|
||||||
current_command = cmd->cmd;
|
current_command = cmd->cmd;
|
||||||
|
|
||||||
if (checkArgcAndPermission(cmd, fd, *permission, argc,
|
if (checkArgcAndPermission(cmd, fd, *permission, argc, argv) < 0) {
|
||||||
argv) < 0) {
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1147,7 +1089,7 @@ static int processCommandInternal(int fd, int *permission,
|
|||||||
ret = cmd->handler(fd, permission, argc, argv);
|
ret = cmd->handler(fd, permission, argc, argv);
|
||||||
} else {
|
} else {
|
||||||
ret = cmd->listHandler(fd, permission, argc, argv,
|
ret = cmd->listHandler(fd, permission, argc, argv,
|
||||||
cmdnode, cmd);
|
cmdnode, cmd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1193,15 +1135,13 @@ mpd_fprintf_ void commandError(int fd, int error, const char *fmt, ...)
|
|||||||
|
|
||||||
if (current_command) {
|
if (current_command) {
|
||||||
fdprintf(fd, "ACK [%i@%i] {%s} ",
|
fdprintf(fd, "ACK [%i@%i] {%s} ",
|
||||||
(int)error, command_listNum, current_command);
|
(int)error, command_listNum, current_command);
|
||||||
current_command = NULL;
|
current_command = NULL;
|
||||||
} else
|
} else
|
||||||
fdprintf(STDERR_FILENO, "ACK [%i@%i] ",
|
fdprintf(STDERR_FILENO, "ACK [%i@%i] ",
|
||||||
(int)error, command_listNum);
|
(int)error, command_listNum);
|
||||||
|
|
||||||
vfdprintf(fd, fmt, args);
|
vfdprintf(fd, fmt, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
fdprintf(fd,"\n");
|
fdprintf(fd, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user