--- embedaddon/lighttpd/src/mod_skeleton.c 2014/06/15 20:20:06 1.1.1.2 +++ embedaddon/lighttpd/src/mod_skeleton.c 2016/11/02 10:35:00 1.1.1.3 @@ -1,3 +1,5 @@ +#include "first.h" + #include "base.h" #include "log.h" #include "buffer.h" @@ -11,7 +13,7 @@ /** * this is a skeleton for a lighttpd plugin * - * just replaces every occurance of 'skeleton' by your plugin name + * just replaces every occurrence of 'skeleton' by your plugin name * * e.g. in vim: * @@ -65,7 +67,7 @@ INIT_FUNC(mod_skeleton_init) { return p; } -/* detroy the plugin data */ +/* destroy the plugin data */ FREE_FUNC(mod_skeleton_free) { plugin_data *p = p_d; @@ -79,7 +81,7 @@ FREE_FUNC(mod_skeleton_free) { for (i = 0; i < srv->config_context->used; i++) { plugin_config *s = p->config_storage[i]; - if (!s) continue; + if (NULL == s) continue; array_free(s->match); @@ -111,6 +113,7 @@ SETDEFAULTS_FUNC(mod_skeleton_set_defaults) { p->config_storage = calloc(1, srv->config_context->used * sizeof(plugin_config *)); for (i = 0; i < srv->config_context->used; i++) { + data_config const* config = (data_config const*)srv->config_context->data[i]; plugin_config *s; s = calloc(1, sizeof(plugin_config)); @@ -120,7 +123,7 @@ SETDEFAULTS_FUNC(mod_skeleton_set_defaults) { p->config_storage[i] = s; - if (0 != config_insert_values_global(srv, ((data_config *)srv->config_context->data[i])->value, cv)) { + if (0 != config_insert_values_global(srv, config->value, cv, i == 0 ? T_CONFIG_SCOPE_SERVER : T_CONFIG_SCOPE_CONNECTION)) { return HANDLER_ERROR; } } @@ -160,25 +163,24 @@ static int mod_skeleton_patch_connection(server *srv, URIHANDLER_FUNC(mod_skeleton_uri_handler) { plugin_data *p = p_d; - int s_len; - size_t k, i; + size_t s_len; + size_t k; UNUSED(srv); if (con->mode != DIRECT) return HANDLER_GO_ON; - if (con->uri.path->used == 0) return HANDLER_GO_ON; + s_len = buffer_string_length(con->uri.path); + if (0 == s_len) return HANDLER_GO_ON; mod_skeleton_patch_connection(srv, con, p); - s_len = con->uri.path->used - 1; - for (k = 0; k < p->conf.match->used; k++) { data_string *ds = (data_string *)p->conf.match->data[k]; - int ct_len = ds->value->used - 1; + size_t ct_len = buffer_string_length(ds->value); if (ct_len > s_len) continue; - if (ds->value->used == 0) continue; + if (ct_len == 0) continue; if (0 == strncmp(con->uri.path->ptr + s_len - ct_len, ds->value->ptr, ct_len)) { con->http_status = 403;