1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-24 11:56: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
+59
View File
@@ -869,6 +869,64 @@ API_FUNC(config_new)
API_RETURN_STRING(result);
}
struct t_hashtable *
weechat_python_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_python_exec (script,
WEECHAT_SCRIPT_EXEC_HASHTABLE,
ptr_function,
"ssih", func_argv);
return ret_hashtable;
}
return NULL;
}
API_FUNC(config_set_version)
{
char *config_file, *function, *data;
int rc, version;
API_INIT_FUNC(1, "config_set_version", API_RETURN_INT(0));
config_file = NULL;
version = 0;
function = NULL;
data = NULL;
if (!PyArg_ParseTuple (args, "siss", &config_file, &version, &function, &data))
API_WRONG_ARGS(API_RETURN_INT(0));
rc = plugin_script_api_config_set_version (
weechat_python_plugin,
python_current_script,
API_STR2PTR(config_file),
version,
&weechat_python_api_config_update_cb,
function,
data);
API_RETURN_INT(rc);
}
int
weechat_python_api_config_read_cb (const void *pointer, void *data,
struct t_config_file *config_file,
@@ -5315,6 +5373,7 @@ PyMethodDef weechat_python_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),