X-Git-Url: https://git.tokkee.org/?p=sysdb.git;a=blobdiff_plain;f=src%2Fcore%2Fplugin.c;h=5c9a233eadc873440fc5c6ce54a1937f4c160db3;hp=a4c8c2db11be7cedd220883bca0a7cf5396a999a;hb=bef7167f0dc1fd405e35d5cbffb3c0820945a9ea;hpb=3a179f6f4ad2586325656b49bd9d5a53efc8700c diff --git a/src/core/plugin.c b/src/core/plugin.c index a4c8c2d..5c9a233 100644 --- a/src/core/plugin.c +++ b/src/core/plugin.c @@ -1,5 +1,5 @@ /* - * syscollector - src/core/plugin.c + * SysDB - src/core/plugin.c * Copyright (C) 2012 Sebastian 'tokkee' Harl * All rights reserved. * @@ -25,7 +25,7 @@ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "syscollector.h" +#include "sysdb.h" #include "core/plugin.h" #include "utils/llist.h" #include "utils/string.h" @@ -49,7 +49,7 @@ * private data types */ -struct sc_plugin_info { +struct sdb_plugin_info { char *name; char *description; @@ -59,72 +59,74 @@ struct sc_plugin_info { int version; int plugin_version; }; -#define SC_PLUGIN_INFO_INIT { "no name set", "no description set", \ +#define SDB_PLUGIN_INFO_INIT { "no name set", "no description set", \ /* copyright */ "", /* license */ "", \ /* version */ -1, /* plugin_version */ -1 } typedef struct { - sc_object_t super; + sdb_object_t super; char cb_name[64]; void *cb_callback; - sc_object_t *cb_user_data; - sc_plugin_ctx_t cb_ctx; -} sc_plugin_cb_t; -#define SC_PLUGIN_CB_INIT { SC_OBJECT_INIT, "", NULL, NULL, SC_PLUGIN_CTX_INIT } + sdb_object_t *cb_user_data; + sdb_plugin_ctx_t cb_ctx; +} sdb_plugin_cb_t; +#define SDB_PLUGIN_CB_INIT { SDB_OBJECT_INIT, /* name = */ "", \ + /* callback = */ NULL, /* user_data = */ NULL, \ + SDB_PLUGIN_CTX_INIT } typedef struct { - sc_plugin_cb_t super; + sdb_plugin_cb_t super; #define ccb_name super.cb_name #define ccb_callback super.cb_callback #define ccb_user_data super.cb_user_data #define ccb_ctx super.cb_ctx - sc_time_t ccb_interval; - sc_time_t ccb_next_update; -} sc_plugin_collector_cb_t; + sdb_time_t ccb_interval; + sdb_time_t ccb_next_update; +} sdb_plugin_collector_cb_t; -#define SC_PLUGIN_CB(obj) ((sc_plugin_cb_t *)(obj)) -#define SC_PLUGIN_CCB(obj) ((sc_plugin_collector_cb_t *)(obj)) +#define SDB_PLUGIN_CB(obj) ((sdb_plugin_cb_t *)(obj)) +#define SDB_PLUGIN_CCB(obj) ((sdb_plugin_collector_cb_t *)(obj)) /* * private variables */ -static sc_plugin_ctx_t plugin_default_ctx = SC_PLUGIN_CTX_INIT; +static sdb_plugin_ctx_t plugin_default_ctx = SDB_PLUGIN_CTX_INIT; static pthread_key_t plugin_ctx_key; static _Bool plugin_ctx_key_initialized = 0; -static sc_llist_t *config_list = NULL; -static sc_llist_t *init_list = NULL; -static sc_llist_t *collector_list = NULL; -static sc_llist_t *shutdown_list = NULL; +static sdb_llist_t *config_list = NULL; +static sdb_llist_t *init_list = NULL; +static sdb_llist_t *collector_list = NULL; +static sdb_llist_t *shutdown_list = NULL; /* * private helper functions */ static void -sc_plugin_ctx_destructor(void *ctx) +sdb_plugin_ctx_destructor(void *ctx) { if (! ctx) return; free(ctx); -} /* sc_plugin_ctx_destructor */ +} /* sdb_plugin_ctx_destructor */ static void -sc_plugin_ctx_init(void) +sdb_plugin_ctx_init(void) { if (plugin_ctx_key_initialized) return; - pthread_key_create(&plugin_ctx_key, sc_plugin_ctx_destructor); + pthread_key_create(&plugin_ctx_key, sdb_plugin_ctx_destructor); plugin_ctx_key_initialized = 1; -} /* sc_plugin_ctx_init */ +} /* sdb_plugin_ctx_init */ -static sc_plugin_ctx_t * -sc_plugin_ctx_create(void) +static sdb_plugin_ctx_t * +sdb_plugin_ctx_create(void) { - sc_plugin_ctx_t *ctx; + sdb_plugin_ctx_t *ctx; ctx = malloc(sizeof(*ctx)); if (! ctx) @@ -133,42 +135,42 @@ sc_plugin_ctx_create(void) *ctx = plugin_default_ctx; if (! plugin_ctx_key_initialized) - sc_plugin_ctx_init(); + sdb_plugin_ctx_init(); pthread_setspecific(plugin_ctx_key, ctx); return ctx; -} /* sc_plugin_ctx_create */ +} /* sdb_plugin_ctx_create */ static int -sc_plugin_cmp_name(const sc_object_t *a, const sc_object_t *b) +sdb_plugin_cmp_name(const sdb_object_t *a, const sdb_object_t *b) { - const sc_plugin_cb_t *cb1 = (const sc_plugin_cb_t *)a; - const sc_plugin_cb_t *cb2 = (const sc_plugin_cb_t *)b; + const sdb_plugin_cb_t *cb1 = (const sdb_plugin_cb_t *)a; + const sdb_plugin_cb_t *cb2 = (const sdb_plugin_cb_t *)b; assert(cb1 && cb2); return strcasecmp(cb1->cb_name, cb2->cb_name); -} /* sc_plugin_cmp_name */ +} /* sdb_plugin_cmp_name */ static int -sc_plugin_cmp_next_update(const sc_object_t *a, const sc_object_t *b) +sdb_plugin_cmp_next_update(const sdb_object_t *a, const sdb_object_t *b) { - const sc_plugin_collector_cb_t *ccb1 - = (const sc_plugin_collector_cb_t *)a; - const sc_plugin_collector_cb_t *ccb2 - = (const sc_plugin_collector_cb_t *)b; + const sdb_plugin_collector_cb_t *ccb1 + = (const sdb_plugin_collector_cb_t *)a; + const sdb_plugin_collector_cb_t *ccb2 + = (const sdb_plugin_collector_cb_t *)b; assert(ccb1 && ccb2); return (ccb1->ccb_next_update > ccb2->ccb_next_update) ? 1 : (ccb1->ccb_next_update < ccb2->ccb_next_update) ? -1 : 0; -} /* sc_plugin_cmp_next_update */ +} /* sdb_plugin_cmp_next_update */ -static sc_plugin_cb_t * -sc_plugin_find_by_name(sc_llist_t *list, const char *name) +static sdb_plugin_cb_t * +sdb_plugin_find_by_name(sdb_llist_t *list, const char *name) { - sc_plugin_cb_t tmp = SC_PLUGIN_CB_INIT; + sdb_plugin_cb_t tmp = SDB_PLUGIN_CB_INIT; - sc_object_t *obj; + sdb_object_t *obj; assert(name); if (! list) @@ -176,56 +178,56 @@ sc_plugin_find_by_name(sc_llist_t *list, const char *name) snprintf(tmp.cb_name, sizeof(tmp.cb_name), "%s", name); tmp.cb_name[sizeof(tmp.cb_name) - 1] = '\0'; - obj = sc_llist_search(list, SC_OBJ(&tmp), sc_plugin_cmp_name); + obj = sdb_llist_search(list, SDB_OBJ(&tmp), sdb_plugin_cmp_name); if (! obj) return NULL; - return SC_PLUGIN_CB(obj); -} /* sc_plugin_find_by_name */ + return SDB_PLUGIN_CB(obj); +} /* sdb_plugin_find_by_name */ static int -sc_plugin_cb_init(sc_object_t *obj, va_list ap) +sdb_plugin_cb_init(sdb_object_t *obj, va_list ap) { - sc_llist_t **list = va_arg(ap, sc_llist_t **); + sdb_llist_t **list = va_arg(ap, sdb_llist_t **); const char *type = va_arg(ap, const char *); const char *name = va_arg(ap, const char *); void *callback = va_arg(ap, void *); - sc_object_t *ud = va_arg(ap, sc_object_t *); + sdb_object_t *ud = va_arg(ap, sdb_object_t *); assert(list); assert(type); assert(obj); - if (sc_plugin_find_by_name(*list, name)) { + if (sdb_plugin_find_by_name(*list, name)) { fprintf(stderr, "plugin: %s callback '%s' has already been " "registered. Ignoring newly registered version.\n", type, name); return -1; } - snprintf(SC_PLUGIN_CB(obj)->cb_name, - sizeof(SC_PLUGIN_CB(obj)->cb_name), + snprintf(SDB_PLUGIN_CB(obj)->cb_name, + sizeof(SDB_PLUGIN_CB(obj)->cb_name), "%s", name); - SC_PLUGIN_CB(obj)->cb_name[sizeof(SC_PLUGIN_CB(obj)->cb_name) - 1] = '\0'; - SC_PLUGIN_CB(obj)->cb_callback = callback; - SC_PLUGIN_CB(obj)->cb_ctx = sc_plugin_get_ctx(); + SDB_PLUGIN_CB(obj)->cb_name[sizeof(SDB_PLUGIN_CB(obj)->cb_name) - 1] = '\0'; + SDB_PLUGIN_CB(obj)->cb_callback = callback; + SDB_PLUGIN_CB(obj)->cb_ctx = sdb_plugin_get_ctx(); - sc_object_ref(ud); - SC_PLUGIN_CB(obj)->cb_user_data = ud; + sdb_object_ref(ud); + SDB_PLUGIN_CB(obj)->cb_user_data = ud; return 0; -} /* sc_plugin_cb_init */ +} /* sdb_plugin_cb_init */ static void -sc_plugin_cb_destroy(sc_object_t *obj) +sdb_plugin_cb_destroy(sdb_object_t *obj) { assert(obj); - sc_object_deref(SC_PLUGIN_CB(obj)->cb_user_data); -} /* sc_plugin_cb_destroy */ + sdb_object_deref(SDB_PLUGIN_CB(obj)->cb_user_data); +} /* sdb_plugin_cb_destroy */ static int -sc_plugin_add_callback(sc_llist_t **list, const char *type, - const char *name, void *callback, sc_object_t *user_data) +sdb_plugin_add_callback(sdb_llist_t **list, const char *type, + const char *name, void *callback, sdb_object_t *user_data) { - sc_object_t *obj; + sdb_object_t *obj; if ((! name) || (! callback)) return -1; @@ -233,40 +235,40 @@ sc_plugin_add_callback(sc_llist_t **list, const char *type, assert(list); if (! *list) - *list = sc_llist_create(); + *list = sdb_llist_create(); if (! *list) return -1; - obj = sc_object_create(sizeof(sc_plugin_cb_t), sc_plugin_cb_init, - sc_plugin_cb_destroy, list, type, name, callback, user_data); + obj = sdb_object_create(sizeof(sdb_plugin_cb_t), sdb_plugin_cb_init, + sdb_plugin_cb_destroy, list, type, name, callback, user_data); if (! obj) return -1; - if (sc_llist_append(*list, obj)) { - sc_object_deref(obj); + if (sdb_llist_append(*list, obj)) { + sdb_object_deref(obj); return -1; } /* pass control to the list */ - sc_object_deref(obj); + sdb_object_deref(obj); fprintf(stderr, "plugin: Registered %s callback '%s'.\n", type, name); return 0; -} /* sc_plugin_add_callback */ +} /* sdb_plugin_add_callback */ /* * public API */ int -sc_plugin_load(const char *name) +sdb_plugin_load(const char *name) { char filename[1024]; lt_dlhandle lh; - int (*mod_init)(sc_plugin_info_t *); - sc_plugin_info_t plugin_info = SC_PLUGIN_INFO_INIT; + int (*mod_init)(sdb_plugin_info_t *); + sdb_plugin_info_t plugin_info = SDB_PLUGIN_INFO_INIT; int status; @@ -277,7 +279,7 @@ sc_plugin_load(const char *name) if (access(filename, R_OK)) { char errbuf[1024]; fprintf(stderr, "plugin: Failed to load plugin '%s': %s\n", - name, sc_strerror(errno, errbuf, sizeof(errbuf))); + name, sdb_strerror(errno, errbuf, sizeof(errbuf))); return -1; } @@ -292,10 +294,10 @@ sc_plugin_load(const char *name) return -1; } - mod_init = (int (*)(sc_plugin_info_t *))lt_dlsym(lh, "sc_module_init"); + mod_init = (int (*)(sdb_plugin_info_t *))lt_dlsym(lh, "sdb_module_init"); if (! mod_init) { fprintf(stderr, "plugin: Failed to load plugin '%s': " - "could not find symbol 'sc_module_init'\n", name); + "could not find symbol 'sdb_module_init'\n", name); return -1; } @@ -307,22 +309,22 @@ sc_plugin_load(const char *name) /* compare minor version */ if ((plugin_info.version < 0) - || ((int)(plugin_info.version / 100) != (int)(SC_VERSION / 100))) + || ((int)(plugin_info.version / 100) != (int)(SDB_VERSION / 100))) fprintf(stderr, "plugin: WARNING: version of plugin '%s' (%i.%i.%i) " "does not match our version (%i.%i.%i); " "this might cause problems\n", - name, SC_VERSION_DECODE(plugin_info.version), - SC_VERSION_DECODE(SC_VERSION)); + name, SDB_VERSION_DECODE(plugin_info.version), + SDB_VERSION_DECODE(SDB_VERSION)); fprintf(stderr, "plugin: Successfully loaded " "plugin '%s' v%i (%s)\n\t%s\n", plugin_info.name, plugin_info.plugin_version, plugin_info.description, plugin_info.copyright); return 0; -} /* sc_plugin_load */ +} /* sdb_plugin_load */ int -sc_plugin_set_info(sc_plugin_info_t *info, int type, ...) +sdb_plugin_set_info(sdb_plugin_info_t *info, int type, ...) { va_list ap; @@ -332,37 +334,37 @@ sc_plugin_set_info(sc_plugin_info_t *info, int type, ...) va_start(ap, type); switch (type) { - case SC_PLUGIN_INFO_NAME: + case SDB_PLUGIN_INFO_NAME: { char *name = va_arg(ap, char *); info->name = name; } break; - case SC_PLUGIN_INFO_DESC: + case SDB_PLUGIN_INFO_DESC: { char *desc = va_arg(ap, char *); info->description = desc; } break; - case SC_PLUGIN_INFO_COPYRIGHT: + case SDB_PLUGIN_INFO_COPYRIGHT: { char *copyright = va_arg(ap, char *); info->copyright = copyright; } break; - case SC_PLUGIN_INFO_LICENSE: + case SDB_PLUGIN_INFO_LICENSE: { char *license = va_arg(ap, char *); info->license = license; } break; - case SC_PLUGIN_INFO_VERSION: + case SDB_PLUGIN_INFO_VERSION: { int version = va_arg(ap, int); info->version = version; } break; - case SC_PLUGIN_INFO_PLUGIN_VERSION: + case SDB_PLUGIN_INFO_PLUGIN_VERSION: { int version = va_arg(ap, int); info->plugin_version = version; @@ -375,135 +377,135 @@ sc_plugin_set_info(sc_plugin_info_t *info, int type, ...) va_end(ap); return 0; -} /* sc_plugin_set_info */ +} /* sdb_plugin_set_info */ int -sc_plugin_register_config(const char *name, sc_plugin_config_cb callback) +sdb_plugin_register_config(const char *name, sdb_plugin_config_cb callback) { - return sc_plugin_add_callback(&config_list, "init", name, + return sdb_plugin_add_callback(&config_list, "init", name, callback, NULL); -} /* sc_plugin_register_config */ +} /* sdb_plugin_register_config */ int -sc_plugin_register_init(const char *name, sc_plugin_init_cb callback, - sc_object_t *user_data) +sdb_plugin_register_init(const char *name, sdb_plugin_init_cb callback, + sdb_object_t *user_data) { - return sc_plugin_add_callback(&init_list, "init", name, + return sdb_plugin_add_callback(&init_list, "init", name, callback, user_data); -} /* sc_plugin_register_init */ +} /* sdb_plugin_register_init */ int -sc_plugin_register_shutdown(const char *name, sc_plugin_shutdown_cb callback, - sc_object_t *user_data) +sdb_plugin_register_shutdown(const char *name, sdb_plugin_shutdown_cb callback, + sdb_object_t *user_data) { - return sc_plugin_add_callback(&shutdown_list, "shutdown", name, + return sdb_plugin_add_callback(&shutdown_list, "shutdown", name, callback, user_data); -} /* sc_plugin_register_shutdown */ +} /* sdb_plugin_register_shutdown */ int -sc_plugin_register_collector(const char *name, sc_plugin_collector_cb callback, - const sc_time_t *interval, sc_object_t *user_data) +sdb_plugin_register_collector(const char *name, sdb_plugin_collector_cb callback, + const sdb_time_t *interval, sdb_object_t *user_data) { - sc_object_t *obj; + sdb_object_t *obj; if ((! name) || (! callback)) return -1; if (! collector_list) - collector_list = sc_llist_create(); + collector_list = sdb_llist_create(); if (! collector_list) return -1; - obj = sc_object_create(sizeof(sc_plugin_collector_cb_t), - sc_plugin_cb_init, sc_plugin_cb_destroy, + obj = sdb_object_create(sizeof(sdb_plugin_collector_cb_t), + sdb_plugin_cb_init, sdb_plugin_cb_destroy, &collector_list, "collector", name, callback, user_data); if (! obj) return -1; if (interval) - SC_PLUGIN_CCB(obj)->ccb_interval = *interval; + SDB_PLUGIN_CCB(obj)->ccb_interval = *interval; else { - sc_time_t tmp = sc_plugin_get_ctx().interval; + sdb_time_t tmp = sdb_plugin_get_ctx().interval; if (tmp > 0) - SC_PLUGIN_CCB(obj)->ccb_interval = tmp; + SDB_PLUGIN_CCB(obj)->ccb_interval = tmp; else - SC_PLUGIN_CCB(obj)->ccb_interval = 0; + SDB_PLUGIN_CCB(obj)->ccb_interval = 0; } - if (! (SC_PLUGIN_CCB(obj)->ccb_next_update = sc_gettime())) { + if (! (SDB_PLUGIN_CCB(obj)->ccb_next_update = sdb_gettime())) { char errbuf[1024]; fprintf(stderr, "plugin: Failed to determine current time: %s\n", - sc_strerror(errno, errbuf, sizeof(errbuf))); - sc_object_deref(obj); + sdb_strerror(errno, errbuf, sizeof(errbuf))); + sdb_object_deref(obj); return -1; } - if (sc_llist_insert_sorted(collector_list, obj, - sc_plugin_cmp_next_update)) { - sc_object_deref(obj); + if (sdb_llist_insert_sorted(collector_list, obj, + sdb_plugin_cmp_next_update)) { + sdb_object_deref(obj); return -1; } /* pass control to the list */ - sc_object_deref(obj); + sdb_object_deref(obj); fprintf(stderr, "plugin: Registered collector callback '%s' " "(interval = %.3fs).\n", name, - SC_TIME_TO_DOUBLE(SC_PLUGIN_CCB(obj)->ccb_interval)); + SDB_TIME_TO_DOUBLE(SDB_PLUGIN_CCB(obj)->ccb_interval)); return 0; -} /* sc_plugin_register_collector */ +} /* sdb_plugin_register_collector */ -sc_plugin_ctx_t -sc_plugin_get_ctx(void) +sdb_plugin_ctx_t +sdb_plugin_get_ctx(void) { - sc_plugin_ctx_t *ctx; + sdb_plugin_ctx_t *ctx; if (! plugin_ctx_key_initialized) - sc_plugin_ctx_init(); + sdb_plugin_ctx_init(); ctx = pthread_getspecific(plugin_ctx_key); if (! ctx) - ctx = sc_plugin_ctx_create(); + ctx = sdb_plugin_ctx_create(); if (! ctx) return plugin_default_ctx; return *ctx; -} /* sc_plugin_get_ctx */ +} /* sdb_plugin_get_ctx */ -sc_plugin_ctx_t -sc_plugin_set_ctx(sc_plugin_ctx_t ctx) +sdb_plugin_ctx_t +sdb_plugin_set_ctx(sdb_plugin_ctx_t ctx) { - sc_plugin_ctx_t *tmp; - sc_plugin_ctx_t old; + sdb_plugin_ctx_t *tmp; + sdb_plugin_ctx_t old; if (! plugin_ctx_key_initialized) - sc_plugin_ctx_init(); + sdb_plugin_ctx_init(); tmp = pthread_getspecific(plugin_ctx_key); if (! tmp) - tmp = sc_plugin_ctx_create(); + tmp = sdb_plugin_ctx_create(); if (! tmp) return plugin_default_ctx; old = *tmp; *tmp = ctx; return old; -} /* sc_plugin_set_ctx */ +} /* sdb_plugin_set_ctx */ int -sc_plugin_configure(const char *name, oconfig_item_t *ci) +sdb_plugin_configure(const char *name, oconfig_item_t *ci) { - sc_plugin_cb_t *plugin; - sc_plugin_config_cb callback; + sdb_plugin_cb_t *plugin; + sdb_plugin_config_cb callback; - sc_plugin_ctx_t old_ctx; + sdb_plugin_ctx_t old_ctx; int status; if ((! name) || (! ci)) return -1; - plugin = sc_plugin_find_by_name(config_list, name); + plugin = sdb_plugin_find_by_name(config_list, name); if (! plugin) { fprintf(stderr, "plugin: Plugin '%s' did not register " "a config callback.\n", name); @@ -511,71 +513,71 @@ sc_plugin_configure(const char *name, oconfig_item_t *ci) return -1; } - old_ctx = sc_plugin_set_ctx(plugin->cb_ctx); + old_ctx = sdb_plugin_set_ctx(plugin->cb_ctx); callback = plugin->cb_callback; status = callback(ci); - sc_plugin_set_ctx(old_ctx); + sdb_plugin_set_ctx(old_ctx); return status; -} /* sc_plugin_configure */ +} /* sdb_plugin_configure */ int -sc_plugin_init_all(void) +sdb_plugin_init_all(void) { - sc_llist_iter_t *iter; + sdb_llist_iter_t *iter; - iter = sc_llist_get_iter(init_list); - while (sc_llist_iter_has_next(iter)) { - sc_plugin_init_cb callback; - sc_plugin_ctx_t old_ctx; + iter = sdb_llist_get_iter(init_list); + while (sdb_llist_iter_has_next(iter)) { + sdb_plugin_init_cb callback; + sdb_plugin_ctx_t old_ctx; - sc_object_t *obj = sc_llist_iter_get_next(iter); + sdb_object_t *obj = sdb_llist_iter_get_next(iter); assert(obj); - callback = SC_PLUGIN_CB(obj)->cb_callback; + callback = SDB_PLUGIN_CB(obj)->cb_callback; - old_ctx = sc_plugin_set_ctx(SC_PLUGIN_CB(obj)->cb_ctx); - if (callback(SC_PLUGIN_CB(obj)->cb_user_data)) { + old_ctx = sdb_plugin_set_ctx(SDB_PLUGIN_CB(obj)->cb_ctx); + if (callback(SDB_PLUGIN_CB(obj)->cb_user_data)) { /* XXX: unload plugin */ } - sc_plugin_set_ctx(old_ctx); + sdb_plugin_set_ctx(old_ctx); } return 0; -} /* sc_plugin_init_all */ +} /* sdb_plugin_init_all */ int -sc_plugin_collector_loop(sc_plugin_loop_t *loop) +sdb_plugin_collector_loop(sdb_plugin_loop_t *loop) { if ((! collector_list) || (! loop)) return -1; while (loop->do_loop) { - sc_plugin_collector_cb callback; - sc_plugin_ctx_t old_ctx; + sdb_plugin_collector_cb callback; + sdb_plugin_ctx_t old_ctx; - sc_time_t interval, now; + sdb_time_t interval, now; - sc_object_t *obj = sc_llist_shift(collector_list); + sdb_object_t *obj = sdb_llist_shift(collector_list); if (! obj) return -1; - callback = SC_PLUGIN_CCB(obj)->ccb_callback; + callback = SDB_PLUGIN_CCB(obj)->ccb_callback; - if (! (now = sc_gettime())) { + if (! (now = sdb_gettime())) { char errbuf[1024]; fprintf(stderr, "plugin: Failed to determine current time: %s\n", - sc_strerror(errno, errbuf, sizeof(errbuf))); - now = SC_PLUGIN_CCB(obj)->ccb_next_update; + sdb_strerror(errno, errbuf, sizeof(errbuf))); + now = SDB_PLUGIN_CCB(obj)->ccb_next_update; } - if (now < SC_PLUGIN_CCB(obj)->ccb_next_update) { - interval = SC_PLUGIN_CCB(obj)->ccb_next_update - now; + if (now < SDB_PLUGIN_CCB(obj)->ccb_next_update) { + interval = SDB_PLUGIN_CCB(obj)->ccb_next_update - now; errno = 0; - while (loop->do_loop && sc_sleep(interval, &interval)) { + while (loop->do_loop && sdb_sleep(interval, &interval)) { if (errno != EINTR) { char errbuf[1024]; fprintf(stderr, "plugin: Failed to sleep: %s\n", - sc_strerror(errno, errbuf, sizeof(errbuf))); + sdb_strerror(errno, errbuf, sizeof(errbuf))); return -1; } errno = 0; @@ -585,53 +587,53 @@ sc_plugin_collector_loop(sc_plugin_loop_t *loop) return 0; } - old_ctx = sc_plugin_set_ctx(SC_PLUGIN_CCB(obj)->ccb_ctx); - if (callback(SC_PLUGIN_CCB(obj)->ccb_user_data)) { + old_ctx = sdb_plugin_set_ctx(SDB_PLUGIN_CCB(obj)->ccb_ctx); + if (callback(SDB_PLUGIN_CCB(obj)->ccb_user_data)) { /* XXX */ } - sc_plugin_set_ctx(old_ctx); + sdb_plugin_set_ctx(old_ctx); - interval = SC_PLUGIN_CCB(obj)->ccb_interval; + interval = SDB_PLUGIN_CCB(obj)->ccb_interval; if (! interval) interval = loop->default_interval; if (! interval) { fprintf(stderr, "plugin: No interval configured " "for plugin '%s'; skipping any further " - "iterations.\n", SC_PLUGIN_CCB(obj)->ccb_name); - sc_object_deref(obj); + "iterations.\n", SDB_PLUGIN_CCB(obj)->ccb_name); + sdb_object_deref(obj); continue; } - SC_PLUGIN_CCB(obj)->ccb_next_update += interval; + SDB_PLUGIN_CCB(obj)->ccb_next_update += interval; - if (! (now = sc_gettime())) { + if (! (now = sdb_gettime())) { char errbuf[1024]; fprintf(stderr, "plugin: Failed to determine current time: %s\n", - sc_strerror(errno, errbuf, sizeof(errbuf))); - now = SC_PLUGIN_CCB(obj)->ccb_next_update; + sdb_strerror(errno, errbuf, sizeof(errbuf))); + now = SDB_PLUGIN_CCB(obj)->ccb_next_update; } - if (now > SC_PLUGIN_CCB(obj)->ccb_next_update) { + if (now > SDB_PLUGIN_CCB(obj)->ccb_next_update) { fprintf(stderr, "plugin: Plugin '%s' took too long; " "skipping iterations to keep up.\n", - SC_PLUGIN_CCB(obj)->ccb_name); - SC_PLUGIN_CCB(obj)->ccb_next_update = now; + SDB_PLUGIN_CCB(obj)->ccb_name); + SDB_PLUGIN_CCB(obj)->ccb_next_update = now; } - if (sc_llist_insert_sorted(collector_list, obj, - sc_plugin_cmp_next_update)) { + if (sdb_llist_insert_sorted(collector_list, obj, + sdb_plugin_cmp_next_update)) { fprintf(stderr, "plugin: Failed to re-insert " "plugin '%s' into collector list.\n", - SC_PLUGIN_CCB(obj)->ccb_name); - sc_object_deref(obj); + SDB_PLUGIN_CCB(obj)->ccb_name); + sdb_object_deref(obj); return -1; } /* pass control back to the list */ - sc_object_deref(obj); + sdb_object_deref(obj); } return 0; -} /* sc_plugin_read_loop */ +} /* sdb_plugin_read_loop */ /* vim: set tw=78 sw=4 ts=4 noexpandtab : */