diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-08 19:09:22 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-08 19:09:22 +0000 |
commit | 2faa747e2303ee774a4b4aace961188e950e185a (patch) | |
tree | 604e79c7481956ce48f458e3546eaf1090b3ffff /modules/examples | |
parent | Initial commit. (diff) | |
download | apache2-2faa747e2303ee774a4b4aace961188e950e185a.tar.xz apache2-2faa747e2303ee774a4b4aace961188e950e185a.zip |
Adding upstream version 2.4.58.upstream/2.4.58
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'modules/examples')
24 files changed, 5622 insertions, 0 deletions
diff --git a/modules/examples/Makefile.in b/modules/examples/Makefile.in new file mode 100644 index 0000000..7c5c149 --- /dev/null +++ b/modules/examples/Makefile.in @@ -0,0 +1,3 @@ +# a modules Makefile has no explicit targets -- they will be defined by +# whatever modules are enabled. just grab special.mk to deal with this. +include $(top_srcdir)/build/special.mk diff --git a/modules/examples/NWGNUcase_flt b/modules/examples/NWGNUcase_flt new file mode 100644 index 0000000..df9a86f --- /dev/null +++ b/modules/examples/NWGNUcase_flt @@ -0,0 +1,256 @@ +# +# Declare the sub-directories to be built here +# + +SUBDIRS = \ + $(EOLIST) + +# +# Get the 'head' of the build environment. This includes default targets and +# paths to tools +# + +include $(AP_WORK)/build/NWGNUhead.inc + +# +# build this level's files + +# +# Make sure all needed macro's are defined +# + +# +# These directories will be at the beginning of the include list, followed by +# INCDIRS +# +XINCDIRS += \ + $(APR)/include \ + $(APRUTIL)/include \ + $(AP_WORK)/include \ + $(NWOS) \ + $(EOLIST) + +# +# These flags will come after CFLAGS +# +XCFLAGS += \ + $(EOLIST) + +# +# These defines will come after DEFINES +# +XDEFINES += \ + $(EOLIST) + +# +# These flags will be added to the link.opt file +# +XLFLAGS += \ + $(EOLIST) + +# +# These values will be appended to the correct variables based on the value of +# RELEASE +# +ifeq "$(RELEASE)" "debug" +XINCDIRS += \ + $(EOLIST) + +XCFLAGS += \ + $(EOLIST) + +XDEFINES += \ + $(EOLIST) + +XLFLAGS += \ + $(EOLIST) +endif + +ifeq "$(RELEASE)" "noopt" +XINCDIRS += \ + $(EOLIST) + +XCFLAGS += \ + $(EOLIST) + +XDEFINES += \ + $(EOLIST) + +XLFLAGS += \ + $(EOLIST) +endif + +ifeq "$(RELEASE)" "release" +XINCDIRS += \ + $(EOLIST) + +XCFLAGS += \ + $(EOLIST) + +XDEFINES += \ + $(EOLIST) + +XLFLAGS += \ + $(EOLIST) +endif + +# +# These are used by the link target if an NLM is being generated +# This is used by the link 'name' directive to name the nlm. If left blank +# TARGET_nlm (see below) will be used. +# +NLM_NAME = case_flt + +# +# This is used by the link '-desc ' directive. +# If left blank, NLM_NAME will be used. +# +NLM_DESCRIPTION = Apache $(VERSION_STR) Case Filter Module + +# +# This is used by the '-threadname' directive. If left blank, +# NLM_NAME Thread will be used. +# +NLM_THREAD_NAME = $(NLM_NAME) Module + +# +# If this is specified, it will override VERSION value in +# $(AP_WORK)/build/NWGNUenvironment.inc +# +NLM_VERSION = + +# +# If this is specified, it will override the default of 64K +# +NLM_STACK_SIZE = 8192 + + +# +# If this is specified it will be used by the link '-entry' directive +# +NLM_ENTRY_SYM = + +# +# If this is specified it will be used by the link '-exit' directive +# +NLM_EXIT_SYM = + +# +# If this is specified it will be used by the link '-check' directive +# +NLM_CHECK_SYM = + +# +# If these are specified it will be used by the link '-flags' directive +# +NLM_FLAGS = + +# +# If this is specified it will be linked in with the XDCData option in the def +# file instead of the default of $(NWOS)/apache.xdc. XDCData can be disabled +# by setting APACHE_UNIPROC in the environment +# +XDCDATA = + +# +# If there is an NLM target, put it here +# +TARGET_nlm = \ + $(OBJDIR)/$(NLM_NAME).nlm \ + $(EOLIST) + +# +# If there is an LIB target, put it here +# +TARGET_lib = \ + $(EOLIST) + +# +# These are the OBJ files needed to create the NLM target above. +# Paths must all use the '/' character +# +FILES_nlm_objs = \ + $(OBJDIR)/mod_case_filter.o \ + $(EOLIST) + +# +# These are the LIB files needed to create the NLM target above. +# These will be added as a library command in the link.opt file. +# +FILES_nlm_libs = \ + $(PRELUDE) \ + $(EOLIST) + +# +# These are the modules that the above NLM target depends on to load. +# These will be added as a module command in the link.opt file. +# +FILES_nlm_modules = \ + aprlib \ + libc \ + $(EOLIST) + +# +# If the nlm has a msg file, put it's path here +# +FILE_nlm_msg = + +# +# If the nlm has a hlp file put it's path here +# +FILE_nlm_hlp = + +# +# If this is specified, it will override $(NWOS)\copyright.txt. +# +FILE_nlm_copyright = + +# +# Any additional imports go here +# +FILES_nlm_Ximports = \ + @aprlib.imp \ + @httpd.imp \ + @libc.imp \ + $(EOLIST) + +# +# Any symbols exported to here +# +FILES_nlm_exports = \ + case_filter_module \ + $(EOLIST) + +# +# These are the OBJ files needed to create the LIB target above. +# Paths must all use the '/' character +# +FILES_lib_objs = \ + $(EOLIST) + +# +# implement targets and dependancies (leave this section alone) +# + +libs :: $(OBJDIR) $(TARGET_lib) + +nlms :: libs $(TARGET_nlm) + +# +# Updated this target to create necessary directories and copy files to the +# correct place. (See $(AP_WORK)/build/NWGNUhead.inc for examples) +# +install :: nlms FORCE + +# +# Any specialized rules here +# + +# +# Include the 'tail' makefile that has targets that depend on variables defined +# in this makefile +# + +include $(APBUILD)/NWGNUtail.inc + + diff --git a/modules/examples/NWGNUcase_flt_in b/modules/examples/NWGNUcase_flt_in new file mode 100644 index 0000000..7429a44 --- /dev/null +++ b/modules/examples/NWGNUcase_flt_in @@ -0,0 +1,256 @@ +# +# Declare the sub-directories to be built here +# + +SUBDIRS = \ + $(EOLIST) + +# +# Get the 'head' of the build environment. This includes default targets and +# paths to tools +# + +include $(AP_WORK)/build/NWGNUhead.inc + +# +# build this level's files + +# +# Make sure all needed macro's are defined +# + +# +# These directories will be at the beginning of the include list, followed by +# INCDIRS +# +XINCDIRS += \ + $(APR)/include \ + $(APRUTIL)/include \ + $(AP_WORK)/include \ + $(NWOS) \ + $(EOLIST) + +# +# These flags will come after CFLAGS +# +XCFLAGS += \ + $(EOLIST) + +# +# These defines will come after DEFINES +# +XDEFINES += \ + $(EOLIST) + +# +# These flags will be added to the link.opt file +# +XLFLAGS += \ + $(EOLIST) + +# +# These values will be appended to the correct variables based on the value of +# RELEASE +# +ifeq "$(RELEASE)" "debug" +XINCDIRS += \ + $(EOLIST) + +XCFLAGS += \ + $(EOLIST) + +XDEFINES += \ + $(EOLIST) + +XLFLAGS += \ + $(EOLIST) +endif + +ifeq "$(RELEASE)" "noopt" +XINCDIRS += \ + $(EOLIST) + +XCFLAGS += \ + $(EOLIST) + +XDEFINES += \ + $(EOLIST) + +XLFLAGS += \ + $(EOLIST) +endif + +ifeq "$(RELEASE)" "release" +XINCDIRS += \ + $(EOLIST) + +XCFLAGS += \ + $(EOLIST) + +XDEFINES += \ + $(EOLIST) + +XLFLAGS += \ + $(EOLIST) +endif + +# +# These are used by the link target if an NLM is being generated +# This is used by the link 'name' directive to name the nlm. If left blank +# TARGET_nlm (see below) will be used. +# +NLM_NAME = case_flt_in + +# +# This is used by the link '-desc ' directive. +# If left blank, NLM_NAME will be used. +# +NLM_DESCRIPTION = Apache $(VERSION_STR) Case Filter In Module + +# +# This is used by the '-threadname' directive. If left blank, +# NLM_NAME Thread will be used. +# +NLM_THREAD_NAME = $(NLM_NAME) Module + +# +# If this is specified, it will override VERSION value in +# $(AP_WORK)/build/NWGNUenvironment.inc +# +NLM_VERSION = + +# +# If this is specified, it will override the default of 64K +# +NLM_STACK_SIZE = 8192 + + +# +# If this is specified it will be used by the link '-entry' directive +# +NLM_ENTRY_SYM = + +# +# If this is specified it will be used by the link '-exit' directive +# +NLM_EXIT_SYM = + +# +# If this is specified it will be used by the link '-check' directive +# +NLM_CHECK_SYM = + +# +# If these are specified it will be used by the link '-flags' directive +# +NLM_FLAGS = + +# +# If this is specified it will be linked in with the XDCData option in the def +# file instead of the default of $(NWOS)/apache.xdc. XDCData can be disabled +# by setting APACHE_UNIPROC in the environment +# +XDCDATA = + +# +# If there is an NLM target, put it here +# +TARGET_nlm = \ + $(OBJDIR)/$(NLM_NAME).nlm \ + $(EOLIST) + +# +# If there is an LIB target, put it here +# +TARGET_lib = \ + $(EOLIST) + +# +# These are the OBJ files needed to create the NLM target above. +# Paths must all use the '/' character +# +FILES_nlm_objs = \ + $(OBJDIR)/mod_case_filter_in.o \ + $(EOLIST) + +# +# These are the LIB files needed to create the NLM target above. +# These will be added as a library command in the link.opt file. +# +FILES_nlm_libs = \ + $(PRELUDE) \ + $(EOLIST) + +# +# These are the modules that the above NLM target depends on to load. +# These will be added as a module command in the link.opt file. +# +FILES_nlm_modules = \ + aprlib \ + libc \ + $(EOLIST) + +# +# If the nlm has a msg file, put it's path here +# +FILE_nlm_msg = + +# +# If the nlm has a hlp file put it's path here +# +FILE_nlm_hlp = + +# +# If this is specified, it will override $(NWOS)\copyright.txt. +# +FILE_nlm_copyright = + +# +# Any additional imports go here +# +FILES_nlm_Ximports = \ + @aprlib.imp \ + @httpd.imp \ + @libc.imp \ + $(EOLIST) + +# +# Any symbols exported to here +# +FILES_nlm_exports = \ + case_filter_in_module \ + $(EOLIST) + +# +# These are the OBJ files needed to create the LIB target above. +# Paths must all use the '/' character +# +FILES_lib_objs = \ + $(EOLIST) + +# +# implement targets and dependancies (leave this section alone) +# + +libs :: $(OBJDIR) $(TARGET_lib) + +nlms :: libs $(TARGET_nlm) + +# +# Updated this target to create necessary directories and copy files to the +# correct place. (See $(AP_WORK)/build/NWGNUhead.inc for examples) +# +install :: nlms FORCE + +# +# Any specialized rules here +# + +# +# Include the 'tail' makefile that has targets that depend on variables defined +# in this makefile +# + +include $(APBUILD)/NWGNUtail.inc + + diff --git a/modules/examples/NWGNUexample_hooks b/modules/examples/NWGNUexample_hooks new file mode 100644 index 0000000..06bc16a --- /dev/null +++ b/modules/examples/NWGNUexample_hooks @@ -0,0 +1,257 @@ +# +# Declare the sub-directories to be built here +# + +SUBDIRS = \ + $(EOLIST) + +# +# Get the 'head' of the build environment. This includes default targets and +# paths to tools +# + +include $(AP_WORK)/build/NWGNUhead.inc + +# +# build this level's files + +# +# Make sure all needed macro's are defined +# + +# +# These directories will be at the beginning of the include list, followed by +# INCDIRS +# +XINCDIRS += \ + $(APR)/include \ + $(APRUTIL)/include \ + $(AP_WORK)/include \ + $(AP_WORK)/server/mpm/netware \ + $(NWOS) \ + $(EOLIST) + +# +# These flags will come after CFLAGS +# +XCFLAGS += \ + $(EOLIST) + +# +# These defines will come after DEFINES +# +XDEFINES += \ + $(EOLIST) + +# +# These flags will be added to the link.opt file +# +XLFLAGS += \ + $(EOLIST) + +# +# These values will be appended to the correct variables based on the value of +# RELEASE +# +ifeq "$(RELEASE)" "debug" +XINCDIRS += \ + $(EOLIST) + +XCFLAGS += \ + $(EOLIST) + +XDEFINES += \ + $(EOLIST) + +XLFLAGS += \ + $(EOLIST) +endif + +ifeq "$(RELEASE)" "noopt" +XINCDIRS += \ + $(EOLIST) + +XCFLAGS += \ + $(EOLIST) + +XDEFINES += \ + $(EOLIST) + +XLFLAGS += \ + $(EOLIST) +endif + +ifeq "$(RELEASE)" "release" +XINCDIRS += \ + $(EOLIST) + +XCFLAGS += \ + $(EOLIST) + +XDEFINES += \ + $(EOLIST) + +XLFLAGS += \ + $(EOLIST) +endif + +# +# These are used by the link target if an NLM is being generated +# This is used by the link 'name' directive to name the nlm. If left blank +# TARGET_nlm (see below) will be used. +# +NLM_NAME = example_hooks + +# +# This is used by the link '-desc ' directive. +# If left blank, NLM_NAME will be used. +# +NLM_DESCRIPTION = Apache $(VERSION_STR) Example Hook Callback Handler Module + +# +# This is used by the '-threadname' directive. If left blank, +# NLM_NAME Thread will be used. +# +NLM_THREAD_NAME = Example Hook Callback Handler Module + +# +# If this is specified, it will override VERSION value in +# $(AP_WORK)/build/NWGNUenvironment.inc +# +NLM_VERSION = + +# +# If this is specified, it will override the default of 64K +# +NLM_STACK_SIZE = 8192 + + +# +# If this is specified it will be used by the link '-entry' directive +# +NLM_ENTRY_SYM = + +# +# If this is specified it will be used by the link '-exit' directive +# +NLM_EXIT_SYM = + +# +# If this is specified it will be used by the link '-check' directive +# +NLM_CHECK_SYM = + +# +# If these are specified it will be used by the link '-flags' directive +# +NLM_FLAGS = + +# +# If this is specified it will be linked in with the XDCData option in the def +# file instead of the default of $(NWOS)/apache.xdc. XDCData can be disabled +# by setting APACHE_UNIPROC in the environment +# +XDCDATA = + +# +# If there is an NLM target, put it here +# +TARGET_nlm = \ + $(OBJDIR)/example_hooks.nlm \ + $(EOLIST) + +# +# If there is an LIB target, put it here +# +TARGET_lib = \ + $(EOLIST) + +# +# These are the OBJ files needed to create the NLM target above. +# Paths must all use the '/' character +# +FILES_nlm_objs = \ + $(OBJDIR)/mod_example_hooks.o \ + $(EOLIST) + +# +# These are the LIB files needed to create the NLM target above. +# These will be added as a library command in the link.opt file. +# +FILES_nlm_libs = \ + $(PRELUDE) \ + $(EOLIST) + +# +# These are the modules that the above NLM target depends on to load. +# These will be added as a module command in the link.opt file. +# +FILES_nlm_modules = \ + aprlib \ + libc \ + $(EOLIST) + +# +# If the nlm has a msg file, put it's path here +# +FILE_nlm_msg = + +# +# If the nlm has a hlp file put it's path here +# +FILE_nlm_hlp = + +# +# If this is specified, it will override $(NWOS)\copyright.txt. +# +FILE_nlm_copyright = + +# +# Any additional imports go here +# +FILES_nlm_Ximports = \ + @aprlib.imp \ + @httpd.imp \ + @libc.imp \ + $(EOLIST) + +# +# Any symbols exported to here +# +FILES_nlm_exports = \ + example_hooks_module \ + $(EOLIST) + +# +# These are the OBJ files needed to create the LIB target above. +# Paths must all use the '/' character +# +FILES_lib_objs = \ + $(EOLIST) + +# +# implement targets and dependancies (leave this section alone) +# + +libs :: $(OBJDIR) $(TARGET_lib) + +nlms :: libs $(TARGET_nlm) + +# +# Updated this target to create necessary directories and copy files to the +# correct place. (See $(AP_WORK)/build/NWGNUhead.inc for examples) +# +install :: nlms FORCE + +# +# Any specialized rules here +# + +# +# Include the 'tail' makefile that has targets that depend on variables defined +# in this makefile +# + +include $(APBUILD)/NWGNUtail.inc + + diff --git a/modules/examples/NWGNUexample_ipc b/modules/examples/NWGNUexample_ipc new file mode 100644 index 0000000..605794b --- /dev/null +++ b/modules/examples/NWGNUexample_ipc @@ -0,0 +1,257 @@ +# +# Declare the sub-directories to be built here +# + +SUBDIRS = \ + $(EOLIST) + +# +# Get the 'head' of the build environment. This includes default targets and +# paths to tools +# + +include $(AP_WORK)/build/NWGNUhead.inc + +# +# build this level's files + +# +# Make sure all needed macro's are defined +# + +# +# These directories will be at the beginning of the include list, followed by +# INCDIRS +# +XINCDIRS += \ + $(APR)/include \ + $(APRUTIL)/include \ + $(AP_WORK)/include \ + $(AP_WORK)/server/mpm/netware \ + $(NWOS) \ + $(EOLIST) + +# +# These flags will come after CFLAGS +# +XCFLAGS += \ + $(EOLIST) + +# +# These defines will come after DEFINES +# +XDEFINES += \ + $(EOLIST) + +# +# These flags will be added to the link.opt file +# +XLFLAGS += \ + $(EOLIST) + +# +# These values will be appended to the correct variables based on the value of +# RELEASE +# +ifeq "$(RELEASE)" "debug" +XINCDIRS += \ + $(EOLIST) + +XCFLAGS += \ + $(EOLIST) + +XDEFINES += \ + $(EOLIST) + +XLFLAGS += \ + $(EOLIST) +endif + +ifeq "$(RELEASE)" "noopt" +XINCDIRS += \ + $(EOLIST) + +XCFLAGS += \ + $(EOLIST) + +XDEFINES += \ + $(EOLIST) + +XLFLAGS += \ + $(EOLIST) +endif + +ifeq "$(RELEASE)" "release" +XINCDIRS += \ + $(EOLIST) + +XCFLAGS += \ + $(EOLIST) + +XDEFINES += \ + $(EOLIST) + +XLFLAGS += \ + $(EOLIST) +endif + +# +# These are used by the link target if an NLM is being generated +# This is used by the link 'name' directive to name the nlm. If left blank +# TARGET_nlm (see below) will be used. +# +NLM_NAME = example_ipc + +# +# This is used by the link '-desc ' directive. +# If left blank, NLM_NAME will be used. +# +NLM_DESCRIPTION = Apache $(VERSION_STR) Example IPC Callback Handler Module + +# +# This is used by the '-threadname' directive. If left blank, +# NLM_NAME Thread will be used. +# +NLM_THREAD_NAME = Example IPC Callback Handler Module + +# +# If this is specified, it will override VERSION value in +# $(AP_WORK)/build/NWGNUenvironment.inc +# +NLM_VERSION = + +# +# If this is specified, it will override the default of 64K +# +NLM_STACK_SIZE = 8192 + + +# +# If this is specified it will be used by the link '-entry' directive +# +NLM_ENTRY_SYM = + +# +# If this is specified it will be used by the link '-exit' directive +# +NLM_EXIT_SYM = + +# +# If this is specified it will be used by the link '-check' directive +# +NLM_CHECK_SYM = + +# +# If these are specified it will be used by the link '-flags' directive +# +NLM_FLAGS = + +# +# If this is specified it will be linked in with the XDCData option in the def +# file instead of the default of $(NWOS)/apache.xdc. XDCData can be disabled +# by setting APACHE_UNIPROC in the environment +# +XDCDATA = + +# +# If there is an NLM target, put it here +# +TARGET_nlm = \ + $(OBJDIR)/example_ipc.nlm \ + $(EOLIST) + +# +# If there is an LIB target, put it here +# +TARGET_lib = \ + $(EOLIST) + +# +# These are the OBJ files needed to create the NLM target above. +# Paths must all use the '/' character +# +FILES_nlm_objs = \ + $(OBJDIR)/mod_example_ipc.o \ + $(EOLIST) + +# +# These are the LIB files needed to create the NLM target above. +# These will be added as a library command in the link.opt file. +# +FILES_nlm_libs = \ + $(PRELUDE) \ + $(EOLIST) + +# +# These are the modules that the above NLM target depends on to load. +# These will be added as a module command in the link.opt file. +# +FILES_nlm_modules = \ + aprlib \ + libc \ + $(EOLIST) + +# +# If the nlm has a msg file, put it's path here +# +FILE_nlm_msg = + +# +# If the nlm has a hlp file put it's path here +# +FILE_nlm_hlp = + +# +# If this is specified, it will override $(NWOS)\copyright.txt. +# +FILE_nlm_copyright = + +# +# Any additional imports go here +# +FILES_nlm_Ximports = \ + @aprlib.imp \ + @httpd.imp \ + @libc.imp \ + $(EOLIST) + +# +# Any symbols exported to here +# +FILES_nlm_exports = \ + example_ipc_module \ + $(EOLIST) + +# +# These are the OBJ files needed to create the LIB target above. +# Paths must all use the '/' character +# +FILES_lib_objs = \ + $(EOLIST) + +# +# implement targets and dependancies (leave this section alone) +# + +libs :: $(OBJDIR) $(TARGET_lib) + +nlms :: libs $(TARGET_nlm) + +# +# Updated this target to create necessary directories and copy files to the +# correct place. (See $(AP_WORK)/build/NWGNUhead.inc for examples) +# +install :: nlms FORCE + +# +# Any specialized rules here +# + +# +# Include the 'tail' makefile that has targets that depend on variables defined +# in this makefile +# + +include $(APBUILD)/NWGNUtail.inc + + diff --git a/modules/examples/NWGNUmakefile b/modules/examples/NWGNUmakefile new file mode 100644 index 0000000..5d716ae --- /dev/null +++ b/modules/examples/NWGNUmakefile @@ -0,0 +1,257 @@ +# +# Declare the sub-directories to be built here +# + +SUBDIRS = \ + $(EOLIST) + +# +# Get the 'head' of the build environment. This includes default targets and +# paths to tools +# + +include $(AP_WORK)/build/NWGNUhead.inc + +# +# build this level's files + +# +# Make sure all needed macro's are defined +# + +# +# These directories will be at the beginning of the include list, followed by +# INCDIRS +# +XINCDIRS += \ + $(EOLIST) + +# +# These flags will come after CFLAGS +# +XCFLAGS += \ + $(EOLIST) + +# +# These defines will come after DEFINES +# +XDEFINES += \ + $(EOLIST) + +# +# These flags will be added to the link.opt file +# +XLFLAGS += \ + $(EOLIST) + +# +# These values will be appended to the correct variables based on the value of +# RELEASE +# +ifeq "$(RELEASE)" "debug" +XINCDIRS += \ + $(EOLIST) + +XCFLAGS += \ + $(EOLIST) + +XDEFINES += \ + $(EOLIST) + +XLFLAGS += \ + $(EOLIST) +endif + +ifeq "$(RELEASE)" "noopt" +XINCDIRS += \ + $(EOLIST) + +XCFLAGS += \ + $(EOLIST) + +XDEFINES += \ + $(EOLIST) + +XLFLAGS += \ + $(EOLIST) +endif + +ifeq "$(RELEASE)" "release" +XINCDIRS += \ + $(EOLIST) + +XCFLAGS += \ + $(EOLIST) + +XDEFINES += \ + $(EOLIST) + +XLFLAGS += \ + $(EOLIST) +endif + +# +# These are used by the link target if an NLM is being generated +# This is used by the link 'name' directive to name the nlm. If left blank +# TARGET_nlm (see below) will be used. +# +NLM_NAME = + +# +# This is used by the link '-desc ' directive. +# If left blank, NLM_NAME will be used. +# +NLM_DESCRIPTION = + +# +# This is used by the '-threadname' directive. If left blank, +# NLM_NAME Thread will be used. +# +NLM_THREAD_NAME = + +# +# If this is specified, it will override VERSION value in +# $(AP_WORK)/build/NWGNUenvironment.inc +# +NLM_VERSION = + +# +# If this is specified, it will override the default of 64K +# +NLM_STACK_SIZE = + + +# +# If this is specified it will be used by the link '-entry' directive +# +NLM_ENTRY_SYM = + +# +# If this is specified it will be used by the link '-exit' directive +# +NLM_EXIT_SYM = + +# +# If this is specified it will be used by the link '-check' directive +# +NLM_CHECK_SYM = + +# +# If these are specified it will be used by the link '-flags' directive +# +NLM_FLAGS = + +# +# If this is specified it will be linked in with the XDCData option in the def +# file instead of the default of $(NWOS)/apache.xdc. XDCData can be disabled +# by setting APACHE_UNIPROC in the environment +# +XDCDATA = + +# +# If there is an NLM target, put it here +# +# If there is only one element to build it needs to be included twice +# in the below target list. +# Normally if there is only one element to be built within a +# directory, the makefile for the single element would be called NWGNUmakefile. +# But if there are multiples, the parent NWGNUmakefile must reference more +# than one submakefile. Because the experimental directory might vary in the +# number of submakefiles, but for the moment only contains one, we reference +# it twice to allow it parent NWGNUmakefile to work properly. If another +# submakefile is added, the extra reference to the first NLM should be removed. +TARGET_nlm = \ + $(OBJDIR)/example_hooks.nlm \ + $(OBJDIR)/example_ipc.nlm \ + $(OBJDIR)/case_flt.nlm \ + $(OBJDIR)/case_flt_in.nlm \ + $(EOLIST) + +# +# If there is an LIB target, put it here +# +TARGET_lib = \ + $(EOLIST) + +# +# These are the OBJ files needed to create the NLM target above. +# Paths must all use the '/' character +# +FILES_nlm_objs = \ + $(EOLIST) + +# +# These are the LIB files needed to create the NLM target above. +# These will be added as a library command in the link.opt file. +# +FILES_nlm_libs = \ + $(EOLIST) + +# +# These are the modules that the above NLM target depends on to load. +# These will be added as a module command in the link.opt file. +# +FILES_nlm_modules = \ + $(EOLIST) + +# +# If the nlm has a msg file, put it's path here +# +FILE_nlm_msg = + +# +# If the nlm has a hlp file put it's path here +# +FILE_nlm_hlp = + +# +# If this is specified, it will override $(NWOS)\copyright.txt. +# +FILE_nlm_copyright = + +# +# Any additional imports go here +# +FILES_nlm_Ximports = \ + $(EOLIST) + +# +# Any symbols exported to here +# +FILES_nlm_exports = \ + $(EOLIST) + +# +# These are the OBJ files needed to create the LIB target above. +# Paths must all use the '/' character +# +FILES_lib_objs = \ + $(EOLIST) + +# +# implement targets and dependancies (leave this section alone) +# + +libs :: $(OBJDIR) $(TARGET_lib) + +nlms :: libs $(TARGET_nlm) + +# +# Updated this target to create necessary directories and copy files to the +# correct place. (See $(AP_WORK)/build/NWGNUhead.inc for examples) +# +install :: nlms FORCE + $(call COPY,$(OBJDIR)/*.nlm, $(INSTALLBASE)/modules/) + +# +# Any specialized rules here +# + +# +# Include the 'tail' makefile that has targets that depend on variables defined +# in this makefile +# + +include $(APBUILD)/NWGNUtail.inc + + diff --git a/modules/examples/README b/modules/examples/README new file mode 100644 index 0000000..2e03362 --- /dev/null +++ b/modules/examples/README @@ -0,0 +1,54 @@ +README for Apache 2.0 Example Module +[April, 1997, updated May 2000] + +The files in the src/modules/examples directory under the Apache +distribution directory tree are provided as an example to those that +wish to write modules that use the Apache API. + +The main file is mod_example_hooks.c, which illustrates all the different +callback mechanisms and call syntaces. By no means does an add-on +module need to include routines for all of the callbacks - quite the +contrary! + +The example module is an actual working module. If you link it into +your server, enable the "example-hooks-handler" handler for a location, +and then browse to that location, you will see a display of some of the +tracing the example module did as the various callbacks were made. + +To include the example module in your server add --enable-example-hooks +to the other ./configure arguments executed from the httpd source tree. +After that run 'make'. + +To add another module of your own: + + A. cp modules/examples/mod_example_hooks.c modules/examples/mod_myexample.c + B. Modify the file + C. Add an entry to modules/examples/config.m4, e.g. + APACHE_MODULE(myexample, my new module, , , no) + The last argument specifies if the module is built by-default + D. Build the server with --enable-myexample + +For windows, the process is slightly different; + + A. copy modules\examples\mod_example_hooks.c modules\examples\mod_myexample.c + B. copy modules\examples\mod_example_hooks.dsp modules\examples\mod_myexample.dsp + C. replace the occurrences of 'example_hooks' with your module name. + D. add the new .dsp to your Apache.dsw workspace, with dependencies + on the libapr, libaprutil and libhttpd projects. With the newer + Developer Studio 2002 through 2005, when you add the new .dsp + file it will be converted to a .vcproj file. + +To activate the example module, include a block similar to the +following in your httpd.conf file: + + <Location /example-info> + SetHandler example-hooks-handler + </Location> + +As an alternative, you can put the following into a .htaccess file and +then request the file "test.example" from that location: + + AddHandler example-hooks-handler .example + +After reloading/restarting your server, you should be able to browse +to this location and see the brief display mentioned earlier. diff --git a/modules/examples/config.m4 b/modules/examples/config.m4 new file mode 100644 index 0000000..dab9e87 --- /dev/null +++ b/modules/examples/config.m4 @@ -0,0 +1,9 @@ + +APACHE_MODPATH_INIT(examples) + +APACHE_MODULE(example_hooks, Example hook callback handler module, , , no) +APACHE_MODULE(case_filter, Example uppercase conversion filter, , , no) +APACHE_MODULE(case_filter_in, Example uppercase conversion input filter, , , no) +APACHE_MODULE(example_ipc, Example of shared memory and mutex usage, , , no) + +APACHE_MODPATH_FINISH diff --git a/modules/examples/mod_case_filter.c b/modules/examples/mod_case_filter.c new file mode 100644 index 0000000..409f65b --- /dev/null +++ b/modules/examples/mod_case_filter.c @@ -0,0 +1,139 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "httpd.h" +#include "http_config.h" +#include "apr_buckets.h" +#include "apr_general.h" +#include "apr_lib.h" +#include "util_filter.h" +#include "http_request.h" + +#include <ctype.h> + +static const char s_szCaseFilterName[] = "CaseFilter"; +module AP_MODULE_DECLARE_DATA case_filter_module; + +typedef struct +{ + int bEnabled; +} CaseFilterConfig; + +static void *CaseFilterCreateServerConfig(apr_pool_t *p, server_rec *s) +{ + CaseFilterConfig *pConfig = apr_pcalloc(p,sizeof *pConfig); + + pConfig->bEnabled = 0; + + return pConfig; +} + +static void CaseFilterInsertFilter(request_rec *r) +{ + CaseFilterConfig *pConfig = ap_get_module_config(r->server->module_config, + &case_filter_module); + + if (!pConfig->bEnabled) + return; + + ap_add_output_filter(s_szCaseFilterName, NULL, r, r->connection); +} + +static apr_status_t CaseFilterOutFilter(ap_filter_t *f, + apr_bucket_brigade *pbbIn) +{ + request_rec *r = f->r; + conn_rec *c = r->connection; + apr_bucket *pbktIn; + apr_bucket_brigade *pbbOut; + + pbbOut = apr_brigade_create(r->pool, c->bucket_alloc); + for (pbktIn = APR_BRIGADE_FIRST(pbbIn); + pbktIn != APR_BRIGADE_SENTINEL(pbbIn); + pbktIn = APR_BUCKET_NEXT(pbktIn)) + { + const char *data; + apr_size_t len; + char *buf; + apr_size_t n; + apr_bucket *pbktOut; + + if (APR_BUCKET_IS_EOS(pbktIn)) { + apr_bucket *pbktEOS = apr_bucket_eos_create(c->bucket_alloc); + APR_BRIGADE_INSERT_TAIL(pbbOut, pbktEOS); + continue; + } + + /* read */ + apr_bucket_read(pbktIn, &data, &len, APR_BLOCK_READ); + + /* write */ + buf = apr_bucket_alloc(len, c->bucket_alloc); + for (n=0 ; n < len ; ++n) { + buf[n] = apr_toupper(data[n]); + } + + pbktOut = apr_bucket_heap_create(buf, len, apr_bucket_free, + c->bucket_alloc); + APR_BRIGADE_INSERT_TAIL(pbbOut, pbktOut); + } + + /* Q: is there any advantage to passing a brigade for each bucket? + * A: obviously, it can cut down server resource consumption, if this + * experimental module was fed a file of 4MB, it would be using 8MB for + * the 'read' buckets and the 'write' buckets. + * + * Note it is more efficient to consume (destroy) each bucket as it's + * processed above than to do a single cleanup down here. In any case, + * don't let our caller pass the same buckets to us, twice; + */ + apr_brigade_cleanup(pbbIn); + return ap_pass_brigade(f->next, pbbOut); +} + +static const char *CaseFilterEnable(cmd_parms *cmd, void *dummy, int arg) +{ + CaseFilterConfig *pConfig = ap_get_module_config(cmd->server->module_config, + &case_filter_module); + pConfig->bEnabled = arg; + + return NULL; +} + +static const command_rec CaseFilterCmds[] = +{ + AP_INIT_FLAG("CaseFilter", CaseFilterEnable, NULL, RSRC_CONF, + "Run a case filter on this host"), + { NULL } +}; + +static void CaseFilterRegisterHooks(apr_pool_t *p) +{ + ap_hook_insert_filter(CaseFilterInsertFilter, NULL, NULL, APR_HOOK_MIDDLE); + ap_register_output_filter(s_szCaseFilterName, CaseFilterOutFilter, NULL, + AP_FTYPE_RESOURCE); +} + +AP_DECLARE_MODULE(case_filter) = +{ + STANDARD20_MODULE_STUFF, + NULL, + NULL, + CaseFilterCreateServerConfig, + NULL, + CaseFilterCmds, + CaseFilterRegisterHooks +}; diff --git a/modules/examples/mod_case_filter.dep b/modules/examples/mod_case_filter.dep new file mode 100644 index 0000000..2b8cfad --- /dev/null +++ b/modules/examples/mod_case_filter.dep @@ -0,0 +1,46 @@ +# Microsoft Developer Studio Generated Dependency File, included by mod_case_filter.mak + +..\..\build\win32\httpd.rc : \ + "..\..\include\ap_release.h"\ + + +.\mod_case_filter.c : \ + "..\..\include\ap_config.h"\ + "..\..\include\ap_config_layout.h"\ + "..\..\include\ap_hooks.h"\ + "..\..\include\ap_mmn.h"\ + "..\..\include\ap_regex.h"\ + "..\..\include\ap_release.h"\ + "..\..\include\apache_noprobes.h"\ + "..\..\include\http_config.h"\ + "..\..\include\http_request.h"\ + "..\..\include\httpd.h"\ + "..\..\include\os.h"\ + "..\..\include\util_cfgtree.h"\ + "..\..\include\util_filter.h"\ + "..\..\srclib\apr-util\include\apr_buckets.h"\ + "..\..\srclib\apr-util\include\apr_hooks.h"\ + "..\..\srclib\apr-util\include\apr_optional.h"\ + "..\..\srclib\apr-util\include\apr_optional_hooks.h"\ + "..\..\srclib\apr-util\include\apr_uri.h"\ + "..\..\srclib\apr-util\include\apu.h"\ + "..\..\srclib\apr\include\apr.h"\ + "..\..\srclib\apr\include\apr_allocator.h"\ + "..\..\srclib\apr\include\apr_errno.h"\ + "..\..\srclib\apr\include\apr_file_info.h"\ + "..\..\srclib\apr\include\apr_file_io.h"\ + "..\..\srclib\apr\include\apr_general.h"\ + "..\..\srclib\apr\include\apr_inherit.h"\ + "..\..\srclib\apr\include\apr_lib.h"\ + "..\..\srclib\apr\include\apr_mmap.h"\ + "..\..\srclib\apr\include\apr_network_io.h"\ + "..\..\srclib\apr\include\apr_poll.h"\ + "..\..\srclib\apr\include\apr_pools.h"\ + "..\..\srclib\apr\include\apr_ring.h"\ + "..\..\srclib\apr\include\apr_tables.h"\ + "..\..\srclib\apr\include\apr_thread_mutex.h"\ + "..\..\srclib\apr\include\apr_thread_proc.h"\ + "..\..\srclib\apr\include\apr_time.h"\ + "..\..\srclib\apr\include\apr_user.h"\ + "..\..\srclib\apr\include\apr_want.h"\ + diff --git a/modules/examples/mod_case_filter.dsp b/modules/examples/mod_case_filter.dsp new file mode 100644 index 0000000..8f65689 --- /dev/null +++ b/modules/examples/mod_case_filter.dsp @@ -0,0 +1,111 @@ +# Microsoft Developer Studio Project File - Name="mod_case_filter" - 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_case_filter - 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_case_filter.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For case_filter: +!MESSAGE +!MESSAGE NMAKE /f "mod_case_filter.mak" CFG="mod_case_filter - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "mod_case_filter - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "mod_case_filter - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe + +!IF "$(CFG)" == "mod_case_filter - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /c +# ADD CPP /nologo /MD /W3 /O2 /Oy- /Zi /I "../../include" /I "../../srclib/apr/include" /I "../../srclib/apr-util/include" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /Fd"Release\mod_case_filter_src" /FD /c +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o /win32 "NUL" +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o /win32 "NUL" +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /fo"Release/mod_case_filter.res" /i "../../include" /i "../../srclib/apr/include" /d "NDEBUG" /d BIN_NAME="mod_case_filter.so" /d LONG_NAME="case_filter_module for Apache" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib /nologo /subsystem:windows /dll /out:".\Release\mod_case_filter.so" /base:@..\..\os\win32\BaseAddr.ref,mod_case_filter.so +# ADD LINK32 kernel32.lib /nologo /subsystem:windows /dll /incremental:no /debug /out:".\Release\mod_case_filter.so" /base:@..\..\os\win32\BaseAddr.ref,mod_case_filter.so /opt:ref +# Begin Special Build Tool +TargetPath=.\Release\mod_case_filter.so +SOURCE="$(InputPath)" +PostBuild_Desc=Embed .manifest +PostBuild_Cmds=if exist $(TargetPath).manifest mt.exe -manifest $(TargetPath).manifest -outputresource:$(TargetPath);2 +# End Special Build Tool + +!ELSEIF "$(CFG)" == "mod_case_filter - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MDd /W3 /EHsc /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FD /c +# ADD CPP /nologo /MDd /W3 /EHsc /Zi /Od /I "../../include" /I "../../srclib/apr/include" /I "../../srclib/apr-util/include" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /Fd"Debug\mod_case_filter_src" /FD /c +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o /win32 "NUL" +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o /win32 "NUL" +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /fo"Debug/mod_case_filter.res" /i "../../include" /i "../../srclib/apr/include" /d "_DEBUG" /d BIN_NAME="mod_case_filter.so" /d LONG_NAME="case_filter_module for Apache" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib /nologo /subsystem:windows /dll /incremental:no /debug /out:".\Debug\mod_case_filter.so" /base:@..\..\os\win32\BaseAddr.ref,mod_case_filter.so +# ADD LINK32 kernel32.lib /nologo /subsystem:windows /dll /incremental:no /debug /out:".\Debug\mod_case_filter.so" /base:@..\..\os\win32\BaseAddr.ref,mod_case_filter.so +# Begin Special Build Tool +TargetPath=.\Debug\mod_case_filter.so +SOURCE="$(InputPath)" +PostBuild_Desc=Embed .manifest +PostBuild_Cmds=if exist $(TargetPath).manifest mt.exe -manifest $(TargetPath).manifest -outputresource:$(TargetPath);2 +# End Special Build Tool + +!ENDIF + +# Begin Target + +# Name "mod_case_filter - Win32 Release" +# Name "mod_case_filter - Win32 Debug" +# Begin Source File + +SOURCE=.\mod_case_filter.c +# End Source File +# Begin Source File + +SOURCE=..\..\build\win32\httpd.rc +# End Source File +# End Target +# End Project diff --git a/modules/examples/mod_case_filter.mak b/modules/examples/mod_case_filter.mak new file mode 100644 index 0000000..a7f04bf --- /dev/null +++ b/modules/examples/mod_case_filter.mak @@ -0,0 +1,353 @@ +# Microsoft Developer Studio Generated NMAKE File, Based on mod_case_filter.dsp +!IF "$(CFG)" == "" +CFG=mod_case_filter - Win32 Debug +!MESSAGE No configuration specified. Defaulting to mod_case_filter - Win32 Debug. +!ENDIF + +!IF "$(CFG)" != "mod_case_filter - Win32 Release" && "$(CFG)" != "mod_case_filter - Win32 Debug" +!MESSAGE Invalid configuration "$(CFG)" specified. +!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_case_filter.mak" CFG="mod_case_filter - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "mod_case_filter - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "mod_case_filter - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE +!ERROR An invalid configuration is specified. +!ENDIF + +!IF "$(OS)" == "Windows_NT" +NULL= +!ELSE +NULL=nul +!ENDIF + +!IF "$(CFG)" == "mod_case_filter - Win32 Release" + +OUTDIR=.\Release +INTDIR=.\Release +DS_POSTBUILD_DEP=$(INTDIR)\postbld.dep +# Begin Custom Macros +OutDir=.\Release +# End Custom Macros + +!IF "$(RECURSE)" == "0" + +ALL : "$(OUTDIR)\mod_case_filter.so" "$(DS_POSTBUILD_DEP)" + +!ELSE + +ALL : "libhttpd - Win32 Release" "libaprutil - Win32 Release" "libapr - Win32 Release" "$(OUTDIR)\mod_case_filter.so" "$(DS_POSTBUILD_DEP)" + +!ENDIF + +!IF "$(RECURSE)" == "1" +CLEAN :"libapr - Win32 ReleaseCLEAN" "libaprutil - Win32 ReleaseCLEAN" "libhttpd - Win32 ReleaseCLEAN" +!ELSE +CLEAN : +!ENDIF + -@erase "$(INTDIR)\mod_case_filter.obj" + -@erase "$(INTDIR)\mod_case_filter.res" + -@erase "$(INTDIR)\mod_case_filter_src.idb" + -@erase "$(INTDIR)\mod_case_filter_src.pdb" + -@erase "$(OUTDIR)\mod_case_filter.exp" + -@erase "$(OUTDIR)\mod_case_filter.lib" + -@erase "$(OUTDIR)\mod_case_filter.pdb" + -@erase "$(OUTDIR)\mod_case_filter.so" + +"$(OUTDIR)" : + if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" + +CPP=cl.exe +CPP_PROJ=/nologo /MD /W3 /Zi /O2 /Oy- /I "../../include" /I "../../srclib/apr/include" /I "../../srclib/apr-util/include" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\mod_case_filter_src" /FD /c + +.c{$(INTDIR)}.obj:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cpp{$(INTDIR)}.obj:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cxx{$(INTDIR)}.obj:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.c{$(INTDIR)}.sbr:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cpp{$(INTDIR)}.sbr:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cxx{$(INTDIR)}.sbr:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +MTL=midl.exe +MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /o /win32 "NUL" +RSC=rc.exe +RSC_PROJ=/l 0x409 /fo"$(INTDIR)\mod_case_filter.res" /i "../../include" /i "../../srclib/apr/include" /d "NDEBUG" /d BIN_NAME="mod_case_filter.so" /d LONG_NAME="case_filter_module for Apache" +BSC32=bscmake.exe +BSC32_FLAGS=/nologo /o"$(OUTDIR)\mod_case_filter.bsc" +BSC32_SBRS= \ + +LINK32=link.exe +LINK32_FLAGS=kernel32.lib /nologo /subsystem:windows /dll /incremental:no /pdb:"$(OUTDIR)\mod_case_filter.pdb" /debug /out:"$(OUTDIR)\mod_case_filter.so" /implib:"$(OUTDIR)\mod_case_filter.lib" /base:@..\..\os\win32\BaseAddr.ref,mod_case_filter.so /opt:ref +LINK32_OBJS= \ + "$(INTDIR)\mod_case_filter.obj" \ + "$(INTDIR)\mod_case_filter.res" \ + "..\..\srclib\apr\Release\libapr-1.lib" \ + "..\..\srclib\apr-util\Release\libaprutil-1.lib" \ + "..\..\Release\libhttpd.lib" + +"$(OUTDIR)\mod_case_filter.so" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) + $(LINK32) @<< + $(LINK32_FLAGS) $(LINK32_OBJS) +<< + +TargetPath=.\Release\mod_case_filter.so +SOURCE="$(InputPath)" +PostBuild_Desc=Embed .manifest +DS_POSTBUILD_DEP=$(INTDIR)\postbld.dep + +# Begin Custom Macros +OutDir=.\Release +# End Custom Macros + +"$(DS_POSTBUILD_DEP)" : "$(OUTDIR)\mod_case_filter.so" + if exist .\Release\mod_case_filter.so.manifest mt.exe -manifest .\Release\mod_case_filter.so.manifest -outputresource:.\Release\mod_case_filter.so;2 + echo Helper for Post-build step > "$(DS_POSTBUILD_DEP)" + +!ELSEIF "$(CFG)" == "mod_case_filter - Win32 Debug" + +OUTDIR=.\Debug +INTDIR=.\Debug +DS_POSTBUILD_DEP=$(INTDIR)\postbld.dep +# Begin Custom Macros +OutDir=.\Debug +# End Custom Macros + +!IF "$(RECURSE)" == "0" + +ALL : "$(OUTDIR)\mod_case_filter.so" "$(DS_POSTBUILD_DEP)" + +!ELSE + +ALL : "libhttpd - Win32 Debug" "libaprutil - Win32 Debug" "libapr - Win32 Debug" "$(OUTDIR)\mod_case_filter.so" "$(DS_POSTBUILD_DEP)" + +!ENDIF + +!IF "$(RECURSE)" == "1" +CLEAN :"libapr - Win32 DebugCLEAN" "libaprutil - Win32 DebugCLEAN" "libhttpd - Win32 DebugCLEAN" +!ELSE +CLEAN : +!ENDIF + -@erase "$(INTDIR)\mod_case_filter.obj" + -@erase "$(INTDIR)\mod_case_filter.res" + -@erase "$(INTDIR)\mod_case_filter_src.idb" + -@erase "$(INTDIR)\mod_case_filter_src.pdb" + -@erase "$(OUTDIR)\mod_case_filter.exp" + -@erase "$(OUTDIR)\mod_case_filter.lib" + -@erase "$(OUTDIR)\mod_case_filter.pdb" + -@erase "$(OUTDIR)\mod_case_filter.so" + +"$(OUTDIR)" : + if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" + +CPP=cl.exe +CPP_PROJ=/nologo /MDd /W3 /Zi /Od /I "../../include" /I "../../srclib/apr/include" /I "../../srclib/apr-util/include" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\mod_case_filter_src" /FD /EHsc /c + +.c{$(INTDIR)}.obj:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cpp{$(INTDIR)}.obj:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cxx{$(INTDIR)}.obj:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.c{$(INTDIR)}.sbr:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cpp{$(INTDIR)}.sbr:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cxx{$(INTDIR)}.sbr:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +MTL=midl.exe +MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /o /win32 "NUL" +RSC=rc.exe +RSC_PROJ=/l 0x409 /fo"$(INTDIR)\mod_case_filter.res" /i "../../include" /i "../../srclib/apr/include" /d "_DEBUG" /d BIN_NAME="mod_case_filter.so" /d LONG_NAME="case_filter_module for Apache" +BSC32=bscmake.exe +BSC32_FLAGS=/nologo /o"$(OUTDIR)\mod_case_filter.bsc" +BSC32_SBRS= \ + +LINK32=link.exe +LINK32_FLAGS=kernel32.lib /nologo /subsystem:windows /dll /incremental:no /pdb:"$(OUTDIR)\mod_case_filter.pdb" /debug /out:"$(OUTDIR)\mod_case_filter.so" /implib:"$(OUTDIR)\mod_case_filter.lib" /base:@..\..\os\win32\BaseAddr.ref,mod_case_filter.so +LINK32_OBJS= \ + "$(INTDIR)\mod_case_filter.obj" \ + "$(INTDIR)\mod_case_filter.res" \ + "..\..\srclib\apr\Debug\libapr-1.lib" \ + "..\..\srclib\apr-util\Debug\libaprutil-1.lib" \ + "..\..\Debug\libhttpd.lib" + +"$(OUTDIR)\mod_case_filter.so" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) + $(LINK32) @<< + $(LINK32_FLAGS) $(LINK32_OBJS) +<< + +TargetPath=.\Debug\mod_case_filter.so +SOURCE="$(InputPath)" +PostBuild_Desc=Embed .manifest +DS_POSTBUILD_DEP=$(INTDIR)\postbld.dep + +# Begin Custom Macros +OutDir=.\Debug +# End Custom Macros + +"$(DS_POSTBUILD_DEP)" : "$(OUTDIR)\mod_case_filter.so" + if exist .\Debug\mod_case_filter.so.manifest mt.exe -manifest .\Debug\mod_case_filter.so.manifest -outputresource:.\Debug\mod_case_filter.so;2 + echo Helper for Post-build step > "$(DS_POSTBUILD_DEP)" + +!ENDIF + + +!IF "$(NO_EXTERNAL_DEPS)" != "1" +!IF EXISTS("mod_case_filter.dep") +!INCLUDE "mod_case_filter.dep" +!ELSE +!MESSAGE Warning: cannot find "mod_case_filter.dep" +!ENDIF +!ENDIF + + +!IF "$(CFG)" == "mod_case_filter - Win32 Release" || "$(CFG)" == "mod_case_filter - Win32 Debug" + +!IF "$(CFG)" == "mod_case_filter - Win32 Release" + +"libapr - Win32 Release" : + cd ".\..\..\srclib\apr" + $(MAKE) /$(MAKEFLAGS) /F ".\libapr.mak" CFG="libapr - Win32 Release" + cd "..\..\modules\examples" + +"libapr - Win32 ReleaseCLEAN" : + cd ".\..\..\srclib\apr" + $(MAKE) /$(MAKEFLAGS) /F ".\libapr.mak" CFG="libapr - Win32 Release" RECURSE=1 CLEAN + cd "..\..\modules\examples" + +!ELSEIF "$(CFG)" == "mod_case_filter - Win32 Debug" + +"libapr - Win32 Debug" : + cd ".\..\..\srclib\apr" + $(MAKE) /$(MAKEFLAGS) /F ".\libapr.mak" CFG="libapr - Win32 Debug" + cd "..\..\modules\examples" + +"libapr - Win32 DebugCLEAN" : + cd ".\..\..\srclib\apr" + $(MAKE) /$(MAKEFLAGS) /F ".\libapr.mak" CFG="libapr - Win32 Debug" RECURSE=1 CLEAN + cd "..\..\modules\examples" + +!ENDIF + +!IF "$(CFG)" == "mod_case_filter - Win32 Release" + +"libaprutil - Win32 Release" : + cd ".\..\..\srclib\apr-util" + $(MAKE) /$(MAKEFLAGS) /F ".\libaprutil.mak" CFG="libaprutil - Win32 Release" + cd "..\..\modules\examples" + +"libaprutil - Win32 ReleaseCLEAN" : + cd ".\..\..\srclib\apr-util" + $(MAKE) /$(MAKEFLAGS) /F ".\libaprutil.mak" CFG="libaprutil - Win32 Release" RECURSE=1 CLEAN + cd "..\..\modules\examples" + +!ELSEIF "$(CFG)" == "mod_case_filter - Win32 Debug" + +"libaprutil - Win32 Debug" : + cd ".\..\..\srclib\apr-util" + $(MAKE) /$(MAKEFLAGS) /F ".\libaprutil.mak" CFG="libaprutil - Win32 Debug" + cd "..\..\modules\examples" + +"libaprutil - Win32 DebugCLEAN" : + cd ".\..\..\srclib\apr-util" + $(MAKE) /$(MAKEFLAGS) /F ".\libaprutil.mak" CFG="libaprutil - Win32 Debug" RECURSE=1 CLEAN + cd "..\..\modules\examples" + +!ENDIF + +!IF "$(CFG)" == "mod_case_filter - Win32 Release" + +"libhttpd - Win32 Release" : + cd ".\..\.." + $(MAKE) /$(MAKEFLAGS) /F ".\libhttpd.mak" CFG="libhttpd - Win32 Release" + cd ".\modules\examples" + +"libhttpd - Win32 ReleaseCLEAN" : + cd ".\..\.." + $(MAKE) /$(MAKEFLAGS) /F ".\libhttpd.mak" CFG="libhttpd - Win32 Release" RECURSE=1 CLEAN + cd ".\modules\examples" + +!ELSEIF "$(CFG)" == "mod_case_filter - Win32 Debug" + +"libhttpd - Win32 Debug" : + cd ".\..\.." + $(MAKE) /$(MAKEFLAGS) /F ".\libhttpd.mak" CFG="libhttpd - Win32 Debug" + cd ".\modules\examples" + +"libhttpd - Win32 DebugCLEAN" : + cd ".\..\.." + $(MAKE) /$(MAKEFLAGS) /F ".\libhttpd.mak" CFG="libhttpd - Win32 Debug" RECURSE=1 CLEAN + cd ".\modules\examples" + +!ENDIF + +SOURCE=..\..\build\win32\httpd.rc + +!IF "$(CFG)" == "mod_case_filter - Win32 Release" + + +"$(INTDIR)\mod_case_filter.res" : $(SOURCE) "$(INTDIR)" + $(RSC) /l 0x409 /fo"$(INTDIR)\mod_case_filter.res" /i "../../include" /i "../../srclib/apr/include" /i "../../build\win32" /d "NDEBUG" /d BIN_NAME="mod_case_filter.so" /d LONG_NAME="case_filter_module for Apache" $(SOURCE) + + +!ELSEIF "$(CFG)" == "mod_case_filter - Win32 Debug" + + +"$(INTDIR)\mod_case_filter.res" : $(SOURCE) "$(INTDIR)" + $(RSC) /l 0x409 /fo"$(INTDIR)\mod_case_filter.res" /i "../../include" /i "../../srclib/apr/include" /i "../../build\win32" /d "_DEBUG" /d BIN_NAME="mod_case_filter.so" /d LONG_NAME="case_filter_module for Apache" $(SOURCE) + + +!ENDIF + +SOURCE=.\mod_case_filter.c + +"$(INTDIR)\mod_case_filter.obj" : $(SOURCE) "$(INTDIR)" + + + +!ENDIF + diff --git a/modules/examples/mod_case_filter_in.c b/modules/examples/mod_case_filter_in.c new file mode 100644 index 0000000..c70a9eb --- /dev/null +++ b/modules/examples/mod_case_filter_in.c @@ -0,0 +1,160 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * An example input filter - this converts input to upper case. Note that + * because of the moment it gets inserted it does NOT convert request headers. + */ + +#include "httpd.h" +#include "http_config.h" +#include "apr_buckets.h" +#include "apr_general.h" +#include "apr_lib.h" +#include "util_filter.h" +#include "http_request.h" + +#include <ctype.h> + +static const char s_szCaseFilterName[] = "CaseFilterIn"; +module AP_MODULE_DECLARE_DATA case_filter_in_module; + +typedef struct +{ + int bEnabled; +} CaseFilterInConfig; + +typedef struct +{ + apr_bucket_brigade *pbbTmp; +} CaseFilterInContext; + +static void *CaseFilterInCreateServerConfig(apr_pool_t *p, server_rec *s) +{ + CaseFilterInConfig *pConfig = apr_pcalloc(p, sizeof *pConfig); + + pConfig->bEnabled = 0; + + return pConfig; +} + +static void CaseFilterInInsertFilter(request_rec *r) +{ + CaseFilterInConfig *pConfig = ap_get_module_config(r->server->module_config, + &case_filter_in_module); + if (!pConfig->bEnabled) + return; + + ap_add_input_filter(s_szCaseFilterName, NULL, r, r->connection); +} + +static apr_status_t CaseFilterInFilter(ap_filter_t *f, + apr_bucket_brigade *pbbOut, + ap_input_mode_t eMode, + apr_read_type_e eBlock, + apr_off_t nBytes) +{ + request_rec *r = f->r; + conn_rec *c = r->connection; + CaseFilterInContext *pCtx; + apr_status_t ret; + + if (!(pCtx = f->ctx)) { + f->ctx = pCtx = apr_palloc(r->pool, sizeof *pCtx); + pCtx->pbbTmp = apr_brigade_create(r->pool, c->bucket_alloc); + } + + if (APR_BRIGADE_EMPTY(pCtx->pbbTmp)) { + ret = ap_get_brigade(f->next, pCtx->pbbTmp, eMode, eBlock, nBytes); + + if (eMode == AP_MODE_EATCRLF || ret != APR_SUCCESS) + return ret; + } + + while (!APR_BRIGADE_EMPTY(pCtx->pbbTmp)) { + apr_bucket *pbktIn = APR_BRIGADE_FIRST(pCtx->pbbTmp); + apr_bucket *pbktOut; + const char *data; + apr_size_t len; + char *buf; + apr_size_t n; + + /* It is tempting to do this... + * APR_BUCKET_REMOVE(pB); + * APR_BRIGADE_INSERT_TAIL(pbbOut,pB); + * and change the case of the bucket data, but that would be wrong + * for a file or socket buffer, for example... + */ + + if (APR_BUCKET_IS_EOS(pbktIn)) { + APR_BUCKET_REMOVE(pbktIn); + APR_BRIGADE_INSERT_TAIL(pbbOut, pbktIn); + break; + } + + ret=apr_bucket_read(pbktIn, &data, &len, eBlock); + if (ret != APR_SUCCESS) + return ret; + + buf = ap_malloc(len); + for (n=0 ; n < len ; ++n) { + buf[n] = apr_toupper(data[n]); + } + + pbktOut = apr_bucket_heap_create(buf, len, free, c->bucket_alloc); + APR_BRIGADE_INSERT_TAIL(pbbOut, pbktOut); + apr_bucket_delete(pbktIn); + } + + return APR_SUCCESS; +} + +static const char *CaseFilterInEnable(cmd_parms *cmd, void *dummy, int arg) +{ + CaseFilterInConfig *pConfig + = ap_get_module_config(cmd->server->module_config, + &case_filter_in_module); + pConfig->bEnabled=arg; + + return NULL; +} + +static const command_rec CaseFilterInCmds[] = +{ + AP_INIT_FLAG("CaseFilterIn", CaseFilterInEnable, NULL, RSRC_CONF, + "Run an input case filter on this host"), + { NULL } +}; + + +static void CaseFilterInRegisterHooks(apr_pool_t *p) +{ + ap_hook_insert_filter(CaseFilterInInsertFilter, NULL, NULL, + APR_HOOK_MIDDLE); + ap_register_input_filter(s_szCaseFilterName, CaseFilterInFilter, NULL, + AP_FTYPE_RESOURCE); +} + +AP_DECLARE_MODULE(case_filter_in) = +{ + STANDARD20_MODULE_STUFF, + NULL, + NULL, + CaseFilterInCreateServerConfig, + NULL, + CaseFilterInCmds, + CaseFilterInRegisterHooks +}; diff --git a/modules/examples/mod_case_filter_in.dep b/modules/examples/mod_case_filter_in.dep new file mode 100644 index 0000000..abf8c16 --- /dev/null +++ b/modules/examples/mod_case_filter_in.dep @@ -0,0 +1,46 @@ +# Microsoft Developer Studio Generated Dependency File, included by mod_case_filter_in.mak + +..\..\build\win32\httpd.rc : \ + "..\..\include\ap_release.h"\ + + +.\mod_case_filter_in.c : \ + "..\..\include\ap_config.h"\ + "..\..\include\ap_config_layout.h"\ + "..\..\include\ap_hooks.h"\ + "..\..\include\ap_mmn.h"\ + "..\..\include\ap_regex.h"\ + "..\..\include\ap_release.h"\ + "..\..\include\apache_noprobes.h"\ + "..\..\include\http_config.h"\ + "..\..\include\http_request.h"\ + "..\..\include\httpd.h"\ + "..\..\include\os.h"\ + "..\..\include\util_cfgtree.h"\ + "..\..\include\util_filter.h"\ + "..\..\srclib\apr-util\include\apr_buckets.h"\ + "..\..\srclib\apr-util\include\apr_hooks.h"\ + "..\..\srclib\apr-util\include\apr_optional.h"\ + "..\..\srclib\apr-util\include\apr_optional_hooks.h"\ + "..\..\srclib\apr-util\include\apr_uri.h"\ + "..\..\srclib\apr-util\include\apu.h"\ + "..\..\srclib\apr\include\apr.h"\ + "..\..\srclib\apr\include\apr_allocator.h"\ + "..\..\srclib\apr\include\apr_errno.h"\ + "..\..\srclib\apr\include\apr_file_info.h"\ + "..\..\srclib\apr\include\apr_file_io.h"\ + "..\..\srclib\apr\include\apr_general.h"\ + "..\..\srclib\apr\include\apr_inherit.h"\ + "..\..\srclib\apr\include\apr_lib.h"\ + "..\..\srclib\apr\include\apr_mmap.h"\ + "..\..\srclib\apr\include\apr_network_io.h"\ + "..\..\srclib\apr\include\apr_poll.h"\ + "..\..\srclib\apr\include\apr_pools.h"\ + "..\..\srclib\apr\include\apr_ring.h"\ + "..\..\srclib\apr\include\apr_tables.h"\ + "..\..\srclib\apr\include\apr_thread_mutex.h"\ + "..\..\srclib\apr\include\apr_thread_proc.h"\ + "..\..\srclib\apr\include\apr_time.h"\ + "..\..\srclib\apr\include\apr_user.h"\ + "..\..\srclib\apr\include\apr_want.h"\ + diff --git a/modules/examples/mod_case_filter_in.dsp b/modules/examples/mod_case_filter_in.dsp new file mode 100644 index 0000000..8a00793 --- /dev/null +++ b/modules/examples/mod_case_filter_in.dsp @@ -0,0 +1,111 @@ +# Microsoft Developer Studio Project File - Name="mod_case_filter_in" - 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_case_filter_in - 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_case_filter_in.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For case_filter_in: +!MESSAGE +!MESSAGE NMAKE /f "mod_case_filter_in.mak" CFG="mod_case_filter_in - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "mod_case_filter_in - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "mod_case_filter_in - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe + +!IF "$(CFG)" == "mod_case_filter_in - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /c +# ADD CPP /nologo /MD /W3 /O2 /Oy- /Zi /I "../../include" /I "../../srclib/apr/include" /I "../../srclib/apr-util/include" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /Fd"Release\mod_case_filter_in_src" /FD /c +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o /win32 "NUL" +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o /win32 "NUL" +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /fo"Release/mod_case_filter_in.res" /i "../../include" /i "../../srclib/apr/include" /d "NDEBUG" /d BIN_NAME="mod_case_filter_in.so" /d LONG_NAME="case_filter_in_module for Apache" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib /nologo /subsystem:windows /dll /out:".\Release\mod_case_filter_in.so" /base:@..\..\os\win32\BaseAddr.ref,mod_case_filter_in.so +# ADD LINK32 kernel32.lib /nologo /subsystem:windows /dll /incremental:no /debug /out:".\Release\mod_case_filter_in.so" /base:@..\..\os\win32\BaseAddr.ref,mod_case_filter_in.so /opt:ref +# Begin Special Build Tool +TargetPath=.\Release\mod_case_filter_in.so +SOURCE="$(InputPath)" +PostBuild_Desc=Embed .manifest +PostBuild_Cmds=if exist $(TargetPath).manifest mt.exe -manifest $(TargetPath).manifest -outputresource:$(TargetPath);2 +# End Special Build Tool + +!ELSEIF "$(CFG)" == "mod_case_filter_in - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MDd /W3 /EHsc /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FD /c +# ADD CPP /nologo /MDd /W3 /EHsc /Zi /Od /I "../../include" /I "../../srclib/apr/include" /I "../../srclib/apr-util/include" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /Fd"Debug\mod_case_filter_in_src" /FD /c +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o /win32 "NUL" +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o /win32 "NUL" +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /fo"Debug/mod_case_filter_in.res" /i "../../include" /i "../../srclib/apr/include" /d "_DEBUG" /d BIN_NAME="mod_case_filter_in.so" /d LONG_NAME="case_filter_in_module for Apache" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib /nologo /subsystem:windows /dll /incremental:no /debug /out:".\Debug\mod_case_filter_in.so" /base:@..\..\os\win32\BaseAddr.ref,mod_case_filter_in.so +# ADD LINK32 kernel32.lib /nologo /subsystem:windows /dll /incremental:no /debug /out:".\Debug\mod_case_filter_in.so" /base:@..\..\os\win32\BaseAddr.ref,mod_case_filter_in.so +# Begin Special Build Tool +TargetPath=.\Debug\mod_case_filter_in.so +SOURCE="$(InputPath)" +PostBuild_Desc=Embed .manifest +PostBuild_Cmds=if exist $(TargetPath).manifest mt.exe -manifest $(TargetPath).manifest -outputresource:$(TargetPath);2 +# End Special Build Tool + +!ENDIF + +# Begin Target + +# Name "mod_case_filter_in - Win32 Release" +# Name "mod_case_filter_in - Win32 Debug" +# Begin Source File + +SOURCE=.\mod_case_filter_in.c +# End Source File +# Begin Source File + +SOURCE=..\..\build\win32\httpd.rc +# End Source File +# End Target +# End Project diff --git a/modules/examples/mod_case_filter_in.mak b/modules/examples/mod_case_filter_in.mak new file mode 100644 index 0000000..28bb848 --- /dev/null +++ b/modules/examples/mod_case_filter_in.mak @@ -0,0 +1,353 @@ +# Microsoft Developer Studio Generated NMAKE File, Based on mod_case_filter_in.dsp +!IF "$(CFG)" == "" +CFG=mod_case_filter_in - Win32 Debug +!MESSAGE No configuration specified. Defaulting to mod_case_filter_in - Win32 Debug. +!ENDIF + +!IF "$(CFG)" != "mod_case_filter_in - Win32 Release" && "$(CFG)" != "mod_case_filter_in - Win32 Debug" +!MESSAGE Invalid configuration "$(CFG)" specified. +!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_case_filter_in.mak" CFG="mod_case_filter_in - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "mod_case_filter_in - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "mod_case_filter_in - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE +!ERROR An invalid configuration is specified. +!ENDIF + +!IF "$(OS)" == "Windows_NT" +NULL= +!ELSE +NULL=nul +!ENDIF + +!IF "$(CFG)" == "mod_case_filter_in - Win32 Release" + +OUTDIR=.\Release +INTDIR=.\Release +DS_POSTBUILD_DEP=$(INTDIR)\postbld.dep +# Begin Custom Macros +OutDir=.\Release +# End Custom Macros + +!IF "$(RECURSE)" == "0" + +ALL : "$(OUTDIR)\mod_case_filter_in.so" "$(DS_POSTBUILD_DEP)" + +!ELSE + +ALL : "libhttpd - Win32 Release" "libaprutil - Win32 Release" "libapr - Win32 Release" "$(OUTDIR)\mod_case_filter_in.so" "$(DS_POSTBUILD_DEP)" + +!ENDIF + +!IF "$(RECURSE)" == "1" +CLEAN :"libapr - Win32 ReleaseCLEAN" "libaprutil - Win32 ReleaseCLEAN" "libhttpd - Win32 ReleaseCLEAN" +!ELSE +CLEAN : +!ENDIF + -@erase "$(INTDIR)\mod_case_filter_in.obj" + -@erase "$(INTDIR)\mod_case_filter_in.res" + -@erase "$(INTDIR)\mod_case_filter_in_src.idb" + -@erase "$(INTDIR)\mod_case_filter_in_src.pdb" + -@erase "$(OUTDIR)\mod_case_filter_in.exp" + -@erase "$(OUTDIR)\mod_case_filter_in.lib" + -@erase "$(OUTDIR)\mod_case_filter_in.pdb" + -@erase "$(OUTDIR)\mod_case_filter_in.so" + +"$(OUTDIR)" : + if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" + +CPP=cl.exe +CPP_PROJ=/nologo /MD /W3 /Zi /O2 /Oy- /I "../../include" /I "../../srclib/apr/include" /I "../../srclib/apr-util/include" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\mod_case_filter_in_src" /FD /c + +.c{$(INTDIR)}.obj:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cpp{$(INTDIR)}.obj:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cxx{$(INTDIR)}.obj:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.c{$(INTDIR)}.sbr:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cpp{$(INTDIR)}.sbr:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cxx{$(INTDIR)}.sbr:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +MTL=midl.exe +MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /o /win32 "NUL" +RSC=rc.exe +RSC_PROJ=/l 0x409 /fo"$(INTDIR)\mod_case_filter_in.res" /i "../../include" /i "../../srclib/apr/include" /d "NDEBUG" /d BIN_NAME="mod_case_filter_in.so" /d LONG_NAME="case_filter_in_module for Apache" +BSC32=bscmake.exe +BSC32_FLAGS=/nologo /o"$(OUTDIR)\mod_case_filter_in.bsc" +BSC32_SBRS= \ + +LINK32=link.exe +LINK32_FLAGS=kernel32.lib /nologo /subsystem:windows /dll /incremental:no /pdb:"$(OUTDIR)\mod_case_filter_in.pdb" /debug /out:"$(OUTDIR)\mod_case_filter_in.so" /implib:"$(OUTDIR)\mod_case_filter_in.lib" /base:@..\..\os\win32\BaseAddr.ref,mod_case_filter_in.so /opt:ref +LINK32_OBJS= \ + "$(INTDIR)\mod_case_filter_in.obj" \ + "$(INTDIR)\mod_case_filter_in.res" \ + "..\..\srclib\apr\Release\libapr-1.lib" \ + "..\..\srclib\apr-util\Release\libaprutil-1.lib" \ + "..\..\Release\libhttpd.lib" + +"$(OUTDIR)\mod_case_filter_in.so" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) + $(LINK32) @<< + $(LINK32_FLAGS) $(LINK32_OBJS) +<< + +TargetPath=.\Release\mod_case_filter_in.so +SOURCE="$(InputPath)" +PostBuild_Desc=Embed .manifest +DS_POSTBUILD_DEP=$(INTDIR)\postbld.dep + +# Begin Custom Macros +OutDir=.\Release +# End Custom Macros + +"$(DS_POSTBUILD_DEP)" : "$(OUTDIR)\mod_case_filter_in.so" + if exist .\Release\mod_case_filter_in.so.manifest mt.exe -manifest .\Release\mod_case_filter_in.so.manifest -outputresource:.\Release\mod_case_filter_in.so;2 + echo Helper for Post-build step > "$(DS_POSTBUILD_DEP)" + +!ELSEIF "$(CFG)" == "mod_case_filter_in - Win32 Debug" + +OUTDIR=.\Debug +INTDIR=.\Debug +DS_POSTBUILD_DEP=$(INTDIR)\postbld.dep +# Begin Custom Macros +OutDir=.\Debug +# End Custom Macros + +!IF "$(RECURSE)" == "0" + +ALL : "$(OUTDIR)\mod_case_filter_in.so" "$(DS_POSTBUILD_DEP)" + +!ELSE + +ALL : "libhttpd - Win32 Debug" "libaprutil - Win32 Debug" "libapr - Win32 Debug" "$(OUTDIR)\mod_case_filter_in.so" "$(DS_POSTBUILD_DEP)" + +!ENDIF + +!IF "$(RECURSE)" == "1" +CLEAN :"libapr - Win32 DebugCLEAN" "libaprutil - Win32 DebugCLEAN" "libhttpd - Win32 DebugCLEAN" +!ELSE +CLEAN : +!ENDIF + -@erase "$(INTDIR)\mod_case_filter_in.obj" + -@erase "$(INTDIR)\mod_case_filter_in.res" + -@erase "$(INTDIR)\mod_case_filter_in_src.idb" + -@erase "$(INTDIR)\mod_case_filter_in_src.pdb" + -@erase "$(OUTDIR)\mod_case_filter_in.exp" + -@erase "$(OUTDIR)\mod_case_filter_in.lib" + -@erase "$(OUTDIR)\mod_case_filter_in.pdb" + -@erase "$(OUTDIR)\mod_case_filter_in.so" + +"$(OUTDIR)" : + if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" + +CPP=cl.exe +CPP_PROJ=/nologo /MDd /W3 /Zi /Od /I "../../include" /I "../../srclib/apr/include" /I "../../srclib/apr-util/include" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\mod_case_filter_in_src" /FD /EHsc /c + +.c{$(INTDIR)}.obj:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cpp{$(INTDIR)}.obj:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cxx{$(INTDIR)}.obj:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.c{$(INTDIR)}.sbr:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cpp{$(INTDIR)}.sbr:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cxx{$(INTDIR)}.sbr:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +MTL=midl.exe +MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /o /win32 "NUL" +RSC=rc.exe +RSC_PROJ=/l 0x409 /fo"$(INTDIR)\mod_case_filter_in.res" /i "../../include" /i "../../srclib/apr/include" /d "_DEBUG" /d BIN_NAME="mod_case_filter_in.so" /d LONG_NAME="case_filter_in_module for Apache" +BSC32=bscmake.exe +BSC32_FLAGS=/nologo /o"$(OUTDIR)\mod_case_filter_in.bsc" +BSC32_SBRS= \ + +LINK32=link.exe +LINK32_FLAGS=kernel32.lib /nologo /subsystem:windows /dll /incremental:no /pdb:"$(OUTDIR)\mod_case_filter_in.pdb" /debug /out:"$(OUTDIR)\mod_case_filter_in.so" /implib:"$(OUTDIR)\mod_case_filter_in.lib" /base:@..\..\os\win32\BaseAddr.ref,mod_case_filter_in.so +LINK32_OBJS= \ + "$(INTDIR)\mod_case_filter_in.obj" \ + "$(INTDIR)\mod_case_filter_in.res" \ + "..\..\srclib\apr\Debug\libapr-1.lib" \ + "..\..\srclib\apr-util\Debug\libaprutil-1.lib" \ + "..\..\Debug\libhttpd.lib" + +"$(OUTDIR)\mod_case_filter_in.so" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) + $(LINK32) @<< + $(LINK32_FLAGS) $(LINK32_OBJS) +<< + +TargetPath=.\Debug\mod_case_filter_in.so +SOURCE="$(InputPath)" +PostBuild_Desc=Embed .manifest +DS_POSTBUILD_DEP=$(INTDIR)\postbld.dep + +# Begin Custom Macros +OutDir=.\Debug +# End Custom Macros + +"$(DS_POSTBUILD_DEP)" : "$(OUTDIR)\mod_case_filter_in.so" + if exist .\Debug\mod_case_filter_in.so.manifest mt.exe -manifest .\Debug\mod_case_filter_in.so.manifest -outputresource:.\Debug\mod_case_filter_in.so;2 + echo Helper for Post-build step > "$(DS_POSTBUILD_DEP)" + +!ENDIF + + +!IF "$(NO_EXTERNAL_DEPS)" != "1" +!IF EXISTS("mod_case_filter_in.dep") +!INCLUDE "mod_case_filter_in.dep" +!ELSE +!MESSAGE Warning: cannot find "mod_case_filter_in.dep" +!ENDIF +!ENDIF + + +!IF "$(CFG)" == "mod_case_filter_in - Win32 Release" || "$(CFG)" == "mod_case_filter_in - Win32 Debug" + +!IF "$(CFG)" == "mod_case_filter_in - Win32 Release" + +"libapr - Win32 Release" : + cd ".\..\..\srclib\apr" + $(MAKE) /$(MAKEFLAGS) /F ".\libapr.mak" CFG="libapr - Win32 Release" + cd "..\..\modules\examples" + +"libapr - Win32 ReleaseCLEAN" : + cd ".\..\..\srclib\apr" + $(MAKE) /$(MAKEFLAGS) /F ".\libapr.mak" CFG="libapr - Win32 Release" RECURSE=1 CLEAN + cd "..\..\modules\examples" + +!ELSEIF "$(CFG)" == "mod_case_filter_in - Win32 Debug" + +"libapr - Win32 Debug" : + cd ".\..\..\srclib\apr" + $(MAKE) /$(MAKEFLAGS) /F ".\libapr.mak" CFG="libapr - Win32 Debug" + cd "..\..\modules\examples" + +"libapr - Win32 DebugCLEAN" : + cd ".\..\..\srclib\apr" + $(MAKE) /$(MAKEFLAGS) /F ".\libapr.mak" CFG="libapr - Win32 Debug" RECURSE=1 CLEAN + cd "..\..\modules\examples" + +!ENDIF + +!IF "$(CFG)" == "mod_case_filter_in - Win32 Release" + +"libaprutil - Win32 Release" : + cd ".\..\..\srclib\apr-util" + $(MAKE) /$(MAKEFLAGS) /F ".\libaprutil.mak" CFG="libaprutil - Win32 Release" + cd "..\..\modules\examples" + +"libaprutil - Win32 ReleaseCLEAN" : + cd ".\..\..\srclib\apr-util" + $(MAKE) /$(MAKEFLAGS) /F ".\libaprutil.mak" CFG="libaprutil - Win32 Release" RECURSE=1 CLEAN + cd "..\..\modules\examples" + +!ELSEIF "$(CFG)" == "mod_case_filter_in - Win32 Debug" + +"libaprutil - Win32 Debug" : + cd ".\..\..\srclib\apr-util" + $(MAKE) /$(MAKEFLAGS) /F ".\libaprutil.mak" CFG="libaprutil - Win32 Debug" + cd "..\..\modules\examples" + +"libaprutil - Win32 DebugCLEAN" : + cd ".\..\..\srclib\apr-util" + $(MAKE) /$(MAKEFLAGS) /F ".\libaprutil.mak" CFG="libaprutil - Win32 Debug" RECURSE=1 CLEAN + cd "..\..\modules\examples" + +!ENDIF + +!IF "$(CFG)" == "mod_case_filter_in - Win32 Release" + +"libhttpd - Win32 Release" : + cd ".\..\.." + $(MAKE) /$(MAKEFLAGS) /F ".\libhttpd.mak" CFG="libhttpd - Win32 Release" + cd ".\modules\examples" + +"libhttpd - Win32 ReleaseCLEAN" : + cd ".\..\.." + $(MAKE) /$(MAKEFLAGS) /F ".\libhttpd.mak" CFG="libhttpd - Win32 Release" RECURSE=1 CLEAN + cd ".\modules\examples" + +!ELSEIF "$(CFG)" == "mod_case_filter_in - Win32 Debug" + +"libhttpd - Win32 Debug" : + cd ".\..\.." + $(MAKE) /$(MAKEFLAGS) /F ".\libhttpd.mak" CFG="libhttpd - Win32 Debug" + cd ".\modules\examples" + +"libhttpd - Win32 DebugCLEAN" : + cd ".\..\.." + $(MAKE) /$(MAKEFLAGS) /F ".\libhttpd.mak" CFG="libhttpd - Win32 Debug" RECURSE=1 CLEAN + cd ".\modules\examples" + +!ENDIF + +SOURCE=..\..\build\win32\httpd.rc + +!IF "$(CFG)" == "mod_case_filter_in - Win32 Release" + + +"$(INTDIR)\mod_case_filter_in.res" : $(SOURCE) "$(INTDIR)" + $(RSC) /l 0x409 /fo"$(INTDIR)\mod_case_filter_in.res" /i "../../include" /i "../../srclib/apr/include" /i "../../build\win32" /d "NDEBUG" /d BIN_NAME="mod_case_filter_in.so" /d LONG_NAME="case_filter_in_module for Apache" $(SOURCE) + + +!ELSEIF "$(CFG)" == "mod_case_filter_in - Win32 Debug" + + +"$(INTDIR)\mod_case_filter_in.res" : $(SOURCE) "$(INTDIR)" + $(RSC) /l 0x409 /fo"$(INTDIR)\mod_case_filter_in.res" /i "../../include" /i "../../srclib/apr/include" /i "../../build\win32" /d "_DEBUG" /d BIN_NAME="mod_case_filter_in.so" /d LONG_NAME="case_filter_in_module for Apache" $(SOURCE) + + +!ENDIF + +SOURCE=.\mod_case_filter_in.c + +"$(INTDIR)\mod_case_filter_in.obj" : $(SOURCE) "$(INTDIR)" + + + +!ENDIF + diff --git a/modules/examples/mod_example_hooks.c b/modules/examples/mod_example_hooks.c new file mode 100644 index 0000000..f7ef5a5 --- /dev/null +++ b/modules/examples/mod_example_hooks.c @@ -0,0 +1,1552 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Apache example_hooks module. Provide demonstrations of how modules do things. + * It is not meant to be used in a production server. Since it participates + * in all of the processing phases, it could conceivable interfere with + * the proper operation of other modules -- particularly the ones related + * to security. + * + * In the interest of brevity, all functions and structures internal to + * this module, but which may have counterparts in *real* modules, are + * prefixed with 'x_' instead of 'example_'. + * + * To use mod_example_hooks, configure the Apache build with + * --enable-example-hooks and compile. Set up a <Location> block in your + * configuration file like so: + * + * <Location /example> + * SetHandler example-hooks-handler + * </Location> + * + * When you look at that location on your server, you will see a backtrace of + * the callbacks that have been invoked up to that point. See the ErrorLog for + * more information on code paths that touch mod_example_hooks. + * + * IMPORTANT NOTES + * =============== + * + * Do NOT use this module on a production server. It attaches itself to every + * phase of the server runtime operations including startup, shutdown and + * request processing, and produces copious amounts of logging data. This will + * negatively affect server performance. + * + * Do NOT use mod_example_hooks as the basis for your own code. This module + * implements every callback hook offered by the Apache core, and your + * module will almost certainly not have to implement this much. If you + * want a simple module skeleton to start development, use apxs -g. + * + * XXX TO DO XXX + * ============= + * + * * Enable HTML backtrace entries for more callbacks that are not directly + * associated with a request + * * Make sure every callback that posts an HTML backtrace entry does so in the * right category, so nothing gets overwritten + * * Implement some logic to show what happens in the parent, and what in the + * child(ren) + */ + +#include "httpd.h" +#include "http_config.h" +#include "http_core.h" +#include "http_log.h" +#include "http_main.h" +#include "http_protocol.h" +#include "http_request.h" +#include "util_script.h" +#include "http_connection.h" +#ifdef HAVE_UNIX_SUEXEC +#include "unixd.h" +#endif +#include "scoreboard.h" +#include "mpm_common.h" + +#include "apr_strings.h" + +#include <stdio.h> + +/*--------------------------------------------------------------------------*/ +/* */ +/* Data declarations. */ +/* */ +/* Here are the static cells and structure declarations private to our */ +/* module. */ +/* */ +/*--------------------------------------------------------------------------*/ + +/* + * Sample configuration record. Used for both per-directory and per-server + * configuration data. + * + * It's perfectly reasonable to have two different structures for the two + * different environments. The same command handlers will be called for + * both, though, so the handlers need to be able to tell them apart. One + * possibility is for both structures to start with an int which is 0 for + * one and 1 for the other. + * + * Note that while the per-directory and per-server configuration records are + * available to most of the module handlers, they should be treated as + * READ-ONLY by all except the command and merge handlers. Sometimes handlers + * are handed a record that applies to the current location by implication or + * inheritance, and modifying it will change the rules for other locations. + */ +typedef struct x_cfg { + int cmode; /* Environment to which record applies + * (directory, server, or combination). + */ +#define CONFIG_MODE_SERVER 1 +#define CONFIG_MODE_DIRECTORY 2 +#define CONFIG_MODE_COMBO 3 /* Shouldn't ever happen. */ + int local; /* Boolean: "Example" directive declared + * here? + */ + int congenital; /* Boolean: did we inherit an "Example"? */ + char *trace; /* Pointer to trace string. */ + char *loc; /* Location to which this record applies. */ +} x_cfg; + +/* + * String pointer to hold the startup trace. No harm working with a global until + * the server is (may be) multi-threaded. + */ +static const char *trace = NULL; + +/* + * Declare ourselves so the configuration routines can find and know us. + * We'll fill it in at the end of the module. + */ +module AP_MODULE_DECLARE_DATA example_hooks_module; + +/*--------------------------------------------------------------------------*/ +/* */ +/* The following pseudo-prototype declarations illustrate the parameters */ +/* passed to command handlers for the different types of directive */ +/* syntax. If an argument was specified in the directive definition */ +/* (look for "command_rec" below), it's available to the command handler */ +/* via the (void *) info field in the cmd_parms argument passed to the */ +/* handler (cmd->info for the examples below). */ +/* */ +/*--------------------------------------------------------------------------*/ + +/* + * Command handler for a NO_ARGS directive. Declared in the command_rec + * list with + * AP_INIT_NO_ARGS("directive", function, mconfig, where, help) + * + * static const char *handle_NO_ARGS(cmd_parms *cmd, void *mconfig); + */ + +/* + * Command handler for a RAW_ARGS directive. The "args" argument is the text + * of the commandline following the directive itself. Declared in the + * command_rec list with + * AP_INIT_RAW_ARGS("directive", function, mconfig, where, help) + * + * static const char *handle_RAW_ARGS(cmd_parms *cmd, void *mconfig, + * const char *args); + */ + +/* + * Command handler for a FLAG directive. The single parameter is passed in + * "bool", which is either zero or not for Off or On respectively. + * Declared in the command_rec list with + * AP_INIT_FLAG("directive", function, mconfig, where, help) + * + * static const char *handle_FLAG(cmd_parms *cmd, void *mconfig, int bool); + */ + +/* + * Command handler for a TAKE1 directive. The single parameter is passed in + * "word1". Declared in the command_rec list with + * AP_INIT_TAKE1("directive", function, mconfig, where, help) + * + * static const char *handle_TAKE1(cmd_parms *cmd, void *mconfig, + * char *word1); + */ + +/* + * Command handler for a TAKE2 directive. TAKE2 commands must always have + * exactly two arguments. Declared in the command_rec list with + * AP_INIT_TAKE2("directive", function, mconfig, where, help) + * + * static const char *handle_TAKE2(cmd_parms *cmd, void *mconfig, + * char *word1, char *word2); + */ + +/* + * Command handler for a TAKE3 directive. Like TAKE2, these must have exactly + * three arguments, or the parser complains and doesn't bother calling us. + * Declared in the command_rec list with + * AP_INIT_TAKE3("directive", function, mconfig, where, help) + * + * static const char *handle_TAKE3(cmd_parms *cmd, void *mconfig, + * char *word1, char *word2, char *word3); + */ + +/* + * Command handler for a TAKE12 directive. These can take either one or two + * arguments. + * - word2 is a NULL pointer if no second argument was specified. + * Declared in the command_rec list with + * AP_INIT_TAKE12("directive", function, mconfig, where, help) + * + * static const char *handle_TAKE12(cmd_parms *cmd, void *mconfig, + * char *word1, char *word2); + */ + +/* + * Command handler for a TAKE123 directive. A TAKE123 directive can be given, + * as might be expected, one, two, or three arguments. + * - word2 is a NULL pointer if no second argument was specified. + * - word3 is a NULL pointer if no third argument was specified. + * Declared in the command_rec list with + * AP_INIT_TAKE123("directive", function, mconfig, where, help) + * + * static const char *handle_TAKE123(cmd_parms *cmd, void *mconfig, + * char *word1, char *word2, char *word3); + */ + +/* + * Command handler for a TAKE13 directive. Either one or three arguments are + * permitted - no two-parameters-only syntax is allowed. + * - word2 and word3 are NULL pointers if only one argument was specified. + * Declared in the command_rec list with + * AP_INIT_TAKE13("directive", function, mconfig, where, help) + * + * static const char *handle_TAKE13(cmd_parms *cmd, void *mconfig, + * char *word1, char *word2, char *word3); + */ + +/* + * Command handler for a TAKE23 directive. At least two and as many as three + * arguments must be specified. + * - word3 is a NULL pointer if no third argument was specified. + * Declared in the command_rec list with + * AP_INIT_TAKE23("directive", function, mconfig, where, help) + * + * static const char *handle_TAKE23(cmd_parms *cmd, void *mconfig, + * char *word1, char *word2, char *word3); + */ + +/* + * Command handler for a ITERATE directive. + * - Handler is called once for each of n arguments given to the directive. + * - word1 points to each argument in turn. + * Declared in the command_rec list with + * AP_INIT_ITERATE("directive", function, mconfig, where, help) + * + * static const char *handle_ITERATE(cmd_parms *cmd, void *mconfig, + * char *word1); + */ + +/* + * Command handler for a ITERATE2 directive. + * - Handler is called once for each of the second and subsequent arguments + * given to the directive. + * - word1 is the same for each call for a particular directive instance (the + * first argument). + * - word2 points to each of the second and subsequent arguments in turn. + * Declared in the command_rec list with + * AP_INIT_ITERATE2("directive", function, mconfig, where, help) + * + * static const char *handle_ITERATE2(cmd_parms *cmd, void *mconfig, + * char *word1, char *word2); + */ + +/*--------------------------------------------------------------------------*/ +/* */ +/* These routines are strictly internal to this module, and support its */ +/* operation. They are not referenced by any external portion of the */ +/* server. */ +/* */ +/*--------------------------------------------------------------------------*/ + +/* + * Locate our directory configuration record for the current request. + */ +static x_cfg *our_dconfig(const request_rec *r) +{ + return (x_cfg *) ap_get_module_config(r->per_dir_config, &example_hooks_module); +} + +/* + * The following utility routines are not used in the module. Don't + * compile them so -Wall doesn't complain about functions that are + * defined but not used. + */ +#if 0 +/* + * Locate our server configuration record for the specified server. + */ +static x_cfg *our_sconfig(const server_rec *s) +{ + return (x_cfg *) ap_get_module_config(s->module_config, &example_hooks_module); +} + +/* + * Likewise for our configuration record for the specified request. + */ +static x_cfg *our_rconfig(const request_rec *r) +{ + return (x_cfg *) ap_get_module_config(r->request_config, &example_hooks_module); +} +#endif /* if 0 */ + +/* + * Likewise for our configuration record for a connection. + */ +static x_cfg *our_cconfig(const conn_rec *c) +{ + return (x_cfg *) ap_get_module_config(c->conn_config, &example_hooks_module); +} + +/* + * You *could* change the following if you wanted to see the calling + * sequence reported in the server's error_log, but beware - almost all of + * these co-routines are called for every single request, and the impact + * on the size (and readability) of the error_log is considerable. + */ +#ifndef EXAMPLE_LOG_EACH +#define EXAMPLE_LOG_EACH 0 +#endif + +#if EXAMPLE_LOG_EACH +static void example_log_each(apr_pool_t *p, server_rec *s, const char *note) +{ + if (s != NULL) { + ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, APLOGNO(02991) + "mod_example_hooks: %s", note); + } + else { + apr_file_t *out = NULL; + apr_file_open_stderr(&out, p); + apr_file_printf(out, "mod_example_hooks traced in non-loggable " + "context: %s\n", note); + } +} +#endif + +/* + * This utility routine traces the hooks called when the server starts up. + * It leaves a trace in a global variable, so it should not be called from + * a hook handler that runs in a multi-threaded situation. + */ + +static void trace_startup(apr_pool_t *p, server_rec *s, x_cfg *mconfig, + const char *note) +{ + const char *sofar; + char *where, *addon; + +#if EXAMPLE_LOG_EACH + example_log_each(p, s, note); +#endif + + /* + * If we weren't passed a configuration record, we can't figure out to + * what location this call applies. This only happens for co-routines + * that don't operate in a particular directory or server context. If we + * got a valid record, extract the location (directory or server) to which + * it applies. + */ + where = (mconfig != NULL) ? mconfig->loc : "nowhere"; + where = (where != NULL) ? where : ""; + + addon = apr_pstrcat(p, + " <li>\n" + " <dl>\n" + " <dt><samp>", note, "</samp></dt>\n" + " <dd><samp>[", where, "]</samp></dd>\n" + " </dl>\n" + " </li>\n", + NULL); + + /* + * Make sure that we start with a valid string, even if we have never been + * called. + */ + sofar = (trace == NULL) ? "" : trace; + + trace = apr_pstrcat(p, sofar, addon, NULL); +} + + +/* + * This utility route traces the hooks called as a request is handled. + * It takes the current request as argument + */ +#define TRACE_NOTE "example-hooks-trace" + +static void trace_request(const request_rec *r, const char *note) +{ + const char *trace_copy, *sofar; + char *addon, *where; + x_cfg *cfg; + +#if EXAMPLE_LOG_EACH + example_log_each(r->pool, r->server, note); +#endif + + if ((sofar = apr_table_get(r->notes, TRACE_NOTE)) == NULL) { + sofar = ""; + } + + cfg = our_dconfig(r); + + where = (cfg != NULL) ? cfg->loc : "nowhere"; + where = (where != NULL) ? where : ""; + + addon = apr_pstrcat(r->pool, + " <li>\n" + " <dl>\n" + " <dt><samp>", note, "</samp></dt>\n" + " <dd><samp>[", where, "]</samp></dd>\n" + " </dl>\n" + " </li>\n", + NULL); + + trace_copy = apr_pstrcat(r->pool, sofar, addon, NULL); + apr_table_set(r->notes, TRACE_NOTE, trace_copy); +} + +/* + * This utility routine traces the hooks called while processing a + * Connection. Its trace is kept in the pool notes of the pool associated + * with the Connection. + */ + +/* + * Key to get and set the userdata. We should be able to get away + * with a constant key, since in prefork mode the process will have + * the connection and its pool to itself entirely, and in + * multi-threaded mode each connection will have its own pool. + */ +#define CONN_NOTE "example-hooks-connection" + +static void trace_connection(conn_rec *c, const char *note) +{ + const char *trace_copy, *sofar; + char *addon, *where; + void *data; + x_cfg *cfg; + +#if EXAMPLE_LOG_EACH + example_log_each(c->pool, c->base_server, note); +#endif + + cfg = our_cconfig(c); + + where = (cfg != NULL) ? cfg->loc : "nowhere"; + where = (where != NULL) ? where : ""; + + addon = apr_pstrcat(c->pool, + " <li>\n" + " <dl>\n" + " <dt><samp>", note, "</samp></dt>\n" + " <dd><samp>[", where, "]</samp></dd>\n" + " </dl>\n" + " </li>\n", + NULL); + + /* Find existing notes and copy */ + apr_pool_userdata_get(&data, CONN_NOTE, c->pool); + sofar = (data == NULL) ? "" : (const char *) data; + + /* Tack addon onto copy */ + trace_copy = apr_pstrcat(c->pool, sofar, addon, NULL); + + /* + * Stash copy back into pool notes. This call has a cleanup + * parameter, but we're not using it because the string has been + * allocated from that same pool. There is also an unused return + * value: we have nowhere to communicate any error that might + * occur, and will have to check for the existence of this data on + * the other end. + */ + apr_pool_userdata_set((const void *) trace_copy, CONN_NOTE, + NULL, c->pool); +} + +static void trace_nocontext(apr_pool_t *p, const char *file, int line, + const char *note) +{ + /* + * Since we have no request or connection to trace, or any idea + * from where this routine was called, there's really not much we + * can do. If we are not logging everything by way of the + * EXAMPLE_LOG_EACH constant, do nothing in this routine. + */ + +#ifdef EXAMPLE_LOG_EACH + ap_log_perror(file, line, APLOG_MODULE_INDEX, APLOG_NOTICE, 0, p, "%s", note); +#endif +} + + +/*--------------------------------------------------------------------------*/ +/* We prototyped the various syntax for command handlers (routines that */ +/* are called when the configuration parser detects a directive declared */ +/* by our module) earlier. Now we actually declare a "real" routine that */ +/* will be invoked by the parser when our "real" directive is */ +/* encountered. */ +/* */ +/* If a command handler encounters a problem processing the directive, it */ +/* signals this fact by returning a non-NULL pointer to a string */ +/* describing the problem. */ +/* */ +/* The magic return value DECLINE_CMD is used to deal with directives */ +/* that might be declared by multiple modules. If the command handler */ +/* returns NULL, the directive was processed; if it returns DECLINE_CMD, */ +/* the next module (if any) that declares the directive is given a chance */ +/* at it. If it returns any other value, it's treated as the text of an */ +/* error message. */ +/*--------------------------------------------------------------------------*/ +/* + * Command handler for the NO_ARGS "Example" directive. All we do is mark the + * call in the trace log, and flag the applicability of the directive to the + * current location in that location's configuration record. + */ +static const char *cmd_example(cmd_parms *cmd, void *mconfig) +{ + x_cfg *cfg = (x_cfg *) mconfig; + + /* + * "Example Wuz Here" + */ + cfg->local = 1; + trace_startup(cmd->pool, cmd->server, cfg, "cmd_example()"); + return NULL; +} + +/* + * This function gets called to create a per-directory configuration + * record. This will be called for the "default" server environment, and for + * each directory for which the parser finds any of our directives applicable. + * If a directory doesn't have any of our directives involved (i.e., they + * aren't in the .htaccess file, or a <Location>, <Directory>, or related + * block), this routine will *not* be called - the configuration for the + * closest ancestor is used. + * + * The return value is a pointer to the created module-specific + * structure. + */ +static void *x_create_dir_config(apr_pool_t *p, char *dirspec) +{ + x_cfg *cfg; + char *dname = dirspec; + char *note; + + /* + * Allocate the space for our record from the pool supplied. + */ + cfg = (x_cfg *) apr_pcalloc(p, sizeof(x_cfg)); + /* + * Now fill in the defaults. If there are any `parent' configuration + * records, they'll get merged as part of a separate callback. + */ + cfg->local = 0; + cfg->congenital = 0; + cfg->cmode = CONFIG_MODE_DIRECTORY; + /* + * Finally, add our trace to the callback list. + */ + dname = (dname != NULL) ? dname : ""; + cfg->loc = apr_pstrcat(p, "DIR(", dname, ")", NULL); + note = apr_psprintf(p, "x_create_dir_config(p == %pp, dirspec == %s)", + (void*) p, dirspec); + trace_startup(p, NULL, cfg, note); + return (void *) cfg; +} + +/* + * This function gets called to merge two per-directory configuration + * records. This is typically done to cope with things like .htaccess files + * or <Location> directives for directories that are beneath one for which a + * configuration record was already created. The routine has the + * responsibility of creating a new record and merging the contents of the + * other two into it appropriately. If the module doesn't declare a merge + * routine, the record for the closest ancestor location (that has one) is + * used exclusively. + * + * The routine MUST NOT modify any of its arguments! + * + * The return value is a pointer to the created module-specific structure + * containing the merged values. + */ +static void *x_merge_dir_config(apr_pool_t *p, void *parent_conf, + void *newloc_conf) +{ + + x_cfg *merged_config = (x_cfg *) apr_pcalloc(p, sizeof(x_cfg)); + x_cfg *pconf = (x_cfg *) parent_conf; + x_cfg *nconf = (x_cfg *) newloc_conf; + char *note; + + /* + * Some things get copied directly from the more-specific record, rather + * than getting merged. + */ + merged_config->local = nconf->local; + merged_config->loc = apr_pstrdup(p, nconf->loc); + /* + * Others, like the setting of the `congenital' flag, get ORed in. The + * setting of that particular flag, for instance, is TRUE if it was ever + * true anywhere in the upstream configuration. + */ + merged_config->congenital = (pconf->congenital | pconf->local); + /* + * If we're merging records for two different types of environment (server + * and directory), mark the new record appropriately. Otherwise, inherit + * the current value. + */ + merged_config->cmode = + (pconf->cmode == nconf->cmode) ? pconf->cmode : CONFIG_MODE_COMBO; + /* + * Now just record our being called in the trace list. Include the + * locations we were asked to merge. + */ + note = apr_psprintf(p, "x_merge_dir_config(p == %pp, parent_conf == " + "%pp, newloc_conf == %pp)", (void*) p, + (void*) parent_conf, (void*) newloc_conf); + trace_startup(p, NULL, merged_config, note); + return (void *) merged_config; +} + +/* + * This function gets called to create a per-server configuration + * record. It will always be called for the "default" server. + * + * The return value is a pointer to the created module-specific + * structure. + */ +static void *x_create_server_config(apr_pool_t *p, server_rec *s) +{ + + x_cfg *cfg; + char *sname = s->server_hostname; + + /* + * As with the x_create_dir_config() reoutine, we allocate and fill + * in an empty record. + */ + cfg = (x_cfg *) apr_pcalloc(p, sizeof(x_cfg)); + cfg->local = 0; + cfg->congenital = 0; + cfg->cmode = CONFIG_MODE_SERVER; + /* + * Note that we were called in the trace list. + */ + sname = (sname != NULL) ? sname : ""; + cfg->loc = apr_pstrcat(p, "SVR(", sname, ")", NULL); + trace_startup(p, s, cfg, "x_create_server_config()"); + return (void *) cfg; +} + +/* + * This function gets called to merge two per-server configuration + * records. This is typically done to cope with things like virtual hosts and + * the default server configuration The routine has the responsibility of + * creating a new record and merging the contents of the other two into it + * appropriately. If the module doesn't declare a merge routine, the more + * specific existing record is used exclusively. + * + * The routine MUST NOT modify any of its arguments! + * + * The return value is a pointer to the created module-specific structure + * containing the merged values. + */ +static void *x_merge_server_config(apr_pool_t *p, void *server1_conf, + void *server2_conf) +{ + + x_cfg *merged_config = (x_cfg *) apr_pcalloc(p, sizeof(x_cfg)); + x_cfg *s1conf = (x_cfg *) server1_conf; + x_cfg *s2conf = (x_cfg *) server2_conf; + char *note; + + /* + * Our inheritance rules are our own, and part of our module's semantics. + * Basically, just note whence we came. + */ + merged_config->cmode = + (s1conf->cmode == s2conf->cmode) ? s1conf->cmode : CONFIG_MODE_COMBO; + merged_config->local = s2conf->local; + merged_config->congenital = (s1conf->congenital | s1conf->local); + merged_config->loc = apr_pstrdup(p, s2conf->loc); + /* + * Trace our call, including what we were asked to merge. + */ + note = apr_pstrcat(p, "x_merge_server_config(\"", s1conf->loc, "\",\"", + s2conf->loc, "\")", NULL); + trace_startup(p, NULL, merged_config, note); + return (void *) merged_config; +} + + +/*--------------------------------------------------------------------------* + * * + * Now let's declare routines for each of the callback hooks in order. * + * (That's the order in which they're listed in the callback list, *not * + * the order in which the server calls them! See the command_rec * + * declaration near the bottom of this file.) Note that these may be * + * called for situations that don't relate primarily to our function - in * + * other words, the fixup handler shouldn't assume that the request has * + * to do with "example_hooks" stuff. * + * * + * With the exception of the content handler, all of our routines will be * + * called for each request, unless an earlier handler from another module * + * aborted the sequence. * + * * + * There are three types of hooks (see include/ap_config.h): * + * * + * VOID : No return code, run all handlers declared by any module * + * RUN_FIRST : Run all handlers until one returns something other * + * than DECLINED. Hook runner result is result of last callback * + * RUN_ALL : Run all handlers until one returns something other than OK * + * or DECLINED. The hook runner returns that other value. If * + * all hooks run, the hook runner returns OK. * + * * + * Handlers that are declared as "int" can return the following: * + * * + * OK Handler accepted the request and did its thing with it. * + * DECLINED Handler took no action. * + * HTTP_mumble Handler looked at request and found it wanting. * + * * + * See include/httpd.h for a list of HTTP_mumble status codes. Handlers * + * that are not declared as int return a valid pointer, or NULL if they * + * DECLINE to handle their phase for that specific request. Exceptions, if * + * any, are noted with each routine. * + *--------------------------------------------------------------------------*/ + +/* + * This routine is called before the server processes the configuration + * files. There is no return value. + */ +static int x_pre_config(apr_pool_t *pconf, apr_pool_t *plog, + apr_pool_t *ptemp) +{ + /* + * Log the call and exit. + */ + trace_startup(pconf, NULL, NULL, "x_pre_config()"); + return OK; +} + +/* + * This routine is called after the server processes the configuration + * files. At this point the module may review and adjust its configuration + * settings in relation to one another and report any problems. On restart, + * this routine will be called twice, once in the startup process (which + * exits shortly after this phase) and once in the running server process. + * + * The return value is OK, DECLINED, or HTTP_mumble. If we return OK, the + * server will still call any remaining modules with an handler for this + * phase. + */ +static int x_check_config(apr_pool_t *pconf, apr_pool_t *plog, + apr_pool_t *ptemp, server_rec *s) +{ + /* + * Log the call and exit. + */ + trace_startup(pconf, s, NULL, "x_check_config()"); + return OK; +} + +/* + * This routine is called when the -t command-line option is supplied. + * It executes only once, in the startup process, after the check_config + * phase and just before the process exits. At this point the module + * may output any information useful in configuration testing. + * + * This is a VOID hook: all defined handlers get called. + */ +static void x_test_config(apr_pool_t *pconf, server_rec *s) +{ + apr_file_t *out = NULL; + + apr_file_open_stderr(&out, pconf); + + apr_file_printf(out, "Example module configuration test routine\n"); + + trace_startup(pconf, s, NULL, "x_test_config()"); +} + +/* + * This routine is called to perform any module-specific log file + * openings. It is invoked just before the post_config phase + * + * The return value is OK, DECLINED, or HTTP_mumble. If we return OK, the + * server will still call any remaining modules with an handler for this + * phase. + */ +static int x_open_logs(apr_pool_t *pconf, apr_pool_t *plog, + apr_pool_t *ptemp, server_rec *s) +{ + /* + * Log the call and exit. + */ + trace_startup(pconf, s, NULL, "x_open_logs()"); + return OK; +} + +/* + * This routine is called after the server finishes the configuration + * process. At this point the module may review and adjust its configuration + * settings in relation to one another and report any problems. On restart, + * this routine will be called only once, in the running server process. + * + * The return value is OK, DECLINED, or HTTP_mumble. If we return OK, the + * server will still call any remaining modules with an handler for this + * phase. + */ +static int x_post_config(apr_pool_t *pconf, apr_pool_t *plog, + apr_pool_t *ptemp, server_rec *s) +{ + /* + * Log the call and exit. + */ + trace_startup(pconf, s, NULL, "x_post_config()"); + return OK; +} + +/* + * All our process-death routine does is add its trace to the log. + */ +static apr_status_t x_child_exit(void *data) +{ + char *note; + server_rec *s = data; + char *sname = s->server_hostname; + + /* + * The arbitrary text we add to our trace entry indicates for which server + * we're being called. + */ + sname = (sname != NULL) ? sname : ""; + note = apr_pstrcat(s->process->pool, "x_child_exit(", sname, ")", NULL); + trace_startup(s->process->pool, s, NULL, note); + return APR_SUCCESS; +} + +/* + * All our process initialiser does is add its trace to the log. + * + * This is a VOID hook: all defined handlers get called. + */ +static void x_child_init(apr_pool_t *p, server_rec *s) +{ + char *note; + char *sname = s->server_hostname; + + /* + * The arbitrary text we add to our trace entry indicates for which server + * we're being called. + */ + sname = (sname != NULL) ? sname : ""; + note = apr_pstrcat(p, "x_child_init(", sname, ")", NULL); + trace_startup(p, s, NULL, note); + + apr_pool_cleanup_register(p, s, x_child_exit, x_child_exit); +} + +/* + * The hook runner for ap_hook_http_scheme is aliased to ap_http_scheme(), + * a routine that the core and other modules call when they need to know + * the URL scheme for the request. For instance, mod_ssl returns "https" + * if the server_rec associated with the request has SSL enabled. + * + * This hook was named 'ap_hook_http_method' in httpd 2.0. + * + * This is a RUN_FIRST hook: the first handler to return a non NULL + * value aborts the handler chain. The http_core module inserts a + * fallback handler (with APR_HOOK_REALLY_LAST preference) that returns + * "http". + */ +static const char *x_http_scheme(const request_rec *r) +{ + /* + * Log the call and exit. + */ + trace_request(r, "x_http_scheme()"); + + /* We have no claims to make about the request scheme */ + return NULL; +} + +/* + * The runner for this hook is aliased to ap_default_port(), which the + * core and other modules call when they need to know the default port + * for a particular server. This is used for instance to omit the + * port number from a Redirect response Location header URL if the port + * number is equal to the default port for the service (like 80 for http). + * + * This is a RUN_FIRST hook: the first handler to return a non-zero + * value is the last one executed. The http_core module inserts a + * fallback handler (with APR_HOOK_REALLY_LAST order specifier) that + * returns 80. + */ +static apr_port_t x_default_port(const request_rec *r) +{ + /* + * Log the call and exit. + */ + trace_request(r, "x_default_port()"); + return 0; +} + +/* + * This routine is called just before the handler gets invoked. It allows + * a module to insert a previously defined filter into the filter chain. + * + * No filter has been defined by this module, so we just log the call + * and exit. + * + * This is a VOID hook: all defined handlers get called. + */ +static void x_insert_filter(request_rec *r) +{ + /* + * Log the call and exit. + */ + trace_request(r, "x_insert_filter()"); +} + +/* + * This routine is called to insert a previously defined error filter into + * the filter chain as the request is being processed. + * + * For the purpose of this example, we don't have a filter to insert, + * so just add to the trace and exit. + * + * This is a VOID hook: all defined handlers get called. + */ +static void x_insert_error_filter(request_rec *r) +{ + trace_request(r, "x_insert_error_filter()"); +} + +/*--------------------------------------------------------------------------*/ +/* */ +/* Now we declare our content handlers, which are invoked when the server */ +/* encounters a document which our module is supposed to have a chance to */ +/* see. (See mod_mime's SetHandler and AddHandler directives, and the */ +/* mod_info and mod_status examples, for more details.) */ +/* */ +/* Since content handlers are dumping data directly into the connection */ +/* (using the r*() routines, such as rputs() and rprintf()) without */ +/* intervention by other parts of the server, they need to make */ +/* sure any accumulated HTTP headers are sent first. This is done by */ +/* calling send_http_header(). Otherwise, no header will be sent at all, */ +/* and the output sent to the client will actually be HTTP-uncompliant. */ +/*--------------------------------------------------------------------------*/ +/* + * Sample content handler. All this does is display the call list that has + * been built up so far. + * + * This routine gets called for every request, unless another handler earlier + * in the callback chain has already handled the request. It is up to us to + * test the request_rec->handler field and see whether we are meant to handle + * this request. + * + * The content handler gets to write directly to the client using calls like + * ap_rputs() and ap_rprintf() + * + * This is a RUN_FIRST hook. + */ +static int x_handler(request_rec *r) +{ + x_cfg *dcfg; + char *note; + void *conn_data; + apr_status_t status; + + dcfg = our_dconfig(r); + /* + * Add our trace to the log, and whether we get to write + * content for this request. + */ + note = apr_pstrcat(r->pool, "x_handler(), handler is \"", + r->handler, "\"", NULL); + trace_request(r, note); + + /* If it's not for us, get out as soon as possible. */ + if (strcmp(r->handler, "example-hooks-handler")) { + return DECLINED; + } + + /* + * Set the Content-type header. Note that we do not actually have to send + * the headers: this is done by the http core. + */ + ap_set_content_type(r, "text/html"); + /* + * If we're only supposed to send header information (HEAD request), we're + * already there. + */ + if (r->header_only) { + return OK; + } + + /* + * Now send our actual output. Since we tagged this as being + * "text/html", we need to embed any HTML. + */ + ap_rputs(DOCTYPE_HTML_3_2, r); + ap_rputs("<HTML>\n", r); + ap_rputs(" <HEAD>\n", r); + ap_rputs(" <TITLE>mod_example_hooks Module Content-Handler Output\n", r); + ap_rputs(" </TITLE>\n", r); + ap_rputs(" </HEAD>\n", r); + ap_rputs(" <BODY>\n", r); + ap_rputs(" <H1><SAMP>mod_example_hooks</SAMP> Module Content-Handler Output\n", r); + ap_rputs(" </H1>\n", r); + ap_rputs(" <P>\n", r); + ap_rprintf(r, " Apache HTTP Server version: \"%s\"\n", + ap_get_server_banner()); + ap_rputs(" <BR>\n", r); + ap_rprintf(r, " Server built: \"%s\"\n", ap_get_server_built()); + ap_rputs(" </P>\n", r); + ap_rputs(" <P>\n", r); + ap_rputs(" The format for the callback trace is:\n", r); + ap_rputs(" </P>\n", r); + ap_rputs(" <DL>\n", r); + ap_rputs(" <DT><EM>n</EM>.<SAMP><routine-name>", r); + ap_rputs("(<routine-data>)</SAMP>\n", r); + ap_rputs(" </DT>\n", r); + ap_rputs(" <DD><SAMP>[<applies-to>]</SAMP>\n", r); + ap_rputs(" </DD>\n", r); + ap_rputs(" </DL>\n", r); + ap_rputs(" <P>\n", r); + ap_rputs(" The <SAMP><routine-data></SAMP> is supplied by\n", r); + ap_rputs(" the routine when it requests the trace,\n", r); + ap_rputs(" and the <SAMP><applies-to></SAMP> is extracted\n", r); + ap_rputs(" from the configuration record at the time of the trace.\n", r); + ap_rputs(" <STRONG>SVR()</STRONG> indicates a server environment\n", r); + ap_rputs(" (blank means the main or default server, otherwise it's\n", r); + ap_rputs(" the name of the VirtualHost); <STRONG>DIR()</STRONG>\n", r); + ap_rputs(" indicates a location in the URL or filesystem\n", r); + ap_rputs(" namespace.\n", r); + ap_rputs(" </P>\n", r); + ap_rprintf(r, " <H2>Startup callbacks so far:</H2>\n <OL>\n%s </OL>\n", + trace); + ap_rputs(" <H2>Connection-specific callbacks so far:</H2>\n", r); + + status = apr_pool_userdata_get(&conn_data, CONN_NOTE, + r->connection->pool); + if ((status == APR_SUCCESS) && conn_data) { + ap_rprintf(r, " <OL>\n%s </OL>\n", (char *) conn_data); + } + else { + ap_rputs(" <P>No connection-specific callback information was " + "retrieved.</P>\n", r); + } + + ap_rputs(" <H2>Request-specific callbacks so far:</H2>\n", r); + ap_rprintf(r, " <OL>\n%s </OL>\n", apr_table_get(r->notes, TRACE_NOTE)); + ap_rputs(" <H2>Environment for <EM>this</EM> call:</H2>\n", r); + ap_rputs(" <UL>\n", r); + ap_rprintf(r, " <LI>Applies-to: <SAMP>%s</SAMP>\n </LI>\n", dcfg->loc); + ap_rprintf(r, " <LI>\"Example\" directive declared here: %s\n </LI>\n", + (dcfg->local ? "YES" : "NO")); + ap_rprintf(r, " <LI>\"Example\" inherited: %s\n </LI>\n", + (dcfg->congenital ? "YES" : "NO")); + ap_rputs(" </UL>\n", r); + ap_rputs(" </BODY>\n", r); + ap_rputs("</HTML>\n", r); + /* + * We're all done, so cancel the timeout we set. Since this is probably + * the end of the request we *could* assume this would be done during + * post-processing - but it's possible that another handler might be + * called and inherit our outstanding timer. Not good; to each its own. + */ + /* + * We did what we wanted to do, so tell the rest of the server we + * succeeded. + */ + return OK; +} + +/* + * The quick_handler hook presents modules with a very powerful opportunity to + * serve their content in a very early request phase. Note that this handler + * can not serve any requests from the file system because hooks like + * map_to_storage have not run. The quick_handler hook also runs before any + * authentication and access control. + * + * This hook is used by mod_cache to serve cached content. + * + * This is a RUN_FIRST hook. Return OK if you have served the request, + * DECLINED if you want processing to continue, or a HTTP_* error code to stop + * processing the request. + */ +static int x_quick_handler(request_rec *r, int lookup_uri) +{ + /* + * Log the call and exit. + */ + trace_request(r, "x_quick_handler()"); + return DECLINED; +} + +/* + * This routine is called just after the server accepts the connection, + * but before it is handed off to a protocol module to be served. The point + * of this hook is to allow modules an opportunity to modify the connection + * as soon as possible. The core server uses this phase to setup the + * connection record based on the type of connection that is being used. + * + * This is a RUN_ALL hook. + */ +static int x_pre_connection(conn_rec *c, void *csd) +{ + char *note; + + /* + * Log the call and exit. + */ + note = apr_psprintf(c->pool, "x_pre_connection(c = %pp, p = %pp)", + (void*) c, (void*) c->pool); + trace_connection(c, note); + + return OK; +} + +/* This routine is used to actually process the connection that was received. + * Only protocol modules should implement this hook, as it gives them an + * opportunity to replace the standard HTTP processing with processing for + * some other protocol. Both echo and POP3 modules are available as + * examples. + * + * This is a RUN_FIRST hook. + */ +static int x_process_connection(conn_rec *c) +{ + trace_connection(c, "x_process_connection()"); + return DECLINED; +} + +/* + * This routine is called after the request has been read but before any other + * phases have been processed. This allows us to make decisions based upon + * the input header fields. + * + * This is a HOOK_VOID hook. + */ +static void x_pre_read_request(request_rec *r, conn_rec *c) +{ + /* + * We don't actually *do* anything here, except note the fact that we were + * called. + */ + trace_request(r, "x_pre_read_request()"); +} + +/* + * This routine is called after the request has been read but before any other + * phases have been processed. This allows us to make decisions based upon + * the input header fields. + * + * This is a RUN_ALL hook. + */ +static int x_post_read_request(request_rec *r) +{ + /* + * We don't actually *do* anything here, except note the fact that we were + * called. + */ + trace_request(r, "x_post_read_request()"); + return DECLINED; +} + +/* + * This routine gives our module an opportunity to translate the URI into an + * actual filename, before URL decoding happens. + * + * This is a RUN_FIRST hook. + */ +static int x_pre_translate_name(request_rec *r) +{ + /* + * We don't actually *do* anything here, except note the fact that we were + * called. + */ + trace_request(r, "x_pre_translate_name()"); + return DECLINED; +} + +/* + * This routine gives our module an opportunity to translate the URI into an + * actual filename. If we don't do anything special, the server's default + * rules (Alias directives and the like) will continue to be followed. + * + * This is a RUN_FIRST hook. + */ +static int x_translate_name(request_rec *r) +{ + /* + * We don't actually *do* anything here, except note the fact that we were + * called. + */ + trace_request(r, "x_translate_name()"); + return DECLINED; +} + +/* + * This routine maps r->filename to a physical file on disk. Useful for + * overriding default core behavior, including skipping mapping for + * requests that are not file based. + * + * This is a RUN_FIRST hook. + */ +static int x_map_to_storage(request_rec *r) +{ + /* + * We don't actually *do* anything here, except note the fact that we were + * called. + */ + trace_request(r, "x_map_to_storage()"); + return DECLINED; +} + +/* + * this routine gives our module another chance to examine the request + * headers and to take special action. This is the first phase whose + * hooks' configuration directives can appear inside the <Directory> + * and similar sections, because at this stage the URI has been mapped + * to the filename. For example this phase can be used to block evil + * clients, while little resources were wasted on these. + * + * This is a RUN_ALL hook. + */ +static int x_header_parser(request_rec *r) +{ + /* + * We don't actually *do* anything here, except note the fact that we were + * called. + */ + trace_request(r, "x_header_parser()"); + return DECLINED; +} + + +/* + * This routine is called to check for any module-specific restrictions placed + * upon the requested resource. (See the mod_access_compat module for an + * example.) + * + * This is a RUN_ALL hook. The first handler to return a status other than OK + * or DECLINED (for instance, HTTP_FORBIDDEN) aborts the callback chain. + */ +static int x_check_access(request_rec *r) +{ + trace_request(r, "x_check_access()"); + return DECLINED; +} + +/* + * This routine is called to check the authentication information sent with + * the request (such as looking up the user in a database and verifying that + * the [encrypted] password sent matches the one in the database). + * + * This is a RUN_FIRST hook. The return value is OK, DECLINED, or some + * HTTP_mumble error (typically HTTP_UNAUTHORIZED). + */ +static int x_check_authn(request_rec *r) +{ + /* + * Don't do anything except log the call. + */ + trace_request(r, "x_check_authn()"); + return DECLINED; +} + +/* + * This routine is called to check to see if the resource being requested + * requires authorisation. + * + * This is a RUN_FIRST hook. The return value is OK, DECLINED, or + * HTTP_mumble. If we return OK, no other modules are called during this + * phase. + * + * If *all* modules return DECLINED, the request is aborted with a server + * error. + */ +static int x_check_authz(request_rec *r) +{ + /* + * Log the call and return OK, or access will be denied (even though we + * didn't actually do anything). + */ + trace_request(r, "x_check_authz()"); + return DECLINED; +} + +/* + * This routine is called to determine and/or set the various document type + * information bits, like Content-type (via r->content_type), language, et + * cetera. + * + * This is a RUN_FIRST hook. + */ +static int x_type_checker(request_rec *r) +{ + /* + * Log the call, but don't do anything else - and report truthfully that + * we didn't do anything. + */ + trace_request(r, "x_type_checker()"); + return DECLINED; +} + +/* + * This routine is called to perform any module-specific fixing of header + * fields, et cetera. It is invoked just before any content-handler. + * + * This is a RUN_ALL HOOK. + */ +static int x_fixups(request_rec *r) +{ + /* + * Log the call and exit. + */ + trace_request(r, "x_fixups()"); + return DECLINED; +} + +/* + * This routine is called to perform any module-specific logging activities + * over and above the normal server things. + * + * This is a RUN_ALL hook. + */ +static int x_log_transaction(request_rec *r) +{ + trace_request(r, "x_log_transaction()"); + return DECLINED; +} + +#ifdef HAVE_UNIX_SUEXEC + +/* + * This routine is called to find out under which user id to run suexec + * Unless our module runs CGI programs, there is no reason for us to + * mess with this information. + * + * This is a RUN_FIRST hook. The return value is a pointer to an + * ap_unix_identity_t or NULL. + */ +static ap_unix_identity_t *x_get_suexec_identity(const request_rec *r) +{ + trace_request(r, "x_get_suexec_identity()"); + return NULL; +} +#endif + +/* + * This routine is called to create a connection. This hook is implemented + * by the Apache core: there is no known reason a module should override + * it. + * + * This is a RUN_FIRST hook. + * + * Return NULL to decline, a valid conn_rec pointer to accept. + */ +static conn_rec *x_create_connection(apr_pool_t *p, server_rec *server, + apr_socket_t *csd, long conn_id, + void *sbh, apr_bucket_alloc_t *alloc) +{ + trace_nocontext(p, __FILE__, __LINE__, "x_create_connection()"); + return NULL; +} + +/* + * This hook is defined in server/core.c, but it is not actually called + * or documented. + * + * This is a RUN_ALL hook. + */ +static int x_get_mgmt_items(apr_pool_t *p, const char *val, apr_hash_t *ht) +{ + /* We have nothing to do here but trace the call, and no context + * in which to trace it. + */ + trace_nocontext(p, __FILE__, __LINE__, "x_check_config()"); + return DECLINED; +} + +/* + * This routine gets called shortly after the request_rec structure + * is created. It provides the opportunity to manipulae the request + * at a very early stage. + * + * This is a RUN_ALL hook. + */ +static int x_create_request(request_rec *r) +{ + /* + * We have a request_rec, but it is not filled in enough to give + * us a usable configuration. So, add a trace without context. + */ + trace_nocontext( r->pool, __FILE__, __LINE__, "x_create_request()"); + return DECLINED; +} + +/* + * This routine gets called during the startup of the MPM. + * No known existing module implements this hook. + * + * This is a RUN_ALL hook. + */ +static int x_pre_mpm(apr_pool_t *p, ap_scoreboard_e sb_type) +{ + trace_nocontext(p, __FILE__, __LINE__, "x_pre_mpm()"); + return DECLINED; +} + +/* + * This hook gets run periodically by a maintenance function inside + * the MPM. Its exact purpose is unknown and undocumented at this time. + * + * This is a RUN_ALL hook. + */ +static int x_monitor(apr_pool_t *p, server_rec *s) +{ + trace_nocontext(p, __FILE__, __LINE__, "x_monitor()"); + return DECLINED; +} + +/*--------------------------------------------------------------------------*/ +/* */ +/* Which functions are responsible for which hooks in the server. */ +/* */ +/*--------------------------------------------------------------------------*/ +/* + * Each function our module provides to handle a particular hook is + * specified here. The functions are registered using + * ap_hook_foo(name, predecessors, successors, position) + * where foo is the name of the hook. + * + * The args are as follows: + * name -> the name of the function to call. + * predecessors -> a list of modules whose calls to this hook must be + * invoked before this module. + * successors -> a list of modules whose calls to this hook must be + * invoked after this module. + * position -> The relative position of this module. One of + * APR_HOOK_FIRST, APR_HOOK_MIDDLE, or APR_HOOK_LAST. + * Most modules will use APR_HOOK_MIDDLE. If multiple + * modules use the same relative position, Apache will + * determine which to call first. + * If your module relies on another module to run first, + * or another module running after yours, use the + * predecessors and/or successors. + * + * The number in brackets indicates the order in which the routine is called + * during request processing. Note that not all routines are necessarily + * called (such as if a resource doesn't have access restrictions). + * The actual delivery of content to the browser [9] is not handled by + * a hook; see the handler declarations below. + */ +static void x_register_hooks(apr_pool_t *p) +{ + trace = NULL; + ap_hook_pre_config(x_pre_config, NULL, NULL, APR_HOOK_MIDDLE); + ap_hook_check_config(x_check_config, NULL, NULL, APR_HOOK_MIDDLE); + ap_hook_test_config(x_test_config, NULL, NULL, APR_HOOK_MIDDLE); + ap_hook_open_logs(x_open_logs, NULL, NULL, APR_HOOK_MIDDLE); + ap_hook_post_config(x_post_config, NULL, NULL, APR_HOOK_MIDDLE); + ap_hook_child_init(x_child_init, NULL, NULL, APR_HOOK_MIDDLE); + ap_hook_handler(x_handler, NULL, NULL, APR_HOOK_MIDDLE); + ap_hook_quick_handler(x_quick_handler, NULL, NULL, APR_HOOK_MIDDLE); + ap_hook_pre_connection(x_pre_connection, NULL, NULL, APR_HOOK_MIDDLE); + ap_hook_process_connection(x_process_connection, NULL, NULL, APR_HOOK_MIDDLE); + ap_hook_pre_read_request(x_pre_read_request, NULL, NULL, + APR_HOOK_MIDDLE); + /* [1] post read_request handling */ + ap_hook_post_read_request(x_post_read_request, NULL, NULL, + APR_HOOK_MIDDLE); + ap_hook_log_transaction(x_log_transaction, NULL, NULL, APR_HOOK_MIDDLE); + ap_hook_http_scheme(x_http_scheme, NULL, NULL, APR_HOOK_MIDDLE); + ap_hook_default_port(x_default_port, NULL, NULL, APR_HOOK_MIDDLE); + ap_hook_pre_translate_name(x_pre_translate_name, NULL, NULL, APR_HOOK_MIDDLE); + ap_hook_translate_name(x_translate_name, NULL, NULL, APR_HOOK_MIDDLE); + ap_hook_map_to_storage(x_map_to_storage, NULL,NULL, APR_HOOK_MIDDLE); + ap_hook_header_parser(x_header_parser, NULL, NULL, APR_HOOK_MIDDLE); + ap_hook_fixups(x_fixups, NULL, NULL, APR_HOOK_MIDDLE); + ap_hook_type_checker(x_type_checker, NULL, NULL, APR_HOOK_MIDDLE); + ap_hook_check_access(x_check_access, NULL, NULL, APR_HOOK_MIDDLE, + AP_AUTH_INTERNAL_PER_CONF); + ap_hook_check_authn(x_check_authn, NULL, NULL, APR_HOOK_MIDDLE, + AP_AUTH_INTERNAL_PER_CONF); + ap_hook_check_authz(x_check_authz, NULL, NULL, APR_HOOK_MIDDLE, + AP_AUTH_INTERNAL_PER_CONF); + ap_hook_insert_filter(x_insert_filter, NULL, NULL, APR_HOOK_MIDDLE); + ap_hook_insert_error_filter(x_insert_error_filter, NULL, NULL, APR_HOOK_MIDDLE); +#ifdef HAVE_UNIX_SUEXEC + ap_hook_get_suexec_identity(x_get_suexec_identity, NULL, NULL, APR_HOOK_MIDDLE); +#endif + ap_hook_create_connection(x_create_connection, NULL, NULL, APR_HOOK_MIDDLE); + ap_hook_get_mgmt_items(x_get_mgmt_items, NULL, NULL, APR_HOOK_MIDDLE); + ap_hook_create_request(x_create_request, NULL, NULL, APR_HOOK_MIDDLE); + ap_hook_pre_mpm(x_pre_mpm, NULL, NULL, APR_HOOK_MIDDLE); + ap_hook_monitor(x_monitor, NULL, NULL, APR_HOOK_MIDDLE); +} + +/*--------------------------------------------------------------------------*/ +/* */ +/* All of the routines have been declared now. Here's the list of */ +/* directives specific to our module, and information about where they */ +/* may appear and how the command parser should pass them to us for */ +/* processing. Note that care must be taken to ensure that there are NO */ +/* collisions of directive names between modules. */ +/* */ +/*--------------------------------------------------------------------------*/ +/* + * List of directives specific to our module. + */ +static const command_rec x_cmds[] = +{ + AP_INIT_NO_ARGS( + "Example", /* directive name */ + cmd_example, /* config action routine */ + NULL, /* argument to include in call */ + OR_OPTIONS, /* where available */ + "Example directive - no arguments" /* directive description */ + ), + {NULL} +}; +/*--------------------------------------------------------------------------*/ +/* */ +/* Finally, the list of callback routines and data structures that provide */ +/* the static hooks into our module from the other parts of the server. */ +/* */ +/*--------------------------------------------------------------------------*/ +/* + * Module definition for configuration. If a particular callback is not + * needed, replace its routine name below with the word NULL. + */ +AP_DECLARE_MODULE(example_hooks) = +{ + STANDARD20_MODULE_STUFF, + x_create_dir_config, /* per-directory config creator */ + x_merge_dir_config, /* dir config merger */ + x_create_server_config, /* server config creator */ + x_merge_server_config, /* server config merger */ + x_cmds, /* command table */ + x_register_hooks, /* set up other request processing hooks */ +}; diff --git a/modules/examples/mod_example_hooks.dep b/modules/examples/mod_example_hooks.dep new file mode 100644 index 0000000..a186c4b --- /dev/null +++ b/modules/examples/mod_example_hooks.dep @@ -0,0 +1,62 @@ +# Microsoft Developer Studio Generated Dependency File, included by mod_example_hooks.mak + +..\..\build\win32\httpd.rc : \ + "..\..\include\ap_release.h"\ + + +.\mod_example_hooks.c : \ + "..\..\include\ap_config.h"\ + "..\..\include\ap_config_layout.h"\ + "..\..\include\ap_expr.h"\ + "..\..\include\ap_hooks.h"\ + "..\..\include\ap_mmn.h"\ + "..\..\include\ap_mpm.h"\ + "..\..\include\ap_regex.h"\ + "..\..\include\ap_release.h"\ + "..\..\include\apache_noprobes.h"\ + "..\..\include\http_config.h"\ + "..\..\include\http_connection.h"\ + "..\..\include\http_core.h"\ + "..\..\include\http_log.h"\ + "..\..\include\http_main.h"\ + "..\..\include\http_protocol.h"\ + "..\..\include\http_request.h"\ + "..\..\include\httpd.h"\ + "..\..\include\mpm_common.h"\ + "..\..\include\os.h"\ + "..\..\include\scoreboard.h"\ + "..\..\include\util_cfgtree.h"\ + "..\..\include\util_filter.h"\ + "..\..\include\util_script.h"\ + "..\..\srclib\apr-util\include\apr_buckets.h"\ + "..\..\srclib\apr-util\include\apr_hooks.h"\ + "..\..\srclib\apr-util\include\apr_optional.h"\ + "..\..\srclib\apr-util\include\apr_optional_hooks.h"\ + "..\..\srclib\apr-util\include\apr_uri.h"\ + "..\..\srclib\apr-util\include\apu.h"\ + "..\..\srclib\apr\include\apr.h"\ + "..\..\srclib\apr\include\apr_allocator.h"\ + "..\..\srclib\apr\include\apr_dso.h"\ + "..\..\srclib\apr\include\apr_errno.h"\ + "..\..\srclib\apr\include\apr_file_info.h"\ + "..\..\srclib\apr\include\apr_file_io.h"\ + "..\..\srclib\apr\include\apr_general.h"\ + "..\..\srclib\apr\include\apr_global_mutex.h"\ + "..\..\srclib\apr\include\apr_hash.h"\ + "..\..\srclib\apr\include\apr_inherit.h"\ + "..\..\srclib\apr\include\apr_mmap.h"\ + "..\..\srclib\apr\include\apr_network_io.h"\ + "..\..\srclib\apr\include\apr_poll.h"\ + "..\..\srclib\apr\include\apr_pools.h"\ + "..\..\srclib\apr\include\apr_portable.h"\ + "..\..\srclib\apr\include\apr_proc_mutex.h"\ + "..\..\srclib\apr\include\apr_ring.h"\ + "..\..\srclib\apr\include\apr_shm.h"\ + "..\..\srclib\apr\include\apr_strings.h"\ + "..\..\srclib\apr\include\apr_tables.h"\ + "..\..\srclib\apr\include\apr_thread_mutex.h"\ + "..\..\srclib\apr\include\apr_thread_proc.h"\ + "..\..\srclib\apr\include\apr_time.h"\ + "..\..\srclib\apr\include\apr_user.h"\ + "..\..\srclib\apr\include\apr_want.h"\ + diff --git a/modules/examples/mod_example_hooks.dsp b/modules/examples/mod_example_hooks.dsp new file mode 100644 index 0000000..abf2fc4 --- /dev/null +++ b/modules/examples/mod_example_hooks.dsp @@ -0,0 +1,111 @@ +# Microsoft Developer Studio Project File - Name="mod_example_hooks" - 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_example_hooks - 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_example_hooks.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_example_hooks.mak" CFG="mod_example_hooks - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "mod_example_hooks - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "mod_example_hooks - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe + +!IF "$(CFG)" == "mod_example_hooks - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /c +# ADD CPP /nologo /MD /W3 /O2 /Oy- /Zi /I "../../include" /I "../../srclib/apr/include" /I "../../srclib/apr-util/include" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /Fd"Release\mod_example_hooks_src" /FD /c +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o /win32 "NUL" +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o /win32 "NUL" +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /fo"Release/mod_example_hooks.res" /i "../../include" /i "../../srclib/apr/include" /d "NDEBUG" /d BIN_NAME="mod_example_hooks.so" /d LONG_NAME="example_hooks_module for Apache" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib /nologo /subsystem:windows /dll /out:".\Release\mod_example_hooks.so" /base:@..\..\os\win32\BaseAddr.ref,mod_example_hooks.so +# ADD LINK32 kernel32.lib /nologo /subsystem:windows /dll /incremental:no /debug /out:".\Release\mod_example_hooks.so" /base:@..\..\os\win32\BaseAddr.ref,mod_example_hooks.so /opt:ref +# Begin Special Build Tool +TargetPath=.\Release\mod_example_hooks.so +SOURCE="$(InputPath)" +PostBuild_Desc=Embed .manifest +PostBuild_Cmds=if exist $(TargetPath).manifest mt.exe -manifest $(TargetPath).manifest -outputresource:$(TargetPath);2 +# End Special Build Tool + +!ELSEIF "$(CFG)" == "mod_example_hooks - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MDd /W3 /EHsc /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FD /c +# ADD CPP /nologo /MDd /W3 /EHsc /Zi /Od /I "../../include" /I "../../srclib/apr/include" /I "../../srclib/apr-util/include" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /Fd"Debug\mod_example_hooks_src" /FD /c +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o /win32 "NUL" +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o /win32 "NUL" +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /fo"Debug/mod_example_hooks.res" /i "../../include" /i "../../srclib/apr/include" /d "_DEBUG" /d BIN_NAME="mod_example_hooks.so" /d LONG_NAME="example_hooks_module for Apache" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib /nologo /subsystem:windows /dll /incremental:no /debug /out:".\Debug\mod_example_hooks.so" /base:@..\..\os\win32\BaseAddr.ref,mod_example_hooks.so +# ADD LINK32 kernel32.lib /nologo /subsystem:windows /dll /incremental:no /debug /out:".\Debug\mod_example_hooks.so" /base:@..\..\os\win32\BaseAddr.ref,mod_example_hooks.so +# Begin Special Build Tool +TargetPath=.\Debug\mod_example_hooks.so +SOURCE="$(InputPath)" +PostBuild_Desc=Embed .manifest +PostBuild_Cmds=if exist $(TargetPath).manifest mt.exe -manifest $(TargetPath).manifest -outputresource:$(TargetPath);2 +# End Special Build Tool + +!ENDIF + +# Begin Target + +# Name "mod_example_hooks - Win32 Release" +# Name "mod_example_hooks - Win32 Debug" +# Begin Source File + +SOURCE=.\mod_example_hooks.c +# End Source File +# Begin Source File + +SOURCE=..\..\build\win32\httpd.rc +# End Source File +# End Target +# End Project diff --git a/modules/examples/mod_example_hooks.mak b/modules/examples/mod_example_hooks.mak new file mode 100644 index 0000000..2c1e562 --- /dev/null +++ b/modules/examples/mod_example_hooks.mak @@ -0,0 +1,353 @@ +# Microsoft Developer Studio Generated NMAKE File, Based on mod_example_hooks.dsp +!IF "$(CFG)" == "" +CFG=mod_example_hooks - Win32 Debug +!MESSAGE No configuration specified. Defaulting to mod_example_hooks - Win32 Debug. +!ENDIF + +!IF "$(CFG)" != "mod_example_hooks - Win32 Release" && "$(CFG)" != "mod_example_hooks - Win32 Debug" +!MESSAGE Invalid configuration "$(CFG)" specified. +!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_example_hooks.mak" CFG="mod_example_hooks - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "mod_example_hooks - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "mod_example_hooks - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE +!ERROR An invalid configuration is specified. +!ENDIF + +!IF "$(OS)" == "Windows_NT" +NULL= +!ELSE +NULL=nul +!ENDIF + +!IF "$(CFG)" == "mod_example_hooks - Win32 Release" + +OUTDIR=.\Release +INTDIR=.\Release +DS_POSTBUILD_DEP=$(INTDIR)\postbld.dep +# Begin Custom Macros +OutDir=.\Release +# End Custom Macros + +!IF "$(RECURSE)" == "0" + +ALL : "$(OUTDIR)\mod_example_hooks.so" "$(DS_POSTBUILD_DEP)" + +!ELSE + +ALL : "libhttpd - Win32 Release" "libaprutil - Win32 Release" "libapr - Win32 Release" "$(OUTDIR)\mod_example_hooks.so" "$(DS_POSTBUILD_DEP)" + +!ENDIF + +!IF "$(RECURSE)" == "1" +CLEAN :"libapr - Win32 ReleaseCLEAN" "libaprutil - Win32 ReleaseCLEAN" "libhttpd - Win32 ReleaseCLEAN" +!ELSE +CLEAN : +!ENDIF + -@erase "$(INTDIR)\mod_example_hooks.obj" + -@erase "$(INTDIR)\mod_example_hooks.res" + -@erase "$(INTDIR)\mod_example_hooks_src.idb" + -@erase "$(INTDIR)\mod_example_hooks_src.pdb" + -@erase "$(OUTDIR)\mod_example_hooks.exp" + -@erase "$(OUTDIR)\mod_example_hooks.lib" + -@erase "$(OUTDIR)\mod_example_hooks.pdb" + -@erase "$(OUTDIR)\mod_example_hooks.so" + +"$(OUTDIR)" : + if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" + +CPP=cl.exe +CPP_PROJ=/nologo /MD /W3 /Zi /O2 /Oy- /I "../../include" /I "../../srclib/apr/include" /I "../../srclib/apr-util/include" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\mod_example_hooks_src" /FD /c + +.c{$(INTDIR)}.obj:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cpp{$(INTDIR)}.obj:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cxx{$(INTDIR)}.obj:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.c{$(INTDIR)}.sbr:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cpp{$(INTDIR)}.sbr:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cxx{$(INTDIR)}.sbr:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +MTL=midl.exe +MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /o /win32 "NUL" +RSC=rc.exe +RSC_PROJ=/l 0x409 /fo"$(INTDIR)\mod_example_hooks.res" /i "../../include" /i "../../srclib/apr/include" /d "NDEBUG" /d BIN_NAME="mod_example_hooks.so" /d LONG_NAME="example_hooks_module for Apache" +BSC32=bscmake.exe +BSC32_FLAGS=/nologo /o"$(OUTDIR)\mod_example_hooks.bsc" +BSC32_SBRS= \ + +LINK32=link.exe +LINK32_FLAGS=kernel32.lib /nologo /subsystem:windows /dll /incremental:no /pdb:"$(OUTDIR)\mod_example_hooks.pdb" /debug /out:"$(OUTDIR)\mod_example_hooks.so" /implib:"$(OUTDIR)\mod_example_hooks.lib" /base:@..\..\os\win32\BaseAddr.ref,mod_example_hooks.so /opt:ref +LINK32_OBJS= \ + "$(INTDIR)\mod_example_hooks.obj" \ + "$(INTDIR)\mod_example_hooks.res" \ + "..\..\srclib\apr\Release\libapr-1.lib" \ + "..\..\srclib\apr-util\Release\libaprutil-1.lib" \ + "..\..\Release\libhttpd.lib" + +"$(OUTDIR)\mod_example_hooks.so" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) + $(LINK32) @<< + $(LINK32_FLAGS) $(LINK32_OBJS) +<< + +TargetPath=.\Release\mod_example_hooks.so +SOURCE="$(InputPath)" +PostBuild_Desc=Embed .manifest +DS_POSTBUILD_DEP=$(INTDIR)\postbld.dep + +# Begin Custom Macros +OutDir=.\Release +# End Custom Macros + +"$(DS_POSTBUILD_DEP)" : "$(OUTDIR)\mod_example_hooks.so" + if exist .\Release\mod_example_hooks.so.manifest mt.exe -manifest .\Release\mod_example_hooks.so.manifest -outputresource:.\Release\mod_example_hooks.so;2 + echo Helper for Post-build step > "$(DS_POSTBUILD_DEP)" + +!ELSEIF "$(CFG)" == "mod_example_hooks - Win32 Debug" + +OUTDIR=.\Debug +INTDIR=.\Debug +DS_POSTBUILD_DEP=$(INTDIR)\postbld.dep +# Begin Custom Macros +OutDir=.\Debug +# End Custom Macros + +!IF "$(RECURSE)" == "0" + +ALL : "$(OUTDIR)\mod_example_hooks.so" "$(DS_POSTBUILD_DEP)" + +!ELSE + +ALL : "libhttpd - Win32 Debug" "libaprutil - Win32 Debug" "libapr - Win32 Debug" "$(OUTDIR)\mod_example_hooks.so" "$(DS_POSTBUILD_DEP)" + +!ENDIF + +!IF "$(RECURSE)" == "1" +CLEAN :"libapr - Win32 DebugCLEAN" "libaprutil - Win32 DebugCLEAN" "libhttpd - Win32 DebugCLEAN" +!ELSE +CLEAN : +!ENDIF + -@erase "$(INTDIR)\mod_example_hooks.obj" + -@erase "$(INTDIR)\mod_example_hooks.res" + -@erase "$(INTDIR)\mod_example_hooks_src.idb" + -@erase "$(INTDIR)\mod_example_hooks_src.pdb" + -@erase "$(OUTDIR)\mod_example_hooks.exp" + -@erase "$(OUTDIR)\mod_example_hooks.lib" + -@erase "$(OUTDIR)\mod_example_hooks.pdb" + -@erase "$(OUTDIR)\mod_example_hooks.so" + +"$(OUTDIR)" : + if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" + +CPP=cl.exe +CPP_PROJ=/nologo /MDd /W3 /Zi /Od /I "../../include" /I "../../srclib/apr/include" /I "../../srclib/apr-util/include" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\mod_example_hooks_src" /FD /EHsc /c + +.c{$(INTDIR)}.obj:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cpp{$(INTDIR)}.obj:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cxx{$(INTDIR)}.obj:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.c{$(INTDIR)}.sbr:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cpp{$(INTDIR)}.sbr:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cxx{$(INTDIR)}.sbr:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +MTL=midl.exe +MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /o /win32 "NUL" +RSC=rc.exe +RSC_PROJ=/l 0x409 /fo"$(INTDIR)\mod_example_hooks.res" /i "../../include" /i "../../srclib/apr/include" /d "_DEBUG" /d BIN_NAME="mod_example_hooks.so" /d LONG_NAME="example_hooks_module for Apache" +BSC32=bscmake.exe +BSC32_FLAGS=/nologo /o"$(OUTDIR)\mod_example_hooks.bsc" +BSC32_SBRS= \ + +LINK32=link.exe +LINK32_FLAGS=kernel32.lib /nologo /subsystem:windows /dll /incremental:no /pdb:"$(OUTDIR)\mod_example_hooks.pdb" /debug /out:"$(OUTDIR)\mod_example_hooks.so" /implib:"$(OUTDIR)\mod_example_hooks.lib" /base:@..\..\os\win32\BaseAddr.ref,mod_example_hooks.so +LINK32_OBJS= \ + "$(INTDIR)\mod_example_hooks.obj" \ + "$(INTDIR)\mod_example_hooks.res" \ + "..\..\srclib\apr\Debug\libapr-1.lib" \ + "..\..\srclib\apr-util\Debug\libaprutil-1.lib" \ + "..\..\Debug\libhttpd.lib" + +"$(OUTDIR)\mod_example_hooks.so" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) + $(LINK32) @<< + $(LINK32_FLAGS) $(LINK32_OBJS) +<< + +TargetPath=.\Debug\mod_example_hooks.so +SOURCE="$(InputPath)" +PostBuild_Desc=Embed .manifest +DS_POSTBUILD_DEP=$(INTDIR)\postbld.dep + +# Begin Custom Macros +OutDir=.\Debug +# End Custom Macros + +"$(DS_POSTBUILD_DEP)" : "$(OUTDIR)\mod_example_hooks.so" + if exist .\Debug\mod_example_hooks.so.manifest mt.exe -manifest .\Debug\mod_example_hooks.so.manifest -outputresource:.\Debug\mod_example_hooks.so;2 + echo Helper for Post-build step > "$(DS_POSTBUILD_DEP)" + +!ENDIF + + +!IF "$(NO_EXTERNAL_DEPS)" != "1" +!IF EXISTS("mod_example_hooks.dep") +!INCLUDE "mod_example_hooks.dep" +!ELSE +!MESSAGE Warning: cannot find "mod_example_hooks.dep" +!ENDIF +!ENDIF + + +!IF "$(CFG)" == "mod_example_hooks - Win32 Release" || "$(CFG)" == "mod_example_hooks - Win32 Debug" + +!IF "$(CFG)" == "mod_example_hooks - Win32 Release" + +"libapr - Win32 Release" : + cd ".\..\..\srclib\apr" + $(MAKE) /$(MAKEFLAGS) /F ".\libapr.mak" CFG="libapr - Win32 Release" + cd "..\..\modules\examples" + +"libapr - Win32 ReleaseCLEAN" : + cd ".\..\..\srclib\apr" + $(MAKE) /$(MAKEFLAGS) /F ".\libapr.mak" CFG="libapr - Win32 Release" RECURSE=1 CLEAN + cd "..\..\modules\examples" + +!ELSEIF "$(CFG)" == "mod_example_hooks - Win32 Debug" + +"libapr - Win32 Debug" : + cd ".\..\..\srclib\apr" + $(MAKE) /$(MAKEFLAGS) /F ".\libapr.mak" CFG="libapr - Win32 Debug" + cd "..\..\modules\examples" + +"libapr - Win32 DebugCLEAN" : + cd ".\..\..\srclib\apr" + $(MAKE) /$(MAKEFLAGS) /F ".\libapr.mak" CFG="libapr - Win32 Debug" RECURSE=1 CLEAN + cd "..\..\modules\examples" + +!ENDIF + +!IF "$(CFG)" == "mod_example_hooks - Win32 Release" + +"libaprutil - Win32 Release" : + cd ".\..\..\srclib\apr-util" + $(MAKE) /$(MAKEFLAGS) /F ".\libaprutil.mak" CFG="libaprutil - Win32 Release" + cd "..\..\modules\examples" + +"libaprutil - Win32 ReleaseCLEAN" : + cd ".\..\..\srclib\apr-util" + $(MAKE) /$(MAKEFLAGS) /F ".\libaprutil.mak" CFG="libaprutil - Win32 Release" RECURSE=1 CLEAN + cd "..\..\modules\examples" + +!ELSEIF "$(CFG)" == "mod_example_hooks - Win32 Debug" + +"libaprutil - Win32 Debug" : + cd ".\..\..\srclib\apr-util" + $(MAKE) /$(MAKEFLAGS) /F ".\libaprutil.mak" CFG="libaprutil - Win32 Debug" + cd "..\..\modules\examples" + +"libaprutil - Win32 DebugCLEAN" : + cd ".\..\..\srclib\apr-util" + $(MAKE) /$(MAKEFLAGS) /F ".\libaprutil.mak" CFG="libaprutil - Win32 Debug" RECURSE=1 CLEAN + cd "..\..\modules\examples" + +!ENDIF + +!IF "$(CFG)" == "mod_example_hooks - Win32 Release" + +"libhttpd - Win32 Release" : + cd ".\..\.." + $(MAKE) /$(MAKEFLAGS) /F ".\libhttpd.mak" CFG="libhttpd - Win32 Release" + cd ".\modules\examples" + +"libhttpd - Win32 ReleaseCLEAN" : + cd ".\..\.." + $(MAKE) /$(MAKEFLAGS) /F ".\libhttpd.mak" CFG="libhttpd - Win32 Release" RECURSE=1 CLEAN + cd ".\modules\examples" + +!ELSEIF "$(CFG)" == "mod_example_hooks - Win32 Debug" + +"libhttpd - Win32 Debug" : + cd ".\..\.." + $(MAKE) /$(MAKEFLAGS) /F ".\libhttpd.mak" CFG="libhttpd - Win32 Debug" + cd ".\modules\examples" + +"libhttpd - Win32 DebugCLEAN" : + cd ".\..\.." + $(MAKE) /$(MAKEFLAGS) /F ".\libhttpd.mak" CFG="libhttpd - Win32 Debug" RECURSE=1 CLEAN + cd ".\modules\examples" + +!ENDIF + +SOURCE=..\..\build\win32\httpd.rc + +!IF "$(CFG)" == "mod_example_hooks - Win32 Release" + + +"$(INTDIR)\mod_example_hooks.res" : $(SOURCE) "$(INTDIR)" + $(RSC) /l 0x409 /fo"$(INTDIR)\mod_example_hooks.res" /i "../../include" /i "../../srclib/apr/include" /i "../../build\win32" /d "NDEBUG" /d BIN_NAME="mod_example_hooks.so" /d LONG_NAME="example_hooks_module for Apache" $(SOURCE) + + +!ELSEIF "$(CFG)" == "mod_example_hooks - Win32 Debug" + + +"$(INTDIR)\mod_example_hooks.res" : $(SOURCE) "$(INTDIR)" + $(RSC) /l 0x409 /fo"$(INTDIR)\mod_example_hooks.res" /i "../../include" /i "../../srclib/apr/include" /i "../../build\win32" /d "_DEBUG" /d BIN_NAME="mod_example_hooks.so" /d LONG_NAME="example_hooks_module for Apache" $(SOURCE) + + +!ENDIF + +SOURCE=.\mod_example_hooks.c + +"$(INTDIR)\mod_example_hooks.obj" : $(SOURCE) "$(INTDIR)" + + + +!ENDIF + diff --git a/modules/examples/mod_example_ipc.c b/modules/examples/mod_example_ipc.c new file mode 100644 index 0000000..6f48a84 --- /dev/null +++ b/modules/examples/mod_example_ipc.c @@ -0,0 +1,356 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * mod_example_ipc -- Apache sample module + * + * This module illustrates the use in an Apache 2.x module of the Interprocess + * Communications routines that come with APR. It is example code, and not meant + * to be used in a production server. + * + * To play with this sample module first compile it into a DSO file and install + * it into Apache's modules directory by running: + * + * $ /path/to/apache2/bin/apxs -c -i mod_example_ipc.c + * + * Then activate it in Apache's httpd.conf file for instance for the URL + * /example_ipc in as follows: + * + * # httpd.conf + * LoadModule example_ipc_module modules/mod_example_ipc.so + * <Location /example_ipc> + * SetHandler example_ipc + * </Location> + * + * Then restart Apache via + * + * $ /path/to/apache2/bin/apachectl restart + * + * The module allocates a counter in shared memory, which is incremented by the + * request handler under a mutex. After installation, activate the handler by + * hitting the URL configured above with ab at various concurrency levels to see + * how mutex contention affects server performance. + */ + +#include "apr.h" +#include "apr_strings.h" + +#include "httpd.h" +#include "http_config.h" +#include "http_core.h" +#include "http_log.h" +#include "http_protocol.h" +#include "util_mutex.h" +#include "ap_config.h" + +#if APR_HAVE_SYS_TYPES_H +#include <sys/types.h> +#endif +#if APR_HAVE_UNISTD_H +#include <unistd.h> +#endif + +#define HTML_HEADER "<html>\n<head>\n<title>Mod_example_IPC Status Page " \ + "</title>\n</head>\n<body>\n<h1>Mod_example_IPC Status</h1>\n" +#define HTML_FOOTER "</body>\n</html>\n" + +/* Number of microseconds to camp out on the mutex */ +#define CAMPOUT 10 +/* Maximum number of times we camp out before giving up */ +#define MAXCAMP 10 +/* Number of microseconds the handler sits on the lock once acquired. */ +#define SLEEPYTIME 1000 + +apr_shm_t *exipc_shm; /* Pointer to shared memory block */ +char *shmfilename; /* Shared memory file name, used on some systems */ +apr_global_mutex_t *exipc_mutex; /* Lock around shared memory segment access */ +static const char *exipc_mutex_type = "example-ipc-shm"; + +/* Data structure for shared memory block */ +typedef struct exipc_data { + apr_uint64_t counter; + /* More fields if necessary */ +} exipc_data; + +/* + * Clean up the shared memory block. This function is registered as + * cleanup function for the configuration pool, which gets called + * on restarts. It assures that the new children will not talk to a stale + * shared memory segment. + */ +static apr_status_t shm_cleanup_wrapper(void *unused) +{ + if (exipc_shm) + return apr_shm_destroy(exipc_shm); + return OK; +} + +/* + * This routine is called in the parent; we must register our + * mutex type before the config is processed so that users can + * adjust the mutex settings using the Mutex directive. + */ + +static int exipc_pre_config(apr_pool_t *pconf, apr_pool_t *plog, + apr_pool_t *ptemp) +{ + ap_mutex_register(pconf, exipc_mutex_type, NULL, APR_LOCK_DEFAULT, 0); + return OK; +} + +/* + * This routine is called in the parent, so we'll set up the shared + * memory segment and mutex here. + */ + +static int exipc_post_config(apr_pool_t *pconf, apr_pool_t *plog, + apr_pool_t *ptemp, server_rec *s) +{ + apr_status_t rs; + exipc_data *base; + const char *tempdir; + + + /* + * Do nothing if we are not creating the final configuration. + * The parent process gets initialized a couple of times as the + * server starts up, and we don't want to create any more mutexes + * and shared memory segments than we're actually going to use. + */ + if (ap_state_query(AP_SQ_MAIN_STATE) == AP_SQ_MS_CREATE_PRE_CONFIG) + return OK; + + /* + * The shared memory allocation routines take a file name. + * Depending on system-specific implementation of these + * routines, that file may or may not actually be created. We'd + * like to store those files in the operating system's designated + * temporary directory, which APR can point us to. + */ + rs = apr_temp_dir_get(&tempdir, pconf); + if (APR_SUCCESS != rs) { + ap_log_error(APLOG_MARK, APLOG_ERR, rs, s, APLOGNO(02992) + "Failed to find temporary directory"); + return HTTP_INTERNAL_SERVER_ERROR; + } + + /* Create the shared memory segment */ + + /* + * Create a unique filename using our pid. This information is + * stashed in the global variable so the children inherit it. + */ + shmfilename = apr_psprintf(pconf, "%s/httpd_shm.%ld", tempdir, + (long int)getpid()); + + /* Now create that segment */ + rs = apr_shm_create(&exipc_shm, sizeof(exipc_data), + (const char *) shmfilename, pconf); + if (APR_SUCCESS != rs) { + ap_log_error(APLOG_MARK, APLOG_ERR, rs, s, APLOGNO(02993) + "Failed to create shared memory segment on file %s", + shmfilename); + return HTTP_INTERNAL_SERVER_ERROR; + } + + /* Created it, now let's zero it out */ + base = (exipc_data *)apr_shm_baseaddr_get(exipc_shm); + base->counter = 0; + + /* Create global mutex */ + + rs = ap_global_mutex_create(&exipc_mutex, NULL, exipc_mutex_type, NULL, + s, pconf, 0); + if (APR_SUCCESS != rs) { + return HTTP_INTERNAL_SERVER_ERROR; + } + + /* + * Destroy the shm segment when the configuration pool gets destroyed. This + * happens on server restarts. The parent will then (above) allocate a new + * shm segment that the new children will bind to. + */ + apr_pool_cleanup_register(pconf, NULL, shm_cleanup_wrapper, + apr_pool_cleanup_null); + return OK; +} + +/* + * This routine gets called when a child inits. We use it to attach + * to the shared memory segment, and reinitialize the mutex. + */ + +static void exipc_child_init(apr_pool_t *p, server_rec *s) +{ + apr_status_t rs; + + /* + * Re-open the mutex for the child. Note we're reusing + * the mutex pointer global here. + */ + rs = apr_global_mutex_child_init(&exipc_mutex, + apr_global_mutex_lockfile(exipc_mutex), + p); + if (APR_SUCCESS != rs) { + ap_log_error(APLOG_MARK, APLOG_CRIT, rs, s, APLOGNO(02994) + "Failed to reopen mutex %s in child", + exipc_mutex_type); + /* There's really nothing else we can do here, since This + * routine doesn't return a status. If this ever goes wrong, + * it will turn Apache into a fork bomb. Let's hope it never + * will. + */ + exit(1); /* Ugly, but what else? */ + } +} + +/* The sample content handler */ +static int exipc_handler(request_rec *r) +{ + int gotlock = 0; + int camped; + apr_time_t startcamp; + apr_int64_t timecamped; + apr_status_t rs; + exipc_data *base; + + if (strcmp(r->handler, "example_ipc")) { + return DECLINED; + } + + /* + * The main function of the handler, aside from sending the + * status page to the client, is to increment the counter in + * the shared memory segment. This action needs to be mutexed + * out using the global mutex. + */ + + /* + * First, acquire the lock. This code is a lot more involved than + * it usually needs to be, because the process based trylock + * routine is not implemented on unix platforms. I left it in to + * show how it would work if trylock worked, and for situations + * and platforms where trylock works. + */ + for (camped = 0, timecamped = 0; camped < MAXCAMP; camped++) { + rs = apr_global_mutex_trylock(exipc_mutex); + if (APR_STATUS_IS_EBUSY(rs)) { + apr_sleep(CAMPOUT); + } + else if (APR_SUCCESS == rs) { + gotlock = 1; + break; /* Get out of the loop */ + } + else if (APR_STATUS_IS_ENOTIMPL(rs)) { + /* If it's not implemented, just hang in the mutex. */ + startcamp = apr_time_now(); + rs = apr_global_mutex_lock(exipc_mutex); + timecamped = (apr_int64_t) (apr_time_now() - startcamp); + if (APR_SUCCESS == rs) { + gotlock = 1; + break; /* Out of the loop */ + } + else { + /* Some error, log and bail */ + ap_log_error(APLOG_MARK, APLOG_ERR, rs, r->server, APLOGNO(02995) + "Child %ld failed to acquire lock", + (long int)getpid()); + break; /* Out of the loop without having the lock */ + } + } + else { + /* Some other error, log and bail */ + ap_log_error(APLOG_MARK, APLOG_ERR, rs, r->server, APLOGNO(02996) + "Child %ld failed to try and acquire lock", + (long int)getpid()); + break; /* Out of the loop without having the lock */ + } + + /* + * The only way to get to this point is if the trylock worked + * and returned BUSY. So, bump the time and try again + */ + timecamped += CAMPOUT; + ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, r->server, APLOGNO(03187) + "Child %ld camping out on mutex for %" APR_INT64_T_FMT + " microseconds", + (long int) getpid(), timecamped); + } /* Lock acquisition loop */ + + /* Sleep for a millisecond to make it a little harder for + * httpd children to acquire the lock. + */ + apr_sleep(SLEEPYTIME); + + r->content_type = "text/html"; + + if (!r->header_only) { + ap_rputs(HTML_HEADER, r); + if (gotlock) { + /* Increment the counter */ + base = (exipc_data *)apr_shm_baseaddr_get(exipc_shm); + base->counter++; + /* Send a page with our pid and the new value of the counter. */ + ap_rprintf(r, "<p>Lock acquired after %ld microseoncds.</p>\n", + (long int) timecamped); + ap_rputs("<table border=\"1\">\n", r); + ap_rprintf(r, "<tr><td>Child pid:</td><td>%d</td></tr>\n", + (int) getpid()); + ap_rprintf(r, "<tr><td>Counter:</td><td>%u</td></tr>\n", + (unsigned int)base->counter); + ap_rputs("</table>\n", r); + } + else { + /* + * Send a page saying that we couldn't get the lock. Don't say + * what the counter is, because without the lock the value could + * race. + */ + ap_rprintf(r, "<p>Child %d failed to acquire lock " + "after camping out for %d microseconds.</p>\n", + (int) getpid(), (int) timecamped); + } + ap_rputs(HTML_FOOTER, r); + } /* r->header_only */ + + /* Release the lock */ + if (gotlock) + rs = apr_global_mutex_unlock(exipc_mutex); + /* Swallowing the result because what are we going to do with it at + * this stage? + */ + + return OK; +} + +static void exipc_register_hooks(apr_pool_t *p) +{ + ap_hook_pre_config(exipc_pre_config, NULL, NULL, APR_HOOK_MIDDLE); + ap_hook_post_config(exipc_post_config, NULL, NULL, APR_HOOK_MIDDLE); + ap_hook_child_init(exipc_child_init, NULL, NULL, APR_HOOK_MIDDLE); + ap_hook_handler(exipc_handler, NULL, NULL, APR_HOOK_MIDDLE); +} + +/* Dispatch list for API hooks */ +AP_DECLARE_MODULE(example_ipc) = { + STANDARD20_MODULE_STUFF, + NULL, /* create per-dir config structures */ + NULL, /* merge per-dir config structures */ + NULL, /* create per-server config structures */ + NULL, /* merge per-server config structures */ + NULL, /* table of config file commands */ + exipc_register_hooks /* register hooks */ +}; diff --git a/modules/examples/mod_example_ipc.dep b/modules/examples/mod_example_ipc.dep new file mode 100644 index 0000000..9859b81 --- /dev/null +++ b/modules/examples/mod_example_ipc.dep @@ -0,0 +1,56 @@ +# Microsoft Developer Studio Generated Dependency File, included by mod_example_ipc.mak + +..\..\build\win32\httpd.rc : \ + "..\..\include\ap_release.h"\ + + +.\mod_example_ipc.c : \ + "..\..\include\ap_config.h"\ + "..\..\include\ap_config_layout.h"\ + "..\..\include\ap_expr.h"\ + "..\..\include\ap_hooks.h"\ + "..\..\include\ap_mmn.h"\ + "..\..\include\ap_regex.h"\ + "..\..\include\ap_release.h"\ + "..\..\include\apache_noprobes.h"\ + "..\..\include\http_config.h"\ + "..\..\include\http_core.h"\ + "..\..\include\http_log.h"\ + "..\..\include\http_protocol.h"\ + "..\..\include\httpd.h"\ + "..\..\include\os.h"\ + "..\..\include\util_cfgtree.h"\ + "..\..\include\util_filter.h"\ + "..\..\include\util_mutex.h"\ + "..\..\srclib\apr-util\include\apr_buckets.h"\ + "..\..\srclib\apr-util\include\apr_hooks.h"\ + "..\..\srclib\apr-util\include\apr_optional.h"\ + "..\..\srclib\apr-util\include\apr_optional_hooks.h"\ + "..\..\srclib\apr-util\include\apr_uri.h"\ + "..\..\srclib\apr-util\include\apu.h"\ + "..\..\srclib\apr\include\apr.h"\ + "..\..\srclib\apr\include\apr_allocator.h"\ + "..\..\srclib\apr\include\apr_dso.h"\ + "..\..\srclib\apr\include\apr_errno.h"\ + "..\..\srclib\apr\include\apr_file_info.h"\ + "..\..\srclib\apr\include\apr_file_io.h"\ + "..\..\srclib\apr\include\apr_general.h"\ + "..\..\srclib\apr\include\apr_global_mutex.h"\ + "..\..\srclib\apr\include\apr_hash.h"\ + "..\..\srclib\apr\include\apr_inherit.h"\ + "..\..\srclib\apr\include\apr_mmap.h"\ + "..\..\srclib\apr\include\apr_network_io.h"\ + "..\..\srclib\apr\include\apr_poll.h"\ + "..\..\srclib\apr\include\apr_pools.h"\ + "..\..\srclib\apr\include\apr_portable.h"\ + "..\..\srclib\apr\include\apr_proc_mutex.h"\ + "..\..\srclib\apr\include\apr_ring.h"\ + "..\..\srclib\apr\include\apr_shm.h"\ + "..\..\srclib\apr\include\apr_strings.h"\ + "..\..\srclib\apr\include\apr_tables.h"\ + "..\..\srclib\apr\include\apr_thread_mutex.h"\ + "..\..\srclib\apr\include\apr_thread_proc.h"\ + "..\..\srclib\apr\include\apr_time.h"\ + "..\..\srclib\apr\include\apr_user.h"\ + "..\..\srclib\apr\include\apr_want.h"\ + diff --git a/modules/examples/mod_example_ipc.dsp b/modules/examples/mod_example_ipc.dsp new file mode 100644 index 0000000..278fcce --- /dev/null +++ b/modules/examples/mod_example_ipc.dsp @@ -0,0 +1,111 @@ +# Microsoft Developer Studio Project File - Name="mod_example_ipc" - 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_example_ipc - 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_example_ipc.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_example_ipc.mak" CFG="mod_example_ipc - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "mod_example_ipc - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "mod_example_ipc - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe + +!IF "$(CFG)" == "mod_example_ipc - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /c +# ADD CPP /nologo /MD /W3 /O2 /Oy- /Zi /I "../../include" /I "../../srclib/apr/include" /I "../../srclib/apr-util/include" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /Fd"Release\mod_example_ipc_src" /FD /c +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o /win32 "NUL" +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o /win32 "NUL" +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /fo"Release/mod_example_ipc.res" /i "../../include" /i "../../srclib/apr/include" /d "NDEBUG" /d BIN_NAME="mod_example_ipc.so" /d LONG_NAME="example_ipc_module for Apache" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib /nologo /subsystem:windows /dll /out:".\Release\mod_example_ipc.so" /base:@..\..\os\win32\BaseAddr.ref,mod_example_ipc.so +# ADD LINK32 kernel32.lib /nologo /subsystem:windows /dll /incremental:no /debug /out:".\Release\mod_example_ipc.so" /base:@..\..\os\win32\BaseAddr.ref,mod_example_ipc.so /opt:ref +# Begin Special Build Tool +TargetPath=.\Release\mod_example_ipc.so +SOURCE="$(InputPath)" +PostBuild_Desc=Embed .manifest +PostBuild_Cmds=if exist $(TargetPath).manifest mt.exe -manifest $(TargetPath).manifest -outputresource:$(TargetPath);2 +# End Special Build Tool + +!ELSEIF "$(CFG)" == "mod_example_ipc - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MDd /W3 /EHsc /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FD /c +# ADD CPP /nologo /MDd /W3 /EHsc /Zi /Od /I "../../include" /I "../../srclib/apr/include" /I "../../srclib/apr-util/include" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /Fd"Debug\mod_example_ipc_src" /FD /c +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o /win32 "NUL" +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o /win32 "NUL" +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /fo"Debug/mod_example_ipc.res" /i "../../include" /i "../../srclib/apr/include" /d "_DEBUG" /d BIN_NAME="mod_example_ipc.so" /d LONG_NAME="example_ipc_module for Apache" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib /nologo /subsystem:windows /dll /incremental:no /debug /out:".\Debug\mod_example_ipc.so" /base:@..\..\os\win32\BaseAddr.ref,mod_example_ipc.so +# ADD LINK32 kernel32.lib /nologo /subsystem:windows /dll /incremental:no /debug /out:".\Debug\mod_example_ipc.so" /base:@..\..\os\win32\BaseAddr.ref,mod_example_ipc.so +# Begin Special Build Tool +TargetPath=.\Debug\mod_example_ipc.so +SOURCE="$(InputPath)" +PostBuild_Desc=Embed .manifest +PostBuild_Cmds=if exist $(TargetPath).manifest mt.exe -manifest $(TargetPath).manifest -outputresource:$(TargetPath);2 +# End Special Build Tool + +!ENDIF + +# Begin Target + +# Name "mod_example_ipc - Win32 Release" +# Name "mod_example_ipc - Win32 Debug" +# Begin Source File + +SOURCE=.\mod_example_ipc.c +# End Source File +# Begin Source File + +SOURCE=..\..\build\win32\httpd.rc +# End Source File +# End Target +# End Project diff --git a/modules/examples/mod_example_ipc.mak b/modules/examples/mod_example_ipc.mak new file mode 100644 index 0000000..218924e --- /dev/null +++ b/modules/examples/mod_example_ipc.mak @@ -0,0 +1,353 @@ +# Microsoft Developer Studio Generated NMAKE File, Based on mod_example_ipc.dsp +!IF "$(CFG)" == "" +CFG=mod_example_ipc - Win32 Debug +!MESSAGE No configuration specified. Defaulting to mod_example_ipc - Win32 Debug. +!ENDIF + +!IF "$(CFG)" != "mod_example_ipc - Win32 Release" && "$(CFG)" != "mod_example_ipc - Win32 Debug" +!MESSAGE Invalid configuration "$(CFG)" specified. +!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_example_ipc.mak" CFG="mod_example_ipc - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "mod_example_ipc - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "mod_example_ipc - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE +!ERROR An invalid configuration is specified. +!ENDIF + +!IF "$(OS)" == "Windows_NT" +NULL= +!ELSE +NULL=nul +!ENDIF + +!IF "$(CFG)" == "mod_example_ipc - Win32 Release" + +OUTDIR=.\Release +INTDIR=.\Release +DS_POSTBUILD_DEP=$(INTDIR)\postbld.dep +# Begin Custom Macros +OutDir=.\Release +# End Custom Macros + +!IF "$(RECURSE)" == "0" + +ALL : "$(OUTDIR)\mod_example_ipc.so" "$(DS_POSTBUILD_DEP)" + +!ELSE + +ALL : "libhttpd - Win32 Release" "libaprutil - Win32 Release" "libapr - Win32 Release" "$(OUTDIR)\mod_example_ipc.so" "$(DS_POSTBUILD_DEP)" + +!ENDIF + +!IF "$(RECURSE)" == "1" +CLEAN :"libapr - Win32 ReleaseCLEAN" "libaprutil - Win32 ReleaseCLEAN" "libhttpd - Win32 ReleaseCLEAN" +!ELSE +CLEAN : +!ENDIF + -@erase "$(INTDIR)\mod_example_ipc.obj" + -@erase "$(INTDIR)\mod_example_ipc.res" + -@erase "$(INTDIR)\mod_example_ipc_src.idb" + -@erase "$(INTDIR)\mod_example_ipc_src.pdb" + -@erase "$(OUTDIR)\mod_example_ipc.exp" + -@erase "$(OUTDIR)\mod_example_ipc.lib" + -@erase "$(OUTDIR)\mod_example_ipc.pdb" + -@erase "$(OUTDIR)\mod_example_ipc.so" + +"$(OUTDIR)" : + if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" + +CPP=cl.exe +CPP_PROJ=/nologo /MD /W3 /Zi /O2 /Oy- /I "../../include" /I "../../srclib/apr/include" /I "../../srclib/apr-util/include" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\mod_example_ipc_src" /FD /c + +.c{$(INTDIR)}.obj:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cpp{$(INTDIR)}.obj:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cxx{$(INTDIR)}.obj:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.c{$(INTDIR)}.sbr:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cpp{$(INTDIR)}.sbr:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cxx{$(INTDIR)}.sbr:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +MTL=midl.exe +MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /o /win32 "NUL" +RSC=rc.exe +RSC_PROJ=/l 0x409 /fo"$(INTDIR)\mod_example_ipc.res" /i "../../include" /i "../../srclib/apr/include" /d "NDEBUG" /d BIN_NAME="mod_example_ipc.so" /d LONG_NAME="example_ipc_module for Apache" +BSC32=bscmake.exe +BSC32_FLAGS=/nologo /o"$(OUTDIR)\mod_example_ipc.bsc" +BSC32_SBRS= \ + +LINK32=link.exe +LINK32_FLAGS=kernel32.lib /nologo /subsystem:windows /dll /incremental:no /pdb:"$(OUTDIR)\mod_example_ipc.pdb" /debug /out:"$(OUTDIR)\mod_example_ipc.so" /implib:"$(OUTDIR)\mod_example_ipc.lib" /base:@..\..\os\win32\BaseAddr.ref,mod_example_ipc.so /opt:ref +LINK32_OBJS= \ + "$(INTDIR)\mod_example_ipc.obj" \ + "$(INTDIR)\mod_example_ipc.res" \ + "..\..\srclib\apr\Release\libapr-1.lib" \ + "..\..\srclib\apr-util\Release\libaprutil-1.lib" \ + "..\..\Release\libhttpd.lib" + +"$(OUTDIR)\mod_example_ipc.so" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) + $(LINK32) @<< + $(LINK32_FLAGS) $(LINK32_OBJS) +<< + +TargetPath=.\Release\mod_example_ipc.so +SOURCE="$(InputPath)" +PostBuild_Desc=Embed .manifest +DS_POSTBUILD_DEP=$(INTDIR)\postbld.dep + +# Begin Custom Macros +OutDir=.\Release +# End Custom Macros + +"$(DS_POSTBUILD_DEP)" : "$(OUTDIR)\mod_example_ipc.so" + if exist .\Release\mod_example_ipc.so.manifest mt.exe -manifest .\Release\mod_example_ipc.so.manifest -outputresource:.\Release\mod_example_ipc.so;2 + echo Helper for Post-build step > "$(DS_POSTBUILD_DEP)" + +!ELSEIF "$(CFG)" == "mod_example_ipc - Win32 Debug" + +OUTDIR=.\Debug +INTDIR=.\Debug +DS_POSTBUILD_DEP=$(INTDIR)\postbld.dep +# Begin Custom Macros +OutDir=.\Debug +# End Custom Macros + +!IF "$(RECURSE)" == "0" + +ALL : "$(OUTDIR)\mod_example_ipc.so" "$(DS_POSTBUILD_DEP)" + +!ELSE + +ALL : "libhttpd - Win32 Debug" "libaprutil - Win32 Debug" "libapr - Win32 Debug" "$(OUTDIR)\mod_example_ipc.so" "$(DS_POSTBUILD_DEP)" + +!ENDIF + +!IF "$(RECURSE)" == "1" +CLEAN :"libapr - Win32 DebugCLEAN" "libaprutil - Win32 DebugCLEAN" "libhttpd - Win32 DebugCLEAN" +!ELSE +CLEAN : +!ENDIF + -@erase "$(INTDIR)\mod_example_ipc.obj" + -@erase "$(INTDIR)\mod_example_ipc.res" + -@erase "$(INTDIR)\mod_example_ipc_src.idb" + -@erase "$(INTDIR)\mod_example_ipc_src.pdb" + -@erase "$(OUTDIR)\mod_example_ipc.exp" + -@erase "$(OUTDIR)\mod_example_ipc.lib" + -@erase "$(OUTDIR)\mod_example_ipc.pdb" + -@erase "$(OUTDIR)\mod_example_ipc.so" + +"$(OUTDIR)" : + if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" + +CPP=cl.exe +CPP_PROJ=/nologo /MDd /W3 /Zi /Od /I "../../include" /I "../../srclib/apr/include" /I "../../srclib/apr-util/include" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\mod_example_ipc_src" /FD /EHsc /c + +.c{$(INTDIR)}.obj:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cpp{$(INTDIR)}.obj:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cxx{$(INTDIR)}.obj:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.c{$(INTDIR)}.sbr:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cpp{$(INTDIR)}.sbr:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cxx{$(INTDIR)}.sbr:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +MTL=midl.exe +MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /o /win32 "NUL" +RSC=rc.exe +RSC_PROJ=/l 0x409 /fo"$(INTDIR)\mod_example_ipc.res" /i "../../include" /i "../../srclib/apr/include" /d "_DEBUG" /d BIN_NAME="mod_example_ipc.so" /d LONG_NAME="example_ipc_module for Apache" +BSC32=bscmake.exe +BSC32_FLAGS=/nologo /o"$(OUTDIR)\mod_example_ipc.bsc" +BSC32_SBRS= \ + +LINK32=link.exe +LINK32_FLAGS=kernel32.lib /nologo /subsystem:windows /dll /incremental:no /pdb:"$(OUTDIR)\mod_example_ipc.pdb" /debug /out:"$(OUTDIR)\mod_example_ipc.so" /implib:"$(OUTDIR)\mod_example_ipc.lib" /base:@..\..\os\win32\BaseAddr.ref,mod_example_ipc.so +LINK32_OBJS= \ + "$(INTDIR)\mod_example_ipc.obj" \ + "$(INTDIR)\mod_example_ipc.res" \ + "..\..\srclib\apr\Debug\libapr-1.lib" \ + "..\..\srclib\apr-util\Debug\libaprutil-1.lib" \ + "..\..\Debug\libhttpd.lib" + +"$(OUTDIR)\mod_example_ipc.so" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) + $(LINK32) @<< + $(LINK32_FLAGS) $(LINK32_OBJS) +<< + +TargetPath=.\Debug\mod_example_ipc.so +SOURCE="$(InputPath)" +PostBuild_Desc=Embed .manifest +DS_POSTBUILD_DEP=$(INTDIR)\postbld.dep + +# Begin Custom Macros +OutDir=.\Debug +# End Custom Macros + +"$(DS_POSTBUILD_DEP)" : "$(OUTDIR)\mod_example_ipc.so" + if exist .\Debug\mod_example_ipc.so.manifest mt.exe -manifest .\Debug\mod_example_ipc.so.manifest -outputresource:.\Debug\mod_example_ipc.so;2 + echo Helper for Post-build step > "$(DS_POSTBUILD_DEP)" + +!ENDIF + + +!IF "$(NO_EXTERNAL_DEPS)" != "1" +!IF EXISTS("mod_example_ipc.dep") +!INCLUDE "mod_example_ipc.dep" +!ELSE +!MESSAGE Warning: cannot find "mod_example_ipc.dep" +!ENDIF +!ENDIF + + +!IF "$(CFG)" == "mod_example_ipc - Win32 Release" || "$(CFG)" == "mod_example_ipc - Win32 Debug" + +!IF "$(CFG)" == "mod_example_ipc - Win32 Release" + +"libapr - Win32 Release" : + cd ".\..\..\srclib\apr" + $(MAKE) /$(MAKEFLAGS) /F ".\libapr.mak" CFG="libapr - Win32 Release" + cd "..\..\modules\examples" + +"libapr - Win32 ReleaseCLEAN" : + cd ".\..\..\srclib\apr" + $(MAKE) /$(MAKEFLAGS) /F ".\libapr.mak" CFG="libapr - Win32 Release" RECURSE=1 CLEAN + cd "..\..\modules\examples" + +!ELSEIF "$(CFG)" == "mod_example_ipc - Win32 Debug" + +"libapr - Win32 Debug" : + cd ".\..\..\srclib\apr" + $(MAKE) /$(MAKEFLAGS) /F ".\libapr.mak" CFG="libapr - Win32 Debug" + cd "..\..\modules\examples" + +"libapr - Win32 DebugCLEAN" : + cd ".\..\..\srclib\apr" + $(MAKE) /$(MAKEFLAGS) /F ".\libapr.mak" CFG="libapr - Win32 Debug" RECURSE=1 CLEAN + cd "..\..\modules\examples" + +!ENDIF + +!IF "$(CFG)" == "mod_example_ipc - Win32 Release" + +"libaprutil - Win32 Release" : + cd ".\..\..\srclib\apr-util" + $(MAKE) /$(MAKEFLAGS) /F ".\libaprutil.mak" CFG="libaprutil - Win32 Release" + cd "..\..\modules\examples" + +"libaprutil - Win32 ReleaseCLEAN" : + cd ".\..\..\srclib\apr-util" + $(MAKE) /$(MAKEFLAGS) /F ".\libaprutil.mak" CFG="libaprutil - Win32 Release" RECURSE=1 CLEAN + cd "..\..\modules\examples" + +!ELSEIF "$(CFG)" == "mod_example_ipc - Win32 Debug" + +"libaprutil - Win32 Debug" : + cd ".\..\..\srclib\apr-util" + $(MAKE) /$(MAKEFLAGS) /F ".\libaprutil.mak" CFG="libaprutil - Win32 Debug" + cd "..\..\modules\examples" + +"libaprutil - Win32 DebugCLEAN" : + cd ".\..\..\srclib\apr-util" + $(MAKE) /$(MAKEFLAGS) /F ".\libaprutil.mak" CFG="libaprutil - Win32 Debug" RECURSE=1 CLEAN + cd "..\..\modules\examples" + +!ENDIF + +!IF "$(CFG)" == "mod_example_ipc - Win32 Release" + +"libhttpd - Win32 Release" : + cd ".\..\.." + $(MAKE) /$(MAKEFLAGS) /F ".\libhttpd.mak" CFG="libhttpd - Win32 Release" + cd ".\modules\examples" + +"libhttpd - Win32 ReleaseCLEAN" : + cd ".\..\.." + $(MAKE) /$(MAKEFLAGS) /F ".\libhttpd.mak" CFG="libhttpd - Win32 Release" RECURSE=1 CLEAN + cd ".\modules\examples" + +!ELSEIF "$(CFG)" == "mod_example_ipc - Win32 Debug" + +"libhttpd - Win32 Debug" : + cd ".\..\.." + $(MAKE) /$(MAKEFLAGS) /F ".\libhttpd.mak" CFG="libhttpd - Win32 Debug" + cd ".\modules\examples" + +"libhttpd - Win32 DebugCLEAN" : + cd ".\..\.." + $(MAKE) /$(MAKEFLAGS) /F ".\libhttpd.mak" CFG="libhttpd - Win32 Debug" RECURSE=1 CLEAN + cd ".\modules\examples" + +!ENDIF + +SOURCE=..\..\build\win32\httpd.rc + +!IF "$(CFG)" == "mod_example_ipc - Win32 Release" + + +"$(INTDIR)\mod_example_ipc.res" : $(SOURCE) "$(INTDIR)" + $(RSC) /l 0x409 /fo"$(INTDIR)\mod_example_ipc.res" /i "../../include" /i "../../srclib/apr/include" /i "../../build\win32" /d "NDEBUG" /d BIN_NAME="mod_example_ipc.so" /d LONG_NAME="example_ipc_module for Apache" $(SOURCE) + + +!ELSEIF "$(CFG)" == "mod_example_ipc - Win32 Debug" + + +"$(INTDIR)\mod_example_ipc.res" : $(SOURCE) "$(INTDIR)" + $(RSC) /l 0x409 /fo"$(INTDIR)\mod_example_ipc.res" /i "../../include" /i "../../srclib/apr/include" /i "../../build\win32" /d "_DEBUG" /d BIN_NAME="mod_example_ipc.so" /d LONG_NAME="example_ipc_module for Apache" $(SOURCE) + + +!ENDIF + +SOURCE=.\mod_example_ipc.c + +"$(INTDIR)\mod_example_ipc.obj" : $(SOURCE) "$(INTDIR)" + + + +!ENDIF + |