2005-02-20 14:27:00 +00:00
|
|
|
#ifndef _PLUGIN_H_
|
|
|
|
#define _PLUGIN_H_
|
2016-03-19 15:14:35 +00:00
|
|
|
#include "first.h"
|
2005-02-20 14:27:00 +00:00
|
|
|
|
2018-03-25 07:45:05 +00:00
|
|
|
#include "base_decls.h"
|
2005-02-20 14:27:00 +00:00
|
|
|
#include "buffer.h"
|
2018-03-25 07:45:05 +00:00
|
|
|
#include "array.h"
|
2019-11-21 03:25:28 +00:00
|
|
|
#include "plugin_config.h"
|
2005-02-20 14:27:00 +00:00
|
|
|
|
2019-11-28 15:27:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The status array can carry all the status information you want
|
|
|
|
* the key to the array is <module-prefix>.<name>
|
|
|
|
* and the values are counters
|
|
|
|
*
|
|
|
|
* example:
|
|
|
|
* fastcgi.backends = 10
|
|
|
|
* fastcgi.active-backends = 6
|
|
|
|
* fastcgi.backend.<key>.load = 24
|
|
|
|
* fastcgi.backend.<key>....
|
|
|
|
*
|
|
|
|
* fastcgi.backend.<key>.disconnects = ...
|
|
|
|
*/
|
|
|
|
extern array plugin_stats;
|
|
|
|
|
|
|
|
|
2005-02-20 14:27:00 +00:00
|
|
|
#define SERVER_FUNC(x) \
|
|
|
|
static handler_t x(server *srv, void *p_d)
|
|
|
|
|
|
|
|
#define CONNECTION_FUNC(x) \
|
2019-11-26 07:13:05 +00:00
|
|
|
static handler_t x(connection *con, void *p_d)
|
2005-02-20 14:27:00 +00:00
|
|
|
|
2020-01-13 02:51:12 +00:00
|
|
|
#define REQUEST_FUNC(x) \
|
|
|
|
static handler_t x(request_st *r, void *p_d)
|
|
|
|
|
2005-02-20 14:27:00 +00:00
|
|
|
#define INIT_FUNC(x) \
|
2019-02-04 04:27:57 +00:00
|
|
|
__attribute_cold__ \
|
2012-08-31 14:11:41 +00:00
|
|
|
static void *x(void)
|
2005-02-20 14:27:00 +00:00
|
|
|
|
2019-11-19 08:39:40 +00:00
|
|
|
#define FREE_FUNC(x) \
|
|
|
|
__attribute_cold__ \
|
|
|
|
static void x(void *p_d)
|
|
|
|
|
2019-02-04 04:27:57 +00:00
|
|
|
#define SETDEFAULTS_FUNC __attribute_cold__ SERVER_FUNC
|
|
|
|
#define SIGHUP_FUNC __attribute_cold__ SERVER_FUNC
|
2005-02-20 14:27:00 +00:00
|
|
|
#define TRIGGER_FUNC SERVER_FUNC
|
|
|
|
|
2020-01-13 02:51:12 +00:00
|
|
|
#define SUBREQUEST_FUNC REQUEST_FUNC
|
|
|
|
#define PHYSICALPATH_FUNC REQUEST_FUNC
|
|
|
|
#define REQUESTDONE_FUNC REQUEST_FUNC
|
|
|
|
#define URIHANDLER_FUNC REQUEST_FUNC
|
2005-02-20 14:27:00 +00:00
|
|
|
|
2019-10-23 01:16:03 +00:00
|
|
|
#define PLUGIN_DATA int id; \
|
|
|
|
int nconfig; \
|
2020-01-11 04:12:08 +00:00
|
|
|
config_plugin_value_t *cvlist; \
|
|
|
|
struct plugin *self
|
2006-10-04 13:26:23 +00:00
|
|
|
|
2019-10-22 02:49:59 +00:00
|
|
|
typedef struct {
|
|
|
|
PLUGIN_DATA;
|
|
|
|
} plugin_data_base;
|
|
|
|
|
2020-01-11 04:12:08 +00:00
|
|
|
struct plugin {
|
2019-10-19 04:30:54 +00:00
|
|
|
void *data;
|
2019-11-26 07:13:05 +00:00
|
|
|
/* is called ... */
|
2020-01-13 02:51:12 +00:00
|
|
|
handler_t (* handle_uri_raw) (request_st *r, void *p_d); /* after uri_raw is set */
|
|
|
|
handler_t (* handle_uri_clean) (request_st *r, void *p_d); /* after uri is set */
|
|
|
|
handler_t (* handle_docroot) (request_st *r, void *p_d); /* getting the document-root */
|
|
|
|
handler_t (* handle_physical) (request_st *r, void *p_d); /* mapping url to physical path */
|
|
|
|
handler_t (* handle_request_env) (request_st *r, void *p_d); /* (deferred env populate) */
|
|
|
|
handler_t (* handle_request_done) (request_st *r, void *p_d); /* at the end of a request */
|
|
|
|
handler_t (* handle_subrequest_start) (request_st *r, void *p_d); /* when handler for request not found yet */
|
|
|
|
handler_t (* handle_subrequest) (request_st *r, void *p_d); /* handler for request (max one per request) */
|
|
|
|
handler_t (* handle_response_start) (request_st *r, void *p_d); /* before response headers are written */
|
|
|
|
handler_t (* connection_reset) (request_st *r, void *p_d); /* after request done or request abort */
|
|
|
|
|
2019-11-26 07:13:05 +00:00
|
|
|
handler_t (* handle_connection_accept) (connection *con, void *p_d); /* after accept() socket */
|
|
|
|
handler_t (* handle_connection_shut_wr)(connection *con, void *p_d); /* done writing to socket */
|
|
|
|
handler_t (* handle_connection_close) (connection *con, void *p_d); /* before close() of socket */
|
|
|
|
|
|
|
|
handler_t (* handle_trigger) (server *srv, void *p_d); /* once a second */
|
|
|
|
handler_t (* handle_sighup) (server *srv, void *p_d); /* at a sighup */
|
2019-10-19 04:30:54 +00:00
|
|
|
handler_t (* handle_waitpid) (server *srv, void *p_d, pid_t pid, int status); /* upon a child process exit */
|
|
|
|
|
|
|
|
void *(* init) ();
|
|
|
|
handler_t (* priv_defaults) (server *srv, void *p_d);
|
|
|
|
handler_t (* set_defaults) (server *srv, void *p_d);
|
|
|
|
handler_t (* worker_init) (server *srv, void *p_d); /* at server startup (each worker after fork()) */
|
2019-11-19 08:39:40 +00:00
|
|
|
void (* cleanup) (void *p_d);
|
2019-10-19 04:30:54 +00:00
|
|
|
|
|
|
|
const char *name;/* name of the plugin */
|
|
|
|
size_t version;
|
|
|
|
void *lib; /* dlopen handle */
|
2020-01-11 04:12:08 +00:00
|
|
|
};
|
2005-02-20 14:27:00 +00:00
|
|
|
|
2019-02-04 04:27:57 +00:00
|
|
|
__attribute_cold__
|
2005-02-20 14:27:00 +00:00
|
|
|
int plugins_load(server *srv);
|
2019-02-04 04:27:57 +00:00
|
|
|
|
|
|
|
__attribute_cold__
|
2005-02-20 14:27:00 +00:00
|
|
|
void plugins_free(server *srv);
|
|
|
|
|
2020-01-13 02:51:12 +00:00
|
|
|
handler_t plugins_call_handle_uri_raw(request_st *r);
|
|
|
|
handler_t plugins_call_handle_uri_clean(request_st *r);
|
|
|
|
handler_t plugins_call_handle_subrequest_start(request_st *r);
|
|
|
|
handler_t plugins_call_handle_response_start(request_st *r);
|
|
|
|
handler_t plugins_call_handle_request_env(request_st *r);
|
|
|
|
handler_t plugins_call_handle_request_done(request_st *r);
|
|
|
|
handler_t plugins_call_handle_docroot(request_st *r);
|
|
|
|
handler_t plugins_call_handle_physical(request_st *r);
|
|
|
|
handler_t plugins_call_connection_reset(request_st *r);
|
|
|
|
|
2019-11-26 07:13:05 +00:00
|
|
|
handler_t plugins_call_handle_connection_accept(connection *con);
|
|
|
|
handler_t plugins_call_handle_connection_shut_wr(connection *con);
|
|
|
|
handler_t plugins_call_handle_connection_close(connection *con);
|
2005-02-20 14:27:00 +00:00
|
|
|
|
2019-11-20 01:12:31 +00:00
|
|
|
void plugins_call_handle_trigger(server *srv);
|
2017-09-10 19:28:51 +00:00
|
|
|
handler_t plugins_call_handle_waitpid(server *srv, pid_t pid, int status);
|
2005-02-20 14:27:00 +00:00
|
|
|
|
2019-02-04 04:27:57 +00:00
|
|
|
__attribute_cold__
|
2019-11-20 01:12:31 +00:00
|
|
|
void plugins_call_handle_sighup(server *srv);
|
2019-02-04 04:27:57 +00:00
|
|
|
|
|
|
|
__attribute_cold__
|
2005-02-20 14:27:00 +00:00
|
|
|
handler_t plugins_call_init(server *srv);
|
2019-02-04 04:27:57 +00:00
|
|
|
|
|
|
|
__attribute_cold__
|
2005-02-20 14:27:00 +00:00
|
|
|
handler_t plugins_call_set_defaults(server *srv);
|
2019-02-04 04:27:57 +00:00
|
|
|
|
2019-03-22 00:29:34 +00:00
|
|
|
__attribute_cold__
|
|
|
|
handler_t plugins_call_worker_init(server *srv);
|
|
|
|
|
2005-02-20 14:27:00 +00:00
|
|
|
#endif
|