/* Copyright 2002 Kevin O'Donnell This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* * Include the core server components. */ #include "httpd.h" #include "http_config.h" /* * This function is registered as a handler for HTTP methods and will * therefore be invoked for all GET requests (and others). Regardless * of the request type, this function simply sends a message to * STDERR (which httpd redirects to logs/error_log). A real module * would do *alot* more at this point. */ static int mod_tut1_method_handler (request_rec *r) { // Send a message to stderr (apache redirects this to the error log) fprintf(stderr,"apache2_mod_tut1: A request was made.\n"); // We need to flush the stream so that the message appears right away. // Performing an fflush() in a production system is not good for // performance - don't do this for real. fflush(stderr); // Return DECLINED so that the Apache core will keep looking for // other modules to handle this request. This effectively makes // this module completely transparent. return DECLINED; } /* * This function is a callback and it declares what other functions * should be called for request processing and configuration requests. * This callback function declares the Handlers for other events. */ static void mod_tut1_register_hooks (apr_pool_t *p) { // I think this is the call to make to register a handler for method calls (GET PUT et. al.). // We will ask to be last so that the comment has a higher tendency to // go at the end. ap_hook_handler(mod_tut1_method_handler, NULL, NULL, APR_HOOK_LAST); } /* * Declare and populate the module's data structure. The * name of this structure ('tut1_module') is important - it * must match the name of the module. This structure is the * only "glue" between the httpd core and the module. */ module AP_MODULE_DECLARE_DATA tut1_module = { // Only one callback function is provided. Real // modules will need to declare callback functions for // server/directory configuration, configuration merging // and other tasks. STANDARD20_MODULE_STUFF, NULL, NULL, NULL, NULL, NULL, mod_tut1_register_hooks, /* callback for registering hooks */ };