aboutsummaryrefslogtreecommitdiffstats
path: root/src/AllCommands.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-10-19 18:48:38 +0200
committerMax Kellermann <max@duempel.org>2013-10-19 18:48:38 +0200
commitff626ac76357940b2f0ac5cb243a68ac13df0f8a (patch)
tree493888a28950f75f5e254c0ded9dc9703ee83dc3 /src/AllCommands.cxx
parent59f8144c50765189594d5932fc25869f9ea6e265 (diff)
downloadmpd-ff626ac76357940b2f0ac5cb243a68ac13df0f8a.tar.gz
mpd-ff626ac76357940b2f0ac5cb243a68ac13df0f8a.tar.xz
mpd-ff626ac76357940b2f0ac5cb243a68ac13df0f8a.zip
*: use references instead of pointers
Diffstat (limited to '')
-rw-r--r--src/AllCommands.cxx45
1 files changed, 20 insertions, 25 deletions
diff --git a/src/AllCommands.cxx b/src/AllCommands.cxx
index 562bbeb49..73dd7d218 100644
--- a/src/AllCommands.cxx
+++ b/src/AllCommands.cxx
@@ -56,15 +56,15 @@ struct command {
unsigned permission;
int min;
int max;
- enum command_return (*handler)(Client *client, int argc, char **argv);
+ enum command_return (*handler)(Client &client, int argc, char **argv);
};
/* don't be fooled, this is the command handler for "commands" command */
static enum command_return
-handle_commands(Client *client, int argc, char *argv[]);
+handle_commands(Client &client, int argc, char *argv[]);
static enum command_return
-handle_not_commands(Client *client, int argc, char *argv[]);
+handle_not_commands(Client &client, int argc, char *argv[]);
/**
* The command registry.
@@ -179,7 +179,7 @@ command_available(gcc_unused const struct command *cmd)
/* don't be fooled, this is the command handler for "commands" command */
static enum command_return
-handle_commands(Client *client,
+handle_commands(Client &client,
gcc_unused int argc, gcc_unused char *argv[])
{
const unsigned permission = client_get_permission(client);
@@ -197,7 +197,7 @@ handle_commands(Client *client,
}
static enum command_return
-handle_not_commands(Client *client,
+handle_not_commands(Client &client,
gcc_unused int argc, gcc_unused char *argv[])
{
const unsigned permission = client_get_permission(client);
@@ -249,17 +249,16 @@ command_lookup(const char *name)
}
static bool
-command_check_request(const struct command *cmd, Client *client,
+command_check_request(const struct command *cmd, Client &client,
unsigned permission, int argc, char *argv[])
{
int min = cmd->min + 1;
int max = cmd->max + 1;
if (cmd->permission != (permission & cmd->permission)) {
- if (client != nullptr)
- command_error(client, ACK_ERROR_PERMISSION,
- "you don't have permission for \"%s\"",
- cmd->cmd);
+ command_error(client, ACK_ERROR_PERMISSION,
+ "you don't have permission for \"%s\"",
+ cmd->cmd);
return false;
}
@@ -267,27 +266,24 @@ command_check_request(const struct command *cmd, Client *client,
return true;
if (min == max && max != argc) {
- if (client != nullptr)
- command_error(client, ACK_ERROR_ARG,
- "wrong number of arguments for \"%s\"",
- argv[0]);
+ command_error(client, ACK_ERROR_ARG,
+ "wrong number of arguments for \"%s\"",
+ argv[0]);
return false;
} else if (argc < min) {
- if (client != nullptr)
- command_error(client, ACK_ERROR_ARG,
- "too few arguments for \"%s\"", argv[0]);
+ command_error(client, ACK_ERROR_ARG,
+ "too few arguments for \"%s\"", argv[0]);
return false;
} else if (argc > max && max /* != 0 */ ) {
- if (client != nullptr)
- command_error(client, ACK_ERROR_ARG,
- "too many arguments for \"%s\"", argv[0]);
+ command_error(client, ACK_ERROR_ARG,
+ "too many arguments for \"%s\"", argv[0]);
return false;
} else
return true;
}
static const struct command *
-command_checked_lookup(Client *client, unsigned permission,
+command_checked_lookup(Client &client, unsigned permission,
int argc, char *argv[])
{
const struct command *cmd;
@@ -299,9 +295,8 @@ command_checked_lookup(Client *client, unsigned permission,
cmd = command_lookup(argv[0]);
if (cmd == nullptr) {
- if (client != nullptr)
- command_error(client, ACK_ERROR_UNKNOWN,
- "unknown command \"%s\"", argv[0]);
+ command_error(client, ACK_ERROR_UNKNOWN,
+ "unknown command \"%s\"", argv[0]);
return nullptr;
}
@@ -314,7 +309,7 @@ command_checked_lookup(Client *client, unsigned permission,
}
enum command_return
-command_process(Client *client, unsigned num, char *line)
+command_process(Client &client, unsigned num, char *line)
{
Error error;
char *argv[COMMAND_ARGV_MAX] = { nullptr };