1#ifndef _PLUGIN_H_
2#define _PLUGIN_H_
3
4#include "base.h"
5#include "buffer.h"
6
7#define SERVER_FUNC(x) \
8		static handler_t x(server *srv, void *p_d)
9
10#define CONNECTION_FUNC(x) \
11		static handler_t x(server *srv, connection *con, void *p_d)
12
13#define INIT_FUNC(x) \
14		static void *x(void)
15
16#define FREE_FUNC          SERVER_FUNC
17#define TRIGGER_FUNC       SERVER_FUNC
18#define SETDEFAULTS_FUNC   SERVER_FUNC
19#define SIGHUP_FUNC        SERVER_FUNC
20
21#define SUBREQUEST_FUNC    CONNECTION_FUNC
22#define JOBLIST_FUNC       CONNECTION_FUNC
23#define PHYSICALPATH_FUNC  CONNECTION_FUNC
24#define REQUESTDONE_FUNC   CONNECTION_FUNC
25#define URIHANDLER_FUNC    CONNECTION_FUNC
26
27#define PLUGIN_DATA        size_t id
28
29typedef struct {
30	size_t version;
31
32	buffer *name; /* name of the plugin */
33
34	void *(* init)                       ();
35	handler_t (* set_defaults)           (server *srv, void *p_d);
36	handler_t (* cleanup)                (server *srv, void *p_d);
37	                                                                                   /* is called ... */
38	handler_t (* handle_trigger)         (server *srv, void *p_d);                     /* once a second */
39	handler_t (* handle_sighup)          (server *srv, void *p_d);                     /* at a signup */
40
41	handler_t (* handle_uri_raw)         (server *srv, connection *con, void *p_d);    /* after uri_raw is set */
42	handler_t (* handle_uri_clean)       (server *srv, connection *con, void *p_d);    /* after uri is set */
43	handler_t (* handle_docroot)         (server *srv, connection *con, void *p_d);    /* getting the document-root */
44	handler_t (* handle_physical)        (server *srv, connection *con, void *p_d);    /* mapping url to physical path */
45	handler_t (* handle_request_done)    (server *srv, connection *con, void *p_d);    /* at the end of a request */
46	handler_t (* handle_connection_close)(server *srv, connection *con, void *p_d);    /* at the end of a connection */
47	handler_t (* handle_joblist)         (server *srv, connection *con, void *p_d);    /* after all events are handled */
48
49
50
51	handler_t (* handle_subrequest_start)(server *srv, connection *con, void *p_d);
52
53	                                                                                   /* when a handler for the request
54											    * has to be found
55											    */
56	handler_t (* handle_subrequest)      (server *srv, connection *con, void *p_d);    /* */
57	handler_t (* connection_reset)       (server *srv, connection *con, void *p_d);    /* */
58	void *data;
59
60	/* dlopen handle */
61	void *lib;
62} plugin;
63
64int plugins_load(server *srv);
65void plugins_free(server *srv);
66
67handler_t plugins_call_handle_uri_raw(server *srv, connection *con);
68handler_t plugins_call_handle_uri_clean(server *srv, connection *con);
69handler_t plugins_call_handle_subrequest_start(server *srv, connection *con);
70handler_t plugins_call_handle_subrequest(server *srv, connection *con);
71handler_t plugins_call_handle_request_done(server *srv, connection *con);
72handler_t plugins_call_handle_docroot(server *srv, connection *con);
73handler_t plugins_call_handle_physical(server *srv, connection *con);
74handler_t plugins_call_handle_connection_close(server *srv, connection *con);
75handler_t plugins_call_handle_joblist(server *srv, connection *con);
76handler_t plugins_call_connection_reset(server *srv, connection *con);
77
78handler_t plugins_call_handle_trigger(server *srv);
79handler_t plugins_call_handle_sighup(server *srv);
80
81handler_t plugins_call_init(server *srv);
82handler_t plugins_call_set_defaults(server *srv);
83handler_t plugins_call_cleanup(server *srv);
84
85int config_insert_values_global(server *srv, array *ca, const config_values_t *cv, config_scope_type_t scope);
86int config_insert_values_internal(server *srv, array *ca, const config_values_t *cv, config_scope_type_t scope);
87int config_setup_connection(server *srv, connection *con);
88int config_patch_connection(server *srv, connection *con, comp_key_t comp);
89int config_check_cond(server *srv, connection *con, data_config *dc);
90int config_append_cond_match_buffer(connection *con, data_config *dc, buffer *buf, int n);
91
92#endif
93