root / trunk / src / plugin.h
History | View | Annotate | Download (5.6 KB)
| 1 |
#ifndef _PLUGIN_H_
|
|---|---|
| 2 |
#define _PLUGIN_H_
|
| 3 |
|
| 4 |
#include "settings.h" |
| 5 |
#include "base.h" |
| 6 |
#include "buffer.h" |
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
#define SERVER_FUNC(x) \
|
| 11 |
static handler_t x(server *srv, void *p_d) |
| 12 |
|
| 13 |
#define CONNECTION_FUNC(x) \
|
| 14 |
static handler_t x(server *srv, connection *con, void *p_d) |
| 15 |
|
| 16 |
#define INIT_FUNC(x) \
|
| 17 |
static void * x(server *srv) |
| 18 |
/*
|
| 19 |
* The PATCH_OPTION() macro is used in the patch_connection() functions
|
| 20 |
* of the modules to update the config object for the current request.
|
| 21 |
*/
|
| 22 |
#define PATCH_OPTION(x) \
|
| 23 |
p->conf.x = s->x |
| 24 |
|
| 25 |
#define FREE_FUNC SERVER_FUNC
|
| 26 |
#define TRIGGER_FUNC SERVER_FUNC
|
| 27 |
#define SETDEFAULTS_FUNC SERVER_FUNC
|
| 28 |
#define SIGHUP_FUNC SERVER_FUNC
|
| 29 |
|
| 30 |
#define SUBREQUEST_FUNC CONNECTION_FUNC
|
| 31 |
#define JOBLIST_FUNC CONNECTION_FUNC
|
| 32 |
#define PHYSICALPATH_FUNC CONNECTION_FUNC
|
| 33 |
#define REQUESTDONE_FUNC CONNECTION_FUNC
|
| 34 |
#define URIHANDLER_FUNC CONNECTION_FUNC
|
| 35 |
|
| 36 |
#define PLUGIN_DATA size_t id
|
| 37 |
|
| 38 |
/**
|
| 39 |
* we have 4 states on the connection:
|
| 40 |
* - read-header
|
| 41 |
* - read-content
|
| 42 |
* - write-header
|
| 43 |
* - write-content
|
| 44 |
*/
|
| 45 |
|
| 46 |
typedef struct { |
| 47 |
size_t version; |
| 48 |
|
| 49 |
buffer *name; /* name of the plugin */
|
| 50 |
|
| 51 |
void *(* init) (server *srv);
|
| 52 |
handler_t (* set_defaults) (server *srv, void *p_d);
|
| 53 |
handler_t (* cleanup) (server *srv, void *p_d);
|
| 54 |
/* is called ... */
|
| 55 |
handler_t (* handle_trigger) (server *srv, void *p_d); /* once a second */ |
| 56 |
handler_t (* handle_sighup) (server *srv, void *p_d); /* at a signup */ |
| 57 |
|
| 58 |
handler_t (* handle_uri_raw) (server *srv, connection *con, void *p_d); /* after uri_raw is set (mod_rewrite) */ |
| 59 |
handler_t (* handle_uri_clean) (server *srv, connection *con, void *p_d); /* after uri is set (mod_access, mod_auth) */ |
| 60 |
handler_t (* handle_docroot) (server *srv, connection *con, void *p_d); /* getting the document-root (e.g. mod_simple_vhost) */ |
| 61 |
handler_t (* handle_physical) (server *srv, connection *con, void *p_d); /* mapping url to physical path (e.g. mod_alias, mod_proxy_core) */ |
| 62 |
handler_t (* handle_start_backend) (server *srv, connection *con, void *p_d); /* file exists locally (e.g. mod_staticfile) */ |
| 63 |
handler_t (* handle_send_request_content)(server *srv, connection *con, void *p_d); /* a handler for the request content */ |
| 64 |
handler_t (* handle_response_header) (server *srv, connection *con, void *p_d); /* a handler for the request content */ |
| 65 |
handler_t (* handle_read_response_content)(server *srv, connection *con, void *p_d); /* read the content from the source and push it to the next queue */ |
| 66 |
handler_t (* handle_filter_response_content)(server *srv, connection *con, void *p_d); /* apply filters to response content (compression/chunk encoding/ etc..) */ |
| 67 |
handler_t (* handle_response_done) (server *srv, connection *con, void *p_d); /* after the response is sent (e.g. mod_accesslog) */ |
| 68 |
handler_t (* connection_reset) (server *srv, connection *con, void *p_d); /* end of a request-response cycle (mod_acceslog, mod_proxy_core) */ |
| 69 |
handler_t (* handle_connection_close)(server *srv, connection *con, void *p_d); /* at the end of a connection [remove-me ?] */ |
| 70 |
handler_t (* handle_joblist) (server *srv, connection *con, void *p_d); /* after all events are handled [remove-me ?] */ |
| 71 |
|
| 72 |
void *data;
|
| 73 |
|
| 74 |
/* dlopen handle */
|
| 75 |
void *lib;
|
| 76 |
|
| 77 |
array *required_plugins; |
| 78 |
} plugin; |
| 79 |
|
| 80 |
LI_EXPORT int plugins_load(server *srv);
|
| 81 |
LI_EXPORT void plugins_free(server *srv);
|
| 82 |
|
| 83 |
LI_EXPORT handler_t plugins_call_handle_uri_raw(server *srv, connection *con); |
| 84 |
LI_EXPORT handler_t plugins_call_handle_uri_clean(server *srv, connection *con); |
| 85 |
LI_EXPORT handler_t plugins_call_handle_docroot(server *srv, connection *con); |
| 86 |
LI_EXPORT handler_t plugins_call_handle_physical(server *srv, connection *con); |
| 87 |
LI_EXPORT handler_t plugins_call_handle_start_backend(server *srv, connection *con); |
| 88 |
LI_EXPORT handler_t plugins_call_handle_send_request_content(server *srv, connection *con); |
| 89 |
LI_EXPORT handler_t plugins_call_handle_response_header(server *srv, connection *con); |
| 90 |
LI_EXPORT handler_t plugins_call_handle_read_response_content(server *srv, connection *con); |
| 91 |
LI_EXPORT handler_t plugins_call_handle_filter_response_content(server *srv, connection *con); |
| 92 |
LI_EXPORT handler_t plugins_call_handle_response_done(server *srv, connection *con); |
| 93 |
LI_EXPORT handler_t plugins_call_handle_connection_close(server *srv, connection *con); |
| 94 |
LI_EXPORT handler_t plugins_call_handle_joblist(server *srv, connection *con); |
| 95 |
LI_EXPORT handler_t plugins_call_connection_reset(server *srv, connection *con); |
| 96 |
|
| 97 |
LI_EXPORT handler_t plugins_call_handle_trigger(server *srv); |
| 98 |
LI_EXPORT handler_t plugins_call_handle_sighup(server *srv); |
| 99 |
|
| 100 |
LI_EXPORT handler_t plugins_call_init(server *srv); |
| 101 |
LI_EXPORT handler_t plugins_call_set_defaults(server *srv); |
| 102 |
LI_EXPORT handler_t plugins_call_cleanup(server *srv); |
| 103 |
|
| 104 |
LI_EXPORT int config_insert_values_global(server *srv, array *ca, const config_values_t *cv); |
| 105 |
LI_EXPORT int config_insert_values_internal(server *srv, array *ca, const config_values_t *cv); |
| 106 |
LI_EXPORT int config_setup_connection(server *srv, connection *con);
|
| 107 |
LI_EXPORT int config_patch_connection(server *srv, connection *con, comp_key_t comp);
|
| 108 |
LI_EXPORT int config_check_cond(server *srv, connection *con, data_config *dc);
|
| 109 |
LI_EXPORT int config_append_cond_match_buffer(connection *con, data_config *dc, buffer *buf, int n); |
| 110 |
LI_EXPORT int config_exec_pcre_keyvalue_buffer(connection *con, pcre_keyvalue_buffer *kvb, data_config *context, buffer *match_buf, buffer *result);
|
| 111 |
|
| 112 |
LI_EXPORT void* plugin_get_config(server *srv, const char *name); |
| 113 |
|
| 114 |
#endif
|