} /* }}} int clua_load_callback */
/* Store the threads in a global variable so they are not cleaned up by the
} /* }}} int clua_load_callback */
/* Store the threads in a global variable so they are not cleaned up by the
lua_pushvalue(L, idx); /* +1 = 3 */
if (!lua_isthread(L, -1)) {
lua_pop(L, 3); /* -3 = 0 */
lua_pushvalue(L, idx); /* +1 = 3 */
if (!lua_isthread(L, -1)) {
lua_pop(L, 3); /* -3 = 0 */
}
luaL_ref(L, LUA_REGISTRYINDEX);
lua_pop(L, 1); /* -1 = 0 */
}
luaL_ref(L, LUA_REGISTRYINDEX);
lua_pop(L, 1); /* -1 = 0 */
ERROR("Lua plugin: Unable to load callback \"%s\" (id %i).",
cb->lua_function_name, cb->callback_id);
pthread_mutex_unlock(&cb->lock);
ERROR("Lua plugin: Unable to load callback \"%s\" (id %i).",
cb->lua_function_name, cb->callback_id);
pthread_mutex_unlock(&cb->lock);
ERROR("Lua plugin: Calling a read callback failed: %s", errmsg);
lua_pop(L, 1);
pthread_mutex_unlock(&cb->lock);
ERROR("Lua plugin: Calling a read callback failed: %s", errmsg);
lua_pop(L, 1);
pthread_mutex_unlock(&cb->lock);
lua_pop(L, 1); /* -1 = 0 */
pthread_mutex_unlock(&cb->lock);
lua_pop(L, 1); /* -1 = 0 */
pthread_mutex_unlock(&cb->lock);
} /* }}} int clua_read */
static int clua_write(const data_set_t *ds, const value_list_t *vl, /* {{{ */
} /* }}} int clua_read */
static int clua_write(const data_set_t *ds, const value_list_t *vl, /* {{{ */
ERROR("Lua plugin: Unable to load callback \"%s\" (id %i).",
cb->lua_function_name, cb->callback_id);
pthread_mutex_unlock(&cb->lock);
ERROR("Lua plugin: Unable to load callback \"%s\" (id %i).",
cb->lua_function_name, cb->callback_id);
pthread_mutex_unlock(&cb->lock);
lua_pop(L, 1); /* -1 = 0 */
pthread_mutex_unlock(&cb->lock);
ERROR("Lua plugin: luaC_pushvaluelist failed.");
lua_pop(L, 1); /* -1 = 0 */
pthread_mutex_unlock(&cb->lock);
ERROR("Lua plugin: luaC_pushvaluelist failed.");
ERROR("Lua plugin: Calling the write callback failed:\n%s", errmsg);
lua_pop(L, 1); /* -1 = 0 */
pthread_mutex_unlock(&cb->lock);
ERROR("Lua plugin: Calling the write callback failed:\n%s", errmsg);
lua_pop(L, 1); /* -1 = 0 */
pthread_mutex_unlock(&cb->lock);
lua_pop(L, 1); /* -1 = 0 */
pthread_mutex_unlock(&cb->lock);
lua_pop(L, 1); /* -1 = 0 */
pthread_mutex_unlock(&cb->lock);
luaL_checktype(L, 1, LUA_TFUNCTION);
char function_name[DATA_MAX_NAME_LEN];
luaL_checktype(L, 1, LUA_TFUNCTION);
char function_name[DATA_MAX_NAME_LEN];
- ssnprintf(function_name, sizeof(function_name), "lua/%s", lua_tostring(L, 1));
+ snprintf(function_name, sizeof(function_name), "lua/%s", lua_tostring(L, 1));
cb->lua_function_name = strdup(function_name);
pthread_mutex_init(&cb->lock, NULL);
cb->lua_function_name = strdup(function_name);
pthread_mutex_init(&cb->lock, NULL);
int status = plugin_register_complex_read(/* group = */ "lua",
/* name = */ function_name,
/* callback = */ clua_read,
/* interval = */ 0,
int status = plugin_register_complex_read(/* group = */ "lua",
/* name = */ function_name,
/* callback = */ clua_read,
/* interval = */ 0,
luaL_checktype(L, 1, LUA_TFUNCTION);
char function_name[DATA_MAX_NAME_LEN] = "";
luaL_checktype(L, 1, LUA_TFUNCTION);
char function_name[DATA_MAX_NAME_LEN] = "";
- ssnprintf(function_name, sizeof(function_name), "lua/%s", lua_tostring(L, 1));
+ snprintf(function_name, sizeof(function_name), "lua/%s", lua_tostring(L, 1));
cb->lua_function_name = strdup(function_name);
pthread_mutex_init(&cb->lock, NULL);
cb->lua_function_name = strdup(function_name);
pthread_mutex_init(&cb->lock, NULL);
int status = plugin_register_write(/* name = */ function_name,
/* callback = */ clua_write,
int status = plugin_register_write(/* name = */ function_name,
/* callback = */ clua_write,
script->lua_state = luaL_newstate();
if (script->lua_state == NULL) {
ERROR("Lua plugin: luaL_newstate() failed.");
script->lua_state = luaL_newstate();
if (script->lua_state == NULL) {
ERROR("Lua plugin: luaL_newstate() failed.");
}
script->script_path = strdup(script_path);
if (script->script_path == NULL) {
ERROR("Lua plugin: strdup failed.");
lua_script_free(script);
}
script->script_path = strdup(script_path);
if (script->script_path == NULL) {
ERROR("Lua plugin: strdup failed.");
lua_script_free(script);
lua_tostring(script->lua_state, -1));
lua_pop(script->lua_state, 1);
lua_script_free(script);
lua_tostring(script->lua_state, -1));
lua_pop(script->lua_state, 1);
lua_script_free(script);
} /* }}} int lua_script_load */
static int lua_config_base_path(const oconfig_item_t *ci) /* {{{ */
{
int status = cf_util_get_string_buffer(ci, base_path, sizeof(base_path));
if (status != 0)
} /* }}} int lua_script_load */
static int lua_config_base_path(const oconfig_item_t *ci) /* {{{ */
{
int status = cf_util_get_string_buffer(ci, base_path, sizeof(base_path));
if (status != 0)
} /* }}} int lua_config_base_path */
static int lua_config_script(const oconfig_item_t *ci) /* {{{ */
} /* }}} int lua_config_base_path */
static int lua_config_script(const oconfig_item_t *ci) /* {{{ */
char abs_path[PATH_MAX];
if (base_path[0] == '\0')
sstrncpy(abs_path, rel_path, sizeof(abs_path));
else
char abs_path[PATH_MAX];
if (base_path[0] == '\0')
sstrncpy(abs_path, rel_path, sizeof(abs_path));
else
- ssnprintf(abs_path, sizeof(abs_path), "%s/%s", base_path, rel_path);
+ snprintf(abs_path, sizeof(abs_path), "%s/%s", base_path, rel_path);
DEBUG("Lua plugin: abs_path = \"%s\";", abs_path);
status = lua_script_load(abs_path);
if (status != 0)
DEBUG("Lua plugin: abs_path = \"%s\";", abs_path);
status = lua_script_load(abs_path);
if (status != 0)
} /* }}} int lua_shutdown */
void module_register(void) {
plugin_register_complex_config("lua", lua_config);
plugin_register_shutdown("lua", lua_shutdown);
}
} /* }}} int lua_shutdown */
void module_register(void) {
plugin_register_complex_config("lua", lua_config);
plugin_register_shutdown("lua", lua_shutdown);
}