2008-06-28 18:37:28 +00:00
|
|
|
#ifndef _LIGHTTPD_PLUGIN_H_
|
|
|
|
#define _LIGHTTPD_PLUGIN_H_
|
2008-06-24 19:19:20 +00:00
|
|
|
|
|
|
|
struct plugin;
|
|
|
|
typedef struct plugin plugin;
|
|
|
|
|
|
|
|
struct module_option;
|
|
|
|
typedef struct module_option module_option;
|
|
|
|
|
2008-06-28 18:37:28 +00:00
|
|
|
struct server_option;
|
|
|
|
typedef struct server_option server_option;
|
|
|
|
|
2008-06-24 19:19:20 +00:00
|
|
|
#define INIT_FUNC(x) \
|
|
|
|
LI_EXPORT void * x(server *srv, plugin *)
|
|
|
|
|
|
|
|
#define PLUGIN_DATA \
|
|
|
|
size_t id; \
|
|
|
|
ssize_t option_base_ndx
|
|
|
|
|
2008-06-28 18:37:28 +00:00
|
|
|
#include "base.h"
|
|
|
|
#include "options.h"
|
|
|
|
|
2008-07-08 19:29:02 +00:00
|
|
|
typedef void (*ModuleInit) (server *srv, plugin *p);
|
|
|
|
typedef void (*ModuleFree) (server *srv, plugin *p);
|
|
|
|
typedef gboolean (*ModuleParseOption) (server *srv, gpointer p_d, size_t ndx, option *opt, gpointer *value);
|
|
|
|
typedef void (*ModuleFreeOption) (server *srv, gpointer p_d, size_t ndx, gpointer value);
|
|
|
|
|
|
|
|
struct module {
|
|
|
|
GString *name;
|
|
|
|
|
|
|
|
GModule *lib;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-06-24 19:19:20 +00:00
|
|
|
struct plugin {
|
|
|
|
size_t version;
|
|
|
|
|
|
|
|
GString *name; /* name of the plugin */
|
|
|
|
|
|
|
|
gpointer data;
|
|
|
|
|
2008-07-08 19:29:02 +00:00
|
|
|
ModuleFree *free;
|
2008-06-24 19:19:20 +00:00
|
|
|
|
|
|
|
module_option *options;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct module_option {
|
|
|
|
const char *key;
|
|
|
|
option_type type;
|
2008-07-08 19:29:02 +00:00
|
|
|
|
|
|
|
ModuleParseOption parse_option;
|
|
|
|
ModuleFreeOption free_option;
|
2008-06-24 19:19:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct server_option {
|
|
|
|
plugin *p;
|
2008-06-28 18:37:28 +00:00
|
|
|
|
|
|
|
/* the plugin must free the _content_ of the option
|
|
|
|
* opt is zero to get the global default value if nothing is specified
|
|
|
|
* save result in value
|
2008-07-08 19:29:02 +00:00
|
|
|
*
|
|
|
|
* Default behaviour (NULL) is to just use the option as value
|
2008-06-28 18:37:28 +00:00
|
|
|
*/
|
2008-07-08 19:29:02 +00:00
|
|
|
ModuleParseOption parse_option;
|
|
|
|
ModuleFreeOption free_option;
|
2008-06-28 18:37:28 +00:00
|
|
|
|
2008-06-24 19:19:20 +00:00
|
|
|
size_t index, module_index;
|
|
|
|
option_type type;
|
|
|
|
};
|
|
|
|
|
2008-07-08 19:29:02 +00:00
|
|
|
LI_API gboolean plugin_register(server *srv, ModuleInit *init);
|
|
|
|
|
|
|
|
LI_API gboolean parse_option(server *srv, const char *key, option *opt, option_set *mark);
|
|
|
|
LI_API void release_option(server *srv, option_set *mark); /** Does not free the option_set memory */
|
|
|
|
|
|
|
|
LI_API gboolean plugin_load(server *srv, const char *module);
|
2008-06-28 18:37:28 +00:00
|
|
|
|
2008-06-24 19:19:20 +00:00
|
|
|
#endif
|