2
0
Fork 0

Prefix li_ cleanup, verified with nm -g --defined-only

personal/stbuehler/wip
Stefan Bühler 2009-10-09 15:38:12 +02:00
parent c735d9a4b6
commit a151eeac2f
55 changed files with 397 additions and 431 deletions

View File

@ -4,10 +4,10 @@
#include <lighttpd/base.h>
#include <lua.h>
LI_API liAction* lua_get_action(lua_State *L, int ndx);
LI_API int lua_push_action(liServer *srv, lua_State *L, liAction *a);
LI_API liAction* li_lua_get_action(lua_State *L, int ndx);
LI_API int li_lua_push_action(liServer *srv, lua_State *L, liAction *a);
/* create new action from lua function */
LI_API liAction* lua_make_action(lua_State *L, int ndx);
LI_API liAction* li_lua_make_action(lua_State *L, int ndx);
#endif

View File

@ -14,7 +14,7 @@ LI_API void li_angel_log(liServer *srv, GString *str);
/* angle_fake definitions, only for internal use */
int angel_fake_listen(liServer *srv, GString *str);
gboolean angel_fake_log(liServer *srv, GString *str);
int li_angel_fake_listen(liServer *srv, GString *str);
gboolean li_angel_fake_log(liServer *srv, GString *str);
#endif

View File

@ -71,8 +71,8 @@ struct liLog {
GString *log_line;
};
void log_init(liServer *srv);
void log_clean(liServer *srv);
LI_API void li_log_init(liServer *srv);
LI_API void li_log_clean(liServer *srv);
LI_API void li_log_write(liServer *srv, liLogLevel log_level, guint flags, const gchar *fmt, ...) G_GNUC_PRINTF(4, 5);

View File

@ -66,16 +66,16 @@ struct liPlugins {
GPtrArray *plugins, *load_plugins; /* plugin* */
};
void plugins_init(liServer *srv, const gchar *module_dir);
void plugins_clear(liServer *srv);
LI_API void li_plugins_init(liServer *srv, const gchar *module_dir);
LI_API void li_plugins_clear(liServer *srv);
void plugins_config_clean(liServer *srv);
gboolean plugins_config_load(liServer *srv, const gchar *filename);
LI_API void li_plugins_config_clean(liServer *srv);
LI_API gboolean li_plugins_config_load(liServer *srv, const gchar *filename);
void plugins_handle_item(liServer *srv, GString *itemname, liValue *hash);
LI_API void li_plugins_handle_item(liServer *srv, GString *itemname, liValue *hash);
/* "core" is a reserved module name for interal use */
gboolean plugins_load_module(liServer *srv, const gchar *name);
LI_API gboolean li_plugins_load_module(liServer *srv, const gchar *name);
/* Needed by modules to register their plugin(s) */
LI_API liPlugin *li_angel_plugin_register(liServer *srv, liModule *mod, const gchar *name, liPluginInitCB init);

View File

@ -41,6 +41,6 @@ struct liPluginCoreListenMask {
} value;
};
gboolean plugin_core_init(liServer *srv);
LI_API gboolean li_plugin_core_init(liServer *srv);
#endif

View File

@ -4,9 +4,9 @@
#include <lighttpd/base.h>
#include <lua.h>
LI_API liCondition* lua_get_condition(lua_State *L, int ndx);
LI_API int lua_push_condition(liServer *srv, lua_State *L, liCondition *c);
LI_API liCondition* li_lua_get_condition(lua_State *L, int ndx);
LI_API int li_lua_push_condition(liServer *srv, lua_State *L, liCondition *c);
LI_API void lua_push_lvalues_dict(liServer *srv, lua_State *L);
LI_API void li_lua_push_lvalues_dict(liServer *srv, lua_State *L);
#endif

View File

