void module_load(char *file) { module_t *mod; VAR_INT_T *load; char key[256]; if (util_stripped_filename(key, sizeof key, file)) { log_die(EX_SOFTWARE, "module_load: util_stripped_filename failed"); } load = (VAR_INT_T *) cf_get_value(VT_INT, "modules", key, NULL); if (load != NULL) { if (!*load) { log_debug("module_glob: %s disabled in config", file); return; } } log_debug("module_glob: load %s", file); mod = (module_t *) malloc(sizeof (module_t)); if (mod == NULL) { log_sys_die(EX_SOFTWARE, "module_load: malloc"); } mod->mod_path = strdup(file); mod->mod_name = strrchr(mod->mod_path, '/') + 1; /* * Open module */ mod->mod_handle = dlopen(file, RTLD_LAZY); if (mod->mod_handle == NULL) { log_sys_die(EX_SOFTWARE, "module_load: dlopen: %s", dlerror()); } /* * Load Symbols */ mod->mod_init = module_symbol_load(mod->mod_handle, file, "init", 1); mod->mod_fini = module_symbol_load(mod->mod_handle, file, "fini", 0); /* * Initialize module */ if (mod->mod_init()) { log_die(EX_SOFTWARE, "module_load: %s: init failed", mod->mod_name); } if (LL_INSERT(module_list, mod) == -1) { log_die(EX_SOFTWARE, "module_load: LL_INSERT failed"); } return; }
int hitlist_register(char *name) { hitlist_t *hl; ll_t *keys; VAR_INT_T *create; VAR_INT_T *update; VAR_INT_T *count; VAR_INT_T *timeout; VAR_INT_T *extend; VAR_INT_T *cleanup; char *sum; char *table; char *value_field; char *expire_field; if (name == NULL) { log_die(EX_SOFTWARE, "hitlist_register: name is NULL"); } keys = cf_get_value(VT_LIST, HITLIST_NAME, name, "keys", NULL); create = cf_get_value(VT_INT, HITLIST_NAME, name, "create", NULL); update = cf_get_value(VT_INT, HITLIST_NAME, name, "update", NULL); count = cf_get_value(VT_INT, HITLIST_NAME, name, "count", NULL); timeout = cf_get_value(VT_INT, HITLIST_NAME, name, "timeout", NULL); extend = cf_get_value(VT_INT, HITLIST_NAME, name, "extend", NULL); cleanup = cf_get_value(VT_INT, HITLIST_NAME, name, "cleanup", NULL); sum = cf_get_value(VT_STRING, HITLIST_NAME, name, "sum", NULL); table = cf_get_value(VT_STRING, HITLIST_NAME, name, "table", NULL); value_field = cf_get_value(VT_STRING, HITLIST_NAME, name, "value_field", NULL); expire_field = cf_get_value(VT_STRING, HITLIST_NAME, name, "expire_field", NULL); if (keys == NULL) { log_die(EX_SOFTWARE, "hitlist_register: %s: need keys", name); } if (keys->ll_size == 0) { log_die(EX_CONFIG, "hitlist_register: %s: keys is empty", name); } hl = hitlist_create(name, keys, create, update, count, timeout, extend, cleanup, sum, table, value_field, expire_field); if (hl == NULL) { log_die(EX_SOFTWARE, "hitlist_register: hl_create failed"); } if (sht_insert(hitlists, name, hl)) { log_die(EX_SOFTWARE, "hitlist_register: sht_insert failed"); } acl_symbol_register(name, MS_ANY, hitlist_lookup, AS_CACHE); return 0; }