1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-28 05:46:38 +02:00

core: add configuration version, add API function config_set_version

This commit is contained in:
Sébastien Helleu
2023-02-21 07:06:01 +01:00
parent 7b8e5b36c0
commit 66571a0b63
27 changed files with 1792 additions and 41 deletions
+60
View File
@@ -940,6 +940,65 @@ API_FUNC(config_new)
API_RETURN_STRING(result);
}
struct t_hashtable *
weechat_lua_api_config_update_cb (const void *pointer, void *data,
struct t_config_file *config_file,
int version_read,
struct t_hashtable *data_read)
{
struct t_plugin_script *script;
void *func_argv[4];
char empty_arg[1] = { '\0' };
const char *ptr_function, *ptr_data;
struct t_hashtable *ret_hashtable;
script = (struct t_plugin_script *)pointer;
plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
if (ptr_function && ptr_function[0])
{
func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = (char *)API_PTR2STR(config_file);
func_argv[2] = &version_read;
func_argv[3] = data_read;
ret_hashtable = weechat_lua_exec (script,
WEECHAT_SCRIPT_EXEC_HASHTABLE,
ptr_function,
"ssih", func_argv);
return ret_hashtable;
}
return NULL;
}
API_FUNC(config_set_version)
{
const char *config_file, *function, *data;
int rc, version;
API_INIT_FUNC(1, "config_set_version", API_RETURN_INT(0));
if (lua_gettop (L) < 4)
API_WRONG_ARGS(API_RETURN_INT(0));
config_file = lua_tostring (L, -4);
version = lua_tonumber (L, -3);
function = lua_tostring (L, -2);
data = lua_tostring (L, -1);
rc = plugin_script_api_config_set_version (
weechat_lua_plugin,
lua_current_script,
API_STR2PTR(config_file),
version,
&weechat_lua_api_config_update_cb,
function,
data);
API_RETURN_INT(rc);
}
int
weechat_lua_api_config_read_cb (const void *pointer, void *data,
struct t_config_file *config_file,
@@ -5451,6 +5510,7 @@ const struct luaL_Reg weechat_lua_api_funcs[] = {
API_DEF_FUNC(list_remove_all),
API_DEF_FUNC(list_free),
API_DEF_FUNC(config_new),
API_DEF_FUNC(config_set_version),
API_DEF_FUNC(config_new_section),
API_DEF_FUNC(config_search_section),
API_DEF_FUNC(config_new_option),