Command Tables
The cmdtable
is a structure which lists all FTP command handlers for the module. Each entry
in this table contains a special command type field which determines
type of handler, be it PRE_CMD
, CMD
,
POST_CMD
, or LOG_CMD
(see the
command handlers documentation for more
details on these types).
Definition
NULL
-terminated ASCII text
sent by a client, in uppercase, for this command. The
include/ftp.h header file has
macros which define all known RFC FTP protocol commands. This name
can also be the special macro C_ANY
, which receives
all commands.
<Limit>
directives, to which this command belongs.
This group can be either G_DIRS
for commands related to
directory listing, G_READ
for commands related to reading
files, G_WRITE
for commands related to writing files, or
the special G_NONE
for those commands against which a
<Limit READ|WRITE|DIRS>
will not be applied.
MODRET func(cmd_rec *cmd)
.
TRUE
if the command cannot be
used before authentication, via the USER/PASS
commands,
has occurred, FALSE
otherwise.
TRUE
if the command can be sent during
a file transfer, FALSE
otherwise. Note: as of
ProFTPD version 1.1.5, this field is obsolete, and is no longer used.
Example
This command table is in the example
mod_sample module:
cmdtable sample_commands[] = { { PRE_CMD, C_ANY, G_NONE, pre_cmd, FALSE, FALSE }, { LOG_CMD, C_ANY, G_NONE, log_cmd, FALSE, FALSE }, { POST_CMD, C_RETR, G_NONE, post_cmd_retr, FALSE, FALSE }, { POST_CMD, C_STOR, G_NONE, post_cmd_stor, FALSE, FALSE }, { POST_CMD, C_APPE, G_NONE, post_cmd_stor, FALSE, FALSE }, { POST_CMD, C_LIST, G_NONE, post_cmd_list, FALSE, FALSE }, { POST_CMD, C_NLST, G_NONE, post_cmd_nlst, FALSE, FALSE }, { CMD, "XFOO", G_DIRS, cmd_xfoo, TRUE, FALSE }, { 0, NULL } };
The one entry in the example table that defines a CMD
demonstrates
how to declare a command handler function for a custom FTP command,
XFOO
in this case. Most FTP clients allow the user to send arbitrary
"commands" to the FTP server; this ability combined with
custom FTP commands handlers such as this XFOO
allow the programmer
to create arbitrary, albeit not widely implemented, FTP commands.
The trailing { 0, NULL }
field is the terminating field in
the table, and should always be used.