ProFTPD Developer's Guide: Command Tables

ProFTPD Version 1.2

Table of Contents

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).


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.

Table of Contents

Author: $Author: castaglia $
Last Updated: $Date: 2003/01/02 17:39:36 $

© Copyright 2000-2003 TJ Saunders
All Rights Reserved