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
1a8c3271
Commit
1a8c3271
authored
Dec 06, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
AllCommands: make variables more local
parent
bd49e8e7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
16 deletions
+13
-16
AllCommands.cxx
src/command/AllCommands.cxx
+13
-16
No files found.
src/command/AllCommands.cxx
View file @
1a8c3271
...
@@ -229,10 +229,9 @@ handle_commands(Client &client,
...
@@ -229,10 +229,9 @@ handle_commands(Client &client,
gcc_unused
unsigned
argc
,
gcc_unused
char
*
argv
[])
gcc_unused
unsigned
argc
,
gcc_unused
char
*
argv
[])
{
{
const
unsigned
permission
=
client
.
GetPermission
();
const
unsigned
permission
=
client
.
GetPermission
();
const
struct
command
*
cmd
;
for
(
unsigned
i
=
0
;
i
<
num_commands
;
++
i
)
{
for
(
unsigned
i
=
0
;
i
<
num_commands
;
++
i
)
{
cmd
=
&
commands
[
i
];
c
onst
struct
command
*
c
md
=
&
commands
[
i
];
if
(
cmd
->
permission
==
(
permission
&
cmd
->
permission
)
&&
if
(
cmd
->
permission
==
(
permission
&
cmd
->
permission
)
&&
command_available
(
client
.
partition
,
cmd
))
command_available
(
client
.
partition
,
cmd
))
...
@@ -247,10 +246,9 @@ handle_not_commands(Client &client,
...
@@ -247,10 +246,9 @@ handle_not_commands(Client &client,
gcc_unused
unsigned
argc
,
gcc_unused
char
*
argv
[])
gcc_unused
unsigned
argc
,
gcc_unused
char
*
argv
[])
{
{
const
unsigned
permission
=
client
.
GetPermission
();
const
unsigned
permission
=
client
.
GetPermission
();
const
struct
command
*
cmd
;
for
(
unsigned
i
=
0
;
i
<
num_commands
;
++
i
)
{
for
(
unsigned
i
=
0
;
i
<
num_commands
;
++
i
)
{
cmd
=
&
commands
[
i
];
c
onst
struct
command
*
c
md
=
&
commands
[
i
];
if
(
cmd
->
permission
!=
(
permission
&
cmd
->
permission
))
if
(
cmd
->
permission
!=
(
permission
&
cmd
->
permission
))
client_printf
(
client
,
"command: %s
\n
"
,
cmd
->
cmd
);
client_printf
(
client
,
"command: %s
\n
"
,
cmd
->
cmd
);
...
@@ -276,13 +274,12 @@ static const struct command *
...
@@ -276,13 +274,12 @@ static const struct command *
command_lookup
(
const
char
*
name
)
command_lookup
(
const
char
*
name
)
{
{
unsigned
a
=
0
,
b
=
num_commands
,
i
;
unsigned
a
=
0
,
b
=
num_commands
,
i
;
int
cmp
;
/* binary search */
/* binary search */
do
{
do
{
i
=
(
a
+
b
)
/
2
;
i
=
(
a
+
b
)
/
2
;
cmp
=
strcmp
(
name
,
commands
[
i
].
cmd
);
c
onst
auto
c
mp
=
strcmp
(
name
,
commands
[
i
].
cmd
);
if
(
cmp
==
0
)
if
(
cmp
==
0
)
return
&
commands
[
i
];
return
&
commands
[
i
];
else
if
(
cmp
<
0
)
else
if
(
cmp
<
0
)
...
@@ -332,14 +329,12 @@ static const struct command *
...
@@ -332,14 +329,12 @@ static const struct command *
command_checked_lookup
(
Client
&
client
,
unsigned
permission
,
command_checked_lookup
(
Client
&
client
,
unsigned
permission
,
unsigned
argc
,
char
*
argv
[])
unsigned
argc
,
char
*
argv
[])
{
{
const
struct
command
*
cmd
;
current_command
=
""
;
current_command
=
""
;
if
(
argc
==
0
)
if
(
argc
==
0
)
return
nullptr
;
return
nullptr
;
cmd
=
command_lookup
(
argv
[
0
]);
c
onst
struct
command
*
c
md
=
command_lookup
(
argv
[
0
]);
if
(
cmd
==
nullptr
)
{
if
(
cmd
==
nullptr
)
{
command_error
(
client
,
ACK_ERROR_UNKNOWN
,
command_error
(
client
,
ACK_ERROR_UNKNOWN
,
"unknown command
\"
%s
\"
"
,
argv
[
0
]);
"unknown command
\"
%s
\"
"
,
argv
[
0
]);
...
@@ -358,15 +353,14 @@ CommandResult
...
@@ -358,15 +353,14 @@ CommandResult
command_process
(
Client
&
client
,
unsigned
num
,
char
*
line
)
command_process
(
Client
&
client
,
unsigned
num
,
char
*
line
)
{
{
Error
error
;
Error
error
;
char
*
argv
[
COMMAND_ARGV_MAX
]
=
{
nullptr
};
const
struct
command
*
cmd
;
CommandResult
ret
=
CommandResult
::
ERROR
;
command_list_num
=
num
;
command_list_num
=
num
;
/* get the command name (first word on the line) */
/* get the command name (first word on the line) */
Tokenizer
tokenizer
(
line
);
Tokenizer
tokenizer
(
line
);
char
*
argv
[
COMMAND_ARGV_MAX
]
=
{
nullptr
};
argv
[
0
]
=
tokenizer
.
NextWord
(
error
);
argv
[
0
]
=
tokenizer
.
NextWord
(
error
);
if
(
argv
[
0
]
==
nullptr
)
{
if
(
argv
[
0
]
==
nullptr
)
{
current_command
=
""
;
current_command
=
""
;
...
@@ -412,10 +406,13 @@ command_process(Client &client, unsigned num, char *line)
...
@@ -412,10 +406,13 @@ command_process(Client &client, unsigned num, char *line)
/* look up and invoke the command handler */
/* look up and invoke the command handler */
cmd
=
command_checked_lookup
(
client
,
client
.
GetPermission
(),
const
struct
command
*
cmd
=
argc
,
argv
);
command_checked_lookup
(
client
,
client
.
GetPermission
(),
if
(
cmd
)
argc
,
argv
);
ret
=
cmd
->
handler
(
client
,
argc
,
argv
);
CommandResult
ret
=
cmd
?
cmd
->
handler
(
client
,
argc
,
argv
)
:
CommandResult
::
ERROR
;
current_command
=
nullptr
;
current_command
=
nullptr
;
command_list_num
=
0
;
command_list_num
=
0
;
...
...
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