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
36cd73df
Commit
36cd73df
authored
Aug 14, 2015
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
client, command: use StringIsEqual()
parent
6f20889f
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
32 additions
and
31 deletions
+32
-31
ClientProcess.cxx
src/client/ClientProcess.cxx
+5
-6
AllCommands.cxx
src/command/AllCommands.cxx
+11
-10
DatabaseCommands.cxx
src/command/DatabaseCommands.cxx
+4
-3
OtherCommands.cxx
src/command/OtherCommands.cxx
+2
-1
StickerCommands.cxx
src/command/StickerCommands.cxx
+10
-11
No files found.
src/client/ClientProcess.cxx
View file @
36cd73df
...
@@ -22,8 +22,7 @@
...
@@ -22,8 +22,7 @@
#include "protocol/Result.hxx"
#include "protocol/Result.hxx"
#include "command/AllCommands.hxx"
#include "command/AllCommands.hxx"
#include "Log.hxx"
#include "Log.hxx"
#include "util/StringAPI.hxx"
#include <string.h>
#define CLIENT_LIST_MODE_BEGIN "command_list_begin"
#define CLIENT_LIST_MODE_BEGIN "command_list_begin"
#define CLIENT_LIST_OK_MODE_BEGIN "command_list_ok_begin"
#define CLIENT_LIST_OK_MODE_BEGIN "command_list_ok_begin"
...
@@ -56,7 +55,7 @@ client_process_line(Client &client, char *line)
...
@@ -56,7 +55,7 @@ client_process_line(Client &client, char *line)
{
{
CommandResult
ret
;
CommandResult
ret
;
if
(
strcmp
(
line
,
"noidle"
)
==
0
)
{
if
(
StringIsEqual
(
line
,
"noidle"
)
)
{
if
(
client
.
idle_waiting
)
{
if
(
client
.
idle_waiting
)
{
/* send empty idle response and leave idle mode */
/* send empty idle response and leave idle mode */
client
.
idle_waiting
=
false
;
client
.
idle_waiting
=
false
;
...
@@ -78,7 +77,7 @@ client_process_line(Client &client, char *line)
...
@@ -78,7 +77,7 @@ client_process_line(Client &client, char *line)
}
}
if
(
client
.
cmd_list
.
IsActive
())
{
if
(
client
.
cmd_list
.
IsActive
())
{
if
(
strcmp
(
line
,
CLIENT_LIST_MODE_END
)
==
0
)
{
if
(
StringIsEqual
(
line
,
CLIENT_LIST_MODE_END
)
)
{
FormatDebug
(
client_domain
,
FormatDebug
(
client_domain
,
"[%u] process command list"
,
"[%u] process command list"
,
client
.
num
);
client
.
num
);
...
@@ -113,10 +112,10 @@ client_process_line(Client &client, char *line)
...
@@ -113,10 +112,10 @@ client_process_line(Client &client, char *line)
ret
=
CommandResult
::
OK
;
ret
=
CommandResult
::
OK
;
}
}
}
else
{
}
else
{
if
(
strcmp
(
line
,
CLIENT_LIST_MODE_BEGIN
)
==
0
)
{
if
(
StringIsEqual
(
line
,
CLIENT_LIST_MODE_BEGIN
)
)
{
client
.
cmd_list
.
Begin
(
false
);
client
.
cmd_list
.
Begin
(
false
);
ret
=
CommandResult
::
OK
;
ret
=
CommandResult
::
OK
;
}
else
if
(
strcmp
(
line
,
CLIENT_LIST_OK_MODE_BEGIN
)
==
0
)
{
}
else
if
(
StringIsEqual
(
line
,
CLIENT_LIST_OK_MODE_BEGIN
)
)
{
client
.
cmd_list
.
Begin
(
true
);
client
.
cmd_list
.
Begin
(
true
);
ret
=
CommandResult
::
OK
;
ret
=
CommandResult
::
OK
;
}
else
{
}
else
{
...
...
src/command/AllCommands.cxx
View file @
36cd73df
...
@@ -40,6 +40,7 @@
...
@@ -40,6 +40,7 @@
#include "util/Tokenizer.hxx"
#include "util/Tokenizer.hxx"
#include "util/Error.hxx"
#include "util/Error.hxx"
#include "util/ConstBuffer.hxx"
#include "util/ConstBuffer.hxx"
#include "util/StringAPI.hxx"
#ifdef ENABLE_SQLITE
#ifdef ENABLE_SQLITE
#include "StickerCommands.hxx"
#include "StickerCommands.hxx"
...
@@ -204,23 +205,23 @@ command_available(gcc_unused const Partition &partition,
...
@@ -204,23 +205,23 @@ command_available(gcc_unused const Partition &partition,
gcc_unused
const
struct
command
*
cmd
)
gcc_unused
const
struct
command
*
cmd
)
{
{
#ifdef ENABLE_SQLITE
#ifdef ENABLE_SQLITE
if
(
strcmp
(
cmd
->
cmd
,
"sticker"
)
==
0
)
if
(
StringIsEqual
(
cmd
->
cmd
,
"sticker"
)
)
return
sticker_enabled
();
return
sticker_enabled
();
#endif
#endif
#ifdef ENABLE_NEIGHBOR_PLUGINS
#ifdef ENABLE_NEIGHBOR_PLUGINS
if
(
strcmp
(
cmd
->
cmd
,
"listneighbors"
)
==
0
)
if
(
StringIsEqual
(
cmd
->
cmd
,
"listneighbors"
)
)
return
neighbor_commands_available
(
partition
.
instance
);
return
neighbor_commands_available
(
partition
.
instance
);
#endif
#endif
if
(
strcmp
(
cmd
->
cmd
,
"save"
)
==
0
||
if
(
StringIsEqual
(
cmd
->
cmd
,
"save"
)
||
strcmp
(
cmd
->
cmd
,
"rm"
)
==
0
||
StringIsEqual
(
cmd
->
cmd
,
"rm"
)
||
strcmp
(
cmd
->
cmd
,
"rename"
)
==
0
||
StringIsEqual
(
cmd
->
cmd
,
"rename"
)
||
strcmp
(
cmd
->
cmd
,
"playlistdelete"
)
==
0
||
StringIsEqual
(
cmd
->
cmd
,
"playlistdelete"
)
||
strcmp
(
cmd
->
cmd
,
"playlistmove"
)
==
0
||
StringIsEqual
(
cmd
->
cmd
,
"playlistmove"
)
||
strcmp
(
cmd
->
cmd
,
"playlistclear"
)
==
0
||
StringIsEqual
(
cmd
->
cmd
,
"playlistclear"
)
||
strcmp
(
cmd
->
cmd
,
"playlistadd"
)
==
0
||
StringIsEqual
(
cmd
->
cmd
,
"playlistadd"
)
||
strcmp
(
cmd
->
cmd
,
"listplaylists"
)
==
0
)
StringIsEqual
(
cmd
->
cmd
,
"listplaylists"
)
)
return
playlist_commands_available
();
return
playlist_commands_available
();
return
true
;
return
true
;
...
...
src/command/DatabaseCommands.cxx
View file @
36cd73df
...
@@ -32,6 +32,7 @@
...
@@ -32,6 +32,7 @@
#include "tag/Tag.hxx"
#include "tag/Tag.hxx"
#include "util/ConstBuffer.hxx"
#include "util/ConstBuffer.hxx"
#include "util/Error.hxx"
#include "util/Error.hxx"
#include "util/StringAPI.hxx"
#include "SongFilter.hxx"
#include "SongFilter.hxx"
#include "BulkEdit.hxx"
#include "BulkEdit.hxx"
...
@@ -70,7 +71,7 @@ static CommandResult
...
@@ -70,7 +71,7 @@ static CommandResult
handle_match
(
Client
&
client
,
Request
args
,
Response
&
r
,
bool
fold_case
)
handle_match
(
Client
&
client
,
Request
args
,
Response
&
r
,
bool
fold_case
)
{
{
RangeArg
window
;
RangeArg
window
;
if
(
args
.
size
>=
2
&&
strcmp
(
args
[
args
.
size
-
2
],
"window"
)
==
0
)
{
if
(
args
.
size
>=
2
&&
StringIsEqual
(
args
[
args
.
size
-
2
],
"window"
)
)
{
if
(
!
args
.
Parse
(
args
.
size
-
1
,
window
,
r
))
if
(
!
args
.
Parse
(
args
.
size
-
1
,
window
,
r
))
return
CommandResult
::
ERROR
;
return
CommandResult
::
ERROR
;
...
@@ -163,7 +164,7 @@ CommandResult
...
@@ -163,7 +164,7 @@ CommandResult
handle_count
(
Client
&
client
,
Request
args
,
Response
&
r
)
handle_count
(
Client
&
client
,
Request
args
,
Response
&
r
)
{
{
TagType
group
=
TAG_NUM_OF_ITEM_TYPES
;
TagType
group
=
TAG_NUM_OF_ITEM_TYPES
;
if
(
args
.
size
>=
2
&&
strcmp
(
args
[
args
.
size
-
2
],
"group"
)
==
0
)
{
if
(
args
.
size
>=
2
&&
StringIsEqual
(
args
[
args
.
size
-
2
],
"group"
)
)
{
const
char
*
s
=
args
[
args
.
size
-
1
];
const
char
*
s
=
args
[
args
.
size
-
1
];
group
=
tag_name_parse_i
(
s
);
group
=
tag_name_parse_i
(
s
);
if
(
group
==
TAG_NUM_OF_ITEM_TYPES
)
{
if
(
group
==
TAG_NUM_OF_ITEM_TYPES
)
{
...
@@ -231,7 +232,7 @@ handle_list(Client &client, Request args, Response &r)
...
@@ -231,7 +232,7 @@ handle_list(Client &client, Request args, Response &r)
}
}
while
(
args
.
size
>=
2
&&
while
(
args
.
size
>=
2
&&
strcmp
(
args
[
args
.
size
-
2
],
"group"
)
==
0
)
{
StringIsEqual
(
args
[
args
.
size
-
2
],
"group"
)
)
{
const
char
*
s
=
args
[
args
.
size
-
1
];
const
char
*
s
=
args
[
args
.
size
-
1
];
TagType
gt
=
tag_name_parse_i
(
s
);
TagType
gt
=
tag_name_parse_i
(
s
);
if
(
gt
==
TAG_NUM_OF_ITEM_TYPES
)
{
if
(
gt
==
TAG_NUM_OF_ITEM_TYPES
)
{
...
...
src/command/OtherCommands.cxx
View file @
36cd73df
...
@@ -37,6 +37,7 @@
...
@@ -37,6 +37,7 @@
#include "util/UriUtil.hxx"
#include "util/UriUtil.hxx"
#include "util/Error.hxx"
#include "util/Error.hxx"
#include "util/ConstBuffer.hxx"
#include "util/ConstBuffer.hxx"
#include "util/StringAPI.hxx"
#include "fs/AllocatedPath.hxx"
#include "fs/AllocatedPath.hxx"
#include "Stats.hxx"
#include "Stats.hxx"
#include "Permission.hxx"
#include "Permission.hxx"
...
@@ -265,7 +266,7 @@ handle_update(Client &client, Request args, Response &r, bool discard)
...
@@ -265,7 +266,7 @@ handle_update(Client &client, Request args, Response &r, bool discard)
if
(
!
args
.
IsEmpty
())
{
if
(
!
args
.
IsEmpty
())
{
path
=
args
.
front
();
path
=
args
.
front
();
if
(
*
path
==
0
||
strcmp
(
path
,
"/"
)
==
0
)
if
(
*
path
==
0
||
StringIsEqual
(
path
,
"/"
)
)
/* backwards compatibility with MPD 0.15 */
/* backwards compatibility with MPD 0.15 */
path
=
""
;
path
=
""
;
else
if
(
!
uri_safe_local
(
path
))
{
else
if
(
!
uri_safe_local
(
path
))
{
...
...
src/command/StickerCommands.cxx
View file @
36cd73df
...
@@ -33,8 +33,7 @@
...
@@ -33,8 +33,7 @@
#include "Instance.hxx"
#include "Instance.hxx"
#include "util/Error.hxx"
#include "util/Error.hxx"
#include "util/ConstBuffer.hxx"
#include "util/ConstBuffer.hxx"
#include "util/StringAPI.hxx"
#include <string.h>
struct
sticker_song_find_data
{
struct
sticker_song_find_data
{
Response
&
r
;
Response
&
r
;
...
@@ -64,7 +63,7 @@ handle_sticker_song(Response &r, Partition &partition, Request args)
...
@@ -64,7 +63,7 @@ handle_sticker_song(Response &r, Partition &partition, Request args)
const
char
*
const
cmd
=
args
.
front
();
const
char
*
const
cmd
=
args
.
front
();
/* get song song_id key */
/* get song song_id key */
if
(
args
.
size
==
4
&&
strcmp
(
cmd
,
"get"
)
==
0
)
{
if
(
args
.
size
==
4
&&
StringIsEqual
(
cmd
,
"get"
)
)
{
const
LightSong
*
song
=
db
->
GetSong
(
args
[
2
],
error
);
const
LightSong
*
song
=
db
->
GetSong
(
args
[
2
],
error
);
if
(
song
==
nullptr
)
if
(
song
==
nullptr
)
return
print_error
(
r
,
error
);
return
print_error
(
r
,
error
);
...
@@ -84,7 +83,7 @@ handle_sticker_song(Response &r, Partition &partition, Request args)
...
@@ -84,7 +83,7 @@ handle_sticker_song(Response &r, Partition &partition, Request args)
return
CommandResult
::
OK
;
return
CommandResult
::
OK
;
/* list song song_id */
/* list song song_id */
}
else
if
(
args
.
size
==
3
&&
strcmp
(
cmd
,
"list"
)
==
0
)
{
}
else
if
(
args
.
size
==
3
&&
StringIsEqual
(
cmd
,
"list"
)
)
{
const
LightSong
*
song
=
db
->
GetSong
(
args
[
2
],
error
);
const
LightSong
*
song
=
db
->
GetSong
(
args
[
2
],
error
);
if
(
song
==
nullptr
)
if
(
song
==
nullptr
)
return
print_error
(
r
,
error
);
return
print_error
(
r
,
error
);
...
@@ -99,7 +98,7 @@ handle_sticker_song(Response &r, Partition &partition, Request args)
...
@@ -99,7 +98,7 @@ handle_sticker_song(Response &r, Partition &partition, Request args)
return
CommandResult
::
OK
;
return
CommandResult
::
OK
;
/* set song song_id id key */
/* set song song_id id key */
}
else
if
(
args
.
size
==
5
&&
strcmp
(
cmd
,
"set"
)
==
0
)
{
}
else
if
(
args
.
size
==
5
&&
StringIsEqual
(
cmd
,
"set"
)
)
{
const
LightSong
*
song
=
db
->
GetSong
(
args
[
2
],
error
);
const
LightSong
*
song
=
db
->
GetSong
(
args
[
2
],
error
);
if
(
song
==
nullptr
)
if
(
song
==
nullptr
)
return
print_error
(
r
,
error
);
return
print_error
(
r
,
error
);
...
@@ -119,7 +118,7 @@ handle_sticker_song(Response &r, Partition &partition, Request args)
...
@@ -119,7 +118,7 @@ handle_sticker_song(Response &r, Partition &partition, Request args)
return
CommandResult
::
OK
;
return
CommandResult
::
OK
;
/* delete song song_id [key] */
/* delete song song_id [key] */
}
else
if
((
args
.
size
==
3
||
args
.
size
==
4
)
&&
}
else
if
((
args
.
size
==
3
||
args
.
size
==
4
)
&&
strcmp
(
cmd
,
"delete"
)
==
0
)
{
StringIsEqual
(
cmd
,
"delete"
)
)
{
const
LightSong
*
song
=
db
->
GetSong
(
args
[
2
],
error
);
const
LightSong
*
song
=
db
->
GetSong
(
args
[
2
],
error
);
if
(
song
==
nullptr
)
if
(
song
==
nullptr
)
return
print_error
(
r
,
error
);
return
print_error
(
r
,
error
);
...
@@ -139,7 +138,7 @@ handle_sticker_song(Response &r, Partition &partition, Request args)
...
@@ -139,7 +138,7 @@ handle_sticker_song(Response &r, Partition &partition, Request args)
return
CommandResult
::
OK
;
return
CommandResult
::
OK
;
/* find song dir key */
/* find song dir key */
}
else
if
((
args
.
size
==
4
||
args
.
size
==
6
)
&&
}
else
if
((
args
.
size
==
4
||
args
.
size
==
6
)
&&
strcmp
(
cmd
,
"find"
)
==
0
)
{
StringIsEqual
(
cmd
,
"find"
)
)
{
/* "sticker find song a/directory name" */
/* "sticker find song a/directory name" */
const
char
*
const
base_uri
=
args
[
2
];
const
char
*
const
base_uri
=
args
[
2
];
...
@@ -153,11 +152,11 @@ handle_sticker_song(Response &r, Partition &partition, Request args)
...
@@ -153,11 +152,11 @@ handle_sticker_song(Response &r, Partition &partition, Request args)
const
char
*
op_s
=
args
[
4
];
const
char
*
op_s
=
args
[
4
];
value
=
args
[
5
];
value
=
args
[
5
];
if
(
strcmp
(
op_s
,
"="
)
==
0
)
if
(
StringIsEqual
(
op_s
,
"="
)
)
op
=
StickerOperator
::
EQUALS
;
op
=
StickerOperator
::
EQUALS
;
else
if
(
strcmp
(
op_s
,
"<"
)
==
0
)
else
if
(
StringIsEqual
(
op_s
,
"<"
)
)
op
=
StickerOperator
::
LESS_THAN
;
op
=
StickerOperator
::
LESS_THAN
;
else
if
(
strcmp
(
op_s
,
">"
)
==
0
)
else
if
(
StringIsEqual
(
op_s
,
">"
)
)
op
=
StickerOperator
::
GREATER_THAN
;
op
=
StickerOperator
::
GREATER_THAN
;
else
{
else
{
r
.
Error
(
ACK_ERROR_ARG
,
"bad operator"
);
r
.
Error
(
ACK_ERROR_ARG
,
"bad operator"
);
...
@@ -200,7 +199,7 @@ handle_sticker(Client &client, Request args, Response &r)
...
@@ -200,7 +199,7 @@ handle_sticker(Client &client, Request args, Response &r)
return
CommandResult
::
ERROR
;
return
CommandResult
::
ERROR
;
}
}
if
(
strcmp
(
args
[
1
],
"song"
)
==
0
)
if
(
StringIsEqual
(
args
[
1
],
"song"
)
)
return
handle_sticker_song
(
r
,
client
.
partition
,
args
);
return
handle_sticker_song
(
r
,
client
.
partition
,
args
);
else
{
else
{
r
.
Error
(
ACK_ERROR_ARG
,
"unknown sticker domain"
);
r
.
Error
(
ACK_ERROR_ARG
,
"unknown sticker domain"
);
...
...
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