protocol/Result: move command_list_num to class Response
This commit is contained in:
parent
c8d0f947d2
commit
d053797340
@ -65,8 +65,8 @@ Response::Error(enum ack code, const char *msg)
|
|||||||
void
|
void
|
||||||
Response::FormatError(enum ack code, const char *fmt, ...)
|
Response::FormatError(enum ack code, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
Format("ACK [%i@%i] {%s} ",
|
Format("ACK [%i@%u] {%s} ",
|
||||||
(int)code, command_list_num, current_command);
|
(int)code, list_index, current_command);
|
||||||
|
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, fmt);
|
va_start(args, fmt);
|
||||||
|
@ -31,8 +31,15 @@ class Client;
|
|||||||
class Response {
|
class Response {
|
||||||
Client &client;
|
Client &client;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This command's index in the command list. Used to generate
|
||||||
|
* error messages.
|
||||||
|
*/
|
||||||
|
const unsigned list_index;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit Response(Client &_client):client(_client) {}
|
Response(Client &_client, unsigned _list_index)
|
||||||
|
:client(_client), list_index(_list_index) {}
|
||||||
|
|
||||||
Response(const Response &) = delete;
|
Response(const Response &) = delete;
|
||||||
Response &operator=(const Response &) = delete;
|
Response &operator=(const Response &) = delete;
|
||||||
|
@ -363,11 +363,9 @@ command_checked_lookup(Response &r, unsigned permission,
|
|||||||
CommandResult
|
CommandResult
|
||||||
command_process(Client &client, unsigned num, char *line)
|
command_process(Client &client, unsigned num, char *line)
|
||||||
{
|
{
|
||||||
Response r(client);
|
Response r(client, num);
|
||||||
Error error;
|
Error error;
|
||||||
|
|
||||||
command_list_num = num;
|
|
||||||
|
|
||||||
/* get the command name (first word on the line) */
|
/* get the command name (first word on the line) */
|
||||||
/* we have to set current_command because Response::Error()
|
/* we have to set current_command because Response::Error()
|
||||||
expects it to be set */
|
expects it to be set */
|
||||||
@ -427,7 +425,6 @@ command_process(Client &client, unsigned num, char *line)
|
|||||||
: CommandResult::ERROR;
|
: CommandResult::ERROR;
|
||||||
|
|
||||||
current_command = nullptr;
|
current_command = nullptr;
|
||||||
command_list_num = 0;
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,6 @@
|
|||||||
#include "client/Client.hxx"
|
#include "client/Client.hxx"
|
||||||
|
|
||||||
const char *current_command;
|
const char *current_command;
|
||||||
int command_list_num;
|
|
||||||
|
|
||||||
void
|
void
|
||||||
command_success(Client &client)
|
command_success(Client &client)
|
||||||
|
@ -25,7 +25,6 @@
|
|||||||
class Client;
|
class Client;
|
||||||
|
|
||||||
extern const char *current_command;
|
extern const char *current_command;
|
||||||
extern int command_list_num;
|
|
||||||
|
|
||||||
void
|
void
|
||||||
command_success(Client &client);
|
command_success(Client &client);
|
||||||
|
@ -37,7 +37,7 @@ void
|
|||||||
ArgParserTest::TestRange()
|
ArgParserTest::TestRange()
|
||||||
{
|
{
|
||||||
Client &client = *(Client *)nullptr;
|
Client &client = *(Client *)nullptr;
|
||||||
Response r(client);
|
Response r(client, 0);
|
||||||
|
|
||||||
RangeArg range;
|
RangeArg range;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user