1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-26 04:46:37 +02:00

Fix bug with writing of configuration files when disk is full (bug #29331)

This commit is contained in:
Sebastien Helleu
2010-03-26 19:01:25 +01:00
parent 24135801b4
commit b9e65ec63d
28 changed files with 570 additions and 320 deletions
+24 -6
View File
@@ -1345,14 +1345,14 @@ weechat_lua_api_config_read_cb (void *data,
* weechat_lua_api_config_section_write_cb: callback for writing section
*/
void
int
weechat_lua_api_config_section_write_cb (void *data,
struct t_config_file *config_file,
const char *section_name)
{
struct t_script_callback *script_callback;
char *lua_argv[4], empty_arg[1] = { '\0' };
int *rc;
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@@ -1368,11 +1368,20 @@ weechat_lua_api_config_section_write_cb (void *data,
script_callback->function,
lua_argv);
if (rc)
if (!rc)
ret = WEECHAT_CONFIG_WRITE_ERROR;
else
{
ret = *rc;
free (rc);
}
if (lua_argv[1])
free (lua_argv[1]);
return ret;
}
return WEECHAT_CONFIG_WRITE_ERROR;
}
/*
@@ -1380,14 +1389,14 @@ weechat_lua_api_config_section_write_cb (void *data,
* default values for section
*/
void
int
weechat_lua_api_config_section_write_default_cb (void *data,
struct t_config_file *config_file,
const char *section_name)
{
struct t_script_callback *script_callback;
char *lua_argv[4], empty_arg[1] = { '\0' };
int *rc;
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@@ -1403,11 +1412,20 @@ weechat_lua_api_config_section_write_default_cb (void *data,
script_callback->function,
lua_argv);
if (rc)
if (!rc)
ret = WEECHAT_CONFIG_WRITE_ERROR;
else
{
ret = *rc;
free (rc);
}
if (lua_argv[1])
free (lua_argv[1]);
return ret;
}
return WEECHAT_CONFIG_WRITE_ERROR;
}
/*
+26 -8
View File
@@ -1119,14 +1119,14 @@ weechat_perl_api_config_section_read_cb (void *data,
* weechat_perl_api_config_section_write_cb: callback for writing section
*/
void
int
weechat_perl_api_config_section_write_cb (void *data,
struct t_config_file *config_file,
const char *section_name)
{
struct t_script_callback *script_callback;
char *perl_argv[4], empty_arg[1] = { '\0' };
int *rc;
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@@ -1142,11 +1142,20 @@ weechat_perl_api_config_section_write_cb (void *data,
script_callback->function,
perl_argv);
if (rc)
if (!rc)
ret = WEECHAT_CONFIG_WRITE_ERROR;
else
{
ret = *rc;
free (rc);
}
if (perl_argv[1])
free (perl_argv[1]);
return ret;
}
return WEECHAT_CONFIG_WRITE_ERROR;
}
/*
@@ -1154,17 +1163,17 @@ weechat_perl_api_config_section_write_cb (void *data,
* default values for section
*/
void
int
weechat_perl_api_config_section_write_default_cb (void *data,
struct t_config_file *config_file,
const char *section_name)
{
struct t_script_callback *script_callback;
char *perl_argv[4], empty_arg[1] = { '\0' };
int *rc;
int *rc, ret;
script_callback = (struct t_script_callback *)data;
if (script_callback && script_callback->function && script_callback->function[0])
{
perl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
@@ -1176,12 +1185,21 @@ weechat_perl_api_config_section_write_default_cb (void *data,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
perl_argv);
if (rc)
if (!rc)
ret = WEECHAT_CONFIG_WRITE_ERROR;
else
{
ret = *rc;
free (rc);
}
if (perl_argv[1])
free (perl_argv[1]);
return ret;
}
return WEECHAT_CONFIG_WRITE_ERROR;
}
/*
@@ -1184,14 +1184,14 @@ weechat_python_api_config_read_cb (void *data,
* weechat_python_api_config_section_write_cb: callback for writing section
*/
void
int
weechat_python_api_config_section_write_cb (void *data,
struct t_config_file *config_file,
const char *section_name)
{
struct t_script_callback *script_callback;
char *python_argv[4], empty_arg[1] = { '\0' };
int *rc;
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@@ -1207,11 +1207,20 @@ weechat_python_api_config_section_write_cb (void *data,
script_callback->function,
python_argv);
if (rc)
if (!rc)
ret = WEECHAT_CONFIG_WRITE_ERROR;
else
{
ret = *rc;
free (rc);
}
if (python_argv[1])
free (python_argv[1]);
return ret;
}
return WEECHAT_CONFIG_WRITE_ERROR;
}
/*
@@ -1219,14 +1228,14 @@ weechat_python_api_config_section_write_cb (void *data,
* default values for section
*/
void
int
weechat_python_api_config_section_write_default_cb (void *data,
struct t_config_file *config_file,
const char *section_name)
{
struct t_script_callback *script_callback;
char *python_argv[4], empty_arg[1] = { '\0' };
int *rc;
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@@ -1242,11 +1251,20 @@ weechat_python_api_config_section_write_default_cb (void *data,
script_callback->function,
python_argv);
if (rc)
if (!rc)
ret = WEECHAT_CONFIG_WRITE_ERROR;
else
{
ret = *rc;
free (rc);
}
if (python_argv[1])
free (python_argv[1]);
return ret;
}
return WEECHAT_CONFIG_WRITE_ERROR;
}
/*
+25 -7
View File
@@ -1353,14 +1353,14 @@ weechat_ruby_api_config_read_cb (void *data,
* weechat_ruby_api_config_section_write_cb: callback for writing section
*/
void
int
weechat_ruby_api_config_section_write_cb (void *data,
struct t_config_file *config_file,
const char *section_name)
{
struct t_script_callback *script_callback;
char *ruby_argv[4], empty_arg[1] = { '\0' };
int *rc;
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@@ -1376,11 +1376,20 @@ weechat_ruby_api_config_section_write_cb (void *data,
script_callback->function,
ruby_argv);
if (rc)
if (!rc)
ret = WEECHAT_CONFIG_WRITE_ERROR;
else
{
ret = *rc;
free (rc);
}
if (ruby_argv[1])
free (ruby_argv[1]);
return ret;
}
return WEECHAT_CONFIG_WRITE_ERROR;
}
/*
@@ -1388,17 +1397,17 @@ weechat_ruby_api_config_section_write_cb (void *data,
* default values for section
*/
void
int
weechat_ruby_api_config_section_write_default_cb (void *data,
struct t_config_file *config_file,
const char *section_name)
{
struct t_script_callback *script_callback;
char *ruby_argv[4], empty_arg[1] = { '\0' };
int *rc;
int *rc, ret;
script_callback = (struct t_script_callback *)data;
if (script_callback && script_callback->function && script_callback->function[0])
{
ruby_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
@@ -1411,11 +1420,20 @@ weechat_ruby_api_config_section_write_default_cb (void *data,
script_callback->function,
ruby_argv);
if (rc)
if (!rc)
ret = WEECHAT_CONFIG_WRITE_ERROR;
else
{
ret = *rc;
free (rc);
}
if (ruby_argv[1])
free (ruby_argv[1]);
return ret;
}
return WEECHAT_CONFIG_WRITE_ERROR;
}
/*
+6 -6
View File
@@ -108,14 +108,14 @@ script_api_config_new_section (struct t_weechat_plugin *weechat_plugin,
const char *value),
const char *function_read,
const char *data_read,
void (*callback_write)(void *data,
struct t_config_file *config_file,
const char *section_name),
int (*callback_write)(void *data,
struct t_config_file *config_file,
const char *section_name),
const char *function_write,
const char *data_write,
void (*callback_write_default)(void *data,
struct t_config_file *config_file,
const char *section_name),
int (*callback_write_default)(void *data,
struct t_config_file *config_file,
const char *section_name),
const char *function_write_default,
const char *data_write_default,
int (*callback_create_option)(void *data,
+2 -2
View File
@@ -41,12 +41,12 @@ extern struct t_config_section *script_api_config_new_section (struct t_weechat_
const char *value),
const char *function_read,
const char *data_read,
void (*callback_write)(void *data,
int (*callback_write)(void *data,
struct t_config_file *config_file,
const char *section_name),
const char *function_write,
const char *data_write,
void (*callback_write_default)(void *data,
int (*callback_write_default)(void *data,
struct t_config_file *config_file,
const char *section_name),
const char *function_write_default,
+49 -31
View File
@@ -1352,34 +1352,43 @@ weechat_tcl_api_config_section_read_cb (void *data,
* weechat_tcl_api_config_section_write_cb: callback for writing section
*/
void
int
weechat_tcl_api_config_section_write_cb (void *data,
struct t_config_file *config_file,
const char *section_name)
{
struct t_script_callback *script_callback;
char *tcl_argv[4], empty_arg[1] = { '\0' };
int *rc;
int *rc, ret;
script_callback = (struct t_script_callback *)data;
if (script_callback && script_callback->function && script_callback->function[0])
{
tcl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
tcl_argv[1] = script_ptr2str (config_file);
tcl_argv[2] = (section_name) ? (char *)section_name : empty_arg;
tcl_argv[3] = NULL;
rc = (int *) weechat_tcl_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
tcl_argv);
if (rc)
rc = (int *) weechat_tcl_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
tcl_argv);
if (!rc)
ret = WEECHAT_CONFIG_WRITE_ERROR;
else
{
ret = *rc;
free (rc);
}
if (tcl_argv[1])
free (tcl_argv[1]);
return ret;
}
return WEECHAT_CONFIG_WRITE_ERROR;
}
/*
@@ -1387,17 +1396,17 @@ weechat_tcl_api_config_section_write_cb (void *data,
* default values for section
*/
void
int
weechat_tcl_api_config_section_write_default_cb (void *data,
struct t_config_file *config_file,
const char *section_name)
{
struct t_script_callback *script_callback;
char *tcl_argv[4], empty_arg[1] = { '\0' };
int *rc;
int *rc, ret;
script_callback = (struct t_script_callback *)data;
if (script_callback && script_callback->function && script_callback->function[0])
{
tcl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
@@ -1406,15 +1415,24 @@ weechat_tcl_api_config_section_write_default_cb (void *data,
tcl_argv[3] = NULL;
rc = (int *) weechat_tcl_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
tcl_argv);
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
tcl_argv);
if (rc)
if (!rc)
ret = WEECHAT_CONFIG_WRITE_ERROR;
else
{
ret = *rc;
free (rc);
}
if (tcl_argv[1])
free (tcl_argv[1]);
return ret;
}
return WEECHAT_CONFIG_WRITE_ERROR;
}
/*
@@ -1445,9 +1463,9 @@ weechat_tcl_api_config_section_create_option_cb (void *data,
tcl_argv[5] = NULL;
rc = (int *) weechat_tcl_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
tcl_argv);
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
tcl_argv);
if (!rc)
ret = WEECHAT_CONFIG_OPTION_SET_ERROR;
@@ -1493,9 +1511,9 @@ weechat_tcl_api_config_section_delete_option_cb (void *data,
tcl_argv[4] = NULL;
rc = (int *) weechat_tcl_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
tcl_argv);
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
tcl_argv);
if (!rc)
ret = WEECHAT_CONFIG_OPTION_UNSET_ERROR;
@@ -1654,9 +1672,9 @@ weechat_tcl_api_config_option_check_value_cb (void *data,
tcl_argv[3] = NULL;
rc = (int *) weechat_tcl_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
tcl_argv);
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
tcl_argv);
if (!rc)
ret = 0;
@@ -1695,9 +1713,9 @@ weechat_tcl_api_config_option_change_cb (void *data,
tcl_argv[2] = NULL;
rc = (int *) weechat_tcl_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
tcl_argv);
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
tcl_argv);
if (tcl_argv[1])
free (tcl_argv[1]);
@@ -1728,9 +1746,9 @@ weechat_tcl_api_config_option_delete_cb (void *data,
tcl_argv[2] = NULL;
rc = (int *) weechat_tcl_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
tcl_argv);
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
tcl_argv);
if (tcl_argv[1])
free (tcl_argv[1]);