@ -5,21 +5,6 @@
typedef struct liConfigParserContext liConfigParserContext;
/* returns a new config parser stack with the first context in it */
GList *config_parser_init(liServer *srv);
void config_parser_finish(liServer *srv, GList *ctx_stack, gboolean free_all);
/* loads a file into memory and parses it */
gboolean config_parser_file(liServer *srv, GList *ctx_stack, const gchar *path);
/* launched a command through the shell and parses the stdout it returns */
gboolean config_parser_shell(liServer *srv,GList *ctx_stack, const gchar *command);
/* parses a buffer pointed to by the previously allocated config_parser_data struct */
gboolean config_parser_buffer(liServer *srv, GList *ctx_stack);
liConfigParserContext *config_parser_context_new(liServer *srv, GList *ctx_stack);
void config_parser_context_free(liServer *srv, liConfigParserContext *ctx, gboolean free_queues);
typedef enum {
LI_CFG_PARSER_CAST_NONE,
LI_CFG_PARSER_CAST_INT,
@ -61,4 +46,11 @@ struct liConfigParserContext {
gsize line; /* holds current line */
};
/* returns a new config parser stack with the first context in it */
LI_API GList* li_config_parser_init(liServer *srv);
LI_API void li_config_parser_finish(liServer *srv, GList *ctx_stack, gboolean free_all);
/* loads a file into memory and parses it */
LI_API gboolean li_config_parser_file(liServer *srv, GList *ctx_stack, const gchar *path);
#endif

View File

@ -7,46 +7,46 @@
#define li_lua_lock(srv) g_mutex_lock((srv)->lualock);
#define li_lua_unlock(srv) g_mutex_unlock((srv)->lualock);
LI_API void lua_init_chunk_mt(lua_State *L);
LI_API liChunk* lua_get_chunk(lua_State *L, int ndx);
LI_API int lua_push_chunk(lua_State *L, liChunk *c);
LI_API liChunkQueue* lua_get_chunkqueue(lua_State *L, int ndx);
LI_API int lua_push_chunkqueue(lua_State *L, liChunkQueue *cq);
LI_API void li_lua_init_chunk_mt(lua_State *L);
LI_API liChunk* li_lua_get_chunk(lua_State *L, int ndx);
LI_API int li_lua_push_chunk(lua_State *L, liChunk *c);
LI_API liChunkQueue* li_lua_get_chunkqueue(lua_State *L, int ndx);
LI_API int li_lua_push_chunkqueue(lua_State *L, liChunkQueue *cq);
LI_API void lua_init_connection_mt(lua_State *L);
LI_API liConnection* lua_get_connection(lua_State *L, int ndx);
LI_API int lua_push_connection(lua_State *L, liConnection *con);
LI_API void li_lua_init_connection_mt(lua_State *L);
LI_API liConnection* li_lua_get_connection(lua_State *L, int ndx);
LI_API int li_lua_push_connection(lua_State *L, liConnection *con);
LI_API void lua_init_environment_mt(lua_State *L);
LI_API liEnvironment* lua_get_environment(lua_State *L, int ndx);
LI_API int lua_push_environment(lua_State *L, liEnvironment *env);
LI_API void li_lua_init_environment_mt(lua_State *L);
LI_API liEnvironment* li_lua_get_environment(lua_State *L, int ndx);
LI_API int li_lua_push_environment(lua_State *L, liEnvironment *env);
LI_API void lua_init_http_headers_mt(lua_State *L);
LI_API liHttpHeaders* lua_get_http_headers(lua_State *L, int ndx);
LI_API int lua_push_http_headers(lua_State *L, liHttpHeaders *headers);
LI_API void li_lua_init_http_headers_mt(lua_State *L);
LI_API liHttpHeaders* li_lua_get_http_headers(lua_State *L, int ndx);
LI_API int li_lua_push_http_headers(lua_State *L, liHttpHeaders *headers);
LI_API void lua_init_physical_mt(lua_State *L);
LI_API liPhysical* lua_get_physical(lua_State *L, int ndx);
LI_API int lua_push_physical(lua_State *L, liPhysical *phys);
LI_API void li_lua_init_physical_mt(lua_State *L);
LI_API liPhysical* li_lua_get_physical(lua_State *L, int ndx);
LI_API int li_lua_push_physical(lua_State *L, liPhysical *phys);
LI_API void lua_init_request_mt(lua_State *L);
LI_API liRequest* lua_get_request(lua_State *L, int ndx);
LI_API int lua_push_request(lua_State *L, liRequest *req);
LI_API void li_lua_init_request_mt(lua_State *L);
LI_API liRequest* li_lua_get_request(lua_State *L, int ndx);
LI_API int li_lua_push_request(lua_State *L, liRequest *req);
LI_API liRequestUri* lua_get_requesturi(lua_State *L, int ndx);
LI_API int lua_push_requesturi(lua_State *L, liRequestUri *uri);
LI_API liRequestUri* li_lua_get_requesturi(lua_State *L, int ndx);
LI_API int li_lua_push_requesturi(lua_State *L, liRequestUri *uri);
LI_API void lua_init_response_mt(lua_State *L);
LI_API liResponse* lua_get_response(lua_State *L, int ndx);
LI_API int lua_push_response(lua_State *L, liResponse *resp);
LI_API void li_lua_init_response_mt(lua_State *L);
LI_API liResponse* li_lua_get_response(lua_State *L, int ndx);
LI_API int li_lua_push_response(lua_State *L, liResponse *resp);
LI_API void li_lua_init_stat_mt(lua_State *L);
LI_API struct stat* li_lua_get_stat(lua_State *L, int ndx);
LI_API int li_lua_push_stat(lua_State *L, struct stat *st);
LI_API void lua_init_vrequest_mt(lua_State *L);
LI_API liVRequest* lua_get_vrequest(lua_State *L, int ndx);
LI_API int lua_push_vrequest(lua_State *L, liVRequest *vr);
LI_API void li_lua_init_vrequest_mt(lua_State *L);
LI_API liVRequest* li_lua_get_vrequest(lua_State *L, int ndx);
LI_API int li_lua_push_vrequest(lua_State *L, liVRequest *vr);
/* return 1 if value is found in mt (on top of the stack), 0 if it is not found (stack balance = 0)
* table, key on stack at pos 0 and 1 (i.e. __index metho)
@ -61,7 +61,7 @@ LI_API void li_lua_restore_globals(lua_State *L);
LI_API void li_lua_new_globals(lua_State *L);
/* joinWith " " (map tostring parameter[from..to]) */
LI_API GString* lua_print_get_string(lua_State *L, int from, int to);
LI_API GString* li_lua_print_get_string(lua_State *L, int from, int to);
/* pairs() for a GHashTable GString -> GString:
* Don't modify the hastable while iterating:

View File

@ -5,11 +5,14 @@
#error Please include <lighttpd/base.h> instead of this file
#endif
#define HEADER_VALUE(h) \
(&(h)->data->str[h->keylen + 2])
#define LI_HEADER_VALUE(h) \
(&(h)->data->str[(h)->keylen + 2])
#define HEADER_VALUE_LEN(h) \
(&(h)->data->str[h->keylen + 2]), ((h)->data->len - (h->keylen + 2))
#define LI_HEADER_VALUE_LEN(h) \
(&(h)->data->str[(h)->keylen + 2]), ((h)->data->len - ((h)->keylen + 2))
#define LI_HEADER_KEY_LEN(h) \
((h)->data->str), ((h)->keylen)
struct liHttpHeader {
guint keylen; /** length of "headername" in data */
@ -52,7 +55,7 @@ LI_API gboolean li_http_header_is(liHttpHeaders *headers, const gchar *key, size
/** concats all headers with key with ', ' - empty if no header exists */
LI_API void li_http_header_get_all(GString *dest, liHttpHeaders *headers, const gchar *key, size_t keylen);
INLINE gboolean http_header_key_is(liHttpHeader *h, const gchar *key, size_t keylen) {
INLINE gboolean li_http_header_key_is(liHttpHeader *h, const gchar *key, size_t keylen) {
return (h->keylen == keylen && 0 == g_ascii_strncasecmp(key, h->data->str, keylen));
}

View File

@ -83,36 +83,22 @@ struct liLogEntry {
};
/* determines the type of a log target by the path given. /absolute/path = file; |app = pipe; stderr = stderr; syslog = syslog */
liLogType log_type_from_path(GString *path);
LI_API liLogType li_log_type_from_path(GString *path);
liLogLevel log_level_from_string(GString *str);
gchar* log_level_str(liLogLevel log_level);
LI_API liLogLevel li_log_level_from_string(GString *str);
LI_API gchar* li_log_level_str(liLogLevel log_level);
/* log_new is used to create a new log target, if a log with the same path already exists, it is referenced instead */
liLog *log_new(liServer *srv, liLogType type, GString *path);
/* avoid calling log_free directly. instead use log_unref which calls log_free if refcount has reached zero */
void log_free(liServer *srv, liLog *log);
void log_free_unlocked(liServer *srv, liLog *log);
LI_API liLog *li_log_new(liServer *srv, liLogType type, GString *path);
void log_ref(liServer *srv, liLog *log);
void log_unref(liServer *srv, liLog *log);
LI_API void li_log_ref(liServer *srv, liLog *log);
LI_API void li_log_unref(liServer *srv, liLog *log);
void log_lock(liLog *log);
void log_unlock(liLog *log);
LI_API void li_log_thread_start(liServer *srv);
LI_API void li_log_thread_wakeup(liServer *srv);
/* do not call directly, use log_rotate_logs instead */
void log_rotate(gchar *path, liLog *log, liServer *srv);
void log_rotate_logs(liServer *srv);
gpointer log_thread(liServer *srv);
void log_thread_start(liServer *srv);
void log_thread_stop(liServer *srv);
void log_thread_finish(liServer *srv);
void log_thread_wakeup(liServer *srv);
void log_init(liServer *srv);
void log_cleanup(liServer *srv);
LI_API void li_log_init(liServer *srv);
LI_API void li_log_cleanup(liServer *srv);
/* li_log_write is used to directly write a message to a log target */
LI_API void li_log_write(liServer *srv, liLog *log, GString *msg);

View File

@ -30,4 +30,6 @@ enum liCoreOptions {
#define CORE_OPTION(idx) _CORE_OPTION(vr, idx)
#define _CORE_OPTION(vr, idx) _OPTION_ABS(vr, idx)
LI_API void li_plugin_core_init(liServer *srv, liPlugin *p);
#endif

View File

@ -15,9 +15,9 @@ struct liProfilerMem {
guint64 free_bytes;
};
void profiler_enable(); /* enables the profiler */
void profiler_finish();
void profiler_dump(); /* dumps memory statistics to stdout */
void profiler_dump_table();
LI_API void li_profiler_enable(); /* enables the profiler */
LI_API void li_profiler_finish();
LI_API void li_profiler_dump(); /* dumps memory statistics to stdout */
LI_API void li_profiler_dump_table();
#endif

View File

@ -83,8 +83,8 @@ struct liStatCache {
guint64 errors;
};
void stat_cache_new(liWorker *wrk, gdouble ttl);
void stat_cache_free(liStatCache *sc);
LI_API void li_stat_cache_new(liWorker *wrk, gdouble ttl);
LI_API void li_stat_cache_free(liStatCache *sc);
/*
gets a stat_cache_entry for a specified path

View File

@ -17,9 +17,9 @@ struct liThrottlePool {
ev_tstamp *last_con_rearm;
};
void throttle_cb(struct ev_loop *loop, ev_timer *w, int revents);
LI_API void li_throttle_cb(struct ev_loop *loop, ev_timer *w, int revents);
liThrottlePool *throttle_pool_new(liServer *srv, GString *name, guint rate);
void throttle_pool_free(liServer *srv, liThrottlePool *pool);
LI_API liThrottlePool *li_throttle_pool_new(liServer *srv, GString *name, guint rate);
LI_API void li_throttle_pool_free(liServer *srv, liThrottlePool *pool);
#endif

View File

@ -67,10 +67,10 @@ LI_API liSocketAddress li_sockaddr_local_from_socket(gint fd);
LI_API liSocketAddress li_sockaddr_remote_from_socket(gint fd);
LI_API void li_sockaddr_clear(liSocketAddress *saddr);
LI_API gboolean ipv4_in_ipv4_net(guint32 target, guint32 match, guint32 networkmask);
LI_API gboolean ipv6_in_ipv6_net(const unsigned char *target, const guint8 *match, guint network);
LI_API gboolean ipv6_in_ipv4_net(const unsigned char *target, guint32 match, guint32 networkmask);
LI_API gboolean ipv4_in_ipv6_net(guint32 target, const guint8 *match, guint network);
LI_API gboolean li_ipv4_in_ipv4_net(guint32 target, guint32 match, guint32 networkmask);
LI_API gboolean li_ipv6_in_ipv6_net(const unsigned char *target, const guint8 *match, guint network);
LI_API gboolean li_ipv6_in_ipv4_net(const unsigned char *target, guint32 match, guint32 networkmask);
LI_API gboolean li_ipv4_in_ipv6_net(guint32 target, const guint8 *match, guint network);
LI_API void li_gstring_replace_char_with_str_len(GString *gstr, gchar c, gchar *str, guint len);

View File

@ -117,4 +117,7 @@ LI_API GString* li_worker_current_timestamp(liWorker *wrk, liTimeFunc, guint for
/* shutdown write and wait for eof before shutdown read and close */
LI_API void li_worker_add_closing_socket(liWorker *wrk, int fd);
/* internal function to recycle connection */
LI_API void li_worker_con_put(liConnection *con);
#endif

View File

@ -102,7 +102,7 @@ static gchar *format_char(pcontext *ctx, gchar c) {
}
action enditem {
plugins_handle_item(srv, ctx->itemname, ctx->itemvalue);
li_plugins_handle_item(srv, ctx->itemname, ctx->itemvalue);
g_string_free(ctx->itemname, TRUE);
ctx->itemname = NULL;
li_value_free(ctx->itemvalue);

View File

@ -1,7 +1,7 @@
#include <lighttpd/angel_base.h>
void log_init(liServer *srv) {
void li_log_init(liServer *srv) {
srv->log.type = LI_LOG_TYPE_STDERR;
srv->log.levels[LI_LOG_LEVEL_ABORT] = TRUE;
@ -16,7 +16,7 @@ void log_init(liServer *srv) {
srv->log.log_line = g_string_sized_new(0);
}
void log_clean(liServer *srv) {
void li_log_clean(liServer *srv) {
g_string_free(srv->log.ts_cache, TRUE);
g_string_free(srv->log.log_line, TRUE);
}

View File

@ -74,7 +74,7 @@ int main(int argc, char *argv[]) {
srv = li_server_new(module_dir);
if (!plugins_config_load(srv, config_path)) {
if (!li_plugins_config_load(srv, config_path)) {
result = -1;
goto cleanup;
}

View File

@ -80,7 +80,7 @@ static server_module* server_module_new(liServer *srv, const gchar *name) { /* m
return sm;
}
void plugins_init(liServer *srv, const gchar *module_dir) {
void li_plugins_init(liServer *srv, const gchar *module_dir) {
liPlugins *ps = &srv->plugins;
ps->modules = li_modules_new(srv, module_dir);
@ -98,10 +98,10 @@ void plugins_init(liServer *srv, const gchar *module_dir) {
ps->load_plugins = g_ptr_array_new();
}
void plugins_clear(liServer *srv) {
void li_plugins_clear(liServer *srv) {
liPlugins *ps = &srv->plugins;
plugins_config_clean(srv);
li_plugins_config_clean(srv);
g_hash_table_destroy(ps->items);
g_hash_table_destroy(ps->load_items);
@ -120,7 +120,7 @@ void plugins_clear(liServer *srv) {
li_modules_free(ps->modules);
}
void plugins_config_clean(liServer *srv) {
void li_plugins_config_clean(liServer *srv) {
liPlugins *ps = &srv->plugins;
guint i;
@ -135,21 +135,21 @@ void plugins_config_clean(liServer *srv) {
g_ptr_array_set_size(ps->load_plugins, 0);
}
gboolean plugins_config_load(liServer *srv, const gchar *filename) {
gboolean li_plugins_config_load(liServer *srv, const gchar *filename) {
liPlugins *ps = &srv->plugins;
GError *error = NULL;
guint i;
if (!plugins_load_module(srv, NULL)) {
if (!li_plugins_load_module(srv, NULL)) {
ERROR(srv, "%s", "failed loading core plugins");
plugins_config_clean(srv);
li_plugins_config_clean(srv);
return FALSE;
}
if (filename && !li_angel_config_parse_file(srv, filename, &error)) {
ERROR(srv, "failed to parse config file: %s", error->message);
g_error_free(error);
plugins_config_clean(srv);
li_plugins_config_clean(srv);
return FALSE;
}
@ -159,7 +159,7 @@ gboolean plugins_config_load(liServer *srv, const gchar *filename) {
if (p->handle_check_config) {
if (!p->handle_check_config(srv, p)) {
ERROR(srv, "%s", "config check failed");
plugins_config_clean(srv);
li_plugins_config_clean(srv);
return FALSE;
}
}
@ -201,7 +201,7 @@ gboolean plugins_config_load(liServer *srv, const gchar *filename) {
return TRUE;
}
void plugins_handle_item(liServer *srv, GString *itemname, liValue *hash) {
void li_plugins_handle_item(liServer *srv, GString *itemname, liValue *hash) {
liPlugins *ps = &srv->plugins;
server_item *si;
@ -312,7 +312,7 @@ item_collission:
return FALSE;
}
gboolean plugins_load_module(liServer *srv, const gchar *name) {
gboolean li_plugins_load_module(liServer *srv, const gchar *name) {
liPlugins *ps = &srv->plugins;
server_module *sm;
const gchar* modname = name ? name : "core";
@ -336,7 +336,7 @@ gboolean plugins_load_module(liServer *srv, const gchar *name) {
}
sm->mod = mod;
} else {
if (!plugin_core_init(srv)) {
if (!li_plugin_core_init(srv)) {
_server_module_release(sm);
return FALSE;
}

View File

@ -276,11 +276,11 @@ static int do_listen(liServer *srv, liPluginCoreConfig *config, GString *str) {
mask = g_ptr_array_index(config->listen_masks, i);
switch (mask->type) {
case LI_PLUGIN_CORE_LISTEN_MASK_IPV4:
if (!ipv4_in_ipv4_net(ipv4, mask->value.ipv4.addr, mask->value.ipv4.networkmask)) continue;
if (!li_ipv4_in_ipv4_net(ipv4, mask->value.ipv4.addr, mask->value.ipv4.networkmask)) continue;
if ((mask->value.ipv4.port != port) && (mask->value.ipv4.port != 0 || (port != 80 && port != 443))) continue;
break;
case LI_PLUGIN_CORE_LISTEN_MASK_IPV6:
if (!ipv4_in_ipv6_net(ipv4, mask->value.ipv6.addr, mask->value.ipv6.network)) continue;
if (!li_ipv4_in_ipv6_net(ipv4, mask->value.ipv6.addr, mask->value.ipv6.network)) continue;
if ((mask->value.ipv6.port != port) && (mask->value.ipv6.port != 0 || (port != 80 && port != 443))) continue;
break;
case LI_PLUGIN_CORE_LISTEN_MASK_UNIX:
@ -332,11 +332,11 @@ static int do_listen(liServer *srv, liPluginCoreConfig *config, GString *str) {
mask = g_ptr_array_index(config->listen_masks, i);
switch (mask->type) {
case LI_PLUGIN_CORE_LISTEN_MASK_IPV4:
if (!ipv6_in_ipv4_net(ipv6, mask->value.ipv4.addr, mask->value.ipv4.networkmask)) continue;
if (!li_ipv6_in_ipv4_net(ipv6, mask->value.ipv4.addr, mask->value.ipv4.networkmask)) continue;
if ((mask->value.ipv4.port != port) && (mask->value.ipv4.port != 0 || (port != 80 && port != 443))) continue;
break;
case LI_PLUGIN_CORE_LISTEN_MASK_IPV6:
if (!ipv6_in_ipv6_net(ipv6, mask->value.ipv6.addr, mask->value.ipv6.network)) continue;
if (!li_ipv6_in_ipv6_net(ipv6, mask->value.ipv6.addr, mask->value.ipv6.network)) continue;
if ((mask->value.ipv6.port != port) && (mask->value.ipv6.port != 0 || (port != 80 && port != 443))) continue;
break;
case LI_PLUGIN_CORE_LISTEN_MASK_UNIX:
@ -547,7 +547,7 @@ static gboolean core_init(liServer *srv, liPlugin *p) {
return TRUE;
}
gboolean plugin_core_init(liServer *srv) {
gboolean li_plugin_core_init(liServer *srv) {
/* load core plugins */
return NULL != li_angel_plugin_register(srv, NULL, "core", core_init);
}

View File

@ -34,15 +34,15 @@ liServer* li_server_new(const gchar *module_dir) {
CATCH_SIGNAL(srv->loop, sigint_cb, TERM);
CATCH_SIGNAL(srv->loop, sigpipe_cb, PIPE);
log_init(srv);
plugins_init(srv, module_dir);
li_log_init(srv);
li_plugins_init(srv, module_dir);
return srv;
}
void li_server_free(liServer* srv) {
plugins_clear(srv);
li_plugins_clear(srv);
log_clean(srv);
li_log_clean(srv);
UNCATCH_SIGNAL(srv->loop, INT);
UNCATCH_SIGNAL(srv->loop, TERM);
@ -55,7 +55,7 @@ void li_server_stop(liServer *srv) {
UNCATCH_SIGNAL(srv->loop, INT);
UNCATCH_SIGNAL(srv->loop, TERM);
plugins_config_load(srv, NULL);
li_plugins_config_load(srv, NULL);
}
static void instance_angel_call_cb(liAngelConnection *acon,

View File

@ -653,11 +653,11 @@ void li_sockaddr_clear(liSocketAddress *saddr) {
saddr->len = 0;
}
gboolean ipv4_in_ipv4_net(guint32 target, guint32 match, guint32 networkmask) {
gboolean li_ipv4_in_ipv4_net(guint32 target, guint32 match, guint32 networkmask) {
return (target & networkmask) == (match & networkmask);
}
gboolean ipv6_in_ipv6_net(const unsigned char *target, const guint8 *match, guint network) {
gboolean li_ipv6_in_ipv6_net(const unsigned char *target, const guint8 *match, guint network) {
guint8 mask = network % 8;
if (0 != memcmp(target, match, network / 8)) return FALSE;
if (!mask) return TRUE;
@ -665,16 +665,16 @@ gboolean ipv6_in_ipv6_net(const unsigned char *target, const guint8 *match, guin
return (target[network / 8] & mask) == (match[network / 8] & mask);
}
gboolean ipv6_in_ipv4_net(const unsigned char *target, guint32 match, guint32 networkmask) {
gboolean li_ipv6_in_ipv4_net(const unsigned char *target, guint32 match, guint32 networkmask) {
static const guint8 ipv6match[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0xFF, 0, 0, 0, 0 };
if (!ipv6_in_ipv6_net(target, ipv6match, 96)) return FALSE;
return ipv4_in_ipv4_net(*(guint32*)(target+12), match, networkmask);
if (!li_ipv6_in_ipv6_net(target, ipv6match, 96)) return FALSE;
return li_ipv4_in_ipv4_net(*(guint32*)(target+12), match, networkmask);
}
gboolean ipv4_in_ipv6_net(guint32 target, const guint8 *match, guint network) {
gboolean li_ipv4_in_ipv6_net(guint32 target, const guint8 *match, guint network) {
guint8 ipv6[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0xFF, 0, 0, 0, 0 };
*(guint32*) (ipv6+12) = target;
return ipv6_in_ipv6_net(ipv6, match, network);
return li_ipv6_in_ipv6_net(ipv6, match, network);
}
/* unused */

View File

@ -7,7 +7,7 @@
#define LUA_ACTION "liAction*"
liAction* lua_get_action(lua_State *L, int ndx) {
liAction* li_lua_get_action(lua_State *L, int ndx) {
if (!lua_isuserdata(L, ndx)) return NULL;
if (!lua_getmetatable(L, ndx)) return NULL;
luaL_getmetatable(L, LUA_ACTION);
@ -29,7 +29,7 @@ static int lua_action_gc(lua_State *L) {
return 0;
}
int lua_push_action(liServer *srv, lua_State *L, liAction *a) {
int li_lua_push_action(liServer *srv, lua_State *L, liAction *a) {
liAction **pa;
pa = (liAction**) lua_newuserdata(L, sizeof(liAction*));
@ -82,7 +82,7 @@ static liHandlerResult lua_action_func(liVRequest *vr, gpointer param, gpointer
lua_setfield(L, -2, "_G");
lua_pop(L, 1);
lua_push_vrequest(L, vr);
li_lua_push_vrequest(L, vr);
errfunc = li_lua_push_traceback(L, 1);
if (lua_pcall(L, 1, 1, errfunc)) {
@ -145,7 +145,7 @@ static void lua_action_free(liServer *srv, gpointer param) {
g_slice_free(lua_action_param, par);
}
liAction* lua_make_action(lua_State *L, int ndx) {
liAction* li_lua_make_action(lua_State *L, int ndx) {
lua_action_param *par = g_slice_new0(lua_action_param);
lua_pushvalue(L, ndx); /* +1 */

View File

@ -56,8 +56,6 @@ static void li_angel_listen_cb(liAngelCall *acall, gpointer pctx, gboolean timeo
li_angel_call_free(acall);
g_slice_free(angel_listen_cb_ctx, pctx);
ERROR(srv, "%s", "listen_cb");
if (timeout) {
ERROR(srv, "listen failed: %s", "time out");
return;
@ -101,7 +99,7 @@ void li_angel_listen(liServer *srv, GString *str, liAngelListenCB cb, gpointer d
g_error_free(err);
}
} else {
int fd = angel_fake_listen(srv, str);
int fd = li_angel_fake_listen(srv, str);
if (-1 == fd) {
ERROR(srv, "listen('%s') failed", str->str);
/* TODO: exit? */
@ -117,5 +115,5 @@ void li_angel_listen(liServer *srv, GString *str, liAngelListenCB cb, gpointer d
/* send log messages while startup to angel */
void li_angel_log(liServer *srv, GString *str) {
angel_fake_log(srv, str);
li_angel_fake_log(srv, str);
}

View File

@ -4,7 +4,7 @@
#include <lighttpd/ip_parsers.h>
/* listen to a socket */
int angel_fake_listen(liServer *srv, GString *str) {
int li_angel_fake_listen(liServer *srv, GString *str) {
guint32 ipv4;
#ifdef HAVE_IPV6
guint8 ipv6[16];
@ -95,7 +95,7 @@ int angel_fake_listen(liServer *srv, GString *str) {
}
/* print log messages during startup to stderr */
gboolean angel_fake_log(liServer *srv, GString *str) {
gboolean li_angel_fake_log(liServer *srv, GString *str) {
const char *buf;
guint len;
ssize_t written;

View File

@ -50,7 +50,7 @@ static int lua_chunkqueue_index(lua_State *L) {
if (li_lua_metatable_index(L)) return 1;
cq = lua_get_chunkqueue(L, 1);
cq = li_lua_get_chunkqueue(L, 1);
if (!cq) return 0;
if (lua_isnumber(L, 2)) return 0;
@ -84,7 +84,7 @@ static int lua_chunkqueue_newindex(lua_State *L) {
lua_error(L);
}
cq = lua_get_chunkqueue(L, 1);
cq = li_lua_get_chunkqueue(L, 1);
if (!cq) return 0;
if (lua_isnumber(L, 2)) return 0;
@ -114,7 +114,7 @@ static int lua_chunkqueue_add(lua_State *L) {
size_t len;
luaL_checkany(L, 2);
cq = lua_get_chunkqueue(L, 1);
cq = li_lua_get_chunkqueue(L, 1);
if (cq == NULL) return 0;
if (lua_isstring(L, 2)) {
s = lua_tolstring(L, 2, &len);
@ -155,7 +155,7 @@ fail:
static int lua_chunkqueue_reset(lua_State *L) {
liChunkQueue *cq;
cq = lua_get_chunkqueue(L, 1);
cq = li_lua_get_chunkqueue(L, 1);
li_chunkqueue_reset(cq);
return 0;
@ -178,7 +178,7 @@ static void init_chunkqueue_mt(lua_State *L) {
lua_setfield(L, -2, "__index");
}
void lua_init_chunk_mt(lua_State *L) {
void li_lua_init_chunk_mt(lua_State *L) {
if (luaL_newmetatable(L, LUA_CHUNK)) {
init_chunk_mt(L);
}
@ -190,7 +190,7 @@ void lua_init_chunk_mt(lua_State *L) {
lua_pop(L, 1);
}
liChunk* lua_get_chunk(lua_State *L, int ndx) {
liChunk* li_lua_get_chunk(lua_State *L, int ndx) {
if (!lua_isuserdata(L, ndx)) return NULL;
if (!lua_getmetatable(L, ndx)) return NULL;
luaL_getmetatable(L, LUA_CHUNK);
@ -202,7 +202,7 @@ liChunk* lua_get_chunk(lua_State *L, int ndx) {
return *(liChunk**) lua_touserdata(L, ndx);
}
int lua_push_chunk(lua_State *L, liChunk *c) {
int li_lua_push_chunk(lua_State *L, liChunk *c) {
liChunk **pc;
pc = (liChunk**) lua_newuserdata(L, sizeof(liChunk*));
@ -216,7 +216,7 @@ int lua_push_chunk(lua_State *L, liChunk *c) {
return 1;
}
liChunkQueue* lua_get_chunkqueue(lua_State *L, int ndx) {
liChunkQueue* li_lua_get_chunkqueue(lua_State *L, int ndx) {
if (!lua_isuserdata(L, ndx)) return NULL;
if (!lua_getmetatable(L, ndx)) return NULL;
luaL_getmetatable(L, LUA_CHUNKQUEUE);
@ -228,7 +228,7 @@ liChunkQueue* lua_get_chunkqueue(lua_State *L, int ndx) {
return *(liChunkQueue**) lua_touserdata(L, ndx);
}
int lua_push_chunkqueue(lua_State *L, liChunkQueue *cq) {
int li_lua_push_chunkqueue(lua_State *L, liChunkQueue *cq) {
liChunkQueue **pcq;
pcq = (liChunkQueue**) lua_newuserdata(L, sizeof(liChunkQueue*));

View File

@ -536,15 +536,15 @@ static liHandlerResult li_condition_check_eval_int(liVRequest *vr, liCondition *
static gboolean ip_in_net(liConditionRValue *target, liConditionRValue *network) {
if (target->type == LI_COND_VALUE_SOCKET_IPV4) {
if (network->type == LI_COND_VALUE_SOCKET_IPV4) {
return ipv4_in_ipv4_net(target->ipv4.addr, network->ipv4.addr, network->ipv4.networkmask);
return li_ipv4_in_ipv4_net(target->ipv4.addr, network->ipv4.addr, network->ipv4.networkmask);
} else if (network->type == LI_COND_VALUE_SOCKET_IPV6) {
return ipv4_in_ipv6_net(target->ipv4.addr, network->ipv6.addr, network->ipv6.network);
return li_ipv4_in_ipv6_net(target->ipv4.addr, network->ipv6.addr, network->ipv6.network);
}
} else if (target->type == LI_COND_VALUE_SOCKET_IPV6) {
if (network->type == LI_COND_VALUE_SOCKET_IPV4) {
return ipv6_in_ipv4_net(target->ipv6.addr, network->ipv4.addr, network->ipv4.networkmask);
return li_ipv6_in_ipv4_net(target->ipv6.addr, network->ipv4.addr, network->ipv4.networkmask);
} else if (network->type == LI_COND_VALUE_SOCKET_IPV6) {
return ipv6_in_ipv6_net(target->ipv6.addr, network->ipv6.addr, network->ipv6.network);
return li_ipv6_in_ipv6_net(target->ipv6.addr, network->ipv6.addr, network->ipv6.network);
}
}
return FALSE;

View File

@ -55,7 +55,7 @@ static void lua_settop_in_dicts(lua_State *L, const gchar *path) {
/* Get objects from lua */
liCondition* lua_get_condition(lua_State *L, int ndx) {
liCondition* li_lua_get_condition(lua_State *L, int ndx) {
if (!lua_isuserdata(L, ndx)) return NULL;
if (!lua_getmetatable(L, ndx)) return NULL;
luaL_getmetatable(L, LUA_CONDITION);
@ -119,7 +119,7 @@ static void lua_push_condition_metatable(liServer *srv, lua_State *L) {
}
}
int lua_push_condition(liServer *srv, lua_State *L, liCondition *c) {
int li_lua_push_condition(liServer *srv, lua_State *L, liCondition *c) {
liCondition **pc;
pc = (liCondition**) lua_newuserdata(L, sizeof(liCondition*));
@ -161,7 +161,7 @@ static int lua_cond_lvalue_bool(lua_State *L) {
c = li_condition_new_bool(srv, lvalue, cmpop == LI_CONFIG_COND_EQ);
if (c) {
li_condition_lvalue_acquire(lvalue);
lua_push_condition(srv, L, c);
li_lua_push_condition(srv, L, c);
return 1;
}
return 0;
@ -182,7 +182,7 @@ static int lua_cond_lvalue_cmp(lua_State *L) {
c = li_condition_new_string(srv, cmpop, lvalue, sval);
if (c) {
li_condition_lvalue_acquire(lvalue);
lua_push_condition(srv, L, c);
li_lua_push_condition(srv, L, c);
return 1;
}
return 0;
@ -271,7 +271,7 @@ static int lua_push_cond_lvalue_t(liServer *srv, lua_State *L, liCondLValue t) {
void lua_push_lvalues_dict(liServer *srv, lua_State *L) {
void li_lua_push_lvalues_dict(liServer *srv, lua_State *L) {
size_t i;
for (i = 0; i < LI_COND_LVALUE_FIRST_WITH_KEY; i++) {

View File

@ -157,7 +157,7 @@ static int handle_server_action(liServer *srv, lua_State *L, gpointer _sa) {
lua_error(L);
}
return lua_push_action(srv, L, a);
return li_lua_push_action(srv, L, a);
}
static int handle_server_setup(liServer *srv, lua_State *L, gpointer _ss) {
@ -209,7 +209,7 @@ gboolean li_config_lua_load(liServer *srv, const gchar *filename, liAction **pac
publish_str_hash(srv, L, srv->actions, handle_server_action);
lua_setfield(L, LUA_GLOBALSINDEX, "action");
lua_push_lvalues_dict(srv, L);
li_lua_push_lvalues_dict(srv, L);
errfunc = li_lua_push_traceback(L, 0);
if (lua_pcall(L, 0, 1, errfunc)) {
@ -224,9 +224,9 @@ gboolean li_config_lua_load(liServer *srv, const gchar *filename, liAction **pac
liAction *act;
lua_getfield(L, LUA_GLOBALSINDEX, "actions");
act = lua_get_action(L, -1);
act = li_lua_get_action(L, -1);
if (NULL == act && lua_isfunction(L, -1)) {
act = lua_make_action(L, -1);
act = li_lua_make_action(L, -1);
} else {
li_action_acquire(act);
}

View File

@ -705,7 +705,7 @@
g_string_append(path, filename);
if (!config_parser_file(srv, ctx_stack, path->str)) {
if (!li_config_parser_file(srv, ctx_stack, path->str)) {
g_string_free(path, TRUE);
g_pattern_spec_free(pattern);
g_dir_close(dir);
@ -1175,61 +1175,7 @@
%% write data;
GList *config_parser_init(liServer* srv) {
liConfigParserContext *ctx = config_parser_context_new(srv, NULL);
srv->mainaction = li_action_new_list();
g_queue_push_head(ctx->action_list_stack, srv->mainaction);
return g_list_append(NULL, ctx);
}
void config_parser_finish(liServer *srv, GList *ctx_stack, gboolean free_all) {
liConfigParserContext *ctx;
GHashTableIter iter;
gpointer key, val;
GList *l;
_printf("ctx_stack size: %u\n", g_list_length(ctx_stack));
/* clear all contexts from the stack */
l = g_list_nth(ctx_stack, 1);
while (l) {
ctx = l->data;
config_parser_context_free(srv, ctx, FALSE);
l = l->next;
}
if (free_all) {
ctx = (liConfigParserContext*) ctx_stack->data;
g_hash_table_iter_init(&iter, ctx->action_blocks);
while (g_hash_table_iter_next(&iter, &key, &val)) {
li_action_release(srv, val);
g_string_free(key, TRUE);
}
g_hash_table_destroy(ctx->action_blocks);
g_hash_table_iter_init(&iter, ctx->uservars);
while (g_hash_table_iter_next(&iter, &key, &val)) {
li_value_free(val);
g_string_free(key, TRUE);
}
g_hash_table_destroy(ctx->uservars);
config_parser_context_free(srv, ctx, TRUE);
g_list_free(ctx_stack);
}
}
liConfigParserContext *config_parser_context_new(liServer *srv, GList *ctx_stack) {
static liConfigParserContext *config_parser_context_new(liServer *srv, GList *ctx_stack) {
liConfigParserContext *ctx;
UNUSED(srv);
@ -1282,8 +1228,7 @@ liConfigParserContext *config_parser_context_new(liServer *srv, GList *ctx_stack
return ctx;
}
void config_parser_context_free(liServer *srv, liConfigParserContext *ctx, gboolean free_queues)
{
static void config_parser_context_free(liServer *srv, liConfigParserContext *ctx, gboolean free_queues) {
g_free(ctx->stack);
if (free_queues) {
@ -1307,7 +1252,63 @@ void config_parser_context_free(liServer *srv, liConfigParserContext *ctx, gbool
g_slice_free(liConfigParserContext, ctx);
}
gboolean config_parser_file(liServer *srv, GList *ctx_stack, const gchar *path) {
GList* li_config_parser_init(liServer* srv) {
liConfigParserContext *ctx = config_parser_context_new(srv, NULL);
srv->mainaction = li_action_new_list();
g_queue_push_head(ctx->action_list_stack, srv->mainaction);
return g_list_append(NULL, ctx);
}
void li_config_parser_finish(liServer *srv, GList *ctx_stack, gboolean free_all) {
liConfigParserContext *ctx;
GHashTableIter iter;
gpointer key, val;
GList *l;
_printf("ctx_stack size: %u\n", g_list_length(ctx_stack));
/* clear all contexts from the stack */
l = g_list_nth(ctx_stack, 1);
while (l) {
ctx = l->data;
config_parser_context_free(srv, ctx, FALSE);
l = l->next;
}
if (free_all) {
ctx = (liConfigParserContext*) ctx_stack->data;
g_hash_table_iter_init(&iter, ctx->action_blocks);
while (g_hash_table_iter_next(&iter, &key, &val)) {
li_action_release(srv, val);
g_string_free(key, TRUE);
}
g_hash_table_destroy(ctx->action_blocks);
g_hash_table_iter_init(&iter, ctx->uservars);
while (g_hash_table_iter_next(&iter, &key, &val)) {
li_value_free(val);
g_string_free(key, TRUE);
}
g_hash_table_destroy(ctx->uservars);
config_parser_context_free(srv, ctx, TRUE);
g_list_free(ctx_stack);
}
}
static gboolean config_parser_buffer(liServer *srv, GList *ctx_stack);
gboolean li_config_parser_file(liServer *srv, GList *ctx_stack, const gchar *path) {
liConfigParserContext *ctx;
gboolean res;
GError *err = NULL;
@ -1315,8 +1316,7 @@ gboolean config_parser_file(liServer *srv, GList *ctx_stack, const gchar *path)
ctx = config_parser_context_new(srv, ctx_stack);
ctx->filename = (gchar*) path;
if (!g_file_get_contents(path, &ctx->ptr, &ctx->len, &err))
{
if (!g_file_get_contents(path, &ctx->ptr, &ctx->len, &err)) {
/* could not read file */
WARNING(srv, "could not read config file \"%s\". reason: \"%s\" (%d)", path, err->message, err->code);
config_parser_context_free(srv, ctx, FALSE);
@ -1342,8 +1342,7 @@ gboolean config_parser_file(liServer *srv, GList *ctx_stack, const gchar *path)
return res;
}
gboolean config_parser_shell(liServer *srv, GList *ctx_stack, const gchar *command)
{
static gboolean config_parser_shell(liServer *srv, GList *ctx_stack, const gchar *command) {
gboolean res;
gchar* _stdout;
gchar* _stderr;
@ -1354,16 +1353,14 @@ gboolean config_parser_shell(liServer *srv, GList *ctx_stack, const gchar *comma
ctx = config_parser_context_new(srv, ctx_stack);
ctx->filename = (gchar*) command;
if (!g_spawn_command_line_sync(command, &_stdout, &_stderr, &status, &err))
{
if (!g_spawn_command_line_sync(command, &_stdout, &_stderr, &status, &err)) {
WARNING(srv, "error launching shell command \"%s\": %s (%d)", command, err->message, err->code);
config_parser_context_free(srv, ctx, FALSE);
g_error_free(err);
return FALSE;
}
if (status != 0)
{
if (status != 0) {
WARNING(srv, "shell command \"%s\" exited with status %d", command, status);
DEBUG(srv, "stdout:\n-----\n%s\n-----\nstderr:\n-----\n%s\n-----", _stdout, _stderr);
g_free(_stdout);
@ -1391,8 +1388,7 @@ gboolean config_parser_shell(liServer *srv, GList *ctx_stack, const gchar *comma
return res;
}
gboolean config_parser_buffer(liServer *srv, GList *ctx_stack)
{
static gboolean config_parser_buffer(liServer *srv, GList *ctx_stack) {
liConfigParserContext *ctx;
/* get top of stack */
@ -1405,8 +1401,7 @@ gboolean config_parser_buffer(liServer *srv, GList *ctx_stack)
%% write exec;
if (ctx->cs == config_parser_error || ctx->cs == config_parser_first_final)
{
if (ctx->cs == config_parser_error || ctx->cs == config_parser_first_final) {
/* parse error */
WARNING(srv, "parse error in line %zd of \"%s\" at character '%c' (0x%.2x)", ctx->line, ctx->filename, *ctx->p, *ctx->p);
return FALSE;

View File

@ -2,9 +2,6 @@
#include <lighttpd/base.h>
#include <lighttpd/plugin_core.h>
/* only call it from the worker context the con belongs to */
void worker_con_put(liConnection *con); /* worker.c */
static void li_connection_reset_keep_alive(liConnection *con);
static void li_connection_internal_error(liConnection *con);
@ -75,7 +72,7 @@ static void connection_request_done(liConnection *con) {
if (con->keep_alive && (LI_SERVER_RUNNING == s || LI_SERVER_WARMUP == s)) {
li_connection_reset_keep_alive(con);
} else {
worker_con_put(con);
li_worker_con_put(con);
}
}
@ -95,7 +92,7 @@ static void connection_close(liConnection *con) {
li_plugins_handle_close(con);
worker_con_put(con);
li_worker_con_put(con);
}
void li_connection_error(liConnection *con) {
@ -106,7 +103,7 @@ void li_connection_error(liConnection *con) {
li_plugins_handle_close(con);
worker_con_put(con);
li_worker_con_put(con);
}
static void li_connection_internal_error(liConnection *con) {
@ -398,7 +395,7 @@ static void connection_cb(struct ev_loop *loop, ev_io *w, int revents) {
static void connection_keepalive_cb(struct ev_loop *loop, ev_timer *w, int revents) {
liConnection *con = (liConnection*) w->data;
UNUSED(loop); UNUSED(revents);
worker_con_put(con);
li_worker_con_put(con);
}
static liHandlerResult mainvr_handle_response_headers(liVRequest *vr) {
@ -597,7 +594,7 @@ static void li_connection_reset_keep_alive(liConnection *con) {
{
con->keep_alive_data.max_idle = CORE_OPTION(LI_CORE_OPTION_MAX_KEEP_ALIVE_IDLE).number;
if (con->keep_alive_data.max_idle == 0) {
worker_con_put(con);
li_worker_con_put(con);
return;
}
if (con->keep_alive_data.max_idle >= con->srv->keep_alive_queue_timeout) {

View File

@ -10,14 +10,14 @@ static void init_con_mt(lua_State *L) {
/* TODO */
}
void lua_init_connection_mt(lua_State *L) {
void li_lua_init_connection_mt(lua_State *L) {
if (luaL_newmetatable(L, LUA_CONNECTION)) {
init_con_mt(L);
}
lua_pop(L, 1);
}
liConnection* lua_get_connection(lua_State *L, int ndx) {
liConnection* li_lua_get_connection(lua_State *L, int ndx) {
if (!lua_isuserdata(L, ndx)) return NULL;
if (!lua_getmetatable(L, ndx)) return NULL;
luaL_getmetatable(L, LUA_CONNECTION);
@ -29,7 +29,7 @@ liConnection* lua_get_connection(lua_State *L, int ndx) {
return *(liConnection**) lua_touserdata(L, ndx);
}
int lua_push_connection(lua_State *L, liConnection *con) {
int li_lua_push_connection(lua_State *L, liConnection *con) {
liConnection **pcon;
pcon = (liConnection**) lua_newuserdata(L, sizeof(liConnection*));

View File

@ -50,7 +50,7 @@ static void li_lua_store_globals(lua_State *L) {
lua_setfield(L, LUA_REGISTRYINDEX, "li_globals"); /* -1 */
}