--- embedaddon/lighttpd/src/mod_evhost.c 2014/06/15 20:20:06 1.1.1.2 +++ embedaddon/lighttpd/src/mod_evhost.c 2016/11/02 10:35:00 1.1.1.3 @@ -1,3 +1,5 @@ +#include "first.h" + #include "plugin.h" #include "log.h" #include "response.h" @@ -46,7 +48,7 @@ FREE_FUNC(mod_evhost_free) { for (i = 0; i < srv->config_context->used; i++) { plugin_config *s = p->config_storage[i]; - if (!s) continue; + if (NULL == s) continue; if(s->path_pieces) { size_t j; @@ -131,6 +133,7 @@ SETDEFAULTS_FUNC(mod_evhost_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)); @@ -142,11 +145,11 @@ SETDEFAULTS_FUNC(mod_evhost_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; } - if (s->path_pieces_raw->used != 0) { + if (!buffer_string_is_empty(s->path_pieces_raw)) { mod_evhost_parse_pattern(s); } } @@ -164,8 +167,7 @@ SETDEFAULTS_FUNC(mod_evhost_set_defaults) { */ static int mod_evhost_parse_host(connection *con,array *host) { - /* con->uri.authority->used is always > 0 if we come here */ - register char *ptr = con->uri.authority->ptr + con->uri.authority->used - 1; + register char *ptr = con->uri.authority->ptr + buffer_string_length(con->uri.authority); char *colon = ptr; /* needed to filter out the colon (if exists) */ int first = 1; data_string *ds; @@ -200,7 +202,7 @@ static int mod_evhost_parse_host(connection *con,array /* is something between the dots */ ds = data_string_init(); buffer_copy_string_len(ds->key,CONST_STR_LEN("%")); - buffer_append_long(ds->key, i++); + buffer_append_int(ds->key, i++); buffer_copy_string_len(ds->value,ptr+1,colon-ptr-1); array_insert_unique(host,(data_unset *)ds); @@ -213,7 +215,7 @@ static int mod_evhost_parse_host(connection *con,array if (colon != ptr) { ds = data_string_init(); buffer_copy_string_len(ds->key,CONST_STR_LEN("%")); - buffer_append_long(ds->key, i /* ++ */); + buffer_append_int(ds->key, i /* ++ */); buffer_copy_string_len(ds->value,ptr,colon-ptr); array_insert_unique(host,(data_unset *)ds); @@ -265,7 +267,7 @@ static handler_t mod_evhost_uri_handler(server *srv, c stat_cache_entry *sce = NULL; /* not authority set */ - if (con->uri.authority->used == 0) return HANDLER_GO_ON; + if (buffer_string_is_empty(con->uri.authority)) return HANDLER_GO_ON; mod_evhost_patch_connection(srv, con, p); @@ -300,9 +302,7 @@ static handler_t mod_evhost_uri_handler(server *srv, c buffer_append_string_len(p->tmp_buf, con->uri.authority->ptr, colon - con->uri.authority->ptr); /* adds fqdn */ } } else if (NULL != (ds = (data_string *)array_get_element(parsed_host,p->conf.path_pieces[i]->ptr))) { - if (ds->value->used) { - buffer_append_string_buffer(p->tmp_buf,ds->value); - } + buffer_append_string_buffer(p->tmp_buf,ds->value); } else { /* unhandled %-sequence */ } @@ -311,7 +311,7 @@ static handler_t mod_evhost_uri_handler(server *srv, c } } - BUFFER_APPEND_SLASH(p->tmp_buf); + buffer_append_slash(p->tmp_buf); array_free(parsed_host); @@ -324,7 +324,7 @@ static handler_t mod_evhost_uri_handler(server *srv, c } if (!not_good) { - buffer_copy_string_buffer(con->physical.doc_root, p->tmp_buf); + buffer_copy_buffer(con->physical.doc_root, p->tmp_buf); } return HANDLER_GO_ON;