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
4b4f7df9
Commit
4b4f7df9
authored
Oct 22, 2008
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
command: renamed CommandEntry to struct command
No CamelCase and no struct typedefs.
parent
e6d90d4e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
12 deletions
+10
-12
command.c
src/command.c
+10
-12
No files found.
src/command.c
View file @
4b4f7df9
...
@@ -128,13 +128,11 @@
...
@@ -128,13 +128,11 @@
*/
*/
#define COMMAND_ARGV_MAX (2+(TAG_NUM_OF_ITEM_TYPES*2))
#define COMMAND_ARGV_MAX (2+(TAG_NUM_OF_ITEM_TYPES*2))
typedef
struct
_CommandEntry
CommandEntry
;
typedef
int
(
*
CommandHandlerFunction
)
(
struct
client
*
,
int
,
char
**
);
typedef
int
(
*
CommandHandlerFunction
)
(
struct
client
*
,
int
,
char
**
);
/* if min: -1 don't check args *
/* if min: -1 don't check args *
* if max: -1 no max args */
* if max: -1 no max args */
struct
_CommandEntry
{
struct
command
{
const
char
*
cmd
;
const
char
*
cmd
;
int
min
;
int
min
;
int
max
;
int
max
;
...
@@ -277,7 +275,7 @@ static void addCommand(const char *name,
...
@@ -277,7 +275,7 @@ static void addCommand(const char *name,
int
maxargs
,
int
maxargs
,
CommandHandlerFunction
handler_func
)
CommandHandlerFunction
handler_func
)
{
{
CommandEntry
*
cmd
=
xmalloc
(
sizeof
(
CommandEntry
));
struct
command
*
cmd
=
xmalloc
(
sizeof
(
*
cmd
));
cmd
->
cmd
=
name
;
cmd
->
cmd
=
name
;
cmd
->
min
=
minargs
;
cmd
->
min
=
minargs
;
cmd
->
max
=
maxargs
;
cmd
->
max
=
maxargs
;
...
@@ -1194,10 +1192,10 @@ static int handleCommands(struct client *client,
...
@@ -1194,10 +1192,10 @@ static int handleCommands(struct client *client,
{
{
const
unsigned
permission
=
client_get_permission
(
client
);
const
unsigned
permission
=
client_get_permission
(
client
);
ListNode
*
node
=
commandList
->
firstNode
;
ListNode
*
node
=
commandList
->
firstNode
;
CommandEntry
*
cmd
;
struct
command
*
cmd
;
while
(
node
!=
NULL
)
{
while
(
node
!=
NULL
)
{
cmd
=
(
CommandEntry
*
)
node
->
data
;
cmd
=
(
struct
command
*
)
node
->
data
;
if
(
cmd
->
reqPermission
==
(
permission
&
cmd
->
reqPermission
))
{
if
(
cmd
->
reqPermission
==
(
permission
&
cmd
->
reqPermission
))
{
client_printf
(
client
,
"command: %s
\n
"
,
cmd
->
cmd
);
client_printf
(
client
,
"command: %s
\n
"
,
cmd
->
cmd
);
}
}
...
@@ -1213,10 +1211,10 @@ static int handleNotcommands(struct client *client,
...
@@ -1213,10 +1211,10 @@ static int handleNotcommands(struct client *client,
{
{
const
unsigned
permission
=
client_get_permission
(
client
);
const
unsigned
permission
=
client_get_permission
(
client
);
ListNode
*
node
=
commandList
->
firstNode
;
ListNode
*
node
=
commandList
->
firstNode
;
CommandEntry
*
cmd
;
struct
command
*
cmd
;
while
(
node
!=
NULL
)
{
while
(
node
!=
NULL
)
{
cmd
=
(
CommandEntry
*
)
node
->
data
;
cmd
=
(
struct
command
*
)
node
->
data
;
if
(
cmd
->
reqPermission
!=
(
permission
&
cmd
->
reqPermission
))
{
if
(
cmd
->
reqPermission
!=
(
permission
&
cmd
->
reqPermission
))
{
client_printf
(
client
,
"command: %s
\n
"
,
cmd
->
cmd
);
client_printf
(
client
,
"command: %s
\n
"
,
cmd
->
cmd
);
...
@@ -1347,7 +1345,7 @@ void finishCommands(void)
...
@@ -1347,7 +1345,7 @@ void finishCommands(void)
freeList
(
commandList
);
freeList
(
commandList
);
}
}
static
int
checkArgcAndPermission
(
CommandEntry
*
cmd
,
struct
client
*
client
,
static
int
checkArgcAndPermission
(
struct
command
*
cmd
,
struct
client
*
client
,
unsigned
permission
,
int
argc
,
char
*
argv
[])
unsigned
permission
,
int
argc
,
char
*
argv
[])
{
{
int
min
=
cmd
->
min
+
1
;
int
min
=
cmd
->
min
+
1
;
...
@@ -1384,13 +1382,13 @@ static int checkArgcAndPermission(CommandEntry * cmd, struct client *client,
...
@@ -1384,13 +1382,13 @@ static int checkArgcAndPermission(CommandEntry * cmd, struct client *client,
return
0
;
return
0
;
}
}
static
CommandEntry
*
getCommandEntryAndCheckArgcAndPermission
(
struct
client
*
client
,
static
struct
command
*
getCommandEntryAndCheckArgcAndPermission
(
struct
client
*
client
,
unsigned
permission
,
unsigned
permission
,
int
argc
,
int
argc
,
char
*
argv
[])
char
*
argv
[])
{
{
static
char
unknown
[]
=
""
;
static
char
unknown
[]
=
""
;
CommandEntry
*
cmd
;
struct
command
*
cmd
;
current_command
=
unknown
;
current_command
=
unknown
;
...
@@ -1417,7 +1415,7 @@ int processCommand(struct client *client, char *commandString)
...
@@ -1417,7 +1415,7 @@ int processCommand(struct client *client, char *commandString)
{
{
int
argc
;
int
argc
;
char
*
argv
[
COMMAND_ARGV_MAX
]
=
{
NULL
};
char
*
argv
[
COMMAND_ARGV_MAX
]
=
{
NULL
};
CommandEntry
*
cmd
;
struct
command
*
cmd
;
int
ret
=
-
1
;
int
ret
=
-
1
;
if
(
!
(
argc
=
buffer2array
(
commandString
,
argv
,
COMMAND_ARGV_MAX
)))
if
(
!
(
argc
=
buffer2array
(
commandString
,
argv
,
COMMAND_ARGV_MAX
)))
...
...
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