Around emacs, linux, etc.
About module struct in Apache
在写apache模块的时候,会用到module这个结构体。module这个结构体实际上是module_struct,后面附上了定义。使用的时候通常都是定义一个这个结构体的变量并赋初值,如:
module AP_MODULE_DECLARE_DATA proxy_module =
{
STANDARD20_MODULE_STUFF,
create_proxy_dir_config, /* create per-directory config structure */
merge_proxy_dir_config, /* merge per-directory config structures */
create_proxy_config, /* create per-server config structure */
merge_proxy_config, /* merge per-server config structures */
proxy_cmds, /* command table */
register_hooks
};
其中STANDARD20_MODULE_STUFF这个宏为module_struct中的API version, minor version, module index, name, danamic load handle, next, magic, rewrite_args赋了初值。随后是per-directory configuration structure的初始化、合并函数和per-server configuration structure的初始化、合并函数。command table是command_rec结构的一个数组,依然是宏展开,描述这个模块在配置文件里面的信息。最后的register_hooks指向用于注册hook的函数。
typedef struct module_struct module; /**
- Module structures. Just about everything is dispatched through
- these, directly or indirectly (through the command and handler
- tables).
- /
- compatible with this version of the server.
- /
- during module init */
- @defvar module_struct *next */
- important for the DSO facility (see also mod_so). */
- hook is only available to MPMs.
- @param The process that the server is running in.
- /
- structures.
- @param p The pool to use for all allocations.
- @param dir The directory currently being processed.
- @return The per-directory structure created
- /
- structures for two directories.
- @param p The pool to use for all allocations.
- @param base_conf The directory structure created for the parent directory.
- @param new_conf The directory structure currently being processed.
- @return The new per-directory structure created
- /
- structures.
- @param p The pool to use for all allocations.
- @param s The server currently being processed.
- @return The per-server structure created
- /
- structures for two servers.
- @param p The pool to use for all allocations.
- @param base_conf The directory structure created for the parent directory.
- @param new_conf The directory structure currently being processed.
- @return The new per-directory structure created
- /
- defines. */
- In this function, modules should call the ap_hook_*() functions to
- register an interest in a specific step in processing the current
- request.
- @param p the pool to use for all allocations
- /
| Print article | This entry was posted by Jay Xie on 2006/04/04 at 3:56 pm, and is filed under Apache. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site. |