xref: /lighttpd1.4/src/plugin.h (revision 9030cfae)
1 #ifndef _PLUGIN_H_
2 #define _PLUGIN_H_
3 #include "first.h"
4 
5 #include "base.h"
6 #include "buffer.h"
7 
8 #define SERVER_FUNC(x) \
9 		static handler_t x(server *srv, void *p_d)
10 
11 #define CONNECTION_FUNC(x) \
12 		static handler_t x(server *srv, connection *con, void *p_d)
13 
14 #define INIT_FUNC(x) \
15 		static void *x(void)
16 
17 #define FREE_FUNC          SERVER_FUNC
18 #define TRIGGER_FUNC       SERVER_FUNC
19 #define SETDEFAULTS_FUNC   SERVER_FUNC
20 #define SIGHUP_FUNC        SERVER_FUNC
21 
22 #define SUBREQUEST_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 
29 typedef struct {
30 	size_t version;
31 
32 	buffer *name; /* name of the plugin */
33 
34 	void *(* init)                       ();
35 	handler_t (* priv_defaults)          (server *srv, void *p_d);
36 	handler_t (* set_defaults)           (server *srv, void *p_d);
37 	handler_t (* cleanup)                (server *srv, void *p_d);
38 	                                                                                   /* is called ... */
39 	handler_t (* handle_trigger)         (server *srv, void *p_d);                     /* once a second */
40 	handler_t (* handle_sighup)          (server *srv, void *p_d);                     /* at a sighup */
41 	handler_t (* handle_waitpid)         (server *srv, void *p_d, pid_t pid, int status); /* upon a child process exit */
42 
43 	handler_t (* handle_uri_raw)         (server *srv, connection *con, void *p_d);    /* after uri_raw is set */
44 	handler_t (* handle_uri_clean)       (server *srv, connection *con, void *p_d);    /* after uri is set */
45 	handler_t (* handle_docroot)         (server *srv, connection *con, void *p_d);    /* getting the document-root */
46 	handler_t (* handle_physical)        (server *srv, connection *con, void *p_d);    /* mapping url to physical path */
47 	handler_t (* handle_request_env)     (server *srv, connection *con, void *p_d);    /* (deferred env populate) */
48 	handler_t (* handle_request_done)    (server *srv, connection *con, void *p_d);    /* at the end of a request */
49 	handler_t (* handle_connection_accept) (server *srv, connection *con, void *p_d);  /* after accept() socket */
50 	handler_t (* handle_connection_shut_wr)(server *srv, connection *con, void *p_d);  /* done writing to socket */
51 	handler_t (* handle_connection_close)  (server *srv, connection *con, void *p_d);  /* before close() of socket */
52 
53 
54 
55 	handler_t (* handle_subrequest_start)(server *srv, connection *con, void *p_d);
56 
57 	                                                                                   /* when a handler for the request
58 											    * has to be found
59 											    */
60 	handler_t (* handle_subrequest)      (server *srv, connection *con, void *p_d);    /* */
61 	handler_t (* handle_response_start)  (server *srv, connection *con, void *p_d);    /* before response headers are written */
62 	handler_t (* connection_reset)       (server *srv, connection *con, void *p_d);    /* after request done or request abort */
63 	void *data;
64 
65 	/* dlopen handle */
66 	void *lib;
67 } plugin;
68 
69 int plugins_load(server *srv);
70 void plugins_free(server *srv);
71 
72 handler_t plugins_call_handle_uri_raw(server *srv, connection *con);
73 handler_t plugins_call_handle_uri_clean(server *srv, connection *con);
74 handler_t plugins_call_handle_subrequest_start(server *srv, connection *con);
75 handler_t plugins_call_handle_subrequest(server *srv, connection *con);
76 handler_t plugins_call_handle_response_start(server *srv, connection *con);
77 handler_t plugins_call_handle_request_env(server *srv, connection *con);
78 handler_t plugins_call_handle_request_done(server *srv, connection *con);
79 handler_t plugins_call_handle_docroot(server *srv, connection *con);
80 handler_t plugins_call_handle_physical(server *srv, connection *con);
81 handler_t plugins_call_handle_connection_accept(server *srv, connection *con);
82 handler_t plugins_call_handle_connection_shut_wr(server *srv, connection *con);
83 handler_t plugins_call_handle_connection_close(server *srv, connection *con);
84 handler_t plugins_call_connection_reset(server *srv, connection *con);
85 
86 handler_t plugins_call_handle_trigger(server *srv);
87 handler_t plugins_call_handle_sighup(server *srv);
88 handler_t plugins_call_handle_waitpid(server *srv, pid_t pid, int status);
89 
90 handler_t plugins_call_init(server *srv);
91 handler_t plugins_call_set_defaults(server *srv);
92 handler_t plugins_call_cleanup(server *srv);
93 
94 int config_insert_values_global(server *srv, array *ca, const config_values_t *cv, config_scope_type_t scope);
95 int config_insert_values_internal(server *srv, array *ca, const config_values_t *cv, config_scope_type_t scope);
96 int config_check_cond(server *srv, connection *con, data_config *dc);
97 int config_append_cond_match_buffer(connection *con, data_config *dc, buffer *buf, int n);
98 
99 #endif
100