xref: /lighttpd1.4/src/plugin.h (revision 6516c5a2)
1bcdc6a3bSJan Kneschke #ifndef _PLUGIN_H_
2bcdc6a3bSJan Kneschke #define _PLUGIN_H_
38abd06a7SGlenn Strauss #include "first.h"
4bcdc6a3bSJan Kneschke 
504d76e7aSGlenn Strauss #include "base_decls.h"
65977ce2bSGlenn Strauss #include "plugin_config.h"
7bcdc6a3bSJan Kneschke 
8f24e6d69SGlenn Strauss 
9bcdc6a3bSJan Kneschke #define SERVER_FUNC(x) \
10bcdc6a3bSJan Kneschke 		static handler_t x(server *srv, void *p_d)
11bcdc6a3bSJan Kneschke 
12bcdc6a3bSJan Kneschke #define CONNECTION_FUNC(x) \
1350bdb55dSGlenn Strauss 		static handler_t x(connection *con, void *p_d)
14bcdc6a3bSJan Kneschke 
157c7f8c46SGlenn Strauss #define REQUEST_FUNC(x) \
167c7f8c46SGlenn Strauss 		static handler_t x(request_st *r, void *p_d)
177c7f8c46SGlenn Strauss 
18bcdc6a3bSJan Kneschke #define INIT_FUNC(x) \
19fb9b8ad8SGlenn Strauss 		__attribute_cold__ \
200c6a5645SCyril Brulebois 		static void *x(void)
21bcdc6a3bSJan Kneschke 
22b73949e0SGlenn Strauss #define FREE_FUNC(x) \
23b73949e0SGlenn Strauss 		__attribute_cold__ \
24b73949e0SGlenn Strauss 		static void x(void *p_d)
25b73949e0SGlenn Strauss 
26fb9b8ad8SGlenn Strauss #define SETDEFAULTS_FUNC   __attribute_cold__ SERVER_FUNC
27fb9b8ad8SGlenn Strauss #define SIGHUP_FUNC        __attribute_cold__ SERVER_FUNC
28bcdc6a3bSJan Kneschke #define TRIGGER_FUNC       SERVER_FUNC
29bcdc6a3bSJan Kneschke 
307c7f8c46SGlenn Strauss #define SUBREQUEST_FUNC    REQUEST_FUNC
317c7f8c46SGlenn Strauss #define PHYSICALPATH_FUNC  REQUEST_FUNC
327c7f8c46SGlenn Strauss #define REQUESTDONE_FUNC   REQUEST_FUNC
337c7f8c46SGlenn Strauss #define URIHANDLER_FUNC    REQUEST_FUNC
34bcdc6a3bSJan Kneschke 
35b87e8783SGlenn Strauss #define PLUGIN_DATA        int id; \
36b87e8783SGlenn Strauss                            int nconfig; \
37eea7cd3cSGlenn Strauss                            config_plugin_value_t *cvlist; \
38eea7cd3cSGlenn Strauss                            struct plugin *self
39bcdc6a3bSJan Kneschke 
40bcdc6a3bSJan Kneschke typedef struct {
41b2b41e36SGlenn Strauss 	PLUGIN_DATA;
42b2b41e36SGlenn Strauss } plugin_data_base;
43b2b41e36SGlenn Strauss 
44eea7cd3cSGlenn Strauss struct plugin {
45e2de4e58SGlenn Strauss 	void *data;
46bcdc6a3bSJan Kneschke 	                                                                      /* is called ... */
477c7f8c46SGlenn Strauss 	handler_t (* handle_uri_raw)           (request_st *r, void *p_d);  /* after uri_raw is set */
487c7f8c46SGlenn Strauss 	handler_t (* handle_uri_clean)         (request_st *r, void *p_d);  /* after uri is set */
497c7f8c46SGlenn Strauss 	handler_t (* handle_docroot)           (request_st *r, void *p_d);  /* getting the document-root */
507c7f8c46SGlenn Strauss 	handler_t (* handle_physical)          (request_st *r, void *p_d);  /* mapping url to physical path */
517c7f8c46SGlenn Strauss 	handler_t (* handle_request_env)       (request_st *r, void *p_d);  /* (deferred env populate) */
527c7f8c46SGlenn Strauss 	handler_t (* handle_request_done)      (request_st *r, void *p_d);  /* at the end of a request */
537c7f8c46SGlenn Strauss 	handler_t (* handle_subrequest_start)  (request_st *r, void *p_d);  /* when handler for request not found yet */
547c7f8c46SGlenn Strauss 	handler_t (* handle_subrequest)        (request_st *r, void *p_d);  /* handler for request (max one per request) */
557c7f8c46SGlenn Strauss 	handler_t (* handle_response_start)    (request_st *r, void *p_d);  /* before response headers are written */
5633c8cf41SGlenn Strauss 	handler_t (* handle_request_reset)     (request_st *r, void *p_d);  /* after request done or request abort */
577c7f8c46SGlenn Strauss 
5850bdb55dSGlenn Strauss 	handler_t (* handle_connection_accept) (connection *con, void *p_d);  /* after accept() socket */
5950bdb55dSGlenn Strauss 	handler_t (* handle_connection_shut_wr)(connection *con, void *p_d);  /* done writing to socket */
6050bdb55dSGlenn Strauss 	handler_t (* handle_connection_close)  (connection *con, void *p_d);  /* before close() of socket */
61bcdc6a3bSJan Kneschke 
62e2de4e58SGlenn Strauss 	handler_t (* handle_trigger)         (server *srv, void *p_d);        /* once a second */
63e2de4e58SGlenn Strauss 	handler_t (* handle_sighup)          (server *srv, void *p_d);        /* at a sighup */
64e2de4e58SGlenn Strauss 	handler_t (* handle_waitpid)         (server *srv, void *p_d, pid_t pid, int status); /* upon a child process exit */
65e2de4e58SGlenn Strauss 
66*6516c5a2SGlenn Strauss 	void *(* init)                       (void);
67e2de4e58SGlenn Strauss 	handler_t (* priv_defaults)          (server *srv, void *p_d);
68e2de4e58SGlenn Strauss 	handler_t (* set_defaults)           (server *srv, void *p_d);
69e2de4e58SGlenn Strauss 	handler_t (* worker_init)            (server *srv, void *p_d); /* at server startup (each worker after fork()) */
70b73949e0SGlenn Strauss 	void (* cleanup)                     (void *p_d);
71e2de4e58SGlenn Strauss 
72e2de4e58SGlenn Strauss 	const char *name;/* name of the plugin */
73e2de4e58SGlenn Strauss 	size_t version;
74e2de4e58SGlenn Strauss 	void *lib;       /* dlopen handle */
75eea7cd3cSGlenn Strauss };
76bcdc6a3bSJan Kneschke 
77bcdc6a3bSJan Kneschke #endif
78