client, command: use StringIsEqual()
This commit is contained in:
parent
6f20889f00
commit
36cd73df51
@ -22,8 +22,7 @@
|
||||
#include "protocol/Result.hxx"
|
||||
#include "command/AllCommands.hxx"
|
||||
#include "Log.hxx"
|
||||
|
||||
#include <string.h>
|
||||
#include "util/StringAPI.hxx"
|
||||
|
||||
#define CLIENT_LIST_MODE_BEGIN "command_list_begin"
|
||||
#define CLIENT_LIST_OK_MODE_BEGIN "command_list_ok_begin"
|
||||
@ -56,7 +55,7 @@ client_process_line(Client &client, char *line)
|
||||
{
|
||||
CommandResult ret;
|
||||
|
||||
if (strcmp(line, "noidle") == 0) {
|
||||
if (StringIsEqual(line, "noidle")) {
|
||||
if (client.idle_waiting) {
|
||||
/* send empty idle response and leave idle mode */
|
||||
client.idle_waiting = false;
|
||||
@ -78,7 +77,7 @@ client_process_line(Client &client, char *line)
|
||||
}
|
||||
|
||||
if (client.cmd_list.IsActive()) {
|
||||
if (strcmp(line, CLIENT_LIST_MODE_END) == 0) {
|
||||
if (StringIsEqual(line, CLIENT_LIST_MODE_END)) {
|
||||
FormatDebug(client_domain,
|
||||
"[%u] process command list",
|
||||
client.num);
|
||||
@ -113,10 +112,10 @@ client_process_line(Client &client, char *line)
|
||||
ret = CommandResult::OK;
|
||||
}
|
||||
} else {
|
||||
if (strcmp(line, CLIENT_LIST_MODE_BEGIN) == 0) {
|
||||
if (StringIsEqual(line, CLIENT_LIST_MODE_BEGIN)) {
|
||||
client.cmd_list.Begin(false);
|
||||
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);
|
||||
ret = CommandResult::OK;
|
||||
} else {
|
||||
|
@ -40,6 +40,7 @@
|
||||
#include "util/Tokenizer.hxx"
|
||||
#include "util/Error.hxx"
|
||||
#include "util/ConstBuffer.hxx"
|
||||
#include "util/StringAPI.hxx"
|
||||
|
||||
#ifdef ENABLE_SQLITE
|
||||
#include "StickerCommands.hxx"
|
||||
@ -204,23 +205,23 @@ command_available(gcc_unused const Partition &partition,
|
||||
gcc_unused const struct command *cmd)
|
||||
{
|
||||
#ifdef ENABLE_SQLITE
|
||||
if (strcmp(cmd->cmd, "sticker") == 0)
|
||||
if (StringIsEqual(cmd->cmd, "sticker"))
|
||||
return sticker_enabled();
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_NEIGHBOR_PLUGINS
|
||||
if (strcmp(cmd->cmd, "listneighbors") == 0)
|
||||
if (StringIsEqual(cmd->cmd, "listneighbors"))
|
||||
return neighbor_commands_available(partition.instance);
|
||||
#endif
|
||||
|
||||
if (strcmp(cmd->cmd, "save") == 0 ||
|
||||
strcmp(cmd->cmd, "rm") == 0 ||
|
||||
strcmp(cmd->cmd, "rename") == 0 ||
|
||||
strcmp(cmd->cmd, "playlistdelete") == 0 ||
|
||||
strcmp(cmd->cmd, "playlistmove") == 0 ||
|
||||
strcmp(cmd->cmd, "playlistclear") == 0 ||
|
||||
strcmp(cmd->cmd, "playlistadd") == 0 ||
|
||||
strcmp(cmd->cmd, "listplaylists") == 0)
|
||||
if (StringIsEqual(cmd->cmd, "save") ||
|
||||
StringIsEqual(cmd->cmd, "rm") ||
|
||||
StringIsEqual(cmd->cmd, "rename") ||
|
||||
StringIsEqual(cmd->cmd, "playlistdelete") ||
|
||||
StringIsEqual(cmd->cmd, "playlistmove") ||
|
||||
StringIsEqual(cmd->cmd, "playlistclear") ||
|
||||
StringIsEqual(cmd->cmd, "playlistadd") ||
|
||||
StringIsEqual(cmd->cmd, "listplaylists"))
|
||||
return playlist_commands_available();
|
||||
|
||||
return true;
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include "tag/Tag.hxx"
|
||||
#include "util/ConstBuffer.hxx"
|
||||
#include "util/Error.hxx"
|
||||
#include "util/StringAPI.hxx"
|
||||
#include "SongFilter.hxx"
|
||||
#include "BulkEdit.hxx"
|
||||
|
||||
@ -70,7 +71,7 @@ static CommandResult
|
||||
handle_match(Client &client, Request args, Response &r, bool fold_case)
|
||||
{
|
||||
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))
|
||||
return CommandResult::ERROR;
|
||||
|
||||
@ -163,7 +164,7 @@ CommandResult
|
||||
handle_count(Client &client, Request args, Response &r)
|
||||
{
|
||||
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];
|
||||
group = tag_name_parse_i(s);
|
||||
if (group == TAG_NUM_OF_ITEM_TYPES) {
|
||||
@ -231,7 +232,7 @@ handle_list(Client &client, Request args, Response &r)
|
||||
}
|
||||
|
||||
while (args.size >= 2 &&
|
||||
strcmp(args[args.size - 2], "group") == 0) {
|
||||
StringIsEqual(args[args.size - 2], "group")) {
|
||||
const char *s = args[args.size - 1];
|
||||
TagType gt = tag_name_parse_i(s);
|
||||
if (gt == TAG_NUM_OF_ITEM_TYPES) {
|
||||
|
@ -37,6 +37,7 @@
|
||||
#include "util/UriUtil.hxx"
|
||||
#include "util/Error.hxx"
|
||||
#include "util/ConstBuffer.hxx"
|
||||
#include "util/StringAPI.hxx"
|
||||
#include "fs/AllocatedPath.hxx"
|
||||
#include "Stats.hxx"
|
||||
#include "Permission.hxx"
|
||||
@ -265,7 +266,7 @@ handle_update(Client &client, Request args, Response &r, bool discard)
|
||||
if (!args.IsEmpty()) {
|
||||
path = args.front();
|
||||
|
||||
if (*path == 0 || strcmp(path, "/") == 0)
|
||||
if (*path == 0 || StringIsEqual(path, "/"))
|
||||
/* backwards compatibility with MPD 0.15 */
|
||||
path = "";
|
||||
else if (!uri_safe_local(path)) {
|
||||
|
@ -33,8 +33,7 @@
|
||||
#include "Instance.hxx"
|
||||
#include "util/Error.hxx"
|
||||
#include "util/ConstBuffer.hxx"
|
||||
|
||||
#include <string.h>
|
||||
#include "util/StringAPI.hxx"
|
||||
|
||||
struct sticker_song_find_data {
|
||||
Response &r;
|
||||
@ -64,7 +63,7 @@ handle_sticker_song(Response &r, Partition &partition, Request args)
|
||||
const char *const cmd = args.front();
|
||||
|
||||
/* 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);
|
||||
if (song == nullptr)
|
||||
return print_error(r, error);
|
||||
@ -84,7 +83,7 @@ handle_sticker_song(Response &r, Partition &partition, Request args)
|
||||
|
||||
return CommandResult::OK;
|
||||
/* 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);
|
||||
if (song == nullptr)
|
||||
return print_error(r, error);
|
||||
@ -99,7 +98,7 @@ handle_sticker_song(Response &r, Partition &partition, Request args)
|
||||
|
||||
return CommandResult::OK;
|
||||
/* 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);
|
||||
if (song == nullptr)
|
||||
return print_error(r, error);
|
||||
@ -119,7 +118,7 @@ handle_sticker_song(Response &r, Partition &partition, Request args)
|
||||
return CommandResult::OK;
|
||||
/* delete song song_id [key] */
|
||||
} else if ((args.size == 3 || args.size == 4) &&
|
||||
strcmp(cmd, "delete") == 0) {
|
||||
StringIsEqual(cmd, "delete")) {
|
||||
const LightSong *song = db->GetSong(args[2], error);
|
||||
if (song == nullptr)
|
||||
return print_error(r, error);
|
||||
@ -139,7 +138,7 @@ handle_sticker_song(Response &r, Partition &partition, Request args)
|
||||
return CommandResult::OK;
|
||||
/* find song dir key */
|
||||
} else if ((args.size == 4 || args.size == 6) &&
|
||||
strcmp(cmd, "find") == 0) {
|
||||
StringIsEqual(cmd, "find")) {
|
||||
/* "sticker find song a/directory name" */
|
||||
|
||||
const char *const base_uri = args[2];
|
||||
@ -153,11 +152,11 @@ handle_sticker_song(Response &r, Partition &partition, Request args)
|
||||
const char *op_s = args[4];
|
||||
value = args[5];
|
||||
|
||||
if (strcmp(op_s, "=") == 0)
|
||||
if (StringIsEqual(op_s, "="))
|
||||
op = StickerOperator::EQUALS;
|
||||
else if (strcmp(op_s, "<") == 0)
|
||||
else if (StringIsEqual(op_s, "<"))
|
||||
op = StickerOperator::LESS_THAN;
|
||||
else if (strcmp(op_s, ">") == 0)
|
||||
else if (StringIsEqual(op_s, ">"))
|
||||
op = StickerOperator::GREATER_THAN;
|
||||
else {
|
||||
r.Error(ACK_ERROR_ARG, "bad operator");
|
||||
@ -200,7 +199,7 @@ handle_sticker(Client &client, Request args, Response &r)
|
||||
return CommandResult::ERROR;
|
||||
}
|
||||
|
||||
if (strcmp(args[1], "song") == 0)
|
||||
if (StringIsEqual(args[1], "song"))
|
||||
return handle_sticker_song(r, client.partition, args);
|
||||
else {
|
||||
r.Error(ACK_ERROR_ARG, "unknown sticker domain");
|
||||
|
Loading…
Reference in New Issue
Block a user