Apache 1.3 API Documentation

Structure module

Definition:

typedef struct module_struct { 
    int version; 
    int minor_version; 
    int module_index; 
    const char *name; 
    void *dynamic_load_handle; 
    struct module_struct *next; 
    unsigned long magic; 
#ifdef ULTRIX_BRAIN_DEATH 
    void (*init) (); 
    void *(*create_dir_config) (); 
    void *(*merge_dir_config) (); 
    void *(*create_server_config) (); 
    void *(*merge_server_config) (); 
#else 
    void (*init) (server_rec *s, pool *p); 
    void *(*create_dir_config) (pool *p, char *dir); 
    void *(*merge_dir_config) (pool *p, void *base_conf, void *new_conf); 
    void *(*create_server_config) (pool *p, server_rec *s); 
    void *(*merge_server_config) (pool *p, void *base_conf, void *new_conf); 
#endif 
    const command_rec *cmds; 
    const handler_rec *handlers; 
    int (*translate_handler) (request_rec *r); 
    int (*ap_check_user_id) (request_rec *r); 
    int (*auth_checker) (request_rec *r); 
    int (*access_checker) (request_rec *r); 
    int (*type_checker) (request_rec *r); 
    int (*fixer_upper) (request_rec *r); 
    int (*logger) (request_rec *r); 
    int (*header_parser) (request_rec *r); 
#ifdef ULTRIX_BRAIN_DEATH 
    void (*child_init) (); 
    void (*child_exit) (); 
#else 
    void (*child_init) (server_rec *s, pool *p); 
    void (*child_exit) (server_rec *s, pool *p); 
#endif 
    int (*post_read_request) (request_rec *)r; 
} module; 
     

Usage example:

module *mpointer; 
   or 
module action_module = 
{ 
    STANDARD_MODULE_STUFF, 
    NULL,                       /* initializer */ 
    create_action_dir_config,   /* dir config creator */ 
    merge_action_dir_configs,   /* dir merger --- default is to override */ 
    NULL,                       /* server config */ 
    NULL,                       /* merge server config */ 
    action_cmds,                /* command table */ 
    action_handlers,            /* handlers */ 
    NULL,                       /* filename translation */ 
    NULL,                       /* check_user_id */ 
    NULL,                       /* check auth */ 
    NULL,                       /* check access */ 
    NULL,                       /* type_checker */ 
    NULL,                       /* fixups */ 
    NULL,                       /* logger */ 
    NULL,                       /* header parser */ 
    NULL,                       /* child_init */ 
    NULL,                       /* child_exit */ 
    NULL                        /* post read-request */ 
}; 
     

A server extension module in Apache can declare handlers for a particular phase --- these are C functions which return an integer status code, and which take as argument a pointer to a structure known as a request_rec, which contains and coordinates all of the information regarding a particular request: the URI requested, type of the request, relevant directory-specific configuration information, and the like. In fact, the interface between the server core and extension modules (including the ones which implement the server's native NCSA emulation functionality) is through a module structure which consists mostly of pointers to handlers for various phases, or NULL, if the module elects not to handle that phase (there is also other information concerned with configuration management).

As a special case, a module can declare several handlers for the response-handling phase, distinguished by the types of entities (scripts, directories, ordinary files of particular kinds, or anything at all) that they wish to handle. The server core code does a dispatch based on the type of the entity requested to find the handler (or handlers, if the first one declines the request) which it eventually invokes.

See also:
ap_add_loaded_module, ap_add_module, ap_add_named_module, AP_MODULE_MAGIC_AT_LEAST, ap_remove_loaded_module, ap_remove_module, core_module, MODULE_MAGIC_AT_LEAST, MODULE_MAGIC_COOKIE, MODULE_MAGIC_NUMBER, MODULE_MAGIC_NUMBER_MAJOR, MODULE_MAGIC_NUMBER_MINOR, STANDARD_MODULE_STUFF, top_module

Previous: HANDLE Next: mutex

Table of Contents (Routines, Structures, Data Cells, Constants)