Overview
Perhaps the most important part of an Apache module is the
module
structure. This is defined in
http_config.h, so all modules should start
(apart from copyright notices, etc.) with the following lines:
#include "httpd.h" #include "http_config.h"
Note that httpd.h is required for all Apache source code.
What is the module structure for? Simple: it
provides the glue between the Apache core and the
module’s code. It contains pointers (to functions,
lists, and so on) that are used by components of the core at the
correct moments. The core knows about the various
module structures because they are listed in
modules.c, which is generated by the
Configure script from the
Configuration file.[2]
Traditionally, each module ends with its module
structure. Here is a particularly trivial example, from
mod_asis.c (1.3):
module asis_module = {
STANDARD_MODULE_STUFF,
NULL, /* initializer */
NULL, /* create per-directory config structure */
NULL, /* merge per-directory config structures */
NULL, /* create per-server config structure */
NULL, /* merge per-server config structures */
NULL, /* command table */
asis_handlers, /* handlers */
NULL, /* translate_handler */
NULL, /* check_user_id */
NULL, /* check auth */
NULL, /* check access */
NULL, /* type_checker */
NULL, /* prerun fixups */
NULL /* logger */
NULL, /* header parser */
NULL, /* child_init */
NULL, /* child_exit */
NULL /* post read request */
};The first entry, STANDARD_MODULE_STUFF, must
appear in all module structures. It ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access