Browse Source

Add plugin angel callbacks

personal/stbuehler/wip
Stefan Bühler 13 years ago
parent
commit
eeddb37e4a
  1. 11
      include/lighttpd/plugin.h
  2. 8
      include/lighttpd/server.h
  3. 4
      include/lighttpd/typedefs.h
  4. 20
      src/main/angel.c
  5. 4
      src/main/plugin.c
  6. 7
      src/main/plugin_core.c
  7. 2
      src/modules/mod_access.c
  8. 2
      src/modules/mod_accesslog.c
  9. 2
      src/modules/mod_balancer.c
  10. 2
      src/modules/mod_cache_disk_etag.c
  11. 2
      src/modules/mod_debug.c
  12. 2
      src/modules/mod_dirlist.c
  13. 2
      src/modules/mod_expire.c
  14. 2
      src/modules/mod_fastcgi.c
  15. 2
      src/modules/mod_fortune.c
  16. 2
      src/modules/mod_redirect.c
  17. 2
      src/modules/mod_rewrite.c
  18. 2
      src/modules/mod_status.c
  19. 2
      src/modules/mod_vhost.c

11
include/lighttpd/plugin.h

@ -18,6 +18,7 @@ typedef gboolean (*liPluginParseOptionCB) (liServer *srv, liPlugin *p, size_t
typedef void (*liPluginFreeOptionCB) (liServer *srv, liPlugin *p, size_t ndx, liOptionValue oval);
typedef liAction*(*liPluginCreateActionCB) (liServer *srv, liPlugin *p, liValue *val);
typedef gboolean (*liPluginSetupCB) (liServer *srv, liPlugin *p, liValue *val);
typedef void (*liPluginAngelCB) (liServer *srv, liPlugin *p, gint32 id, GString *data);
typedef void (*liPluginHandleCloseCB) (liConnection *con, liPlugin *p);
typedef liHandlerResult(*liPluginHandleVRequestCB)(liVRequest *vr, liPlugin *p);
@ -46,7 +47,8 @@ struct liPlugin {
const liPluginOption *options;
const liPluginAction *actions;
const liliPluginSetupCB *setups;
const liPluginSetup *setups;
const liPluginAngel *angelcbs;
};
struct liPluginOption {
@ -63,11 +65,16 @@ struct liPluginAction {
liPluginCreateActionCB li_create_action;
};
struct liliPluginSetupCB {
struct liPluginSetup {
const gchar *name;
liPluginSetupCB setup;
};
struct liPluginAngel {
const gchar *name;
liPluginAngelCB angel_cb;
};
/* Internal structures */
struct liServerOption {
liPlugin *p;

8
include/lighttpd/server.h

@ -42,13 +42,13 @@ struct liServer {
liModules *modules;
GHashTable *plugins; /**< const gchar* => (plugin*) */
GHashTable *plugins; /**< const gchar* => (liPlugin*) */
liPlugin *core_plugin;
/* registered by plugins */
GHashTable *options; /**< const gchar* => (server_option*) */
GHashTable *actions; /**< const gchar* => (server_action*) */
GHashTable *setups; /**< const gchar* => (server_setup*) */
GHashTable *options; /**< const gchar* => (liServerOption*) */
GHashTable *actions; /**< const gchar* => (liServerAction*) */
GHashTable *setups; /**< const gchar* => (liServerSetup*) */
GArray *li_plugins_handle_close; /** list of handle_close callbacks */
GArray *li_plugins_handle_vrclose; /** list of handle_vrclose callbacks */

4
include/lighttpd/typedefs.h

@ -130,10 +130,12 @@ typedef struct liPluginAction liPluginAction;
typedef struct liServerAction liServerAction;
typedef struct liliPluginSetupCB liliPluginSetupCB;
typedef struct liPluginSetup liPluginSetup;
typedef struct liServerSetup liServerSetup;
typedef struct liPluginAngel liPluginAngel;
/* request.h */
typedef enum {

20
src/main/angel.c

@ -6,8 +6,24 @@ static void angel_call_cb(liAngelConnection *acon,
const gchar *mod, gsize mod_len, const gchar *action, gsize action_len,
gint32 id, GString *data) {
liServer *srv = acon->data;
ERROR(srv, "received message for %s:%s, not implemented yet", mod, action);
if (-1 != id) li_angel_send_result(acon, id, g_string_new_len(CONST_STR_LEN("not implemented yet")), NULL, NULL, NULL);
liPlugin *p;
const liPluginAngel *acb;
if (NULL == (p = g_hash_table_lookup(srv->plugins, mod))) goto not_found;
if (NULL == p->angelcbs) goto not_found;
for (acb = p->angelcbs; acb->name; acb++) {
if (0 == strcmp(acb->name, action)) break;
}
if (!acb->name) goto not_found;
acb->angel_cb(srv, p, id, data);
return;
not_found:
ERROR(srv, "received message for %s:%s, couldn't find receiver", mod, action);
if (-1 != id) li_angel_send_result(acon, id, g_string_new_len(CONST_STR_LEN("receiver not found")), NULL, NULL, NULL);
}
static void angel_close_cb(liAngelConnection *acon, GError *err) {

4
src/main/plugin.c

@ -38,7 +38,7 @@ static void li_plugin_free_actions(liServer *srv, liPlugin *p) {
static void li_plugin_free_setups(liServer *srv, liPlugin *p) {
size_t i;
const liliPluginSetupCB *ps;
const liPluginSetup *ps;
liServerSetup *ss;
if (!p->setups) return;
@ -169,7 +169,7 @@ liPlugin *li_plugin_register(liServer *srv, const gchar *name, liPluginInitCB in
if (p->setups) {
size_t i;
liServerSetup *ss;
const liliPluginSetupCB *ps;
const liPluginSetup *ps;
for (i = 0; (ps = &p->setups[i])->name; i++) {
if (NULL != (ss = (liServerSetup*)g_hash_table_lookup(srv->setups, ps->name))) {

7
src/main/plugin_core.c

@ -1344,7 +1344,7 @@ static const liPluginAction actions[] = {
{ NULL, NULL }
};
static const liliPluginSetupCB setups[] = {
static const liPluginSetup setups[] = {
{ "set_default", core_setup_set },
{ "listen", core_listen },
{ "event_handler", core_event_handler },
@ -1356,6 +1356,10 @@ static const liliPluginSetupCB setups[] = {
{ NULL, NULL }
};
static const liPluginAngel angelcbs[] = {
{ NULL, NULL }
};
void plugin_core_init(liServer *srv, liPlugin *p);
void plugin_core_init(liServer *srv, liPlugin *p) {
UNUSED(srv);
@ -1363,4 +1367,5 @@ void plugin_core_init(liServer *srv, liPlugin *p) {
p->options = options;
p->actions = actions;
p->setups = setups;
p->angelcbs = angelcbs;
}

2
src/modules/mod_access.c

@ -233,7 +233,7 @@ static const liPluginAction actions[] = {
{ NULL, NULL }
};
static const liliPluginSetupCB setups[] = {
static const liPluginSetup setups[] = {
{ NULL, NULL }
};

2
src/modules/mod_accesslog.c

@ -464,7 +464,7 @@ static const liPluginAction actions[] = {
{ NULL, NULL }
};
static const liliPluginSetupCB setups[] = {
static const liPluginSetup setups[] = {
{ NULL, NULL }
};

2
src/modules/mod_balancer.c

@ -164,7 +164,7 @@ static const liPluginAction actions[] = {
{ NULL, NULL }
};
static const liliPluginSetupCB setups[] = {
static const liPluginSetup setups[] = {
{ NULL, NULL }
};

2
src/modules/mod_cache_disk_etag.c

@ -327,7 +327,7 @@ static const liPluginAction actions[] = {
{ NULL, NULL }
};
static const liliPluginSetupCB setups[] = {
static const liPluginSetup setups[] = {
{ NULL, NULL }
};

2
src/modules/mod_debug.c

@ -309,7 +309,7 @@ static const liPluginAction actions[] = {
{ NULL, NULL }
};
static const liliPluginSetupCB setups[] = {
static const liPluginSetup setups[] = {
{ NULL, NULL }
};

2
src/modules/mod_dirlist.c

@ -563,7 +563,7 @@ static const liPluginAction actions[] = {
{ NULL, NULL }
};
static const liliPluginSetupCB setups[] = {
static const liPluginSetup setups[] = {
{ NULL, NULL }
};

2
src/modules/mod_expire.c

@ -219,7 +219,7 @@ static const liPluginAction actions[] = {
{ NULL, NULL }
};
static const liliPluginSetupCB setups[] = {
static const liPluginSetup setups[] = {
{ NULL, NULL }
};

2
src/modules/mod_fastcgi.c

@ -785,7 +785,7 @@ static const liPluginAction actions[] = {
{ NULL, NULL }
};
static const liliPluginSetupCB setups[] = {
static const liPluginSetup setups[] = {
{ NULL, NULL }
};

2
src/modules/mod_fortune.c

@ -147,7 +147,7 @@ static const liPluginAction actions[] = {
{ NULL, NULL }
};
static const liliPluginSetupCB setups[] = {
static const liPluginSetup setups[] = {
{ "fortune.load", fortune_load },
{ NULL, NULL }
};

2
src/modules/mod_redirect.c

@ -518,7 +518,7 @@ static const liPluginAction actions[] = {
{ NULL, NULL }
};
static const liliPluginSetupCB setups[] = {
static const liPluginSetup setups[] = {
{ NULL, NULL }
};

2
src/modules/mod_rewrite.c

@ -493,7 +493,7 @@ static const liPluginAction actions[] = {
{ NULL, NULL }
};
static const liliPluginSetupCB setups[] = {
static const liPluginSetup setups[] = {
{ NULL, NULL }
};

2
src/modules/mod_status.c

@ -895,7 +895,7 @@ static const liPluginAction actions[] = {
{ NULL, NULL }
};
static const liliPluginSetupCB setups[] = {
static const liPluginSetup setups[] = {
{ NULL, NULL }
};

2
src/modules/mod_vhost.c

@ -700,7 +700,7 @@ static const liPluginAction actions[] = {
{ NULL, NULL }
};
static const liliPluginSetupCB setups[] = {
static const liPluginSetup setups[] = {
{ NULL, NULL }
};

Loading…
Cancel
Save