mirror of
https://github.com/weechat/weechat.git
synced 2026-07-01 07:16:37 +02:00
Fix bug with writing of configuration files when disk is full (bug #29331)
This commit is contained in:
@@ -144,7 +144,7 @@ alias_config_reload (void *data, struct t_config_file *config_file)
|
||||
* file in section "cmd" (command)
|
||||
*/
|
||||
|
||||
void
|
||||
int
|
||||
alias_config_cmd_write_default_cb (void *data,
|
||||
struct t_config_file *config_file,
|
||||
const char *section_name)
|
||||
@@ -152,38 +152,71 @@ alias_config_cmd_write_default_cb (void *data,
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
weechat_config_write_line (config_file, section_name, NULL);
|
||||
if (!weechat_config_write_line (config_file, section_name, NULL))
|
||||
return WEECHAT_CONFIG_WRITE_ERROR;
|
||||
|
||||
weechat_config_write_line (config_file, "AAWAY", "%s", "\"allserv /away\"");
|
||||
weechat_config_write_line (config_file, "AME", "%s", "\"allchan /me\"");
|
||||
weechat_config_write_line (config_file, "AMSG", "%s", "\"allchan /msg *\"");
|
||||
weechat_config_write_line (config_file, "ANICK", "%s", "\"allserv /nick\"");
|
||||
weechat_config_write_line (config_file, "BYE", "%s", "\"quit\"");
|
||||
weechat_config_write_line (config_file, "C", "%s", "\"buffer clear\"");
|
||||
weechat_config_write_line (config_file, "CL", "%s", "\"buffer clear\"");
|
||||
weechat_config_write_line (config_file, "CLOSE", "%s", "\"buffer close\"");
|
||||
weechat_config_write_line (config_file, "CHAT", "%s", "\"dcc chat\"");
|
||||
weechat_config_write_line (config_file, "EXIT", "%s", "\"quit\"");
|
||||
weechat_config_write_line (config_file, "IG", "%s", "\"ignore\"");
|
||||
weechat_config_write_line (config_file, "J", "%s", "\"join\"");
|
||||
weechat_config_write_line (config_file, "K", "%s", "\"kick\"");
|
||||
weechat_config_write_line (config_file, "KB", "%s", "\"kickban\"");
|
||||
weechat_config_write_line (config_file, "LEAVE", "%s", "\"part\"");
|
||||
weechat_config_write_line (config_file, "M", "%s", "\"msg\"");
|
||||
weechat_config_write_line (config_file, "MUB", "%s", "\"unban *\"");
|
||||
weechat_config_write_line (config_file, "N", "%s", "\"names\"");
|
||||
weechat_config_write_line (config_file, "Q", "%s", "\"query\"");
|
||||
weechat_config_write_line (config_file, "REDRAW", "%s", "\"window refresh\"");
|
||||
weechat_config_write_line (config_file, "SAY", "%s", "\"msg *\"");
|
||||
weechat_config_write_line (config_file, "SIGNOFF", "%s", "\"quit\"");
|
||||
weechat_config_write_line (config_file, "T", "%s", "\"topic\"");
|
||||
weechat_config_write_line (config_file, "UB", "%s", "\"unban\"");
|
||||
weechat_config_write_line (config_file, "V", "%s", "\"command core version\"");
|
||||
weechat_config_write_line (config_file, "W", "%s", "\"who\"");
|
||||
weechat_config_write_line (config_file, "WC", "%s", "\"window merge\"");
|
||||
weechat_config_write_line (config_file, "WI", "%s", "\"whois\"");
|
||||
weechat_config_write_line (config_file, "WII", "%s", "\"whois $1 $1\"");
|
||||
weechat_config_write_line (config_file, "WW", "%s", "\"whowas\"");
|
||||
if (!weechat_config_write_line (config_file, "AAWAY", "%s", "\"allserv /away\""))
|
||||
return WEECHAT_CONFIG_WRITE_ERROR;
|
||||
if (!weechat_config_write_line (config_file, "AME", "%s", "\"allchan /me\""))
|
||||
return WEECHAT_CONFIG_WRITE_ERROR;
|
||||
if (!weechat_config_write_line (config_file, "AMSG", "%s", "\"allchan /msg *\""))
|
||||
return WEECHAT_CONFIG_WRITE_ERROR;
|
||||
if (!weechat_config_write_line (config_file, "ANICK", "%s", "\"allserv /nick\""))
|
||||
return WEECHAT_CONFIG_WRITE_ERROR;
|
||||
if (!weechat_config_write_line (config_file, "BYE", "%s", "\"quit\""))
|
||||
return WEECHAT_CONFIG_WRITE_ERROR;
|
||||
if (!weechat_config_write_line (config_file, "C", "%s", "\"buffer clear\""))
|
||||
return WEECHAT_CONFIG_WRITE_ERROR;
|
||||
if (!weechat_config_write_line (config_file, "CL", "%s", "\"buffer clear\""))
|
||||
return WEECHAT_CONFIG_WRITE_ERROR;
|
||||
if (!weechat_config_write_line (config_file, "CLOSE", "%s", "\"buffer close\""))
|
||||
return WEECHAT_CONFIG_WRITE_ERROR;
|
||||
if (!weechat_config_write_line (config_file, "CHAT", "%s", "\"dcc chat\""))
|
||||
return WEECHAT_CONFIG_WRITE_ERROR;
|
||||
if (!weechat_config_write_line (config_file, "EXIT", "%s", "\"quit\""))
|
||||
return WEECHAT_CONFIG_WRITE_ERROR;
|
||||
if (!weechat_config_write_line (config_file, "IG", "%s", "\"ignore\""))
|
||||
return WEECHAT_CONFIG_WRITE_ERROR;
|
||||
if (!weechat_config_write_line (config_file, "J", "%s", "\"join\""))
|
||||
return WEECHAT_CONFIG_WRITE_ERROR;
|
||||
if (!weechat_config_write_line (config_file, "K", "%s", "\"kick\""))
|
||||
return WEECHAT_CONFIG_WRITE_ERROR;
|
||||
if (!weechat_config_write_line (config_file, "KB", "%s", "\"kickban\""))
|
||||
return WEECHAT_CONFIG_WRITE_ERROR;
|
||||
if (!weechat_config_write_line (config_file, "LEAVE", "%s", "\"part\""))
|
||||
return WEECHAT_CONFIG_WRITE_ERROR;
|
||||
if (!weechat_config_write_line (config_file, "M", "%s", "\"msg\""))
|
||||
return WEECHAT_CONFIG_WRITE_ERROR;
|
||||
if (!weechat_config_write_line (config_file, "MUB", "%s", "\"unban *\""))
|
||||
return WEECHAT_CONFIG_WRITE_ERROR;
|
||||
if (!weechat_config_write_line (config_file, "N", "%s", "\"names\""))
|
||||
return WEECHAT_CONFIG_WRITE_ERROR;
|
||||
if (!weechat_config_write_line (config_file, "Q", "%s", "\"query\""))
|
||||
return WEECHAT_CONFIG_WRITE_ERROR;
|
||||
if (!weechat_config_write_line (config_file, "REDRAW", "%s", "\"window refresh\""))
|
||||
return WEECHAT_CONFIG_WRITE_ERROR;
|
||||
if (!weechat_config_write_line (config_file, "SAY", "%s", "\"msg *\""))
|
||||
return WEECHAT_CONFIG_WRITE_ERROR;
|
||||
if (!weechat_config_write_line (config_file, "SIGNOFF", "%s", "\"quit\""))
|
||||
return WEECHAT_CONFIG_WRITE_ERROR;
|
||||
if (!weechat_config_write_line (config_file, "T", "%s", "\"topic\""))
|
||||
return WEECHAT_CONFIG_WRITE_ERROR;
|
||||
if (!weechat_config_write_line (config_file, "UB", "%s", "\"unban\""))
|
||||
return WEECHAT_CONFIG_WRITE_ERROR;
|
||||
if (!weechat_config_write_line (config_file, "V", "%s", "\"command core version\""))
|
||||
return WEECHAT_CONFIG_WRITE_ERROR;
|
||||
if (!weechat_config_write_line (config_file, "W", "%s", "\"who\""))
|
||||
return WEECHAT_CONFIG_WRITE_ERROR;
|
||||
if (!weechat_config_write_line (config_file, "WC", "%s", "\"window merge\""))
|
||||
return WEECHAT_CONFIG_WRITE_ERROR;
|
||||
if (!weechat_config_write_line (config_file, "WI", "%s", "\"whois\""))
|
||||
return WEECHAT_CONFIG_WRITE_ERROR;
|
||||
if (!weechat_config_write_line (config_file, "WII", "%s", "\"whois $1 $1\""))
|
||||
return WEECHAT_CONFIG_WRITE_ERROR;
|
||||
if (!weechat_config_write_line (config_file, "WW", "%s", "\"whowas\""))
|
||||
return WEECHAT_CONFIG_WRITE_ERROR;
|
||||
|
||||
return WEECHAT_CONFIG_WRITE_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -744,15 +744,15 @@ irc_config_ctcp_create_option (void *data, struct t_config_file *config_file,
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_config_ignore_read: read ignore option from configuration file
|
||||
* return 1 if ok, 0 if error
|
||||
* irc_config_ignore_read_cb: read ignore option from configuration file
|
||||
* return 1 if ok, 0 if error
|
||||
*/
|
||||
|
||||
int
|
||||
irc_config_ignore_read (void *data,
|
||||
struct t_config_file *config_file,
|
||||
struct t_config_section *section,
|
||||
const char *option_name, const char *value)
|
||||
irc_config_ignore_read_cb (void *data,
|
||||
struct t_config_file *config_file,
|
||||
struct t_config_section *section,
|
||||
const char *option_name, const char *value)
|
||||
{
|
||||
char **argv, **argv_eol;
|
||||
int argc;
|
||||
@@ -783,30 +783,34 @@ irc_config_ignore_read (void *data,
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_config_ignore_write: write ignore section in configuration file
|
||||
* irc_config_ignore_write_cb: write ignore section in configuration file
|
||||
*/
|
||||
|
||||
void
|
||||
irc_config_ignore_write (void *data, struct t_config_file *config_file,
|
||||
const char *section_name)
|
||||
int
|
||||
irc_config_ignore_write_cb (void *data, struct t_config_file *config_file,
|
||||
const char *section_name)
|
||||
{
|
||||
struct t_irc_ignore *ptr_ignore;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
weechat_config_write_line (config_file, section_name, NULL);
|
||||
if (!weechat_config_write_line (config_file, section_name, NULL))
|
||||
return WEECHAT_CONFIG_WRITE_ERROR;
|
||||
|
||||
for (ptr_ignore = irc_ignore_list; ptr_ignore;
|
||||
ptr_ignore = ptr_ignore->next_ignore)
|
||||
{
|
||||
weechat_config_write_line (config_file,
|
||||
"ignore",
|
||||
"%s;%s;%s",
|
||||
(ptr_ignore->server) ? ptr_ignore->server : "*",
|
||||
(ptr_ignore->channel) ? ptr_ignore->channel : "*",
|
||||
ptr_ignore->mask);
|
||||
if (!weechat_config_write_line (config_file,
|
||||
"ignore",
|
||||
"%s;%s;%s",
|
||||
(ptr_ignore->server) ? ptr_ignore->server : "*",
|
||||
(ptr_ignore->channel) ? ptr_ignore->channel : "*",
|
||||
ptr_ignore->mask))
|
||||
return WEECHAT_CONFIG_WRITE_ERROR;
|
||||
}
|
||||
|
||||
return WEECHAT_CONFIG_WRITE_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -814,7 +818,7 @@ irc_config_ignore_write (void *data, struct t_config_file *config_file,
|
||||
* configuration file
|
||||
*/
|
||||
|
||||
void
|
||||
int
|
||||
irc_config_server_write_default_cb (void *data,
|
||||
struct t_config_file *config_file,
|
||||
const char *section_name)
|
||||
@@ -825,7 +829,8 @@ irc_config_server_write_default_cb (void *data,
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
weechat_config_write_line (config_file, section_name, NULL);
|
||||
if (!weechat_config_write_line (config_file, section_name, NULL))
|
||||
return WEECHAT_CONFIG_WRITE_ERROR;
|
||||
|
||||
for (i = 0; i < IRC_SERVER_NUM_OPTIONS; i++)
|
||||
{
|
||||
@@ -835,17 +840,21 @@ irc_config_server_write_default_cb (void *data,
|
||||
switch (i)
|
||||
{
|
||||
case IRC_SERVER_OPTION_ADDRESSES:
|
||||
weechat_config_write_line (config_file,
|
||||
option_name,
|
||||
"%s", "\"chat.freenode.net/6667\"");
|
||||
if (!weechat_config_write_line (config_file,
|
||||
option_name,
|
||||
"%s", "\"chat.freenode.net/6667\""))
|
||||
return WEECHAT_CONFIG_WRITE_ERROR;
|
||||
break;
|
||||
default:
|
||||
weechat_config_write_line (config_file,
|
||||
option_name,
|
||||
WEECHAT_CONFIG_OPTION_NULL);
|
||||
if (!weechat_config_write_line (config_file,
|
||||
option_name,
|
||||
WEECHAT_CONFIG_OPTION_NULL))
|
||||
return WEECHAT_CONFIG_WRITE_ERROR;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return WEECHAT_CONFIG_WRITE_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1251,7 +1260,7 @@ irc_config_server_read_cb (void *data, struct t_config_file *config_file,
|
||||
* irc_config_server_write_cb: write server section in configuration file
|
||||
*/
|
||||
|
||||
void
|
||||
int
|
||||
irc_config_server_write_cb (void *data, struct t_config_file *config_file,
|
||||
const char *section_name)
|
||||
{
|
||||
@@ -1261,7 +1270,8 @@ irc_config_server_write_cb (void *data, struct t_config_file *config_file,
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
weechat_config_write_line (config_file, section_name, NULL);
|
||||
if (!weechat_config_write_line (config_file, section_name, NULL))
|
||||
return WEECHAT_CONFIG_WRITE_ERROR;
|
||||
|
||||
for (ptr_server = irc_servers; ptr_server;
|
||||
ptr_server = ptr_server->next_server)
|
||||
@@ -1270,11 +1280,14 @@ irc_config_server_write_cb (void *data, struct t_config_file *config_file,
|
||||
{
|
||||
for (i = 0; i < IRC_SERVER_NUM_OPTIONS; i++)
|
||||
{
|
||||
weechat_config_write_option (config_file,
|
||||
ptr_server->options[i]);
|
||||
if (!weechat_config_write_option (config_file,
|
||||
ptr_server->options[i]))
|
||||
return WEECHAT_CONFIG_WRITE_ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return WEECHAT_CONFIG_WRITE_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1741,9 +1754,9 @@ irc_config_init ()
|
||||
/* ignore */
|
||||
ptr_section = weechat_config_new_section (irc_config_file, "ignore",
|
||||
0, 0,
|
||||
&irc_config_ignore_read, NULL,
|
||||
&irc_config_ignore_write, NULL,
|
||||
&irc_config_ignore_write, NULL,
|
||||
&irc_config_ignore_read_cb, NULL,
|
||||
&irc_config_ignore_write_cb, NULL,
|
||||
&irc_config_ignore_write_cb, NULL,
|
||||
NULL, NULL, NULL, NULL);
|
||||
if (!ptr_section)
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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]);
|
||||
|
||||
@@ -248,13 +248,13 @@ struct t_weechat_plugin
|
||||
const char *option_name,
|
||||
const char *value),
|
||||
void *callback_read_data,
|
||||
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),
|
||||
void *callback_write_data,
|
||||
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),
|
||||
void *callback_write_default_data,
|
||||
int (*callback_create_option)(void *data,
|
||||
struct t_config_file *config_file,
|
||||
@@ -325,11 +325,11 @@ struct t_weechat_plugin
|
||||
const char *(*config_string_default) (struct t_config_option *option);
|
||||
const char *(*config_color) (struct t_config_option *option);
|
||||
const char *(*config_color_default) (struct t_config_option *option);
|
||||
void (*config_write_option) (struct t_config_file *config_file,
|
||||
struct t_config_option *option);
|
||||
void (*config_write_line) (struct t_config_file *config_file,
|
||||
const char *option_name,
|
||||
const char *value, ...);
|
||||
int (*config_write_option) (struct t_config_file *config_file,
|
||||
struct t_config_option *option);
|
||||
int (*config_write_line) (struct t_config_file *config_file,
|
||||
const char *option_name,
|
||||
const char *value, ...);
|
||||
int (*config_write) (struct t_config_file *config_file);
|
||||
int (*config_read) (struct t_config_file *config_file);
|
||||
int (*config_reload) (struct t_config_file *config_file);
|
||||
|
||||
Reference in New Issue
Block a user