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
1ce5f4d7
Commit
1ce5f4d7
authored
Sep 07, 2008
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
command: use client_[gs]et_permission()
Don't pass a pointer to client->permission to processCommand(), better let the code in command.c use the new permission getter/setter functions.
parent
2835e376
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
86 additions
and
84 deletions
+86
-84
client.c
src/client.c
+1
-3
command.c
src/command.c
+83
-78
command.h
src/command.h
+2
-3
No files found.
src/client.c
View file @
1ce5f4d7
...
@@ -337,7 +337,6 @@ static int client_process_line(struct client *client)
...
@@ -337,7 +337,6 @@ static int client_process_line(struct client *client)
DEBUG
(
"client %i: process command "
DEBUG
(
"client %i: process command "
"list
\n
"
,
client
->
num
);
"list
\n
"
,
client
->
num
);
ret
=
processListOfCommands
(
client
,
ret
=
processListOfCommands
(
client
,
&
(
client
->
permission
),
client
->
cmd_list_OK
,
client
->
cmd_list_OK
,
client
->
cmd_list
);
client
->
cmd_list
);
DEBUG
(
"client %i: process command "
DEBUG
(
"client %i: process command "
...
@@ -384,8 +383,7 @@ static int client_process_line(struct client *client)
...
@@ -384,8 +383,7 @@ static int client_process_line(struct client *client)
}
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
,
ret
=
processCommand
(
client
,
line
);
&
(
client
->
permission
),
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 @
1ce5f4d7
...
@@ -126,9 +126,9 @@
...
@@ -126,9 +126,9 @@
typedef
struct
_CommandEntry
CommandEntry
;
typedef
struct
_CommandEntry
CommandEntry
;
typedef
int
(
*
CommandHandlerFunction
)
(
struct
client
*
,
int
*
,
int
,
char
**
);
typedef
int
(
*
CommandHandlerFunction
)
(
struct
client
*
,
int
,
char
**
);
typedef
int
(
*
CommandListHandlerFunction
)
typedef
int
(
*
CommandListHandlerFunction
)
(
struct
client
*
,
int
*
,
int
,
char
**
,
struct
strnode
*
,
CommandEntry
*
);
(
struct
client
*
,
int
,
char
**
,
struct
strnode
*
,
CommandEntry
*
);
/* if min: -1 don't check args *
/* if min: -1 don't check args *
* if max: -1 no max args */
* if max: -1 no max args */
...
@@ -297,20 +297,20 @@ static void addCommand(const char *name,
...
@@ -297,20 +297,20 @@ static void addCommand(const char *name,
insertInList
(
commandList
,
cmd
->
cmd
,
cmd
);
insertInList
(
commandList
,
cmd
->
cmd
,
cmd
);
}
}
static
int
handleUrlHandlers
(
struct
client
*
client
,
mpd_unused
int
*
permission
,
static
int
handleUrlHandlers
(
struct
client
*
client
,
mpd_unused
int
argc
,
mpd_unused
char
*
argv
[])
mpd_unused
int
argc
,
mpd_unused
char
*
argv
[])
{
{
return
printRemoteUrlHandlers
(
client
);
return
printRemoteUrlHandlers
(
client
);
}
}
static
int
handleTagTypes
(
struct
client
*
client
,
mpd_unused
int
*
permission
,
static
int
handleTagTypes
(
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
,
mpd_unused
int
*
permission
,
static
int
handlePlay
(
struct
client
*
client
,
int
argc
,
char
*
argv
[])
int
argc
,
char
*
argv
[])
{
{
int
song
=
-
1
;
int
song
=
-
1
;
...
@@ -322,7 +322,7 @@ static int handlePlay(struct client *client, mpd_unused int *permission,
...
@@ -322,7 +322,7 @@ static int handlePlay(struct client *client, mpd_unused int *permission,
return
print_playlist_result
(
client
,
result
);
return
print_playlist_result
(
client
,
result
);
}
}
static
int
handlePlayId
(
struct
client
*
client
,
mpd_unused
int
*
permission
,
static
int
handlePlayId
(
struct
client
*
client
,
int
argc
,
char
*
argv
[])
int
argc
,
char
*
argv
[])
{
{
int
id
=
-
1
;
int
id
=
-
1
;
...
@@ -335,14 +335,14 @@ static int handlePlayId(struct client *client, mpd_unused int *permission,
...
@@ -335,14 +335,14 @@ static int handlePlayId(struct client *client, mpd_unused int *permission,
return
print_playlist_result
(
client
,
result
);
return
print_playlist_result
(
client
,
result
);
}
}
static
int
handleStop
(
mpd_unused
struct
client
*
client
,
mpd_unused
int
*
permission
,
static
int
handleStop
(
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
,
mpd_unused
int
*
permission
,
static
int
handleCurrentSong
(
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
();
...
@@ -355,7 +355,7 @@ static int handleCurrentSong(struct client *client, mpd_unused int *permission,
...
@@ -355,7 +355,7 @@ static int handleCurrentSong(struct client *client, mpd_unused int *permission,
return
print_playlist_result
(
client
,
result
);
return
print_playlist_result
(
client
,
result
);
}
}
static
int
handlePause
(
struct
client
*
client
,
mpd_unused
int
*
permission
,
static
int
handlePause
(
struct
client
*
client
,
int
argc
,
char
*
argv
[])
int
argc
,
char
*
argv
[])
{
{
if
(
argc
==
2
)
{
if
(
argc
==
2
)
{
...
@@ -370,7 +370,7 @@ static int handlePause(struct client *client, mpd_unused int *permission,
...
@@ -370,7 +370,7 @@ static int handlePause(struct client *client, mpd_unused int *permission,
return
0
;
return
0
;
}
}
static
int
commandStatus
(
struct
client
*
client
,
mpd_unused
int
*
permission
,
static
int
commandStatus
(
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
;
...
@@ -439,19 +439,19 @@ static int commandStatus(struct client *client, mpd_unused int *permission,
...
@@ -439,19 +439,19 @@ static int commandStatus(struct client *client, mpd_unused int *permission,
return
0
;
return
0
;
}
}
static
int
handleKill
(
mpd_unused
struct
client
*
client
,
mpd_unused
int
*
permission
,
static
int
handleKill
(
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
,
mpd_unused
int
*
permission
,
static
int
handleClose
(
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
,
mpd_unused
int
*
permission
,
static
int
handleAdd
(
struct
client
*
client
,
mpd_unused
int
argc
,
char
*
argv
[])
mpd_unused
int
argc
,
char
*
argv
[])
{
{
char
*
path
=
argv
[
1
];
char
*
path
=
argv
[
1
];
...
@@ -470,7 +470,7 @@ static int handleAdd(struct client *client, mpd_unused int *permission,
...
@@ -470,7 +470,7 @@ static int handleAdd(struct client *client, mpd_unused int *permission,
return
print_playlist_result
(
client
,
result
);
return
print_playlist_result
(
client
,
result
);
}
}
static
int
handleAddId
(
struct
client
*
client
,
mpd_unused
int
*
permission
,
static
int
handleAddId
(
struct
client
*
client
,
int
argc
,
char
*
argv
[])
int
argc
,
char
*
argv
[])
{
{
int
added_id
;
int
added_id
;
...
@@ -496,7 +496,7 @@ static int handleAddId(struct client *client, mpd_unused int *permission,
...
@@ -496,7 +496,7 @@ static int handleAddId(struct client *client, mpd_unused int *permission,
return
result
;
return
result
;
}
}
static
int
handleDelete
(
struct
client
*
client
,
mpd_unused
int
*
permission
,
static
int
handleDelete
(
struct
client
*
client
,
mpd_unused
int
argc
,
char
*
argv
[])
mpd_unused
int
argc
,
char
*
argv
[])
{
{
int
song
;
int
song
;
...
@@ -509,7 +509,7 @@ static int handleDelete(struct client *client, mpd_unused int *permission,
...
@@ -509,7 +509,7 @@ static int handleDelete(struct client *client, mpd_unused int *permission,
return
print_playlist_result
(
client
,
result
);
return
print_playlist_result
(
client
,
result
);
}
}
static
int
handleDeleteId
(
struct
client
*
client
,
mpd_unused
int
*
permission
,
static
int
handleDeleteId
(
struct
client
*
client
,
mpd_unused
int
argc
,
char
*
argv
[])
mpd_unused
int
argc
,
char
*
argv
[])
{
{
int
id
;
int
id
;
...
@@ -522,7 +522,7 @@ static int handleDeleteId(struct client *client, mpd_unused int *permission,
...
@@ -522,7 +522,7 @@ static int handleDeleteId(struct client *client, mpd_unused int *permission,
return
print_playlist_result
(
client
,
result
);
return
print_playlist_result
(
client
,
result
);
}
}
static
int
handlePlaylist
(
struct
client
*
client
,
mpd_unused
int
*
permission
,
static
int
handlePlaylist
(
struct
client
*
client
,
mpd_unused
int
argc
,
mpd_unused
char
*
argv
[])
mpd_unused
int
argc
,
mpd_unused
char
*
argv
[])
{
{
showPlaylist
(
client
);
showPlaylist
(
client
);
...
@@ -530,21 +530,20 @@ static int handlePlaylist(struct client *client, mpd_unused int *permission,
...
@@ -530,21 +530,20 @@ static int handlePlaylist(struct client *client, mpd_unused int *permission,
}
}
static
int
handleShuffle
(
mpd_unused
struct
client
*
client
,
static
int
handleShuffle
(
mpd_unused
struct
client
*
client
,
mpd_unused
int
*
permission
,
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
,
mpd_unused
int
*
permission
,
static
int
handleClear
(
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
,
mpd_unused
int
*
permission
,
static
int
handleSave
(
struct
client
*
client
,
mpd_unused
int
argc
,
char
*
argv
[])
mpd_unused
int
argc
,
char
*
argv
[])
{
{
enum
playlist_result
result
;
enum
playlist_result
result
;
...
@@ -553,7 +552,7 @@ static int handleSave(struct client *client, mpd_unused int *permission,
...
@@ -553,7 +552,7 @@ static int handleSave(struct client *client, mpd_unused int *permission,
return
print_playlist_result
(
client
,
result
);
return
print_playlist_result
(
client
,
result
);
}
}
static
int
handleLoad
(
struct
client
*
client
,
mpd_unused
int
*
permission
,
static
int
handleLoad
(
struct
client
*
client
,
mpd_unused
int
argc
,
char
*
argv
[])
mpd_unused
int
argc
,
char
*
argv
[])
{
{
enum
playlist_result
result
;
enum
playlist_result
result
;
...
@@ -562,7 +561,7 @@ static int handleLoad(struct client *client, mpd_unused int *permission,
...
@@ -562,7 +561,7 @@ static int handleLoad(struct client *client, mpd_unused int *permission,
return
print_playlist_result
(
client
,
result
);
return
print_playlist_result
(
client
,
result
);
}
}
static
int
handleListPlaylist
(
struct
client
*
client
,
mpd_unused
int
*
permission
,
static
int
handleListPlaylist
(
struct
client
*
client
,
mpd_unused
int
argc
,
char
*
argv
[])
mpd_unused
int
argc
,
char
*
argv
[])
{
{
int
ret
;
int
ret
;
...
@@ -574,7 +573,7 @@ static int handleListPlaylist(struct client *client, mpd_unused int *permission,
...
@@ -574,7 +573,7 @@ static int handleListPlaylist(struct client *client, mpd_unused int *permission,
return
ret
;
return
ret
;
}
}
static
int
handleListPlaylistInfo
(
struct
client
*
client
,
mpd_unused
int
*
permission
,
static
int
handleListPlaylistInfo
(
struct
client
*
client
,
mpd_unused
int
argc
,
char
*
argv
[])
mpd_unused
int
argc
,
char
*
argv
[])
{
{
int
ret
;
int
ret
;
...
@@ -586,7 +585,7 @@ static int handleListPlaylistInfo(struct client *client, mpd_unused int *permiss
...
@@ -586,7 +585,7 @@ static int handleListPlaylistInfo(struct client *client, mpd_unused int *permiss
return
ret
;
return
ret
;
}
}
static
int
handleLsInfo
(
struct
client
*
client
,
mpd_unused
int
*
permission
,
static
int
handleLsInfo
(
struct
client
*
client
,
int
argc
,
char
*
argv
[])
int
argc
,
char
*
argv
[])
{
{
const
char
*
path
=
""
;
const
char
*
path
=
""
;
...
@@ -606,7 +605,7 @@ static int handleLsInfo(struct client *client, mpd_unused int *permission,
...
@@ -606,7 +605,7 @@ static int handleLsInfo(struct client *client, mpd_unused int *permission,
return
0
;
return
0
;
}
}
static
int
handleRm
(
struct
client
*
client
,
mpd_unused
int
*
permission
,
static
int
handleRm
(
struct
client
*
client
,
mpd_unused
int
argc
,
char
*
argv
[])
mpd_unused
int
argc
,
char
*
argv
[])
{
{
enum
playlist_result
result
;
enum
playlist_result
result
;
...
@@ -615,7 +614,7 @@ static int handleRm(struct client *client, mpd_unused int *permission,
...
@@ -615,7 +614,7 @@ static int handleRm(struct client *client, mpd_unused int *permission,
return
print_playlist_result
(
client
,
result
);
return
print_playlist_result
(
client
,
result
);
}
}
static
int
handleRename
(
struct
client
*
client
,
mpd_unused
int
*
permission
,
static
int
handleRename
(
struct
client
*
client
,
mpd_unused
int
argc
,
char
*
argv
[])
mpd_unused
int
argc
,
char
*
argv
[])
{
{
enum
playlist_result
result
;
enum
playlist_result
result
;
...
@@ -624,7 +623,7 @@ static int handleRename(struct client *client, mpd_unused int *permission,
...
@@ -624,7 +623,7 @@ static int handleRename(struct client *client, mpd_unused int *permission,
return
print_playlist_result
(
client
,
result
);
return
print_playlist_result
(
client
,
result
);
}
}
static
int
handlePlaylistChanges
(
struct
client
*
client
,
mpd_unused
int
*
permission
,
static
int
handlePlaylistChanges
(
struct
client
*
client
,
mpd_unused
int
argc
,
char
*
argv
[])
mpd_unused
int
argc
,
char
*
argv
[])
{
{
mpd_uint32
version
;
mpd_uint32
version
;
...
@@ -634,7 +633,7 @@ static int handlePlaylistChanges(struct client *client, mpd_unused int *permissi
...
@@ -634,7 +633,7 @@ static int handlePlaylistChanges(struct client *client, mpd_unused int *permissi
return
playlistChanges
(
client
,
version
);
return
playlistChanges
(
client
,
version
);
}
}
static
int
handlePlaylistChangesPosId
(
struct
client
*
client
,
mpd_unused
int
*
permission
,
static
int
handlePlaylistChangesPosId
(
struct
client
*
client
,
mpd_unused
int
argc
,
char
*
argv
[])
mpd_unused
int
argc
,
char
*
argv
[])
{
{
mpd_uint32
version
;
mpd_uint32
version
;
...
@@ -644,7 +643,7 @@ static int handlePlaylistChangesPosId(struct client *client, mpd_unused int *per
...
@@ -644,7 +643,7 @@ static int handlePlaylistChangesPosId(struct client *client, mpd_unused int *per
return
playlistChangesPosId
(
client
,
version
);
return
playlistChangesPosId
(
client
,
version
);
}
}
static
int
handlePlaylistInfo
(
struct
client
*
client
,
mpd_unused
int
*
permission
,
static
int
handlePlaylistInfo
(
struct
client
*
client
,
int
argc
,
char
*
argv
[])
int
argc
,
char
*
argv
[])
{
{
int
song
=
-
1
;
int
song
=
-
1
;
...
@@ -657,7 +656,7 @@ static int handlePlaylistInfo(struct client *client, mpd_unused int *permission,
...
@@ -657,7 +656,7 @@ static int handlePlaylistInfo(struct client *client, mpd_unused int *permission,
return
print_playlist_result
(
client
,
result
);
return
print_playlist_result
(
client
,
result
);
}
}
static
int
handlePlaylistId
(
struct
client
*
client
,
mpd_unused
int
*
permission
,
static
int
handlePlaylistId
(
struct
client
*
client
,
int
argc
,
char
*
argv
[])
int
argc
,
char
*
argv
[])
{
{
int
id
=
-
1
;
int
id
=
-
1
;
...
@@ -670,7 +669,7 @@ static int handlePlaylistId(struct client *client, mpd_unused int *permission,
...
@@ -670,7 +669,7 @@ static int handlePlaylistId(struct client *client, mpd_unused int *permission,
return
print_playlist_result
(
client
,
result
);
return
print_playlist_result
(
client
,
result
);
}
}
static
int
handleFind
(
struct
client
*
client
,
mpd_unused
int
*
permission
,
static
int
handleFind
(
struct
client
*
client
,
int
argc
,
char
*
argv
[])
int
argc
,
char
*
argv
[])
{
{
int
ret
;
int
ret
;
...
@@ -695,7 +694,7 @@ static int handleFind(struct client *client, mpd_unused int *permission,
...
@@ -695,7 +694,7 @@ static int handleFind(struct client *client, mpd_unused int *permission,
return
ret
;
return
ret
;
}
}
static
int
handleSearch
(
struct
client
*
client
,
mpd_unused
int
*
permission
,
static
int
handleSearch
(
struct
client
*
client
,
int
argc
,
char
*
argv
[])
int
argc
,
char
*
argv
[])
{
{
int
ret
;
int
ret
;
...
@@ -720,7 +719,7 @@ static int handleSearch(struct client *client, mpd_unused int *permission,
...
@@ -720,7 +719,7 @@ static int handleSearch(struct client *client, mpd_unused int *permission,
return
ret
;
return
ret
;
}
}
static
int
handleCount
(
struct
client
*
client
,
mpd_unused
int
*
permission
,
static
int
handleCount
(
struct
client
*
client
,
int
argc
,
char
*
argv
[])
int
argc
,
char
*
argv
[])
{
{
int
ret
;
int
ret
;
...
@@ -745,7 +744,7 @@ static int handleCount(struct client *client, mpd_unused int *permission,
...
@@ -745,7 +744,7 @@ static int handleCount(struct client *client, mpd_unused int *permission,
return
ret
;
return
ret
;
}
}
static
int
handlePlaylistFind
(
struct
client
*
client
,
mpd_unused
int
*
permission
,
static
int
handlePlaylistFind
(
struct
client
*
client
,
int
argc
,
char
*
argv
[])
int
argc
,
char
*
argv
[])
{
{
LocateTagItem
*
items
;
LocateTagItem
*
items
;
...
@@ -765,7 +764,7 @@ static int handlePlaylistFind(struct client *client, mpd_unused int *permission,
...
@@ -765,7 +764,7 @@ static int handlePlaylistFind(struct client *client, mpd_unused int *permission,
return
0
;
return
0
;
}
}
static
int
handlePlaylistSearch
(
struct
client
*
client
,
mpd_unused
int
*
permission
,
static
int
handlePlaylistSearch
(
struct
client
*
client
,
int
argc
,
char
*
argv
[])
int
argc
,
char
*
argv
[])
{
{
LocateTagItem
*
items
;
LocateTagItem
*
items
;
...
@@ -785,7 +784,7 @@ static int handlePlaylistSearch(struct client *client, mpd_unused int *permissio
...
@@ -785,7 +784,7 @@ static int handlePlaylistSearch(struct client *client, mpd_unused int *permissio
return
0
;
return
0
;
}
}
static
int
handlePlaylistDelete
(
struct
client
*
client
,
mpd_unused
int
*
permission
,
static
int
handlePlaylistDelete
(
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
;
...
@@ -798,7 +797,7 @@ static int handlePlaylistDelete(struct client *client, mpd_unused int *permissio
...
@@ -798,7 +797,7 @@ static int handlePlaylistDelete(struct client *client, mpd_unused int *permissio
return
print_playlist_result
(
client
,
result
);
return
print_playlist_result
(
client
,
result
);
}
}
static
int
handlePlaylistMove
(
struct
client
*
client
,
mpd_unused
int
*
permission
,
static
int
handlePlaylistMove
(
struct
client
*
client
,
mpd_unused
mpd_unused
int
argc
,
char
*
argv
[])
mpd_unused
mpd_unused
int
argc
,
char
*
argv
[])
{
{
char
*
playlist
=
argv
[
1
];
char
*
playlist
=
argv
[
1
];
...
@@ -815,7 +814,6 @@ static int handlePlaylistMove(struct client *client, mpd_unused int *permission,
...
@@ -815,7 +814,6 @@ static int handlePlaylistMove(struct client *client, mpd_unused int *permission,
}
}
static
int
listHandleUpdate
(
struct
client
*
client
,
static
int
listHandleUpdate
(
struct
client
*
client
,
mpd_unused
int
*
permission
,
mpd_unused
int
argc
,
mpd_unused
int
argc
,
char
*
argv
[],
char
*
argv
[],
struct
strnode
*
cmdnode
,
CommandEntry
*
cmd
)
struct
strnode
*
cmdnode
,
CommandEntry
*
cmd
)
...
@@ -833,7 +831,8 @@ static int listHandleUpdate(struct client *client,
...
@@ -833,7 +831,8 @@ static int listHandleUpdate(struct client *client,
insertInList
(
pathList
,
""
,
NULL
);
insertInList
(
pathList
,
""
,
NULL
);
if
(
next
)
if
(
next
)
nextCmd
=
getCommandEntryFromString
(
next
->
data
,
*
permission
);
nextCmd
=
getCommandEntryFromString
(
next
->
data
,
client_get_permission
(
client
));
if
(
cmd
!=
nextCmd
)
{
if
(
cmd
!=
nextCmd
)
{
int
ret
=
updateInit
(
pathList
);
int
ret
=
updateInit
(
pathList
);
...
@@ -863,7 +862,7 @@ static int listHandleUpdate(struct client *client,
...
@@ -863,7 +862,7 @@ static int listHandleUpdate(struct client *client,
return
0
;
return
0
;
}
}
static
int
handleUpdate
(
struct
client
*
client
,
mpd_unused
int
*
permission
,
static
int
handleUpdate
(
struct
client
*
client
,
mpd_unused
int
argc
,
char
*
argv
[])
mpd_unused
int
argc
,
char
*
argv
[])
{
{
int
ret
;
int
ret
;
...
@@ -897,21 +896,21 @@ static int handleUpdate(struct client *client, mpd_unused int *permission,
...
@@ -897,21 +896,21 @@ static int handleUpdate(struct client *client, mpd_unused int *permission,
return
ret
;
return
ret
;
}
}
static
int
handleNext
(
mpd_unused
struct
client
*
client
,
mpd_unused
int
*
permission
,
static
int
handleNext
(
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
,
mpd_unused
int
*
permission
,
static
int
handlePrevious
(
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
,
mpd_unused
int
*
permission
,
static
int
handleListAll
(
struct
client
*
client
,
mpd_unused
int
argc
,
char
*
argv
[])
mpd_unused
int
argc
,
char
*
argv
[])
{
{
char
*
directory
=
NULL
;
char
*
directory
=
NULL
;
...
@@ -928,7 +927,7 @@ static int handleListAll(struct client *client, mpd_unused int *permission,
...
@@ -928,7 +927,7 @@ static int handleListAll(struct client *client, mpd_unused int *permission,
return
ret
;
return
ret
;
}
}
static
int
handleVolume
(
struct
client
*
client
,
mpd_unused
int
*
permission
,
static
int
handleVolume
(
struct
client
*
client
,
mpd_unused
int
argc
,
char
*
argv
[])
mpd_unused
int
argc
,
char
*
argv
[])
{
{
int
change
,
ret
;
int
change
,
ret
;
...
@@ -944,7 +943,7 @@ static int handleVolume(struct client *client, mpd_unused int *permission,
...
@@ -944,7 +943,7 @@ static int handleVolume(struct client *client, mpd_unused int *permission,
return
ret
;
return
ret
;
}
}
static
int
handleSetVol
(
struct
client
*
client
,
mpd_unused
int
*
permission
,
static
int
handleSetVol
(
struct
client
*
client
,
mpd_unused
int
argc
,
char
*
argv
[])
mpd_unused
int
argc
,
char
*
argv
[])
{
{
int
level
,
ret
;
int
level
,
ret
;
...
@@ -960,7 +959,7 @@ static int handleSetVol(struct client *client, mpd_unused int *permission,
...
@@ -960,7 +959,7 @@ static int handleSetVol(struct client *client, mpd_unused int *permission,
return
ret
;
return
ret
;
}
}
static
int
handleRepeat
(
struct
client
*
client
,
mpd_unused
int
*
permission
,
static
int
handleRepeat
(
struct
client
*
client
,
mpd_unused
int
argc
,
char
*
argv
[])
mpd_unused
int
argc
,
char
*
argv
[])
{
{
int
status
;
int
status
;
...
@@ -978,7 +977,7 @@ static int handleRepeat(struct client *client, mpd_unused int *permission,
...
@@ -978,7 +977,7 @@ static int handleRepeat(struct client *client, mpd_unused int *permission,
return
0
;
return
0
;
}
}
static
int
handleRandom
(
struct
client
*
client
,
mpd_unused
int
*
permission
,
static
int
handleRandom
(
struct
client
*
client
,
mpd_unused
int
argc
,
char
*
argv
[])
mpd_unused
int
argc
,
char
*
argv
[])
{
{
int
status
;
int
status
;
...
@@ -996,20 +995,20 @@ static int handleRandom(struct client *client, mpd_unused int *permission,
...
@@ -996,20 +995,20 @@ static int handleRandom(struct client *client, mpd_unused int *permission,
return
0
;
return
0
;
}
}
static
int
handleStats
(
struct
client
*
client
,
mpd_unused
int
*
permission
,
static
int
handleStats
(
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
,
mpd_unused
int
*
permission
,
static
int
handleClearError
(
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
,
mpd_unused
int
*
permission
,
static
int
handleList
(
struct
client
*
client
,
int
argc
,
char
*
argv
[])
int
argc
,
char
*
argv
[])
{
{
int
numConditionals
;
int
numConditionals
;
...
@@ -1063,7 +1062,7 @@ static int handleList(struct client *client, mpd_unused int *permission,
...
@@ -1063,7 +1062,7 @@ static int handleList(struct client *client, mpd_unused int *permission,
return
ret
;
return
ret
;
}
}
static
int
handleMove
(
struct
client
*
client
,
mpd_unused
int
*
permission
,
static
int
handleMove
(
struct
client
*
client
,
mpd_unused
int
argc
,
char
*
argv
[])
mpd_unused
int
argc
,
char
*
argv
[])
{
{
int
from
,
to
;
int
from
,
to
;
...
@@ -1077,7 +1076,7 @@ static int handleMove(struct client *client, mpd_unused int *permission,
...
@@ -1077,7 +1076,7 @@ static int handleMove(struct client *client, mpd_unused int *permission,
return
print_playlist_result
(
client
,
result
);
return
print_playlist_result
(
client
,
result
);
}
}
static
int
handleMoveId
(
struct
client
*
client
,
mpd_unused
int
*
permission
,
static
int
handleMoveId
(
struct
client
*
client
,
mpd_unused
int
argc
,
char
*
argv
[])
mpd_unused
int
argc
,
char
*
argv
[])
{
{
int
id
,
to
;
int
id
,
to
;
...
@@ -1091,7 +1090,7 @@ static int handleMoveId(struct client *client, mpd_unused int *permission,
...
@@ -1091,7 +1090,7 @@ static int handleMoveId(struct client *client, mpd_unused int *permission,
return
print_playlist_result
(
client
,
result
);
return
print_playlist_result
(
client
,
result
);
}
}
static
int
handleSwap
(
struct
client
*
client
,
mpd_unused
int
*
permission
,
static
int
handleSwap
(
struct
client
*
client
,
mpd_unused
int
argc
,
char
*
argv
[])
mpd_unused
int
argc
,
char
*
argv
[])
{
{
int
song1
,
song2
;
int
song1
,
song2
;
...
@@ -1105,7 +1104,7 @@ static int handleSwap(struct client *client, mpd_unused int *permission,
...
@@ -1105,7 +1104,7 @@ static int handleSwap(struct client *client, mpd_unused int *permission,
return
print_playlist_result
(
client
,
result
);
return
print_playlist_result
(
client
,
result
);
}
}
static
int
handleSwapId
(
struct
client
*
client
,
mpd_unused
int
*
permission
,
static
int
handleSwapId
(
struct
client
*
client
,
mpd_unused
int
argc
,
char
*
argv
[])
mpd_unused
int
argc
,
char
*
argv
[])
{
{
int
id1
,
id2
;
int
id1
,
id2
;
...
@@ -1119,7 +1118,7 @@ static int handleSwapId(struct client *client, mpd_unused int *permission,
...
@@ -1119,7 +1118,7 @@ static int handleSwapId(struct client *client, mpd_unused int *permission,
return
print_playlist_result
(
client
,
result
);
return
print_playlist_result
(
client
,
result
);
}
}
static
int
handleSeek
(
struct
client
*
client
,
mpd_unused
int
*
permission
,
static
int
handleSeek
(
struct
client
*
client
,
mpd_unused
int
argc
,
char
*
argv
[])
mpd_unused
int
argc
,
char
*
argv
[])
{
{
int
song
,
seek_time
;
int
song
,
seek_time
;
...
@@ -1134,7 +1133,7 @@ static int handleSeek(struct client *client, mpd_unused int *permission,
...
@@ -1134,7 +1133,7 @@ static int handleSeek(struct client *client, mpd_unused int *permission,
return
print_playlist_result
(
client
,
result
);
return
print_playlist_result
(
client
,
result
);
}
}
static
int
handleSeekId
(
struct
client
*
client
,
mpd_unused
int
*
permission
,
static
int
handleSeekId
(
struct
client
*
client
,
mpd_unused
int
argc
,
char
*
argv
[])
mpd_unused
int
argc
,
char
*
argv
[])
{
{
int
id
,
seek_time
;
int
id
,
seek_time
;
...
@@ -1149,7 +1148,7 @@ static int handleSeekId(struct client *client, mpd_unused int *permission,
...
@@ -1149,7 +1148,7 @@ static int handleSeekId(struct client *client, mpd_unused int *permission,
return
print_playlist_result
(
client
,
result
);
return
print_playlist_result
(
client
,
result
);
}
}
static
int
handleListAllInfo
(
struct
client
*
client
,
mpd_unused
int
*
permission
,
static
int
handleListAllInfo
(
struct
client
*
client
,
mpd_unused
int
argc
,
char
*
argv
[])
mpd_unused
int
argc
,
char
*
argv
[])
{
{
char
*
directory
=
NULL
;
char
*
directory
=
NULL
;
...
@@ -1166,24 +1165,28 @@ static int handleListAllInfo(struct client *client, mpd_unused int *permission,
...
@@ -1166,24 +1165,28 @@ static int handleListAllInfo(struct client *client, mpd_unused int *permission,
return
ret
;
return
ret
;
}
}
static
int
handlePing
(
mpd_unused
struct
client
*
client
,
mpd_unused
int
*
permission
,
static
int
handlePing
(
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
,
mpd_unused
int
*
permission
,
static
int
handlePassword
(
struct
client
*
client
,
mpd_unused
int
argc
,
char
*
argv
[])
mpd_unused
int
argc
,
char
*
argv
[])
{
{
if
(
getPermissionFromPassword
(
argv
[
1
],
permission
)
<
0
)
{
int
permission
=
0
;
if
(
getPermissionFromPassword
(
argv
[
1
],
&
permission
)
<
0
)
{
command_error
(
client
,
ACK_ERROR_PASSWORD
,
"incorrect password"
);
command_error
(
client
,
ACK_ERROR_PASSWORD
,
"incorrect password"
);
return
-
1
;
return
-
1
;
}
}
client_set_permission
(
client
,
permission
);
return
0
;
return
0
;
}
}
static
int
handleCrossfade
(
struct
client
*
client
,
mpd_unused
int
*
permission
,
static
int
handleCrossfade
(
struct
client
*
client
,
mpd_unused
int
argc
,
char
*
argv
[])
mpd_unused
int
argc
,
char
*
argv
[])
{
{
int
xfade_time
;
int
xfade_time
;
...
@@ -1195,7 +1198,7 @@ static int handleCrossfade(struct client *client, mpd_unused int *permission,
...
@@ -1195,7 +1198,7 @@ static int handleCrossfade(struct client *client, mpd_unused int *permission,
return
0
;
return
0
;
}
}
static
int
handleEnableDevice
(
struct
client
*
client
,
mpd_unused
int
*
permission
,
static
int
handleEnableDevice
(
struct
client
*
client
,
mpd_unused
int
argc
,
char
*
argv
[])
mpd_unused
int
argc
,
char
*
argv
[])
{
{
int
device
,
ret
;
int
device
,
ret
;
...
@@ -1211,7 +1214,7 @@ static int handleEnableDevice(struct client *client, mpd_unused int *permission,
...
@@ -1211,7 +1214,7 @@ static int handleEnableDevice(struct client *client, mpd_unused int *permission,
return
ret
;
return
ret
;
}
}
static
int
handleDisableDevice
(
struct
client
*
client
,
mpd_unused
int
*
permission
,
static
int
handleDisableDevice
(
struct
client
*
client
,
mpd_unused
int
argc
,
char
*
argv
[])
mpd_unused
int
argc
,
char
*
argv
[])
{
{
int
device
,
ret
;
int
device
,
ret
;
...
@@ -1227,7 +1230,7 @@ static int handleDisableDevice(struct client *client, mpd_unused int *permission
...
@@ -1227,7 +1230,7 @@ static int handleDisableDevice(struct client *client, mpd_unused int *permission
return
ret
;
return
ret
;
}
}
static
int
handleDevices
(
struct
client
*
client
,
mpd_unused
int
*
permission
,
static
int
handleDevices
(
struct
client
*
client
,
mpd_unused
int
argc
,
mpd_unused
char
*
argv
[])
mpd_unused
int
argc
,
mpd_unused
char
*
argv
[])
{
{
printAudioDevices
(
client
);
printAudioDevices
(
client
);
...
@@ -1236,15 +1239,16 @@ static int handleDevices(struct client *client, mpd_unused int *permission,
...
@@ -1236,15 +1239,16 @@ static int handleDevices(struct client *client, mpd_unused int *permission,
}
}
/* 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
,
mpd_unused
int
*
permission
,
static
int
handleCommands
(
struct
client
*
client
,
mpd_unused
int
argc
,
mpd_unused
char
*
argv
[])
mpd_unused
int
argc
,
mpd_unused
char
*
argv
[])
{
{
const
int
permission
=
client_get_permission
(
client
);
ListNode
*
node
=
commandList
->
firstNode
;
ListNode
*
node
=
commandList
->
firstNode
;
CommandEntry
*
cmd
;
CommandEntry
*
cmd
;
while
(
node
!=
NULL
)
{
while
(
node
!=
NULL
)
{
cmd
=
(
CommandEntry
*
)
node
->
data
;
cmd
=
(
CommandEntry
*
)
node
->
data
;
if
(
cmd
->
reqPermission
==
(
*
permission
&
cmd
->
reqPermission
))
{
if
(
cmd
->
reqPermission
==
(
permission
&
cmd
->
reqPermission
))
{
client_printf
(
client
,
"command: %s
\n
"
,
cmd
->
cmd
);
client_printf
(
client
,
"command: %s
\n
"
,
cmd
->
cmd
);
}
}
...
@@ -1254,16 +1258,17 @@ static int handleCommands(struct client *client, mpd_unused int *permission,
...
@@ -1254,16 +1258,17 @@ static int handleCommands(struct client *client, mpd_unused int *permission,
return
0
;
return
0
;
}
}
static
int
handleNotcommands
(
struct
client
*
client
,
mpd_unused
int
*
permission
,
static
int
handleNotcommands
(
struct
client
*
client
,
mpd_unused
int
argc
,
mpd_unused
char
*
argv
[])
mpd_unused
int
argc
,
mpd_unused
char
*
argv
[])
{
{
const
int
permission
=
client_get_permission
(
client
);
ListNode
*
node
=
commandList
->
firstNode
;
ListNode
*
node
=
commandList
->
firstNode
;
CommandEntry
*
cmd
;
CommandEntry
*
cmd
;
while
(
node
!=
NULL
)
{
while
(
node
!=
NULL
)
{
cmd
=
(
CommandEntry
*
)
node
->
data
;
cmd
=
(
CommandEntry
*
)
node
->
data
;
if
(
cmd
->
reqPermission
!=
(
*
permission
&
cmd
->
reqPermission
))
{
if
(
cmd
->
reqPermission
!=
(
permission
&
cmd
->
reqPermission
))
{
client_printf
(
client
,
"command: %s
\n
"
,
cmd
->
cmd
);
client_printf
(
client
,
"command: %s
\n
"
,
cmd
->
cmd
);
}
}
...
@@ -1273,7 +1278,7 @@ static int handleNotcommands(struct client *client, mpd_unused int *permission,
...
@@ -1273,7 +1278,7 @@ static int handleNotcommands(struct client *client, mpd_unused int *permission,
return
0
;
return
0
;
}
}
static
int
handlePlaylistClear
(
struct
client
*
client
,
mpd_unused
int
*
permission
,
static
int
handlePlaylistClear
(
struct
client
*
client
,
mpd_unused
int
argc
,
char
*
argv
[])
mpd_unused
int
argc
,
char
*
argv
[])
{
{
enum
playlist_result
result
;
enum
playlist_result
result
;
...
@@ -1282,7 +1287,7 @@ static int handlePlaylistClear(struct client *client, mpd_unused int *permission
...
@@ -1282,7 +1287,7 @@ static int handlePlaylistClear(struct client *client, mpd_unused int *permission
return
print_playlist_result
(
client
,
result
);
return
print_playlist_result
(
client
,
result
);
}
}
static
int
handlePlaylistAdd
(
struct
client
*
client
,
mpd_unused
int
*
permission
,
static
int
handlePlaylistAdd
(
struct
client
*
client
,
mpd_unused
int
argc
,
char
*
argv
[])
mpd_unused
int
argc
,
char
*
argv
[])
{
{
char
*
playlist
=
argv
[
1
];
char
*
playlist
=
argv
[
1
];
...
@@ -1462,7 +1467,6 @@ static CommandEntry *getCommandEntryFromString(char *string, int permission)
...
@@ -1462,7 +1467,6 @@ static CommandEntry *getCommandEntryFromString(char *string, int permission)
}
}
static
int
processCommandInternal
(
struct
client
*
client
,
static
int
processCommandInternal
(
struct
client
*
client
,
mpd_unused
int
*
permission
,
char
*
commandString
,
struct
strnode
*
cmdnode
)
char
*
commandString
,
struct
strnode
*
cmdnode
)
{
{
int
argc
;
int
argc
;
...
@@ -1475,12 +1479,13 @@ static int processCommandInternal(struct client *client,
...
@@ -1475,12 +1479,13 @@ static int processCommandInternal(struct client *client,
if
(
argc
==
0
)
if
(
argc
==
0
)
return
0
;
return
0
;
if
((
cmd
=
getCommandEntryAndCheckArgcAndPermission
(
client
,
*
permission
,
if
((
cmd
=
getCommandEntryAndCheckArgcAndPermission
(
client
,
client_get_permission
(
client
),
argc
,
argv
)))
{
argc
,
argv
)))
{
if
(
!
cmdnode
||
!
cmd
->
listHandler
)
{
if
(
!
cmdnode
||
!
cmd
->
listHandler
)
{
ret
=
cmd
->
handler
(
client
,
permission
,
argc
,
argv
);
ret
=
cmd
->
handler
(
client
,
argc
,
argv
);
}
else
{
}
else
{
ret
=
cmd
->
listHandler
(
client
,
permission
,
argc
,
argv
,
ret
=
cmd
->
listHandler
(
client
,
argc
,
argv
,
cmdnode
,
cmd
);
cmdnode
,
cmd
);
}
}
}
}
...
@@ -1490,7 +1495,7 @@ static int processCommandInternal(struct client *client,
...
@@ -1490,7 +1495,7 @@ static int processCommandInternal(struct client *client,
return
ret
;
return
ret
;
}
}
int
processListOfCommands
(
struct
client
*
client
,
int
*
permission
,
int
processListOfCommands
(
struct
client
*
client
,
int
listOK
,
struct
strnode
*
list
)
int
listOK
,
struct
strnode
*
list
)
{
{
struct
strnode
*
cur
=
list
;
struct
strnode
*
cur
=
list
;
...
@@ -1501,7 +1506,7 @@ int processListOfCommands(struct client *client, int *permission,
...
@@ -1501,7 +1506,7 @@ int processListOfCommands(struct client *client, int *permission,
while
(
cur
)
{
while
(
cur
)
{
DEBUG
(
"processListOfCommands: process command
\"
%s
\"\n
"
,
DEBUG
(
"processListOfCommands: process command
\"
%s
\"\n
"
,
cur
->
data
);
cur
->
data
);
ret
=
processCommandInternal
(
client
,
permission
,
cur
->
data
,
cur
);
ret
=
processCommandInternal
(
client
,
cur
->
data
,
cur
);
DEBUG
(
"processListOfCommands: command returned %i
\n
"
,
ret
);
DEBUG
(
"processListOfCommands: command returned %i
\n
"
,
ret
);
if
(
ret
!=
0
||
client_is_expired
(
client
))
if
(
ret
!=
0
||
client_is_expired
(
client
))
goto
out
;
goto
out
;
...
@@ -1515,7 +1520,7 @@ out:
...
@@ -1515,7 +1520,7 @@ out:
return
ret
;
return
ret
;
}
}
int
processCommand
(
struct
client
*
client
,
int
*
permission
,
char
*
commandString
)
int
processCommand
(
struct
client
*
client
,
char
*
commandString
)
{
{
return
processCommandInternal
(
client
,
permission
,
commandString
,
NULL
);
return
processCommandInternal
(
client
,
commandString
,
NULL
);
}
}
src/command.h
View file @
1ce5f4d7
...
@@ -29,11 +29,10 @@
...
@@ -29,11 +29,10 @@
struct
client
;
struct
client
;
int
processListOfCommands
(
struct
client
*
client
,
int
*
permission
,
int
processListOfCommands
(
struct
client
*
client
,
int
listOK
,
struct
strnode
*
list
);
int
listOK
,
struct
strnode
*
list
);
int
processCommand
(
struct
client
*
client
,
int
processCommand
(
struct
client
*
client
,
char
*
commandString
);
int
*
permission
,
char
*
commandString
);
void
initCommands
(
void
);
void
initCommands
(
void
);
...
...
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