Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
51a6ee88
Commit
51a6ee88
authored
Oct 22, 2008
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
command: no CamelCase
Eliminate CamelCase in all public and static functions.
parent
69c563b5
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
230 additions
and
208 deletions
+230
-208
client.c
src/client.c
+2
-2
command.c
src/command.c
+219
-199
command.h
src/command.h
+7
-5
main.c
src/main.c
+2
-2
No files found.
src/client.c
View file @
51a6ee88
...
@@ -335,7 +335,7 @@ static int client_process_line(struct client *client, char *line)
...
@@ -335,7 +335,7 @@ 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 "
...
@@ -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
);
...
...
src/command.c
View file @
51a6ee88
...
@@ -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
reqP
ermission
;
unsigned
p
ermission
;
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_list
N
um
;
static
int
command_list
_n
um
;
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_list
N
um
,
current_command
);
(
int
)
error
,
command_list
_n
um
,
current_command
);
client_vprintf
(
client
,
fmt
,
args
);
client_vprintf
(
client
,
fmt
,
args
);
client_puts
(
client
,
"
\n
"
);
client_puts
(
client
,
"
\n
"
);
...
@@ -219,7 +219,8 @@ print_spl_list(struct client *client, GPtrArray *list)
...
@@ -219,7 +219,8 @@ print_spl_list(struct client *client, GPtrArray *list)
}
}
}
}
static
int
handleUrlHandlers
(
struct
client
*
client
,
static
int
handle_urlhandlers
(
struct
client
*
client
,
mpd_unused
int
argc
,
mpd_unused
char
*
argv
[])
mpd_unused
int
argc
,
mpd_unused
char
*
argv
[])
{
{
if
(
client_get_uid
(
client
)
>
0
)
if
(
client_get_uid
(
client
)
>
0
)
...
@@ -227,15 +228,16 @@ static int handleUrlHandlers(struct client *client,
...
@@ -227,15 +228,16 @@ static int handleUrlHandlers(struct client *client,
return
printRemoteUrlHandlers
(
client
);
return
printRemoteUrlHandlers
(
client
);
}
}
static
int
handleTagTypes
(
struct
client
*
client
,
static
int
handle_tagtypes
(
struct
client
*
client
,
mpd_unused
int
argc
,
mpd_unused
char
*
argv
[])
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,14 +261,16 @@ static int handlePlayId(struct client *client,
...
@@ -259,14 +261,16 @@ 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
handle_stop
(
mpd_unused
struct
client
*
client
,
mpd_unused
int
argc
,
mpd_unused
char
*
argv
[])
mpd_unused
int
argc
,
mpd_unused
char
*
argv
[])
{
{
stopPlaylist
();
stopPlaylist
();
return
0
;
return
0
;
}
}
static
int
handleCurrentSong
(
struct
client
*
client
,
static
int
handle_currentsong
(
struct
client
*
client
,
mpd_unused
int
argc
,
mpd_unused
char
*
argv
[])
mpd_unused
int
argc
,
mpd_unused
char
*
argv
[])
{
{
int
song
=
getPlaylistCurrentSong
();
int
song
=
getPlaylistCurrentSong
();
...
@@ -279,7 +283,8 @@ static int handleCurrentSong(struct client *client,
...
@@ -279,7 +283,8 @@ 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
handle_pause
(
struct
client
*
client
,
int
argc
,
char
*
argv
[])
int
argc
,
char
*
argv
[])
{
{
if
(
argc
==
2
)
{
if
(
argc
==
2
)
{
...
@@ -294,7 +299,8 @@ static int handlePause(struct client *client,
...
@@ -294,7 +299,8 @@ static int handlePause(struct client *client,
return
0
;
return
0
;
}
}
static
int
commandStatus
(
struct
client
*
client
,
static
int
handle_status
(
struct
client
*
client
,
mpd_unused
int
argc
,
mpd_unused
char
*
argv
[])
mpd_unused
int
argc
,
mpd_unused
char
*
argv
[])
{
{
const
char
*
state
=
NULL
;
const
char
*
state
=
NULL
;
...
@@ -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
handle_kill
(
mpd_unused
struct
client
*
client
,
mpd_unused
int
argc
,
mpd_unused
char
*
argv
[])
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
handle_close
(
mpd_unused
struct
client
*
client
,
mpd_unused
int
argc
,
mpd_unused
char
*
argv
[])
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,28 +468,32 @@ static int handleDeleteId(struct client *client,
...
@@ -460,28 +468,32 @@ 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
handle_playlist
(
struct
client
*
client
,
mpd_unused
int
argc
,
mpd_unused
char
*
argv
[])
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
handle_shuffle
(
mpd_unused
struct
client
*
client
,
mpd_unused
int
argc
,
mpd_unused
char
*
argv
[])
mpd_unused
int
argc
,
mpd_unused
char
*
argv
[])
{
{
shufflePlaylist
();
shufflePlaylist
();
return
0
;
return
0
;
}
}
static
int
handleClear
(
mpd_unused
struct
client
*
client
,
static
int
handle_clear
(
mpd_unused
struct
client
*
client
,
mpd_unused
int
argc
,
mpd_unused
char
*
argv
[])
mpd_unused
int
argc
,
mpd_unused
char
*
argv
[])
{
{
clearPlaylist
();
clearPlaylist
();
return
0
;
return
0
;
}
}
static
int
handleSave
(
struct
client
*
client
,
static
int
handle_save
(
struct
client
*
client
,
mpd_unused
int
argc
,
char
*
argv
[])
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,7 +523,8 @@ static int handleListPlaylist(struct client *client,
...
@@ -511,7 +523,8 @@ static int handleListPlaylist(struct client *client,
return
ret
;
return
ret
;
}
}
static
int
handleListPlaylistInfo
(
struct
client
*
client
,
static
int
handle_listplaylistinfo
(
struct
client
*
client
,
mpd_unused
int
argc
,
char
*
argv
[])
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,7 +744,8 @@ static int handlePlaylistSearch(struct client *client,
...
@@ -731,7 +744,8 @@ static int handlePlaylistSearch(struct client *client,
return
0
;
return
0
;
}
}
static
int
handlePlaylistDelete
(
struct
client
*
client
,
static
int
handle_playlistdelete
(
struct
client
*
client
,
mpd_unused
int
argc
,
char
*
argv
[])
{
mpd_unused
int
argc
,
char
*
argv
[])
{
char
*
playlist
=
argv
[
1
];
char
*
playlist
=
argv
[
1
];
int
from
;
int
from
;
...
@@ -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
handle_next
(
mpd_unused
struct
client
*
client
,
mpd_unused
int
argc
,
mpd_unused
char
*
argv
[])
mpd_unused
int
argc
,
mpd_unused
char
*
argv
[])
{
{
nextSongInPlaylist
();
nextSongInPlaylist
();
return
0
;
return
0
;
}
}
static
int
handlePrevious
(
mpd_unused
struct
client
*
client
,
static
int
handle_previous
(
mpd_unused
struct
client
*
client
,
mpd_unused
int
argc
,
mpd_unused
char
*
argv
[])
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
handle_stats
(
struct
client
*
client
,
mpd_unused
int
argc
,
mpd_unused
char
*
argv
[])
mpd_unused
int
argc
,
mpd_unused
char
*
argv
[])
{
{
return
printStats
(
client
);
return
printStats
(
client
);
}
}
static
int
handleClearError
(
mpd_unused
struct
client
*
client
,
static
int
handle_clearerror
(
mpd_unused
struct
client
*
client
,
mpd_unused
int
argc
,
mpd_unused
char
*
argv
[])
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
handle_ping
(
mpd_unused
struct
client
*
client
,
mpd_unused
int
argc
,
mpd_unused
char
*
argv
[])
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,7 +1136,8 @@ static int handleDisableDevice(struct client *client,
...
@@ -1117,7 +1136,8 @@ static int handleDisableDevice(struct client *client,
return
ret
;
return
ret
;
}
}
static
int
handleDevices
(
struct
client
*
client
,
static
int
handle_devices
(
struct
client
*
client
,
mpd_unused
int
argc
,
mpd_unused
char
*
argv
[])
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
handle_commands
(
struct
client
*
client
,
mpd_unused
int
argc
,
mpd_unused
char
*
argv
[]);
mpd_unused
int
argc
,
mpd_unused
char
*
argv
[]);
static
int
handleNotcommands
(
struct
client
*
client
,
static
int
handle_not_commands
(
struct
client
*
client
,
mpd_unused
int
argc
,
mpd_unused
char
*
argv
[]);
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,7 +1185,7 @@ static int handlePlaylistAdd(struct client *client,
...
@@ -1163,7 +1185,7 @@ 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
();
...
@@ -1195,78 +1217,78 @@ handle_idle(struct client *client,
...
@@ -1195,78 +1217,78 @@ 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
,
handle
A
dd
},
{
"add"
,
PERMISSION_ADD
,
1
,
1
,
handle
_a
dd
},
{
"addid"
,
PERMISSION_ADD
,
1
,
2
,
handle
AddI
d
},
{
"addid"
,
PERMISSION_ADD
,
1
,
2
,
handle
_addi
d
},
{
"clear"
,
PERMISSION_CONTROL
,
0
,
0
,
handle
C
lear
},
{
"clear"
,
PERMISSION_CONTROL
,
0
,
0
,
handle
_c
lear
},
{
"clearerror"
,
PERMISSION_CONTROL
,
0
,
0
,
handle
ClearE
rror
},
{
"clearerror"
,
PERMISSION_CONTROL
,
0
,
0
,
handle
_cleare
rror
},
{
"close"
,
PERMISSION_NONE
,
-
1
,
-
1
,
handle
C
lose
},
{
"close"
,
PERMISSION_NONE
,
-
1
,
-
1
,
handle
_c
lose
},
{
"commands"
,
PERMISSION_NONE
,
0
,
0
,
handle
C
ommands
},
{
"commands"
,
PERMISSION_NONE
,
0
,
0
,
handle
_c
ommands
},
{
"count"
,
PERMISSION_READ
,
2
,
-
1
,
handle
C
ount
},
{
"count"
,
PERMISSION_READ
,
2
,
-
1
,
handle
_c
ount
},
{
"crossfade"
,
PERMISSION_CONTROL
,
1
,
1
,
handle
C
rossfade
},
{
"crossfade"
,
PERMISSION_CONTROL
,
1
,
1
,
handle
_c
rossfade
},
{
"currentsong"
,
PERMISSION_READ
,
0
,
0
,
handle
CurrentS
ong
},
{
"currentsong"
,
PERMISSION_READ
,
0
,
0
,
handle
_currents
ong
},
{
"delete"
,
PERMISSION_CONTROL
,
1
,
1
,
handle
D
elete
},
{
"delete"
,
PERMISSION_CONTROL
,
1
,
1
,
handle
_d
elete
},
{
"deleteid"
,
PERMISSION_CONTROL
,
1
,
1
,
handle
DeleteI
d
},
{
"deleteid"
,
PERMISSION_CONTROL
,
1
,
1
,
handle
_deletei
d
},
{
"disableoutput"
,
PERMISSION_ADMIN
,
1
,
1
,
handle
DisableDevice
},
{
"disableoutput"
,
PERMISSION_ADMIN
,
1
,
1
,
handle
_disableoutput
},
{
"enableoutput"
,
PERMISSION_ADMIN
,
1
,
1
,
handle
EnableDevice
},
{
"enableoutput"
,
PERMISSION_ADMIN
,
1
,
1
,
handle
_enableoutput
},
{
"find"
,
PERMISSION_READ
,
2
,
-
1
,
handle
F
ind
},
{
"find"
,
PERMISSION_READ
,
2
,
-
1
,
handle
_f
ind
},
{
"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
handle_commands
(
struct
client
*
client
,
mpd_unused
int
argc
,
mpd_unused
char
*
argv
[])
mpd_unused
int
argc
,
mpd_unused
char
*
argv
[])
{
{
const
unsigned
permission
=
client_get_permission
(
client
);
const
unsigned
permission
=
client_get_permission
(
client
);
...
@@ -1275,15 +1297,15 @@ static int handleCommands(struct client *client,
...
@@ -1275,15 +1297,15 @@ 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
handle_not_commands
(
struct
client
*
client
,
mpd_unused
int
argc
,
mpd_unused
char
*
argv
[])
mpd_unused
int
argc
,
mpd_unused
char
*
argv
[])
{
{
const
unsigned
permission
=
client_get_permission
(
client
);
const
unsigned
permission
=
client_get_permission
(
client
);
...
@@ -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
c
heckArgcAndPermission
(
const
struct
command
*
cmd
,
struct
client
*
client
,
c
ommand_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
->
reqP
ermission
))
{
if
(
cmd
->
permission
!=
(
permission
&
cmd
->
p
ermission
))
{
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,8 +1395,7 @@ checkArgcAndPermission(const struct command *cmd, struct client *client,
...
@@ -1374,8 +1395,7 @@ 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
[]
=
""
;
...
@@ -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
(
c
heckArgcAndPermission
(
cmd
,
client
,
permission
,
argc
,
argv
)
<
0
)
{
if
(
c
ommand_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,8 +1433,7 @@ int processCommand(struct client *client, char *commandString)
...
@@ -1413,8 +1433,7 @@ 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_list
N
um
=
0
;
command_list
_n
um
=
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
(
list
OK
)
else
if
(
list
_ok
)
client_puts
(
client
,
"list_OK
\n
"
);
client_puts
(
client
,
"list_OK
\n
"
);
command_list
N
um
++
;
command_list
_n
um
++
;
cur
=
cur
->
next
;
cur
=
cur
->
next
;
}
}
out:
out:
command_list
N
um
=
0
;
command_list
_n
um
=
0
;
return
ret
;
return
ret
;
}
}
src/command.h
View file @
51a6ee88
...
@@ -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
);
...
...
src/main.c
View file @
51a6ee88
...
@@ -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
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment