You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by wr...@apache.org on 2009/07/16 18:42:24 UTC
svn commit: r794746 - in /httpd/mod_ftp/trunk: mod_ftp.dsw
modules/ftp/NWGNUftpcmdpwd modules/ftp/mod_ftp_cmd_pwd.c
modules/ftp/mod_ftp_cmd_pwd.dsp modules/ftp/mod_ftp_example.c
modules/ftp/mod_ftp_example.dsp modules/ftp/modules.mk.apxs
Author: wrowe
Date: Thu Jul 16 16:42:24 2009
New Revision: 794746
URL: http://svn.apache.org/viewvc?rev=794746&view=rev
Log:
Why include an example that subverts the spec? Instead, here is an
example with two SITE commands, ECHO and PING, with a syntax check.
Something devs will more often ask how to implement.
Added:
httpd/mod_ftp/trunk/modules/ftp/mod_ftp_example.c
- copied, changed from r794718, httpd/mod_ftp/trunk/modules/ftp/mod_ftp_cmd_pwd.c
httpd/mod_ftp/trunk/modules/ftp/mod_ftp_example.dsp
- copied, changed from r794724, httpd/mod_ftp/trunk/modules/ftp/mod_ftp_cmd_pwd.dsp
Removed:
httpd/mod_ftp/trunk/modules/ftp/mod_ftp_cmd_pwd.c
httpd/mod_ftp/trunk/modules/ftp/mod_ftp_cmd_pwd.dsp
Modified:
httpd/mod_ftp/trunk/mod_ftp.dsw
httpd/mod_ftp/trunk/modules/ftp/NWGNUftpcmdpwd
httpd/mod_ftp/trunk/modules/ftp/modules.mk.apxs
Modified: httpd/mod_ftp/trunk/mod_ftp.dsw
URL: http://svn.apache.org/viewvc/httpd/mod_ftp/trunk/mod_ftp.dsw?rev=794746&r1=794745&r2=794746&view=diff
==============================================================================
--- httpd/mod_ftp/trunk/mod_ftp.dsw (original)
+++ httpd/mod_ftp/trunk/mod_ftp.dsw Thu Jul 16 16:42:24 2009
@@ -15,7 +15,7 @@
###############################################################################
-Project: "mod_ftp_cmd_pwd"=".\modules\ftp\mod_ftp_cmd_pwd.dsp" - Package Owner=<4>
+Project: "mod_ftp_example"=".\modules\ftp\mod_ftp_example.dsp" - Package Owner=<4>
Package=<5>
{{{
Modified: httpd/mod_ftp/trunk/modules/ftp/NWGNUftpcmdpwd
URL: http://svn.apache.org/viewvc/httpd/mod_ftp/trunk/modules/ftp/NWGNUftpcmdpwd?rev=794746&r1=794745&r2=794746&view=diff
==============================================================================
--- httpd/mod_ftp/trunk/modules/ftp/NWGNUftpcmdpwd (original)
+++ httpd/mod_ftp/trunk/modules/ftp/NWGNUftpcmdpwd Thu Jul 16 16:42:24 2009
@@ -110,7 +110,7 @@
# This is used by the link '-desc ' directive.
# If left blank, NLM_NAME will be used.
#
-NLM_DESCRIPTION = Apache $(VERSION_STR) ftp_cmd_pwd Module
+NLM_DESCRIPTION = Apache $(VERSION_STR) ftp_example Module
#
# This is used by the '-threadname' directive. If left blank,
@@ -175,7 +175,7 @@
# Paths must all use the '/' character
#
FILES_nlm_objs = \
- $(OBJDIR)/mod_ftp_cmd_pwd.o \
+ $(OBJDIR)/mod_ftp_example.o \
$(EOLIST)
#
@@ -231,7 +231,7 @@
# Any symbols exported to here
#
FILES_nlm_exports = \
- ftp_cmd_pwd_module \
+ ftp_example_module \
$(EOLIST)
#
Copied: httpd/mod_ftp/trunk/modules/ftp/mod_ftp_example.c (from r794718, httpd/mod_ftp/trunk/modules/ftp/mod_ftp_cmd_pwd.c)
URL: http://svn.apache.org/viewvc/httpd/mod_ftp/trunk/modules/ftp/mod_ftp_example.c?p2=httpd/mod_ftp/trunk/modules/ftp/mod_ftp_example.c&p1=httpd/mod_ftp/trunk/modules/ftp/mod_ftp_cmd_pwd.c&r1=794718&r2=794746&rev=794746&view=diff
==============================================================================
--- httpd/mod_ftp/trunk/modules/ftp/mod_ftp_cmd_pwd.c (original)
+++ httpd/mod_ftp/trunk/modules/ftp/mod_ftp_example.c Thu Jul 16 16:42:24 2009
@@ -26,32 +26,55 @@
* than DECLINED. All core commands are registered as FTP_HOOK_LAST, so
* any module can override using FTP_HOOK_MIDDLE or FTP_HOOK_FIRST.
*
- * -rpm 2/28/2001
+ * Implements simple SITE PING and SITE ECHO commands
*/
#include "mod_ftp.h"
#include "apr_strings.h"
-extern AP_MODULE_DECLARE_DATA module ftp_cmd_pwd_module;
+extern AP_MODULE_DECLARE_DATA module ftp_example_module;
-static int mod_ftp_cmd_pwd2(request_rec *r, const char *arg)
+static int mod_ftp_cmd_site(request_rec *r, const char *arg)
{
ftp_connection *fc = ftp_get_module_config(r->connection->conn_config);
- fc->response_notes = apr_psprintf(r->pool,
- "PWD command has been overridden by "
- "an external module!");
- return FTP_REPLY_PATH_CREATED;
+ if ((strncasecmp(arg, "ECHO", 4) && strncasecmp(arg, "PING", 4))
+ || (arg[4] && arg[4] != ' '))
+ return DECLINED;
+
+ if (!strncasecmp(arg, "PING", 4))
+ {
+ for (arg += 4; *arg == ' '; ++arg)
+ /* noop */;
+ if (*arg) {
+ fc->response_notes = apr_pstrcat(r->pool, "Unknown PING parameter ",
+ arg, NULL);
+ return FTP_REPLY_COMMAND_NOT_IMPL_PARAM;
+ }
+ else
+ fc->response_notes = "PONG";
+ }
+ else /* !strncasecmp(arg, "ECHO", 4) */
+ {
+ fc->response_notes = arg + 4;
+ }
+ return FTP_REPLY_COMMAND_OK;
+}
+
+static int example_pre_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp)
+{
+ ftp_hook_cmd("SITE", mod_ftp_cmd_site, FTP_HOOK_MIDDLE,
+ FTP_NEED_LOGIN | FTP_TAKE1 | FTP_KEEP_WHITESPACE,
+ "<sp> [ PING | ECHO <sp> message ]");
+ return OK;
}
static void register_hooks(apr_pool_t *p)
{
- ftp_hook_cmd("PWD", mod_ftp_cmd_pwd2, FTP_HOOK_MIDDLE,
- FTP_NEED_LOGIN | FTP_TAKE0,
- "This command does not do anything.");
+ ap_hook_pre_config(example_pre_config, NULL, NULL, APR_HOOK_MIDDLE);
}
-AP_MODULE_DECLARE_DATA module ftp_cmd_pwd_module = {
+AP_MODULE_DECLARE_DATA module ftp_example_module = {
STANDARD20_MODULE_STUFF,
NULL, /* create per-directory config structure */
NULL, /* merge per-directory config structures */
Copied: httpd/mod_ftp/trunk/modules/ftp/mod_ftp_example.dsp (from r794724, httpd/mod_ftp/trunk/modules/ftp/mod_ftp_cmd_pwd.dsp)
URL: http://svn.apache.org/viewvc/httpd/mod_ftp/trunk/modules/ftp/mod_ftp_example.dsp?p2=httpd/mod_ftp/trunk/modules/ftp/mod_ftp_example.dsp&p1=httpd/mod_ftp/trunk/modules/ftp/mod_ftp_cmd_pwd.dsp&r1=794724&r2=794746&rev=794746&view=diff
==============================================================================
--- httpd/mod_ftp/trunk/modules/ftp/mod_ftp_cmd_pwd.dsp (original)
+++ httpd/mod_ftp/trunk/modules/ftp/mod_ftp_example.dsp Thu Jul 16 16:42:24 2009
@@ -1,24 +1,24 @@
-# Microsoft Developer Studio Project File - Name="mod_ftp_cmd_pwd" - Package Owner=<4>
+# Microsoft Developer Studio Project File - Name="mod_ftp_example" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
-CFG=mod_ftp_cmd_pwd - Win32 Debug
+CFG=mod_ftp_example - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
-!MESSAGE NMAKE /f "mod_ftp_cmd_pwd.mak".
+!MESSAGE NMAKE /f "mod_ftp_example.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
-!MESSAGE NMAKE /f "mod_ftp_cmd_pwd.mak" CFG="mod_ftp_cmd_pwd - Win32 Debug"
+!MESSAGE NMAKE /f "mod_ftp_example.mak" CFG="mod_ftp_example - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
-!MESSAGE "mod_ftp_cmd_pwd - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "mod_ftp_cmd_pwd - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "mod_ftp_example - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "mod_ftp_example - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE
# Begin Project
@@ -29,7 +29,7 @@
MTL=midl.exe
RSC=rc.exe
-!IF "$(CFG)" == "mod_ftp_cmd_pwd - Win32 Release"
+!IF "$(CFG)" == "mod_ftp_example - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
@@ -42,7 +42,7 @@
# PROP Intermediate_Dir "Release"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MD /W3 /O2 /Zi /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "SRC_EXPORTS" /FD /c
-# ADD CPP /nologo /MD /W3 /O2 /Oy- /Zi /I "../../include" /I "$(APACHE2_HOME)/include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /Fd"Release/mod_ftp_cmd_pwd_src" /FD /c
+# ADD CPP /nologo /MD /W3 /O2 /Oy- /Zi /I "../../include" /I "$(APACHE2_HOME)/include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /Fd"Release/mod_ftp_example_src" /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "NDEBUG"
@@ -52,9 +52,9 @@
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 /nologo /dll /machine:I386
-# ADD LINK32 libapr-1.lib libaprutil-1.lib libhttpd.lib /nologo /dll /debug /incremental:no /out:"Release/mod_ftp_cmd_pwd.so" /libpath:"$(APACHE2_HOME)\lib" /base:"0x46530000" /opt:ref
+# ADD LINK32 libapr-1.lib libaprutil-1.lib libhttpd.lib /nologo /dll /debug /incremental:no /out:"Release/mod_ftp_example.so" /libpath:"$(APACHE2_HOME)\lib" /base:"0x46530000" /opt:ref
-!ELSEIF "$(CFG)" == "mod_ftp_cmd_pwd - Win32 Debug"
+!ELSEIF "$(CFG)" == "mod_ftp_example - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
@@ -68,7 +68,7 @@
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MDd /W3 /GX /Od /Zi /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SRC_EXPORTS" /FD /c
-# ADD CPP /nologo /MDd /W3 /GX /Od /Zi /I "../../include" /I "$(APACHE2_HOME)/include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /Fd"Debug\mod_ftp_cmd_pwd_src" /FD /c
+# ADD CPP /nologo /MDd /W3 /GX /Od /Zi /I "../../include" /I "$(APACHE2_HOME)/include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /Fd"Debug\mod_ftp_example_src" /FD /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "_DEBUG"
@@ -78,17 +78,17 @@
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 /nologo /dll /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 libapr-1.lib libaprutil-1.lib libhttpd.lib /nologo /dll /debug /incremental:no /out:"Debug/mod_ftp_cmd_pwd.so" /libpath:"$(APACHE2_HOME)\lib" /base:"0x46530000"
+# ADD LINK32 libapr-1.lib libaprutil-1.lib libhttpd.lib /nologo /dll /debug /incremental:no /out:"Debug/mod_ftp_example.so" /libpath:"$(APACHE2_HOME)\lib" /base:"0x46530000"
!ENDIF
# Begin Target
-# Name "mod_ftp_cmd_pwd - Win32 Release"
-# Name "mod_ftp_cmd_pwd - Win32 Debug"
+# Name "mod_ftp_example - Win32 Release"
+# Name "mod_ftp_example - Win32 Debug"
# Begin Source File
-SOURCE=.\mod_ftp_cmd_pwd.c
+SOURCE=.\mod_ftp_example.c
# End Source File
# Begin Source File
Modified: httpd/mod_ftp/trunk/modules/ftp/modules.mk.apxs
URL: http://svn.apache.org/viewvc/httpd/mod_ftp/trunk/modules/ftp/modules.mk.apxs?rev=794746&r1=794745&r2=794746&view=diff
==============================================================================
--- httpd/mod_ftp/trunk/modules/ftp/modules.mk.apxs (original)
+++ httpd/mod_ftp/trunk/modules/ftp/modules.mk.apxs Thu Jul 16 16:42:24 2009
@@ -1,8 +1,8 @@
mod_ftp.la: mod_ftp.slo ftp_commands.slo ftp_connection.slo ftp_data_connection.slo ftp_data_filters.slo ftp_filters.slo ftp_inet_pton.slo ftp_limitlogin.slo ftp_log.slo ftp_message.slo ftp_protocol.slo ftp_request.slo ftp_util.slo ftp_lowportd.slo
$(SH_LINK) -rpath $(libexecdir) -module -avoid-version mod_ftp.lo ftp_commands.lo ftp_connection.lo ftp_data_connection.lo ftp_data_filters.lo ftp_filters.lo ftp_inet_pton.lo ftp_limitlogin.lo ftp_log.lo ftp_message.lo ftp_protocol.lo ftp_request.lo ftp_util.lo ftp_lowportd.lo
-mod_ftp_cmd_pwd.la: mod_ftp.la mod_ftp_cmd_pwd.slo
- $(SH_LINK) -rpath $(libexecdir) -module -avoid-version mod_ftp_cmd_pwd.lo
+mod_ftp_example.la: mod_ftp.la mod_ftp_example.slo
+ $(SH_LINK) -rpath $(libexecdir) -module -avoid-version mod_ftp_example.lo
DISTCLEAN_TARGETS = modules.mk
static =
shared = mod_ftp.la
-# not by default; mod_ftp_cmd_pwd.la
+# not by default; mod_ftp_example.la