Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
76ad23d0
Commit
76ad23d0
authored
Jun 07, 2018
by
Itamar Haber
Browse files
Adds MODULE HELP and implements addReplySubSyntaxError
parent
f847dd3a
Changes
3
Show whitespace changes
Inline
Side-by-side
src/module.c
View file @
76ad23d0
...
@@ -4499,7 +4499,15 @@ int moduleUnload(sds name) {
...
@@ -4499,7 +4499,15 @@ int moduleUnload(sds name) {
* MODULE LOAD <path> [args...] */
* MODULE LOAD <path> [args...] */
void
moduleCommand
(
client
*
c
)
{
void
moduleCommand
(
client
*
c
)
{
char
*
subcmd
=
c
->
argv
[
1
]
->
ptr
;
char
*
subcmd
=
c
->
argv
[
1
]
->
ptr
;
if
(
c
->
argc
==
2
&&
!
strcasecmp
(
subcmd
,
"help"
))
{
const
char
*
help
[]
=
{
"list -- Return a list of loaded modules."
,
"load <path> [arg ...] -- Load a module library from <path>."
,
"unload <name> -- Unload a module."
,
NULL
};
addReplyHelp
(
c
,
help
);
}
else
if
(
!
strcasecmp
(
subcmd
,
"load"
)
&&
c
->
argc
>=
3
)
{
if
(
!
strcasecmp
(
subcmd
,
"load"
)
&&
c
->
argc
>=
3
)
{
robj
**
argv
=
NULL
;
robj
**
argv
=
NULL
;
int
argc
=
0
;
int
argc
=
0
;
...
@@ -4548,7 +4556,8 @@ void moduleCommand(client *c) {
...
@@ -4548,7 +4556,8 @@ void moduleCommand(client *c) {
}
}
dictReleaseIterator
(
di
);
dictReleaseIterator
(
di
);
}
else
{
}
else
{
addReply(c,shared.syntaxerr);
addReplySubSyntaxError
(
c
);
return
;
}
}
}
}
...
...
src/networking.c
View file @
76ad23d0
...
@@ -560,6 +560,18 @@ void addReplyHelp(client *c, const char **help) {
...
@@ -560,6 +560,18 @@ void addReplyHelp(client *c, const char **help) {
setDeferredMultiBulkLength
(
c
,
blenp
,
blen
);
setDeferredMultiBulkLength
(
c
,
blenp
,
blen
);
}
}
/* Add a suggestive error reply.
* This function is typically invoked by from commands that support
* subcommands in response to an unknown subcommand or argument error. */
void
addReplySubSyntaxError
(
client
*
c
)
{
sds
cmd
=
sdsnew
((
char
*
)
c
->
argv
[
0
]
->
ptr
);
sdstoupper
(
cmd
);
addReplyErrorFormat
(
c
,
"Unknown subcommand or wrong number of arguments for '%s'. Try %s HELP."
,
c
->
argv
[
1
]
->
ptr
,
cmd
);
sdsfree
(
cmd
);
}
/* Copy 'src' client output buffers into 'dst' client output buffers.
/* Copy 'src' client output buffers into 'dst' client output buffers.
* The function takes care of freeing the old output buffers of the
* The function takes care of freeing the old output buffers of the
* destination client. */
* destination client. */
...
...
src/server.h
View file @
76ad23d0
...
@@ -1410,6 +1410,7 @@ void addReplyHumanLongDouble(client *c, long double d);
...
@@ -1410,6 +1410,7 @@ void addReplyHumanLongDouble(client *c, long double d);
void
addReplyLongLong
(
client
*
c
,
long
long
ll
);
void
addReplyLongLong
(
client
*
c
,
long
long
ll
);
void
addReplyMultiBulkLen
(
client
*
c
,
long
length
);
void
addReplyMultiBulkLen
(
client
*
c
,
long
length
);
void
addReplyHelp
(
client
*
c
,
const
char
**
help
);
void
addReplyHelp
(
client
*
c
,
const
char
**
help
);
void
addReplySubSyntaxError
(
client
*
c
);
void
copyClientOutputBuffer
(
client
*
dst
,
client
*
src
);
void
copyClientOutputBuffer
(
client
*
dst
,
client
*
src
);
size_t
sdsZmallocSize
(
sds
s
);
size_t
sdsZmallocSize
(
sds
s
);
size_t
getStringObjectSdsUsedMemory
(
robj
*
o
);
size_t
getStringObjectSdsUsedMemory
(
robj
*
o
);
...
...
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