Commit 51a6ee88 authored by Max Kellermann's avatar Max Kellermann

command: no CamelCase

Eliminate CamelCase in all public and static functions.
parent 69c563b5
...@@ -335,9 +335,9 @@ static int client_process_line(struct client *client, char *line) ...@@ -335,9 +335,9 @@ static int client_process_line(struct client *client, char *line)
if (strcmp(line, CLIENT_LIST_MODE_END) == 0) { if (strcmp(line, CLIENT_LIST_MODE_END) == 0) {
DEBUG("client %i: process command " DEBUG("client %i: process command "
"list\n", client->num); "list\n", client->num);
ret = processListOfCommands(client, ret = command_process_list(client,
client->cmd_list_OK, client->cmd_list_OK,
client->cmd_list); client->cmd_list);
DEBUG("client %i: process command " DEBUG("client %i: process command "
"list returned %i\n", client->num, ret); "list returned %i\n", client->num, ret);
...@@ -379,7 +379,7 @@ static int client_process_line(struct client *client, char *line) ...@@ -379,7 +379,7 @@ static int client_process_line(struct client *client, char *line)
} else { } else {
DEBUG("client %i: process command \"%s\"\n", DEBUG("client %i: process command \"%s\"\n",
client->num, line); client->num, line);
ret = processCommand(client, line); ret = command_process(client, line);
DEBUG("client %i: command returned %i\n", DEBUG("client %i: command returned %i\n",
client->num, ret); client->num, ret);
......
...@@ -67,7 +67,7 @@ ...@@ -67,7 +67,7 @@
* if max: -1 no max args */ * if max: -1 no max args */
struct command { struct command {
const char *cmd; const char *cmd;
unsigned reqPermission; unsigned permission;
int min; int min;
int max; int max;
int (*handler)(struct client *client, int argc, char **argv); int (*handler)(struct client *client, int argc, char **argv);
...@@ -83,7 +83,7 @@ static const char check_boolean[] = "\"%s\" is not 0 or 1"; ...@@ -83,7 +83,7 @@ static const char check_boolean[] = "\"%s\" is not 0 or 1";
static const char check_non_negative[] = "\"%s\" is not an integer >= 0"; static const char check_non_negative[] = "\"%s\" is not an integer >= 0";
static const char *current_command; static const char *current_command;
static int command_listNum; static int command_list_num;
void command_success(struct client *client) void command_success(struct client *client)
{ {
...@@ -97,7 +97,7 @@ static void command_error_v(struct client *client, enum ack error, ...@@ -97,7 +97,7 @@ static void command_error_v(struct client *client, enum ack error,
assert(current_command != NULL); assert(current_command != NULL);
client_printf(client, "ACK [%i@%i] {%s} ", client_printf(client, "ACK [%i@%i] {%s} ",
(int)error, command_listNum, current_command); (int)error, command_list_num, current_command);
client_vprintf(client, fmt, args); client_vprintf(client, fmt, args);
client_puts(client, "\n"); client_puts(client, "\n");
...@@ -219,23 +219,25 @@ print_spl_list(struct client *client, GPtrArray *list) ...@@ -219,23 +219,25 @@ print_spl_list(struct client *client, GPtrArray *list)
} }
} }
static int handleUrlHandlers(struct client *client, static int
mpd_unused int argc, mpd_unused char *argv[]) handle_urlhandlers(struct client *client,
mpd_unused int argc, mpd_unused char *argv[])
{ {
if (client_get_uid(client) > 0) if (client_get_uid(client) > 0)
client_puts(client, "handler: file://\n"); client_puts(client, "handler: file://\n");
return printRemoteUrlHandlers(client); return printRemoteUrlHandlers(client);
} }
static int handleTagTypes(struct client *client, static int
mpd_unused int argc, mpd_unused char *argv[]) handle_tagtypes(struct client *client,
mpd_unused int argc, mpd_unused char *argv[])
{ {
tag_print_types(client); tag_print_types(client);
return 0; return 0;
} }
static int handlePlay(struct client *client, static int
int argc, char *argv[]) handle_play(struct client *client, int argc, char *argv[])
{ {
int song = -1; int song = -1;
enum playlist_result result; enum playlist_result result;
...@@ -246,8 +248,8 @@ static int handlePlay(struct client *client, ...@@ -246,8 +248,8 @@ static int handlePlay(struct client *client,
return print_playlist_result(client, result); return print_playlist_result(client, result);
} }
static int handlePlayId(struct client *client, static int
int argc, char *argv[]) handle_playid(struct client *client, int argc, char *argv[])
{ {
int id = -1; int id = -1;
enum playlist_result result; enum playlist_result result;
...@@ -259,15 +261,17 @@ static int handlePlayId(struct client *client, ...@@ -259,15 +261,17 @@ static int handlePlayId(struct client *client,
return print_playlist_result(client, result); return print_playlist_result(client, result);
} }
static int handleStop(mpd_unused struct client *client, static int
mpd_unused int argc, mpd_unused char *argv[]) handle_stop(mpd_unused struct client *client,
mpd_unused int argc, mpd_unused char *argv[])
{ {
stopPlaylist(); stopPlaylist();
return 0; return 0;
} }
static int handleCurrentSong(struct client *client, static int
mpd_unused int argc, mpd_unused char *argv[]) handle_currentsong(struct client *client,
mpd_unused int argc, mpd_unused char *argv[])
{ {
int song = getPlaylistCurrentSong(); int song = getPlaylistCurrentSong();
enum playlist_result result; enum playlist_result result;
...@@ -279,8 +283,9 @@ static int handleCurrentSong(struct client *client, ...@@ -279,8 +283,9 @@ static int handleCurrentSong(struct client *client,
return print_playlist_result(client, result); return print_playlist_result(client, result);
} }
static int handlePause(struct client *client, static int
int argc, char *argv[]) handle_pause(struct client *client,
int argc, char *argv[])
{ {
if (argc == 2) { if (argc == 2) {
int pause_flag; int pause_flag;
...@@ -294,8 +299,9 @@ static int handlePause(struct client *client, ...@@ -294,8 +299,9 @@ static int handlePause(struct client *client,
return 0; return 0;
} }
static int commandStatus(struct client *client, static int
mpd_unused int argc, mpd_unused char *argv[]) handle_status(struct client *client,
mpd_unused int argc, mpd_unused char *argv[])
{ {
const char *state = NULL; const char *state = NULL;
int updateJobId; int updateJobId;
...@@ -364,20 +370,22 @@ static int commandStatus(struct client *client, ...@@ -364,20 +370,22 @@ static int commandStatus(struct client *client,
return 0; return 0;
} }
static int handleKill(mpd_unused struct client *client, static int
mpd_unused int argc, mpd_unused char *argv[]) handle_kill(mpd_unused struct client *client,
mpd_unused int argc, mpd_unused char *argv[])
{ {
return COMMAND_RETURN_KILL; return COMMAND_RETURN_KILL;
} }
static int handleClose(mpd_unused struct client *client, static int
mpd_unused int argc, mpd_unused char *argv[]) handle_close(mpd_unused struct client *client,
mpd_unused int argc, mpd_unused char *argv[])
{ {
return COMMAND_RETURN_CLOSE; return COMMAND_RETURN_CLOSE;
} }
static int handleAdd(struct client *client, static int
mpd_unused int argc, char *argv[]) handle_add(struct client *client, mpd_unused int argc, char *argv[])
{ {
char *path = argv[1]; char *path = argv[1];
enum playlist_result result; enum playlist_result result;
...@@ -401,8 +409,8 @@ static int handleAdd(struct client *client, ...@@ -401,8 +409,8 @@ static int handleAdd(struct client *client,
return print_playlist_result(client, result); return print_playlist_result(client, result);
} }
static int handleAddId(struct client *client, static int
int argc, char *argv[]) handle_addid(struct client *client, int argc, char *argv[])
{ {
int added_id; int added_id;
enum playlist_result result; enum playlist_result result;
...@@ -434,8 +442,8 @@ static int handleAddId(struct client *client, ...@@ -434,8 +442,8 @@ static int handleAddId(struct client *client,
return result; return result;
} }
static int handleDelete(struct client *client, static int
mpd_unused int argc, char *argv[]) handle_delete(struct client *client, mpd_unused int argc, char *argv[])
{ {
int song; int song;
enum playlist_result result; enum playlist_result result;
...@@ -447,8 +455,8 @@ static int handleDelete(struct client *client, ...@@ -447,8 +455,8 @@ static int handleDelete(struct client *client,
return print_playlist_result(client, result); return print_playlist_result(client, result);
} }
static int handleDeleteId(struct client *client, static int
mpd_unused int argc, char *argv[]) handle_deleteid(struct client *client, mpd_unused int argc, char *argv[])
{ {
int id; int id;
enum playlist_result result; enum playlist_result result;
...@@ -460,29 +468,33 @@ static int handleDeleteId(struct client *client, ...@@ -460,29 +468,33 @@ static int handleDeleteId(struct client *client,
return print_playlist_result(client, result); return print_playlist_result(client, result);
} }
static int handlePlaylist(struct client *client, static int
mpd_unused int argc, mpd_unused char *argv[]) handle_playlist(struct client *client,
mpd_unused int argc, mpd_unused char *argv[])
{ {
showPlaylist(client); showPlaylist(client);
return 0; return 0;
} }
static int handleShuffle(mpd_unused struct client *client, static int
mpd_unused int argc, mpd_unused char *argv[]) handle_shuffle(mpd_unused struct client *client,
mpd_unused int argc, mpd_unused char *argv[])
{ {
shufflePlaylist(); shufflePlaylist();
return 0; return 0;
} }
static int handleClear(mpd_unused struct client *client, static int
mpd_unused int argc, mpd_unused char *argv[]) handle_clear(mpd_unused struct client *client,
mpd_unused int argc, mpd_unused char *argv[])
{ {
clearPlaylist(); clearPlaylist();
return 0; return 0;
} }
static int handleSave(struct client *client, static int
mpd_unused int argc, char *argv[]) handle_save(struct client *client,
mpd_unused int argc, char *argv[])
{ {
enum playlist_result result; enum playlist_result result;
...@@ -490,8 +502,8 @@ static int handleSave(struct client *client, ...@@ -490,8 +502,8 @@ static int handleSave(struct client *client,
return print_playlist_result(client, result); return print_playlist_result(client, result);
} }
static int handleLoad(struct client *client, static int
mpd_unused int argc, char *argv[]) handle_load(struct client *client, mpd_unused int argc, char *argv[])
{ {
enum playlist_result result; enum playlist_result result;
...@@ -499,8 +511,8 @@ static int handleLoad(struct client *client, ...@@ -499,8 +511,8 @@ static int handleLoad(struct client *client,
return print_playlist_result(client, result); return print_playlist_result(client, result);
} }
static int handleListPlaylist(struct client *client, static int
mpd_unused int argc, char *argv[]) handle_listplaylist(struct client *client, mpd_unused int argc, char *argv[])
{ {
int ret; int ret;
...@@ -511,8 +523,9 @@ static int handleListPlaylist(struct client *client, ...@@ -511,8 +523,9 @@ static int handleListPlaylist(struct client *client,
return ret; return ret;
} }
static int handleListPlaylistInfo(struct client *client, static int
mpd_unused int argc, char *argv[]) handle_listplaylistinfo(struct client *client,
mpd_unused int argc, char *argv[])
{ {
int ret; int ret;
...@@ -523,8 +536,8 @@ static int handleListPlaylistInfo(struct client *client, ...@@ -523,8 +536,8 @@ static int handleListPlaylistInfo(struct client *client,
return ret; return ret;
} }
static int handleLsInfo(struct client *client, static int
int argc, char *argv[]) handle_lsinfo(struct client *client, int argc, char *argv[])
{ {
const char *path = ""; const char *path = "";
const struct directory *directory; const struct directory *directory;
...@@ -552,8 +565,8 @@ static int handleLsInfo(struct client *client, ...@@ -552,8 +565,8 @@ static int handleLsInfo(struct client *client,
return 0; return 0;
} }
static int handleRm(struct client *client, static int
mpd_unused int argc, char *argv[]) handle_rm(struct client *client, mpd_unused int argc, char *argv[])
{ {
enum playlist_result result; enum playlist_result result;
...@@ -561,8 +574,8 @@ static int handleRm(struct client *client, ...@@ -561,8 +574,8 @@ static int handleRm(struct client *client,
return print_playlist_result(client, result); return print_playlist_result(client, result);
} }
static int handleRename(struct client *client, static int
mpd_unused int argc, char *argv[]) handle_rename(struct client *client, mpd_unused int argc, char *argv[])
{ {
enum playlist_result result; enum playlist_result result;
...@@ -570,8 +583,8 @@ static int handleRename(struct client *client, ...@@ -570,8 +583,8 @@ static int handleRename(struct client *client,
return print_playlist_result(client, result); return print_playlist_result(client, result);
} }
static int handlePlaylistChanges(struct client *client, static int
mpd_unused int argc, char *argv[]) handle_plchanges(struct client *client, mpd_unused int argc, char *argv[])
{ {
uint32_t version; uint32_t version;
...@@ -580,8 +593,8 @@ static int handlePlaylistChanges(struct client *client, ...@@ -580,8 +593,8 @@ static int handlePlaylistChanges(struct client *client,
return playlistChanges(client, version); return playlistChanges(client, version);
} }
static int handlePlaylistChangesPosId(struct client *client, static int
mpd_unused int argc, char *argv[]) handle_plchangesposid(struct client *client, mpd_unused int argc, char *argv[])
{ {
uint32_t version; uint32_t version;
...@@ -590,8 +603,8 @@ static int handlePlaylistChangesPosId(struct client *client, ...@@ -590,8 +603,8 @@ static int handlePlaylistChangesPosId(struct client *client,
return playlistChangesPosId(client, version); return playlistChangesPosId(client, version);
} }
static int handlePlaylistInfo(struct client *client, static int
int argc, char *argv[]) handle_playlistinfo(struct client *client, int argc, char *argv[])
{ {
int song = -1; int song = -1;
enum playlist_result result; enum playlist_result result;
...@@ -603,8 +616,8 @@ static int handlePlaylistInfo(struct client *client, ...@@ -603,8 +616,8 @@ static int handlePlaylistInfo(struct client *client,
return print_playlist_result(client, result); return print_playlist_result(client, result);
} }
static int handlePlaylistId(struct client *client, static int
int argc, char *argv[]) handle_playlistid(struct client *client, int argc, char *argv[])
{ {
int id = -1; int id = -1;
enum playlist_result result; enum playlist_result result;
...@@ -616,8 +629,8 @@ static int handlePlaylistId(struct client *client, ...@@ -616,8 +629,8 @@ static int handlePlaylistId(struct client *client,
return print_playlist_result(client, result); return print_playlist_result(client, result);
} }
static int handleFind(struct client *client, static int
int argc, char *argv[]) handle_find(struct client *client, int argc, char *argv[])
{ {
int ret; int ret;
...@@ -641,8 +654,8 @@ static int handleFind(struct client *client, ...@@ -641,8 +654,8 @@ static int handleFind(struct client *client,
return ret; return ret;
} }
static int handleSearch(struct client *client, static int
int argc, char *argv[]) handle_search(struct client *client, int argc, char *argv[])
{ {
int ret; int ret;
...@@ -666,8 +679,8 @@ static int handleSearch(struct client *client, ...@@ -666,8 +679,8 @@ static int handleSearch(struct client *client,
return ret; return ret;
} }
static int handleCount(struct client *client, static int
int argc, char *argv[]) handle_count(struct client *client, int argc, char *argv[])
{ {
int ret; int ret;
...@@ -691,8 +704,8 @@ static int handleCount(struct client *client, ...@@ -691,8 +704,8 @@ static int handleCount(struct client *client,
return ret; return ret;
} }
static int handlePlaylistFind(struct client *client, static int
int argc, char *argv[]) handle_playlistfind(struct client *client, int argc, char *argv[])
{ {
LocateTagItem *items; LocateTagItem *items;
int numItems = newLocateTagItemArrayFromArgArray(argv + 1, int numItems = newLocateTagItemArrayFromArgArray(argv + 1,
...@@ -711,8 +724,8 @@ static int handlePlaylistFind(struct client *client, ...@@ -711,8 +724,8 @@ static int handlePlaylistFind(struct client *client,
return 0; return 0;
} }
static int handlePlaylistSearch(struct client *client, static int
int argc, char *argv[]) handle_playlistsearch(struct client *client, int argc, char *argv[])
{ {
LocateTagItem *items; LocateTagItem *items;
int numItems = newLocateTagItemArrayFromArgArray(argv + 1, int numItems = newLocateTagItemArrayFromArgArray(argv + 1,
...@@ -731,8 +744,9 @@ static int handlePlaylistSearch(struct client *client, ...@@ -731,8 +744,9 @@ static int handlePlaylistSearch(struct client *client,
return 0; return 0;
} }
static int handlePlaylistDelete(struct client *client, static int
mpd_unused int argc, char *argv[]) { handle_playlistdelete(struct client *client,
mpd_unused int argc, char *argv[]) {
char *playlist = argv[1]; char *playlist = argv[1];
int from; int from;
enum playlist_result result; enum playlist_result result;
...@@ -744,8 +758,8 @@ static int handlePlaylistDelete(struct client *client, ...@@ -744,8 +758,8 @@ static int handlePlaylistDelete(struct client *client,
return print_playlist_result(client, result); return print_playlist_result(client, result);
} }
static int handlePlaylistMove(struct client *client, static int
mpd_unused mpd_unused int argc, char *argv[]) handle_playlistmove(struct client *client, mpd_unused int argc, char *argv[])
{ {
char *playlist = argv[1]; char *playlist = argv[1];
int from, to; int from, to;
...@@ -760,8 +774,8 @@ static int handlePlaylistMove(struct client *client, ...@@ -760,8 +774,8 @@ static int handlePlaylistMove(struct client *client,
return print_playlist_result(client, result); return print_playlist_result(client, result);
} }
static int handleUpdate(struct client *client, static int
mpd_unused int argc, char *argv[]) handle_update(struct client *client, mpd_unused int argc, char *argv[])
{ {
char *path = NULL; char *path = NULL;
unsigned ret; unsigned ret;
...@@ -783,22 +797,24 @@ static int handleUpdate(struct client *client, ...@@ -783,22 +797,24 @@ static int handleUpdate(struct client *client,
} }
} }
static int handleNext(mpd_unused struct client *client, static int
mpd_unused int argc, mpd_unused char *argv[]) handle_next(mpd_unused struct client *client,
mpd_unused int argc, mpd_unused char *argv[])
{ {
nextSongInPlaylist(); nextSongInPlaylist();
return 0; return 0;
} }
static int handlePrevious(mpd_unused struct client *client, static int
mpd_unused int argc, mpd_unused char *argv[]) handle_previous(mpd_unused struct client *client,
mpd_unused int argc, mpd_unused char *argv[])
{ {
previousSongInPlaylist(); previousSongInPlaylist();
return 0; return 0;
} }
static int handleListAll(struct client *client, static int
mpd_unused int argc, char *argv[]) handle_listall(struct client *client, mpd_unused int argc, char *argv[])
{ {
char *directory = NULL; char *directory = NULL;
int ret; int ret;
...@@ -814,8 +830,8 @@ static int handleListAll(struct client *client, ...@@ -814,8 +830,8 @@ static int handleListAll(struct client *client,
return ret; return ret;
} }
static int handleVolume(struct client *client, static int
mpd_unused int argc, char *argv[]) handle_volume(struct client *client, mpd_unused int argc, char *argv[])
{ {
int change, ret; int change, ret;
...@@ -830,8 +846,8 @@ static int handleVolume(struct client *client, ...@@ -830,8 +846,8 @@ static int handleVolume(struct client *client,
return ret; return ret;
} }
static int handleSetVol(struct client *client, static int
mpd_unused int argc, char *argv[]) handle_setvol(struct client *client, mpd_unused int argc, char *argv[])
{ {
int level, ret; int level, ret;
...@@ -846,8 +862,8 @@ static int handleSetVol(struct client *client, ...@@ -846,8 +862,8 @@ static int handleSetVol(struct client *client,
return ret; return ret;
} }
static int handleRepeat(struct client *client, static int
mpd_unused int argc, char *argv[]) handle_repeat(struct client *client, mpd_unused int argc, char *argv[])
{ {
int status; int status;
...@@ -864,8 +880,8 @@ static int handleRepeat(struct client *client, ...@@ -864,8 +880,8 @@ static int handleRepeat(struct client *client,
return 0; return 0;
} }
static int handleRandom(struct client *client, static int
mpd_unused int argc, char *argv[]) handle_random(struct client *client, mpd_unused int argc, char *argv[])
{ {
int status; int status;
...@@ -882,21 +898,23 @@ static int handleRandom(struct client *client, ...@@ -882,21 +898,23 @@ static int handleRandom(struct client *client,
return 0; return 0;
} }
static int handleStats(struct client *client, static int
mpd_unused int argc, mpd_unused char *argv[]) handle_stats(struct client *client,
mpd_unused int argc, mpd_unused char *argv[])
{ {
return printStats(client); return printStats(client);
} }
static int handleClearError(mpd_unused struct client *client, static int
mpd_unused int argc, mpd_unused char *argv[]) handle_clearerror(mpd_unused struct client *client,
mpd_unused int argc, mpd_unused char *argv[])
{ {
clearPlayerError(); clearPlayerError();
return 0; return 0;
} }
static int handleList(struct client *client, static int
int argc, char *argv[]) handle_list(struct client *client, int argc, char *argv[])
{ {
int numConditionals; int numConditionals;
LocateTagItem *conditionals = NULL; LocateTagItem *conditionals = NULL;
...@@ -949,8 +967,8 @@ static int handleList(struct client *client, ...@@ -949,8 +967,8 @@ static int handleList(struct client *client,
return ret; return ret;
} }
static int handleMove(struct client *client, static int
mpd_unused int argc, char *argv[]) handle_move(struct client *client, mpd_unused int argc, char *argv[])
{ {
int from, to; int from, to;
enum playlist_result result; enum playlist_result result;
...@@ -963,8 +981,8 @@ static int handleMove(struct client *client, ...@@ -963,8 +981,8 @@ static int handleMove(struct client *client,
return print_playlist_result(client, result); return print_playlist_result(client, result);
} }
static int handleMoveId(struct client *client, static int
mpd_unused int argc, char *argv[]) handle_moveid(struct client *client, mpd_unused int argc, char *argv[])
{ {
int id, to; int id, to;
enum playlist_result result; enum playlist_result result;
...@@ -977,8 +995,8 @@ static int handleMoveId(struct client *client, ...@@ -977,8 +995,8 @@ static int handleMoveId(struct client *client,
return print_playlist_result(client, result); return print_playlist_result(client, result);
} }
static int handleSwap(struct client *client, static int
mpd_unused int argc, char *argv[]) handle_swap(struct client *client, mpd_unused int argc, char *argv[])
{ {
int song1, song2; int song1, song2;
enum playlist_result result; enum playlist_result result;
...@@ -991,8 +1009,8 @@ static int handleSwap(struct client *client, ...@@ -991,8 +1009,8 @@ static int handleSwap(struct client *client,
return print_playlist_result(client, result); return print_playlist_result(client, result);
} }
static int handleSwapId(struct client *client, static int
mpd_unused int argc, char *argv[]) handle_swapid(struct client *client, mpd_unused int argc, char *argv[])
{ {
int id1, id2; int id1, id2;
enum playlist_result result; enum playlist_result result;
...@@ -1005,8 +1023,8 @@ static int handleSwapId(struct client *client, ...@@ -1005,8 +1023,8 @@ static int handleSwapId(struct client *client,
return print_playlist_result(client, result); return print_playlist_result(client, result);
} }
static int handleSeek(struct client *client, static int
mpd_unused int argc, char *argv[]) handle_seek(struct client *client, mpd_unused int argc, char *argv[])
{ {
int song, seek_time; int song, seek_time;
enum playlist_result result; enum playlist_result result;
...@@ -1020,8 +1038,8 @@ static int handleSeek(struct client *client, ...@@ -1020,8 +1038,8 @@ static int handleSeek(struct client *client,
return print_playlist_result(client, result); return print_playlist_result(client, result);
} }
static int handleSeekId(struct client *client, static int
mpd_unused int argc, char *argv[]) handle_seekid(struct client *client, mpd_unused int argc, char *argv[])
{ {
int id, seek_time; int id, seek_time;
enum playlist_result result; enum playlist_result result;
...@@ -1035,8 +1053,8 @@ static int handleSeekId(struct client *client, ...@@ -1035,8 +1053,8 @@ static int handleSeekId(struct client *client,
return print_playlist_result(client, result); return print_playlist_result(client, result);
} }
static int handleListAllInfo(struct client *client, static int
mpd_unused int argc, char *argv[]) handle_listallinfo(struct client *client, mpd_unused int argc, char *argv[])
{ {
char *directory = NULL; char *directory = NULL;
int ret; int ret;
...@@ -1052,14 +1070,15 @@ static int handleListAllInfo(struct client *client, ...@@ -1052,14 +1070,15 @@ static int handleListAllInfo(struct client *client,
return ret; return ret;
} }
static int handlePing(mpd_unused struct client *client, static int
mpd_unused int argc, mpd_unused char *argv[]) handle_ping(mpd_unused struct client *client,
mpd_unused int argc, mpd_unused char *argv[])
{ {
return 0; return 0;
} }
static int handlePassword(struct client *client, static int
mpd_unused int argc, char *argv[]) handle_password(struct client *client, mpd_unused int argc, char *argv[])
{ {
unsigned permission = 0; unsigned permission = 0;
...@@ -1073,8 +1092,8 @@ static int handlePassword(struct client *client, ...@@ -1073,8 +1092,8 @@ static int handlePassword(struct client *client,
return 0; return 0;
} }
static int handleCrossfade(struct client *client, static int
mpd_unused int argc, char *argv[]) handle_crossfade(struct client *client, mpd_unused int argc, char *argv[])
{ {
int xfade_time; int xfade_time;
...@@ -1085,8 +1104,8 @@ static int handleCrossfade(struct client *client, ...@@ -1085,8 +1104,8 @@ static int handleCrossfade(struct client *client,
return 0; return 0;
} }
static int handleEnableDevice(struct client *client, static int
mpd_unused int argc, char *argv[]) handle_enableoutput(struct client *client, mpd_unused int argc, char *argv[])
{ {
int device, ret; int device, ret;
...@@ -1101,8 +1120,8 @@ static int handleEnableDevice(struct client *client, ...@@ -1101,8 +1120,8 @@ static int handleEnableDevice(struct client *client,
return ret; return ret;
} }
static int handleDisableDevice(struct client *client, static int
mpd_unused int argc, char *argv[]) handle_disableoutput(struct client *client, mpd_unused int argc, char *argv[])
{ {
int device, ret; int device, ret;
...@@ -1117,8 +1136,9 @@ static int handleDisableDevice(struct client *client, ...@@ -1117,8 +1136,9 @@ static int handleDisableDevice(struct client *client,
return ret; return ret;
} }
static int handleDevices(struct client *client, static int
mpd_unused int argc, mpd_unused char *argv[]) handle_devices(struct client *client,
mpd_unused int argc, mpd_unused char *argv[])
{ {
printAudioDevices(client); printAudioDevices(client);
...@@ -1126,14 +1146,16 @@ static int handleDevices(struct client *client, ...@@ -1126,14 +1146,16 @@ static int handleDevices(struct client *client,
} }
/* 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(struct client *client, static int
mpd_unused int argc, mpd_unused char *argv[]); handle_commands(struct client *client,
mpd_unused int argc, mpd_unused char *argv[]);
static int handleNotcommands(struct client *client, static int
mpd_unused int argc, mpd_unused char *argv[]); handle_not_commands(struct client *client,
mpd_unused int argc, mpd_unused char *argv[]);
static int handlePlaylistClear(struct client *client, static int
mpd_unused int argc, char *argv[]) handle_playlistclear(struct client *client, mpd_unused int argc, char *argv[])
{ {
enum playlist_result result; enum playlist_result result;
...@@ -1141,8 +1163,8 @@ static int handlePlaylistClear(struct client *client, ...@@ -1141,8 +1163,8 @@ static int handlePlaylistClear(struct client *client,
return print_playlist_result(client, result); return print_playlist_result(client, result);
} }
static int handlePlaylistAdd(struct client *client, static int
mpd_unused int argc, char *argv[]) handle_playlistadd(struct client *client, mpd_unused int argc, char *argv[])
{ {
char *playlist = argv[1]; char *playlist = argv[1];
char *path = argv[2]; char *path = argv[2];
...@@ -1163,8 +1185,8 @@ static int handlePlaylistAdd(struct client *client, ...@@ -1163,8 +1185,8 @@ static int handlePlaylistAdd(struct client *client,
} }
static int static int
handle_list_playlists(struct client *client, handle_listplaylists(struct client *client,
mpd_unused int argc, mpd_unused char *argv[]) mpd_unused int argc, mpd_unused char *argv[])
{ {
GPtrArray *list = spl_list(); GPtrArray *list = spl_list();
if (list == NULL) { if (list == NULL) {
...@@ -1195,79 +1217,79 @@ handle_idle(struct client *client, ...@@ -1195,79 +1217,79 @@ handle_idle(struct client *client,
* This array must be sorted! * This array must be sorted!
*/ */
static const struct command commands[] = { static const struct command commands[] = {
{ "add", PERMISSION_ADD, 1, 1, handleAdd }, { "add", PERMISSION_ADD, 1, 1, handle_add },
{ "addid", PERMISSION_ADD, 1, 2, handleAddId }, { "addid", PERMISSION_ADD, 1, 2, handle_addid },
{ "clear", PERMISSION_CONTROL, 0, 0, handleClear }, { "clear", PERMISSION_CONTROL, 0, 0, handle_clear },
{ "clearerror", PERMISSION_CONTROL, 0, 0, handleClearError }, { "clearerror", PERMISSION_CONTROL, 0, 0, handle_clearerror },
{ "close", PERMISSION_NONE, -1, -1, handleClose }, { "close", PERMISSION_NONE, -1, -1, handle_close },
{ "commands", PERMISSION_NONE, 0, 0, handleCommands }, { "commands", PERMISSION_NONE, 0, 0, handle_commands },
{ "count", PERMISSION_READ, 2, -1, handleCount }, { "count", PERMISSION_READ, 2, -1, handle_count },
{ "crossfade", PERMISSION_CONTROL, 1, 1, handleCrossfade }, { "crossfade", PERMISSION_CONTROL, 1, 1, handle_crossfade },
{ "currentsong", PERMISSION_READ, 0, 0, handleCurrentSong }, { "currentsong", PERMISSION_READ, 0, 0, handle_currentsong },
{ "delete", PERMISSION_CONTROL, 1, 1, handleDelete }, { "delete", PERMISSION_CONTROL, 1, 1, handle_delete },
{ "deleteid", PERMISSION_CONTROL, 1, 1, handleDeleteId }, { "deleteid", PERMISSION_CONTROL, 1, 1, handle_deleteid },
{ "disableoutput", PERMISSION_ADMIN, 1, 1, handleDisableDevice }, { "disableoutput", PERMISSION_ADMIN, 1, 1, handle_disableoutput },
{ "enableoutput", PERMISSION_ADMIN, 1, 1, handleEnableDevice }, { "enableoutput", PERMISSION_ADMIN, 1, 1, handle_enableoutput },
{ "find", PERMISSION_READ, 2, -1, handleFind }, { "find", PERMISSION_READ, 2, -1, handle_find },
{ "idle", PERMISSION_READ, 0, 0, handle_idle }, { "idle", PERMISSION_READ, 0, 0, handle_idle },
{ "kill", PERMISSION_ADMIN, -1, -1, handleKill }, { "kill", PERMISSION_ADMIN, -1, -1, handle_kill },
{ "list", PERMISSION_READ, 1, -1, handleList }, { "list", PERMISSION_READ, 1, -1, handle_list },
{ "listall", PERMISSION_READ, 0, 1, handleListAll }, { "listall", PERMISSION_READ, 0, 1, handle_listall },
{ "listallinfo", PERMISSION_READ, 0, 1, handleListAllInfo }, { "listallinfo", PERMISSION_READ, 0, 1, handle_listallinfo },
{ "listplaylist", PERMISSION_READ, 1, 1, handleListPlaylist }, { "listplaylist", PERMISSION_READ, 1, 1, handle_listplaylist },
{ "listplaylistinfo", PERMISSION_READ, 1, 1, handleListPlaylistInfo }, { "listplaylistinfo", PERMISSION_READ, 1, 1, handle_listplaylistinfo },
{ "listplaylists", PERMISSION_READ, 0, 0, handle_list_playlists }, { "listplaylists", PERMISSION_READ, 0, 0, handle_listplaylists },
{ "load", PERMISSION_ADD, 1, 1, handleLoad }, { "load", PERMISSION_ADD, 1, 1, handle_load },
{ "lsinfo", PERMISSION_READ, 0, 1, handleLsInfo }, { "lsinfo", PERMISSION_READ, 0, 1, handle_lsinfo },
{ "move", PERMISSION_CONTROL, 2, 2, handleMove }, { "move", PERMISSION_CONTROL, 2, 2, handle_move },
{ "moveid", PERMISSION_CONTROL, 2, 2, handleMoveId }, { "moveid", PERMISSION_CONTROL, 2, 2, handle_moveid },
{ "next", PERMISSION_CONTROL, 0, 0, handleNext }, { "next", PERMISSION_CONTROL, 0, 0, handle_next },
{ "notcommands", PERMISSION_NONE, 0, 0, handleNotcommands }, { "notcommands", PERMISSION_NONE, 0, 0, handle_not_commands },
{ "outputs", PERMISSION_READ, 0, 0, handleDevices }, { "outputs", PERMISSION_READ, 0, 0, handle_devices },
{ "password", PERMISSION_NONE, 1, 1, handlePassword }, { "password", PERMISSION_NONE, 1, 1, handle_password },
{ "pause", PERMISSION_CONTROL, 0, 1, handlePause }, { "pause", PERMISSION_CONTROL, 0, 1, handle_pause },
{ "ping", PERMISSION_NONE, 0, 0, handlePing }, { "ping", PERMISSION_NONE, 0, 0, handle_ping },
{ "play", PERMISSION_CONTROL, 0, 1, handlePlay }, { "play", PERMISSION_CONTROL, 0, 1, handle_play },
{ "playid", PERMISSION_CONTROL, 0, 1, handlePlayId }, { "playid", PERMISSION_CONTROL, 0, 1, handle_playid },
{ "playlist", PERMISSION_READ, 0, 0, handlePlaylist }, { "playlist", PERMISSION_READ, 0, 0, handle_playlist },
{ "playlistadd", PERMISSION_CONTROL, 2, 2, handlePlaylistAdd }, { "playlistadd", PERMISSION_CONTROL, 2, 2, handle_playlistadd },
{ "playlistclear", PERMISSION_CONTROL, 1, 1, handlePlaylistClear }, { "playlistclear", PERMISSION_CONTROL, 1, 1, handle_playlistclear },
{ "playlistdelete", PERMISSION_CONTROL, 2, 2, handlePlaylistDelete }, { "playlistdelete", PERMISSION_CONTROL, 2, 2, handle_playlistdelete },
{ "playlistfind", PERMISSION_READ, 2, -1, handlePlaylistFind }, { "playlistfind", PERMISSION_READ, 2, -1, handle_playlistfind },
{ "playlistid", PERMISSION_READ, 0, 1, handlePlaylistId }, { "playlistid", PERMISSION_READ, 0, 1, handle_playlistid },
{ "playlistinfo", PERMISSION_READ, 0, 1, handlePlaylistInfo }, { "playlistinfo", PERMISSION_READ, 0, 1, handle_playlistinfo },
{ "playlistmove", PERMISSION_CONTROL, 3, 3, handlePlaylistMove }, { "playlistmove", PERMISSION_CONTROL, 3, 3, handle_playlistmove },
{ "playlistsearch", PERMISSION_READ, 2, -1, handlePlaylistSearch }, { "playlistsearch", PERMISSION_READ, 2, -1, handle_playlistsearch },
{ "plchanges", PERMISSION_READ, 1, 1, handlePlaylistChanges }, { "plchanges", PERMISSION_READ, 1, 1, handle_plchanges },
{ "plchangesposid", PERMISSION_READ, 1, 1, { "plchangesposid", PERMISSION_READ, 1, 1, handle_plchangesposid },
handlePlaylistChangesPosId }, { "previous", PERMISSION_CONTROL, 0, 0, handle_previous },
{ "previous", PERMISSION_CONTROL, 0, 0, handlePrevious }, { "random", PERMISSION_CONTROL, 1, 1, handle_random },
{ "random", PERMISSION_CONTROL, 1, 1, handleRandom }, { "rename", PERMISSION_CONTROL, 2, 2, handle_rename },
{ "rename", PERMISSION_CONTROL, 2, 2, handleRename }, { "repeat", PERMISSION_CONTROL, 1, 1, handle_repeat },
{ "repeat", PERMISSION_CONTROL, 1, 1, handleRepeat }, { "rm", PERMISSION_CONTROL, 1, 1, handle_rm },
{ "rm", PERMISSION_CONTROL, 1, 1, handleRm }, { "save", PERMISSION_CONTROL, 1, 1, handle_save },
{ "save", PERMISSION_CONTROL, 1, 1, handleSave }, { "search", PERMISSION_READ, 2, -1, handle_search },
{ "search", PERMISSION_READ, 2, -1, handleSearch }, { "seek", PERMISSION_CONTROL, 2, 2, handle_seek },
{ "seek", PERMISSION_CONTROL, 2, 2, handleSeek }, { "seekid", PERMISSION_CONTROL, 2, 2, handle_seekid },
{ "seekid", PERMISSION_CONTROL, 2, 2, handleSeekId }, { "setvol", PERMISSION_CONTROL, 1, 1, handle_setvol },
{ "setvol", PERMISSION_CONTROL, 1, 1, handleSetVol }, { "shuffle", PERMISSION_CONTROL, 0, 0, handle_shuffle },
{ "shuffle", PERMISSION_CONTROL, 0, 0, handleShuffle }, { "stats", PERMISSION_READ, 0, 0, handle_stats },
{ "stats", PERMISSION_READ, 0, 0, handleStats }, { "status", PERMISSION_READ, 0, 0, handle_status },
{ "status", PERMISSION_READ, 0, 0, commandStatus }, { "stop", PERMISSION_CONTROL, 0, 0, handle_stop },
{ "stop", PERMISSION_CONTROL, 0, 0, handleStop }, { "swap", PERMISSION_CONTROL, 2, 2, handle_swap },
{ "swap", PERMISSION_CONTROL, 2, 2, handleSwap }, { "swapid", PERMISSION_CONTROL, 2, 2, handle_swapid },
{ "swapid", PERMISSION_CONTROL, 2, 2, handleSwapId }, { "tagtypes", PERMISSION_READ, 0, 0, handle_tagtypes },
{ "tagtypes", PERMISSION_READ, 0, 0, handleTagTypes }, { "update", PERMISSION_ADMIN, 0, 1, handle_update },
{ "update", PERMISSION_ADMIN, 0, 1, handleUpdate }, { "urlhandlers", PERMISSION_READ, 0, 0, handle_urlhandlers },
{ "urlhandlers", PERMISSION_READ, 0, 0, handleUrlHandlers }, { "volume", PERMISSION_CONTROL, 1, 1, handle_volume },
{ "volume", PERMISSION_CONTROL, 1, 1, handleVolume },
}; };
static const unsigned num_commands = sizeof(commands) / sizeof(commands[0]); static const unsigned num_commands = sizeof(commands) / sizeof(commands[0]);
/* 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(struct client *client, static int
mpd_unused int argc, mpd_unused char *argv[]) handle_commands(struct client *client,
mpd_unused int argc, mpd_unused char *argv[])
{ {
const unsigned permission = client_get_permission(client); const unsigned permission = client_get_permission(client);
const struct command *cmd; const struct command *cmd;
...@@ -1275,16 +1297,16 @@ static int handleCommands(struct client *client, ...@@ -1275,16 +1297,16 @@ static int handleCommands(struct client *client,
for (unsigned i = 0; i < num_commands; ++i) { for (unsigned i = 0; i < num_commands; ++i) {
cmd = &commands[i]; cmd = &commands[i];
if (cmd->reqPermission == (permission & cmd->reqPermission)) { if (cmd->permission == (permission & cmd->permission))
client_printf(client, "command: %s\n", cmd->cmd); client_printf(client, "command: %s\n", cmd->cmd);
}
} }
return 0; return 0;
} }
static int handleNotcommands(struct client *client, static int
mpd_unused int argc, mpd_unused char *argv[]) handle_not_commands(struct client *client,
mpd_unused int argc, mpd_unused char *argv[])
{ {
const unsigned permission = client_get_permission(client); const unsigned permission = client_get_permission(client);
const struct command *cmd; const struct command *cmd;
...@@ -1292,15 +1314,14 @@ static int handleNotcommands(struct client *client, ...@@ -1292,15 +1314,14 @@ static int handleNotcommands(struct client *client,
for (unsigned i = 0; i < num_commands; ++i) { for (unsigned i = 0; i < num_commands; ++i) {
cmd = &commands[i]; cmd = &commands[i];
if (cmd->reqPermission != (permission & cmd->reqPermission)) { if (cmd->permission != (permission & cmd->permission))
client_printf(client, "command: %s\n", cmd->cmd); client_printf(client, "command: %s\n", cmd->cmd);
}
} }
return 0; return 0;
} }
void initCommands(void) void command_init(void)
{ {
#ifndef NDEBUG #ifndef NDEBUG
/* ensure that the command list is sorted */ /* ensure that the command list is sorted */
...@@ -1309,7 +1330,7 @@ void initCommands(void) ...@@ -1309,7 +1330,7 @@ void initCommands(void)
#endif #endif
} }
void finishCommands(void) void command_finish(void)
{ {
} }
...@@ -1336,13 +1357,13 @@ command_lookup(const char *name) ...@@ -1336,13 +1357,13 @@ command_lookup(const char *name)
} }
static int static int
checkArgcAndPermission(const struct command *cmd, struct client *client, command_check_request(const struct command *cmd, struct client *client,
unsigned permission, int argc, char *argv[]) unsigned permission, int argc, char *argv[])
{ {
int min = cmd->min + 1; int min = cmd->min + 1;
int max = cmd->max + 1; int max = cmd->max + 1;
if (cmd->reqPermission != (permission & cmd->reqPermission)) { if (cmd->permission != (permission & cmd->permission)) {
if (client != NULL) if (client != NULL)
command_error(client, ACK_ERROR_PERMISSION, command_error(client, ACK_ERROR_PERMISSION,
"you don't have permission for \"%s\"", "you don't have permission for \"%s\"",
...@@ -1374,9 +1395,8 @@ checkArgcAndPermission(const struct command *cmd, struct client *client, ...@@ -1374,9 +1395,8 @@ checkArgcAndPermission(const struct command *cmd, struct client *client,
} }
static const struct command * static const struct command *
getCommandEntryAndCheckArgcAndPermission(struct client *client, command_checked_lookup(struct client *client, unsigned permission,
unsigned permission, int argc, char *argv[])
int argc, char *argv[])
{ {
static char unknown[] = ""; static char unknown[] = "";
const struct command *cmd; const struct command *cmd;
...@@ -1396,14 +1416,14 @@ getCommandEntryAndCheckArgcAndPermission(struct client *client, ...@@ -1396,14 +1416,14 @@ getCommandEntryAndCheckArgcAndPermission(struct client *client,
current_command = cmd->cmd; current_command = cmd->cmd;
if (checkArgcAndPermission(cmd, client, permission, argc, argv) < 0) { if (command_check_request(cmd, client, permission, argc, argv) < 0)
return NULL; return NULL;
}
return cmd; return cmd;
} }
int processCommand(struct client *client, char *commandString) int
command_process(struct client *client, char *commandString)
{ {
int argc; int argc;
char *argv[COMMAND_ARGV_MAX] = { NULL }; char *argv[COMMAND_ARGV_MAX] = { NULL };
...@@ -1413,9 +1433,8 @@ int processCommand(struct client *client, char *commandString) ...@@ -1413,9 +1433,8 @@ int processCommand(struct client *client, char *commandString)
if (!(argc = buffer2array(commandString, argv, COMMAND_ARGV_MAX))) if (!(argc = buffer2array(commandString, argv, COMMAND_ARGV_MAX)))
return 0; return 0;
cmd = getCommandEntryAndCheckArgcAndPermission(client, cmd = command_checked_lookup(client, client_get_permission(client),
client_get_permission(client), argc, argv);
argc, argv);
if (cmd) if (cmd)
ret = cmd->handler(client, argc, argv); ret = cmd->handler(client, argc, argv);
...@@ -1424,27 +1443,28 @@ int processCommand(struct client *client, char *commandString) ...@@ -1424,27 +1443,28 @@ int processCommand(struct client *client, char *commandString)
return ret; return ret;
} }
int processListOfCommands(struct client *client, int
int listOK, struct strnode *list) command_process_list(struct client *client,
int list_ok, struct strnode *list)
{ {
struct strnode *cur = list; struct strnode *cur = list;
int ret = 0; int ret = 0;
command_listNum = 0; command_list_num = 0;
while (cur) { while (cur) {
DEBUG("processListOfCommands: process command \"%s\"\n", DEBUG("command_process_list: process command \"%s\"\n",
cur->data); cur->data);
ret = processCommand(client, cur->data); ret = command_process(client, cur->data);
DEBUG("processListOfCommands: command returned %i\n", ret); DEBUG("command_process_list: command returned %i\n", ret);
if (ret != 0 || client_is_expired(client)) if (ret != 0 || client_is_expired(client))
goto out; goto out;
else if (listOK) else if (list_ok)
client_puts(client, "list_OK\n"); client_puts(client, "list_OK\n");
command_listNum++; command_list_num++;
cur = cur->next; cur = cur->next;
} }
out: out:
command_listNum = 0; command_list_num = 0;
return ret; return ret;
} }
...@@ -29,14 +29,16 @@ ...@@ -29,14 +29,16 @@
struct client; struct client;
int processListOfCommands(struct client *client, void command_init(void);
int listOK, struct strnode *list);
int processCommand(struct client *client, char *commandString); void command_finish(void);
void initCommands(void); int
command_process_list(struct client *client,
int list_ok, struct strnode *list);
void finishCommands(void); int
command_process(struct client *client, char *commandString);
void command_success(struct client *client); void command_success(struct client *client);
......
...@@ -420,7 +420,7 @@ int main(int argc, char *argv[]) ...@@ -420,7 +420,7 @@ int main(int argc, char *argv[])
openDB(&options, argv[0]); openDB(&options, argv[0]);
initCommands(); command_init();
initPlayerData(); initPlayerData();
pc_init(buffered_before_play); pc_init(buffered_before_play);
ob_init(buffered_chunks, &pc.notify); ob_init(buffered_chunks, &pc.notify);
...@@ -484,7 +484,7 @@ int main(int argc, char *argv[]) ...@@ -484,7 +484,7 @@ int main(int argc, char *argv[])
finishPermissions(); finishPermissions();
dc_deinit(); dc_deinit();
pc_deinit(); pc_deinit();
finishCommands(); command_finish();
decoder_plugin_deinit_all(); decoder_plugin_deinit_all();
ob_free(); ob_free();
cleanUpPidFile(); cleanUpPidFile();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment