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
8e408725
Commit
8e408725
authored
Aug 14, 2015
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
protocol/Result: move current_command to class Response
parent
d0537973
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
13 additions
and
21 deletions
+13
-21
Response.cxx
src/client/Response.cxx
+1
-2
Response.hxx
src/client/Response.hxx
+10
-1
AllCommands.cxx
src/command/AllCommands.cxx
+2
-14
Result.cxx
src/protocol/Result.cxx
+0
-2
Result.hxx
src/protocol/Result.hxx
+0
-2
No files found.
src/client/Response.cxx
View file @
8e408725
...
...
@@ -20,7 +20,6 @@
#include "config.h"
#include "Response.hxx"
#include "Client.hxx"
#include "protocol/Result.hxx"
#include "util/FormatString.hxx"
#include <string.h>
...
...
@@ -66,7 +65,7 @@ void
Response
::
FormatError
(
enum
ack
code
,
const
char
*
fmt
,
...)
{
Format
(
"ACK [%i@%u] {%s} "
,
(
int
)
code
,
list_index
,
c
urrent_c
ommand
);
(
int
)
code
,
list_index
,
command
);
va_list
args
;
va_start
(
args
,
fmt
);
...
...
src/client/Response.hxx
View file @
8e408725
...
...
@@ -37,13 +37,22 @@ class Response {
*/
const
unsigned
list_index
;
/**
* This command's name. Used to generate error messages.
*/
const
char
*
command
;
public
:
Response
(
Client
&
_client
,
unsigned
_list_index
)
:
client
(
_client
),
list_index
(
_list_index
)
{}
:
client
(
_client
),
list_index
(
_list_index
)
,
command
(
""
)
{}
Response
(
const
Response
&
)
=
delete
;
Response
&
operator
=
(
const
Response
&
)
=
delete
;
void
SetCommand
(
const
char
*
_command
)
{
command
=
_command
;
}
bool
Write
(
const
void
*
data
,
size_t
length
);
bool
Write
(
const
char
*
data
);
bool
FormatV
(
const
char
*
fmt
,
va_list
args
);
...
...
src/command/AllCommands.cxx
View file @
8e408725
...
...
@@ -33,7 +33,6 @@
#include "OtherCommands.hxx"
#include "Permission.hxx"
#include "tag/TagType.h"
#include "protocol/Result.hxx"
#include "Partition.hxx"
#include "client/Client.hxx"
#include "client/Response.hxx"
...
...
@@ -343,8 +342,6 @@ static const struct command *
command_checked_lookup
(
Response
&
r
,
unsigned
permission
,
const
char
*
cmd_name
,
Request
args
)
{
current_command
=
""
;
const
struct
command
*
cmd
=
command_lookup
(
cmd_name
);
if
(
cmd
==
nullptr
)
{
r
.
FormatError
(
ACK_ERROR_UNKNOWN
,
...
...
@@ -352,7 +349,7 @@ command_checked_lookup(Response &r, unsigned permission,
return
nullptr
;
}
current_command
=
cmd
->
cmd
;
r
.
SetCommand
(
cmd
->
cmd
)
;
if
(
!
command_check_request
(
cmd
,
r
,
permission
,
args
))
return
nullptr
;
...
...
@@ -372,18 +369,13 @@ command_process(Client &client, unsigned num, char *line)
Tokenizer
tokenizer
(
line
);
const
char
*
const
cmd_name
=
current_command
=
tokenizer
.
NextWord
(
error
);
const
char
*
const
cmd_name
=
tokenizer
.
NextWord
(
error
);
if
(
cmd_name
==
nullptr
)
{
current_command
=
""
;
if
(
tokenizer
.
IsEnd
())
r
.
FormatError
(
ACK_ERROR_UNKNOWN
,
"No command given"
);
else
r
.
Error
(
ACK_ERROR_UNKNOWN
,
error
.
GetMessage
());
current_command
=
nullptr
;
/* this client does not speak the MPD protocol; kick
the connection */
return
CommandResult
::
FINISH
;
...
...
@@ -397,7 +389,6 @@ command_process(Client &client, unsigned num, char *line)
while
(
true
)
{
if
(
args
.
size
==
COMMAND_ARGV_MAX
)
{
r
.
Error
(
ACK_ERROR_ARG
,
"Too many arguments"
);
current_command
=
nullptr
;
return
CommandResult
::
ERROR
;
}
...
...
@@ -407,7 +398,6 @@ command_process(Client &client, unsigned num, char *line)
break
;
r
.
Error
(
ACK_ERROR_UNKNOWN
,
error
.
GetMessage
());
current_command
=
nullptr
;
return
CommandResult
::
ERROR
;
}
...
...
@@ -424,7 +414,5 @@ command_process(Client &client, unsigned num, char *line)
?
cmd
->
handler
(
client
,
args
,
r
)
:
CommandResult
::
ERROR
;
current_command
=
nullptr
;
return
ret
;
}
src/protocol/Result.cxx
View file @
8e408725
...
...
@@ -21,8 +21,6 @@
#include "Result.hxx"
#include "client/Client.hxx"
const
char
*
current_command
;
void
command_success
(
Client
&
client
)
{
...
...
src/protocol/Result.hxx
View file @
8e408725
...
...
@@ -24,8 +24,6 @@
class
Client
;
extern
const
char
*
current_command
;
void
command_success
(
Client
&
client
);
...
...
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