Add constants for config file read/write/set/unset callbacks

This commit is contained in:
Sebastien Helleu 2008-06-02 15:42:43 +02:00
parent 40ec612e73
commit 96a3481b69
14 changed files with 416 additions and 173 deletions

View File

@ -1103,8 +1103,8 @@ msgstr "la cadena mostrada tras la finalización de los nombres de usuario"
#, fuzzy
msgid "use a marker (line or char) on buffers to show first unread line"
msgstr ""
"usar un marcador en los servidores/canales para mostrar la primera línea "
"sin leer"
"usar un marcador en los servidores/canales para mostrar la primera línea sin "
"leer"
#, fuzzy
msgid "save configuration file on exit"
@ -1599,8 +1599,8 @@ msgid ""
"support.\n"
"Be careful, private info may be in these files.\n"
msgstr ""
"Por favor, envía %s/%s, %s/%s y los mensajes de arriba a los "
"desarrolladores de Weechat para el soporte.\n"
"Por favor, envía %s/%s, %s/%s y los mensajes de arriba a los desarrolladores "
"de Weechat para el soporte.\n"
"Sé cuidadoso, puede que haya información privada en estos ficheros.\n"
#, c-format
@ -5374,8 +5374,8 @@ msgstr "%s falta un argumento para la opción --dir\n"
#~ "maximum number of lines in history for one server/channel/private window "
#~ "(0 = unlimited)"
#~ msgstr ""
#~ "número máximo de líneas en el histórico para un servidor/canal/"
#~ "privado (0 = ilimitado)"
#~ "número máximo de líneas en el histórico para un servidor/canal/privado "
#~ "(0 = ilimitado)"
#, fuzzy
#~ msgid "log messages from plugins"
@ -5569,8 +5569,8 @@ msgstr "%s falta un argumento para la opción --dir\n"
#~ "max size for aligning nick and other messages (should be >= to "
#~ "look_align_size)"
#~ msgstr ""
#~ "tamaño máximo para la alineación de nick y otros mensajes (debería "
#~ "ser >= a look_align_size)"
#~ "tamaño máximo para la alineación de nick y otros mensajes (debería ser "
#~ ">= a look_align_size)"
#~ msgid "server name not found"
#~ msgstr "nombre de servidor no encontrado"
@ -6357,8 +6357,7 @@ msgstr "%s falta un argumento para la opción --dir\n"
#~ msgid "color for chan owner symbol (specific to unrealircd)"
#~ msgstr ""
#~ "color para el símbolo de propietario de canal (especificado en "
#~ "unrealircd)"
#~ "color para el símbolo de propietario de canal (especificado en unrealircd)"
#~ msgid "color for chan admin symbol"
#~ msgstr "color para el símbolo de administrador de canal"

View File

@ -48,6 +48,7 @@
#include "../gui/gui-color.h"
#include "../gui/gui-filter.h"
#include "../gui/gui-history.h"
#include "../gui/gui-hotlist.h"
#include "../gui/gui-input.h"
#include "../gui/gui-keyboard.h"
#include "../gui/gui-status.h"
@ -481,20 +482,20 @@ command_buffer (void *data, struct t_gui_buffer *buffer,
GUI_COLOR(GUI_COLOR_CHAT));
switch (number)
{
case 0:
case GUI_HOTLIST_LOW:
gui_chat_printf (NULL,
_("(hotlist: never)"));
break;
case 1:
case GUI_HOTLIST_MESSAGE:
gui_chat_printf (NULL,
_("(hotlist: highlights)"));
break;
case 2:
case GUI_HOTLIST_PRIVATE:
gui_chat_printf (NULL,
_("(hotlist: highlights + "
"messages)"));
break;
case 3:
case GUI_HOTLIST_HIGHLIGHT:
gui_chat_printf (NULL,
_("(hotlist: highlights + "
"messages + join/part "
@ -2051,13 +2052,13 @@ command_set (void *data, struct t_gui_buffer *buffer,
free (value);
switch (rc)
{
case 0:
case WEECHAT_CONFIG_OPTION_SET_ERROR:
gui_chat_printf (NULL,
_("%sError: failed to set option \"%s\""),
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR],
argv[1]);
return WEECHAT_RC_ERROR;
case -1:
case WEECHAT_CONFIG_OPTION_SET_OPTION_NOT_FOUND:
gui_chat_printf (NULL,
_("%sError: configuration option \"%s\" not "
"found"),
@ -2127,21 +2128,21 @@ command_unset (void *data, struct t_gui_buffer *buffer,
{
switch (config_file_option_unset (ptr_option))
{
case -1: /* error */
case WEECHAT_CONFIG_OPTION_UNSET_ERROR:
gui_chat_printf (NULL,
_("%sFailed to unset "
"option \"%s\""),
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR],
option_full_name);
break;
case 0: /* unset not needed on this option */
case WEECHAT_CONFIG_OPTION_UNSET_OK_NO_RESET:
break;
case 1: /* option reset */
case WEECHAT_CONFIG_OPTION_UNSET_OK_RESET:
command_set_display_option (ptr_option,
_("Option reset: "));
number_reset++;
break;
case 2: /* option removed */
case WEECHAT_CONFIG_OPTION_UNSET_OK_REMOVED:
gui_chat_printf (NULL,
_("Option removed: %s"),
option_full_name);

View File

@ -37,6 +37,7 @@
#include "wee-string.h"
#include "../gui/gui-color.h"
#include "../gui/gui-chat.h"
#include "../plugins/plugin.h"
struct t_config_file *config_files = NULL;
@ -734,9 +735,14 @@ config_file_string_to_boolean (char *text)
/*
* config_file_option_reset: set default value for an option
* return: 2 if ok (value changed)
* 1 if ok (value is the same)
* 0 if failed
* return one of these values:
* WEECHAT_CONFIG_OPTION_SET_OK_CHANGED
* WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE
* WEECHAT_CONFIG_OPTION_SET_ERROR
*
* 2 if ok (value changed)
* 1 if ok (value is the same)
* 0 if failed
*/
int
@ -746,43 +752,43 @@ config_file_option_reset (struct t_config_option *option, int run_callback)
char value[256], *option_full_name;
if (!option)
return 0;
return WEECHAT_CONFIG_OPTION_SET_ERROR;
rc = 0;
rc = WEECHAT_CONFIG_OPTION_SET_ERROR;
value[0] = '\0';
switch (option->type)
{
case CONFIG_OPTION_TYPE_BOOLEAN:
if (CONFIG_BOOLEAN(option) == CONFIG_BOOLEAN_DEFAULT(option))
rc = 1;
rc = WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
else
{
CONFIG_BOOLEAN(option) = CONFIG_BOOLEAN_DEFAULT(option);
snprintf (value, sizeof (value), "%s",
CONFIG_BOOLEAN(option) ?
config_boolean_true[0] : config_boolean_false[0]);
rc = 2;
rc = WEECHAT_CONFIG_OPTION_SET_OK_CHANGED;
}
break;
case CONFIG_OPTION_TYPE_INTEGER:
if (CONFIG_INTEGER(option) == CONFIG_INTEGER_DEFAULT(option))
rc = 1;
rc = WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
else
{
CONFIG_INTEGER(option) = CONFIG_INTEGER_DEFAULT(option);
snprintf (value, sizeof (value), "%d",
CONFIG_INTEGER(option));
rc = 2;
rc = WEECHAT_CONFIG_OPTION_SET_OK_CHANGED;
}
break;
case CONFIG_OPTION_TYPE_STRING:
rc = 1;
rc = WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
if ((!option->value && option->default_value)
|| (option->value && !option->default_value)
|| (strcmp ((char *)option->value,
(char *)option->default_value) != 0))
rc = 2;
rc = WEECHAT_CONFIG_OPTION_SET_OK_CHANGED;
if (option->value)
free (option->value);
if (option->default_value)
@ -794,32 +800,33 @@ config_file_option_reset (struct t_config_option *option, int run_callback)
CONFIG_STRING(option));
}
else
rc = 0;
rc = WEECHAT_CONFIG_OPTION_SET_ERROR;
}
else
option->value = NULL;
break;
case CONFIG_OPTION_TYPE_COLOR:
if (CONFIG_COLOR(option) == CONFIG_COLOR_DEFAULT(option))
rc = 1;
rc = WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
else
{
CONFIG_COLOR(option) = CONFIG_COLOR_DEFAULT(option);
snprintf (value, sizeof (value), "%d",
CONFIG_COLOR(option));
rc = 2;
rc = WEECHAT_CONFIG_OPTION_SET_OK_CHANGED;
}
break;
case CONFIG_NUM_OPTION_TYPES:
break;
}
if ((rc == 2) && run_callback && option->callback_change)
if ((rc == WEECHAT_CONFIG_OPTION_SET_OK_CHANGED)
&& run_callback && option->callback_change)
{
(void)(option->callback_change)(option->callback_change_data, option);
}
if (rc > 0)
if (rc != WEECHAT_CONFIG_OPTION_SET_ERROR)
{
if (option->config_file && option->section)
{
@ -845,9 +852,10 @@ config_file_option_reset (struct t_config_option *option, int run_callback)
/*
* config_file_option_set: set value for an option
* if value is NULL, then default value for option is set
* return: 2 if ok (value changed)
* 1 if ok (value is the same)
* 0 if failed
* return one of these values:
* WEECHAT_CONFIG_OPTION_SET_OK_CHANGED
* WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE
* WEECHAT_CONFIG_OPTION_SET_ERROR
*/
int
@ -859,9 +867,9 @@ config_file_option_set (struct t_config_option *option, char *value,
char *error, *option_full_name;
if (!option)
return 0;
return WEECHAT_CONFIG_OPTION_SET_ERROR;
rc = 0;
rc = WEECHAT_CONFIG_OPTION_SET_ERROR;
if (value && option->callback_check_value)
{
@ -869,7 +877,7 @@ config_file_option_set (struct t_config_option *option, char *value,
(option->callback_check_value_data,
option,
value))
return 0;
return WEECHAT_CONFIG_OPTION_SET_ERROR;
}
switch (option->type)
@ -882,7 +890,7 @@ config_file_option_set (struct t_config_option *option, char *value,
*((int *)option->value) =
(*((int *)option->value) == CONFIG_BOOLEAN_TRUE) ?
CONFIG_BOOLEAN_FALSE : CONFIG_BOOLEAN_TRUE;
rc = 2;
rc = WEECHAT_CONFIG_OPTION_SET_OK_CHANGED;
}
else
{
@ -890,11 +898,11 @@ config_file_option_set (struct t_config_option *option, char *value,
{
value_int = config_file_string_to_boolean (value);
if (value_int == *((int *)option->value))
rc = 1;
rc = WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
else
{
*((int *)option->value) = value_int;
rc = 2;
rc = WEECHAT_CONFIG_OPTION_SET_OK_CHANGED;
}
}
}
@ -943,11 +951,11 @@ config_file_option_set (struct t_config_option *option, char *value,
if (value_int >= 0)
{
if (value_int == *((int *)option->value))
rc = 1;
rc = WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
else
{
*((int *)option->value) = value_int;
rc = 2;
rc = WEECHAT_CONFIG_OPTION_SET_OK_CHANGED;
}
}
}
@ -991,29 +999,29 @@ config_file_option_set (struct t_config_option *option, char *value,
if (new_value_ok)
{
if (value_int == *((int *)option->value))
rc = 1;
rc = WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
else
{
*((int *)option->value) = value_int;
rc = 2;
rc = WEECHAT_CONFIG_OPTION_SET_OK_CHANGED;
}
}
}
}
break;
case CONFIG_OPTION_TYPE_STRING:
rc = 1;
rc = WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
if ((!option->value && value)
|| (option->value && !value)
|| (strcmp ((char *)option->value, value) != 0))
rc = 2;
rc = WEECHAT_CONFIG_OPTION_SET_OK_CHANGED;
if (option->value)
free (option->value);
if (value)
{
option->value = strdup (value);
if (!option->value)
rc = 0;
rc = WEECHAT_CONFIG_OPTION_SET_ERROR;
}
else
option->value = NULL;
@ -1049,11 +1057,11 @@ config_file_option_set (struct t_config_option *option, char *value,
if (value_int >= 0)
{
if (value_int == *((int *)option->value))
rc = 1;
rc = WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
else
{
*((int *)option->value) = value_int;
rc = 2;
rc = WEECHAT_CONFIG_OPTION_SET_OK_CHANGED;
}
}
break;
@ -1061,12 +1069,13 @@ config_file_option_set (struct t_config_option *option, char *value,
break;
}
if ((rc == 2) && run_callback && option->callback_change)
if ((rc == WEECHAT_CONFIG_OPTION_SET_OK_CHANGED)
&& run_callback && option->callback_change)
{
(void)(option->callback_change)(option->callback_change_data, option);
}
if (rc > 0)
if (rc != WEECHAT_CONFIG_OPTION_SET_ERROR)
{
if (option->config_file && option->section)
{
@ -1091,10 +1100,11 @@ config_file_option_set (struct t_config_option *option, char *value,
/*
* config_file_option_unset: unset/reset option
* return: -1 if failed
* 0 if reset not needed
* 1 if option reset
* 2 if option removed
* return one of these values:
* WEECHAT_CONFIG_OPTION_UNSET_OK_NO_RESET
* WEECHAT_CONFIG_OPTION_UNSET_OK_RESET
* WEECHAT_CONFIG_OPTION_UNSET_OK_REMOVED
* WEECHAT_CONFIG_OPTION_UNSET_ERROR
*/
int
@ -1102,7 +1112,7 @@ config_file_option_unset (struct t_config_option *option)
{
int rc;
rc = 0;
rc = WEECHAT_CONFIG_OPTION_UNSET_OK_NO_RESET;
if (option->section && option->section->user_can_delete_options)
{
@ -1114,21 +1124,21 @@ config_file_option_unset (struct t_config_option *option)
option);
}
config_file_option_free (option);
rc = 2;
rc = WEECHAT_CONFIG_OPTION_UNSET_OK_REMOVED;
}
else
{
/* reset value */
switch (config_file_option_reset (option, 1))
{
case 0:
rc = -1;
case WEECHAT_CONFIG_OPTION_SET_ERROR:
rc = WEECHAT_CONFIG_OPTION_UNSET_ERROR;
break;
case 1:
rc = 0;
case WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE:
rc = WEECHAT_CONFIG_OPTION_UNSET_OK_NO_RESET;
break;
case 2:
rc = 1;
case WEECHAT_CONFIG_OPTION_SET_OK_CHANGED:
rc = WEECHAT_CONFIG_OPTION_UNSET_OK_RESET;
break;
}
}
@ -1207,10 +1217,11 @@ config_file_option_get_pointer (struct t_config_option *option, char *property)
/*
* config_file_option_set_with_string: set value for an option (with a string
* for name of option)
* return: 2 if ok (value changed)
* 1 if ok (value is the same)
* 0 if failed to set option
* -1 if option is not found
* return one of these values:
* WEECHAT_CONFIG_OPTION_SET_OK_CHANGED
* WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE
* WEECHAT_CONFIG_OPTION_SET_ERROR
* WEECHAT_CONFIG_OPTION_SET_OPTION_NOT_FOUND
*/
int
@ -1222,7 +1233,7 @@ config_file_option_set_with_string (char *option_name, char *value)
struct t_config_option *ptr_option;
char *pos_option;
rc = 0;
rc = WEECHAT_CONFIG_OPTION_SET_OPTION_NOT_FOUND;
config_file_search_with_string (option_name, &ptr_config, &ptr_section,
&ptr_option, &pos_option);
@ -1242,8 +1253,11 @@ config_file_option_set_with_string (char *option_name, char *value)
ptr_section,
pos_option,
value);
if (rc > 0)
if ((rc == WEECHAT_CONFIG_OPTION_SET_OK_CHANGED)
|| (rc == WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE))
{
hook_config_exec (option_name, value);
}
}
}
}
@ -1253,10 +1267,11 @@ config_file_option_set_with_string (char *option_name, char *value)
/*
* config_file_option_unset_with_string: unset/reset option
* return: -1 if failed
* 0 if reset not needed
* 1 if option reset
* 2 if option removed
* return one of these values:
* WEECHAT_CONFIG_OPTION_UNSET_OK_NO_RESET
* WEECHAT_CONFIG_OPTION_UNSET_OK_RESET
* WEECHAT_CONFIG_OPTION_UNSET_OK_REMOVED
* WEECHAT_CONFIG_OPTION_UNSET_ERROR
*/
int
@ -1265,7 +1280,7 @@ config_file_option_unset_with_string (char *option_name)
struct t_config_option *ptr_option;
int rc;
rc = -1;
rc = WEECHAT_CONFIG_OPTION_UNSET_ERROR;
config_file_search_with_string (option_name, NULL, NULL, &ptr_option, NULL);
@ -1448,9 +1463,10 @@ config_file_write_line (struct t_config_file *config_file,
/*
* config_file_write_internal: write a configuration file
* (should not be called directly)
* return: 0 if ok
* -1 if error writing file
* -2 if not enough memory
* return one of these values:
* WEECHAT_CONFIG_WRITE_OK
* WEECHAT_CONFIG_WRITE_ERROR
* WEECHAT_CONFIG_WRITE_MEMORY_ERROR
*/
int
@ -1464,14 +1480,14 @@ config_file_write_internal (struct t_config_file *config_file,
struct t_config_option *ptr_option;
if (!config_file)
return -1;
return WEECHAT_CONFIG_WRITE_ERROR;
/* build filename */
filename_length = strlen (weechat_home) +
strlen (config_file->filename) + 2;
filename = malloc (filename_length);
if (!filename)
return -2;
return WEECHAT_CONFIG_WRITE_MEMORY_ERROR;
snprintf (filename, filename_length, "%s%s%s",
weechat_home, DIR_SEPARATOR, config_file->filename);
@ -1481,7 +1497,7 @@ config_file_write_internal (struct t_config_file *config_file,
if (!filename2)
{
free (filename);
return -2;
return WEECHAT_CONFIG_WRITE_MEMORY_ERROR;
}
snprintf (filename2, filename_length + 32, "%s.weechattmp", filename);
@ -1495,7 +1511,7 @@ config_file_write_internal (struct t_config_file *config_file,
filename2);
free (filename);
free (filename2);
return -1;
return WEECHAT_CONFIG_WRITE_ERROR;
}
log_printf (_("Writing configuration file %s %s"),
@ -1556,16 +1572,19 @@ config_file_write_internal (struct t_config_file *config_file,
free (filename);
free (filename2);
if (rc != 0)
return -1;
return 0;
return WEECHAT_CONFIG_WRITE_ERROR;
return WEECHAT_CONFIG_WRITE_OK;
}
/*
* config_file_write: write a configuration file
* return: 0 if ok
* -1 if error writing file
* -2 if not enough memory
* return one of these values:
* WEECHAT_CONFIG_WRITE_OK
* WEECHAT_CONFIG_WRITE_ERROR
* WEECHAT_CONFIG_WRITE_MEMORY_ERROR
*/
int
@ -1577,9 +1596,10 @@ config_file_write (struct t_config_file *config_file)
/*
* config_file_read_internal: read a configuration file
* (should not be called directly)
* return: 0 = successful
* -1 = config file file not found
* -2 = error in config file
* return one of these values:
* WEECHAT_CONFIG_READ_OK
* WEECHAT_CONFIG_READ_MEMORY_ERROR
* WEECHAT_CONFIG_READ_FILE_NOT_FOUND
*/
int
@ -1592,13 +1612,13 @@ config_file_read_internal (struct t_config_file *config_file, int reload)
char line[1024], *ptr_line, *ptr_line2, *pos, *pos2;
if (!config_file)
return -1;
return WEECHAT_CONFIG_READ_FILE_NOT_FOUND;
/* build filename */
filename_length = strlen (weechat_home) + strlen (config_file->filename) + 2;
filename = malloc (filename_length);
if (!filename)
return -2;
return WEECHAT_CONFIG_READ_MEMORY_ERROR;
snprintf (filename, filename_length, "%s%s%s",
weechat_home, DIR_SEPARATOR, config_file->filename);
config_file->file = fopen (filename, "r");
@ -1613,7 +1633,7 @@ config_file_read_internal (struct t_config_file *config_file, int reload)
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR],
filename);
free (filename);
return -1;
return WEECHAT_CONFIG_READ_FILE_NOT_FOUND;
}
}
@ -1744,7 +1764,7 @@ config_file_read_internal (struct t_config_file *config_file, int reload)
}
else
{
rc = -1;
rc = WEECHAT_CONFIG_OPTION_SET_OPTION_NOT_FOUND;
ptr_option = config_file_search_option (config_file,
ptr_section,
line);
@ -1770,7 +1790,7 @@ config_file_read_internal (struct t_config_file *config_file, int reload)
switch (rc)
{
case -1:
case WEECHAT_CONFIG_OPTION_SET_OPTION_NOT_FOUND:
if (ptr_section)
gui_chat_printf (NULL,
_("%sWarning: %s, line %d: "
@ -1789,7 +1809,7 @@ config_file_read_internal (struct t_config_file *config_file, int reload)
filename, line_number,
line);
break;
case 0:
case WEECHAT_CONFIG_OPTION_SET_ERROR:
gui_chat_printf (NULL,
_("%sWarning: %s, line %d: "
"invalid value for option "
@ -1808,14 +1828,15 @@ config_file_read_internal (struct t_config_file *config_file, int reload)
config_file->file = NULL;
free (filename);
return 0;
return WEECHAT_CONFIG_READ_OK;
}
/*
* config_file_read: read a configuration file
* return: 0 = successful
* -1 = config file file not found
* -2 = error in config file
* return one of these values:
* WEECHAT_CONFIG_READ_OK
* WEECHAT_CONFIG_READ_MEMORY_ERROR
* WEECHAT_CONFIG_READ_FILE_NOT_FOUND
*/
int
@ -1826,9 +1847,10 @@ config_file_read (struct t_config_file *config_file)
/*
* config_file_reload: reload a configuration file
* return: 0 = successful
* -1 = config file file not found
* -2 = error in config file
* return one of these values:
* WEECHAT_CONFIG_READ_OK
* WEECHAT_CONFIG_READ_MEMORY_ERROR
* WEECHAT_CONFIG_READ_FILE_NOT_FOUND
*/
int
@ -1839,7 +1861,7 @@ config_file_reload (struct t_config_file *config_file)
int rc;
if (!config_file)
return -1;
return WEECHAT_CONFIG_READ_FILE_NOT_FOUND;
log_printf (_("Reloading configuration file %s"), config_file->filename);

View File

@ -486,9 +486,10 @@ config_change_day_change (void *data, struct t_config_option *option)
/*
* config_weechat_reload: reload WeeChat configuration file
* return: 0 = successful
* -1 = config file file not found
* -2 = error in config file
* return one of these values:
* WEECHAT_CONFIG_READ_OK
* WEECHAT_CONFIG_READ_MEMORY_ERROR
* WEECHAT_CONFIG_READ_FILE_NOT_FOUND
*/
int
@ -511,7 +512,7 @@ config_weechat_reload (void *data, struct t_config_file *config_file)
rc = config_file_reload (weechat_config_file);
if (rc == 0)
if (rc == WEECHAT_CONFIG_READ_OK)
{
gui_bar_use_temp_bars ();
}
@ -630,8 +631,6 @@ config_weechat_filter_read (void *data,
/*
* config_weechat_filter_write: write filter section in configuration file
* Return: 0 = successful
* -1 = write error
*/
void
@ -691,8 +690,6 @@ config_weechat_key_read (void *data, struct t_config_file *config_file,
/*
* config_weechat_key_write: write key section in configuration file
* Return: 0 = successful
* -1 = write error
*/
void
@ -1614,9 +1611,10 @@ config_weechat_init ()
/*
* config_weechat_read: read WeeChat configuration file
* return: 0 = successful
* -1 = configuration file file not found
* -2 = error in configuration file
* return one of these values:
* WEECHAT_CONFIG_READ_OK
* WEECHAT_CONFIG_READ_MEMORY_ERROR
* WEECHAT_CONFIG_READ_FILE_NOT_FOUND
*/
int
@ -1625,7 +1623,7 @@ config_weechat_read ()
int rc;
rc = config_file_read (weechat_config_file);
if (rc == 0)
if (rc == WEECHAT_CONFIG_READ_OK)
{
config_change_infobar_seconds (NULL, NULL);
config_change_day_change (NULL, NULL);
@ -1637,8 +1635,10 @@ config_weechat_read ()
/*
* config_weechat_write: write WeeChat configuration file
* return: 0 if ok
* < 0 if error
* return one of these values:
* WEECHAT_CONFIG_WRITE_OK
* WEECHAT_CONFIG_WRITE_ERROR
* WEECHAT_CONFIG_WRITE_MEMORY_ERROR
*/
int

View File

@ -573,7 +573,7 @@ alias_config_create_option (void *data, struct t_config_file *config_file,
/* make C compiler happy */
(void) data;
rc = 0;
rc = WEECHAT_CONFIG_OPTION_SET_ERROR;
/* create config option */
weechat_config_new_option (
@ -588,11 +588,12 @@ alias_config_create_option (void *data, struct t_config_file *config_file,
if (ptr_alias)
alias_free (ptr_alias);
if (value && value[0])
rc = (alias_new (option_name, value)) ? 1 : 0;
rc = (alias_new (option_name, value)) ?
WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE : WEECHAT_CONFIG_OPTION_SET_ERROR;
else
rc = 1;
rc = WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
if (rc == 0)
if (rc == WEECHAT_CONFIG_OPTION_SET_ERROR)
{
weechat_printf (NULL,
"%s%s: error creating alias \"%s\" => \"%s\"",

View File

@ -112,7 +112,7 @@ charset_config_create_option (void *data, struct t_config_file *config_file,
/* make C compiler happy */
(void) data;
rc = 0;
rc = WEECHAT_CONFIG_OPTION_SET_ERROR;
if (option_name)
{
@ -125,7 +125,7 @@ charset_config_create_option (void *data, struct t_config_file *config_file,
else
{
weechat_config_option_free (ptr_option);
rc = 1;
rc = WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
}
}
else
@ -136,14 +136,15 @@ charset_config_create_option (void *data, struct t_config_file *config_file,
config_file, section,
option_name, "string", NULL,
NULL, 0, 0, value, NULL, NULL, NULL, NULL, NULL, NULL);
rc = (ptr_option) ? 1 : 0;
rc = (ptr_option) ?
WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE : WEECHAT_CONFIG_OPTION_SET_ERROR;
}
else
rc = 1;
rc = WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
}
}
if (rc == 0)
if (rc == WEECHAT_CONFIG_OPTION_SET_ERROR)
{
weechat_printf (NULL,
_("%s%s: error creating charset \"%s\" => \"%s\""),

View File

@ -454,7 +454,7 @@ irc_config_reload (void *data, struct t_config_file *config_file)
rc = weechat_config_reload (config_file);
if (rc == 0)
if (rc == WEECHAT_CONFIG_READ_OK)
irc_config_reload_servers_from_config (1);
ptr_server = irc_servers;
@ -698,7 +698,7 @@ irc_config_server_create_option (void *data, struct t_config_file *config_file,
/* make C compiler happy */
(void) data;
rc = 0;
rc = WEECHAT_CONFIG_OPTION_SET_ERROR;
if (option_name)
{
@ -753,7 +753,7 @@ irc_config_server_create_option (void *data, struct t_config_file *config_file,
index_option,
ptr_option);
}
rc = 1;
rc = WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
}
}
}
@ -763,7 +763,7 @@ irc_config_server_create_option (void *data, struct t_config_file *config_file,
}
}
if (rc == 0)
if (rc == WEECHAT_CONFIG_OPTION_SET_ERROR)
{
weechat_printf (NULL,
_("%s%s: error creating server option \"%s\""),
@ -1062,9 +1062,6 @@ irc_config_init ()
/*
* irc_config_read: read IRC configuration file
* return: 0 = successful
* -1 = configuration file file not found
* -2 = error in configuration file
*/
int
@ -1075,8 +1072,6 @@ irc_config_read ()
/*
* irc_config_write: write IRC configuration file
* return: 0 if ok
* < 0 if error
*/
int

View File

@ -74,7 +74,6 @@ plugin_config_search (char *plugin_name, char *option_name)
/*
* plugin_config_set_internal: set value for a plugin option (internal function)
* This function should not be called directly.
* Return: 1 if ok, 0 if error
*/
int
@ -83,7 +82,7 @@ plugin_config_set_internal (char *option, char *value)
int rc;
struct t_config_option *ptr_option;
rc = 0;
rc = WEECHAT_CONFIG_OPTION_SET_ERROR;
ptr_option = config_file_search_option (plugin_config_file,
plugin_config_section_var,
@ -98,7 +97,7 @@ plugin_config_set_internal (char *option, char *value)
plugin_config_file, plugin_config_section_var,
option, "string", NULL,
NULL, 0, 0, value, NULL, NULL, NULL, NULL, NULL, NULL);
rc = (ptr_option) ? 1 : 0;
rc = (ptr_option) ? WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE : WEECHAT_CONFIG_OPTION_SET_ERROR;
}
return rc;
@ -106,7 +105,6 @@ plugin_config_set_internal (char *option, char *value)
/*
* plugin_config_set: set value for a plugin option (create it if not found)
* Return: 1 if ok, 0 if error
*/
int
@ -115,7 +113,7 @@ plugin_config_set (char *plugin_name, char *option_name, char *value)
int length, rc;
char *option_full_name;
rc = 0;
rc = WEECHAT_CONFIG_OPTION_SET_ERROR;
length = strlen (plugin_name) + 1 + strlen (option_name) + 1;
option_full_name = malloc (length);
@ -133,9 +131,6 @@ plugin_config_set (char *plugin_name, char *option_name, char *value)
/*
* plugin_config_reload: reload plugins configuration file
* return: 0 = successful
* -1 = config file file not found
* -2 = error in config file
*/
int
@ -170,7 +165,8 @@ plugin_config_create_option (void *data, struct t_config_file *config_file,
option_name, "string", NULL,
NULL, 0, 0, value, NULL, NULL, NULL, NULL, NULL, NULL);
return (ptr_option) ? 1 : 0;
return (ptr_option) ?
WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE : WEECHAT_CONFIG_OPTION_SET_ERROR;
}
/*
@ -197,9 +193,6 @@ plugin_config_init ()
/*
* plugin_config_read: read plugins configuration file
* return: 0 = successful
* -1 = config file file not found
* -2 = error in config file
*/
int
@ -210,8 +203,6 @@ plugin_config_read ()
/*
* plugin_config_write: write plugins configuration file
* return: 0 if ok
* < 0 if error
*/
int

View File

@ -4660,7 +4660,147 @@ weechat_lua_api_constant_weechat_rc_error (lua_State *L)
lua_pushnumber (lua_current_interpreter, WEECHAT_RC_ERROR);
return 1;
}
static int
weechat_lua_api_constant_weechat_config_read_ok (lua_State *L)
{
/* make C compiler happy */
(void) L;
lua_pushnumber (lua_current_interpreter, WEECHAT_CONFIG_READ_OK);
return 1;
}
static int
weechat_lua_api_constant_weechat_config_read_memory_error (lua_State *L)
{
/* make C compiler happy */
(void) L;
lua_pushnumber (lua_current_interpreter, WEECHAT_CONFIG_READ_MEMORY_ERROR);
return 1;
}
static int
weechat_lua_api_constant_weechat_config_read_file_not_found (lua_State *L)
{
/* make C compiler happy */
(void) L;
lua_pushnumber (lua_current_interpreter, WEECHAT_CONFIG_READ_FILE_NOT_FOUND);
return 1;
}
static int
weechat_lua_api_constant_weechat_config_write_ok (lua_State *L)
{
/* make C compiler happy */
(void) L;
lua_pushnumber (lua_current_interpreter, WEECHAT_CONFIG_WRITE_OK);
return 1;
}
static int
weechat_lua_api_constant_weechat_config_write_error (lua_State *L)
{
/* make C compiler happy */
(void) L;
lua_pushnumber (lua_current_interpreter, WEECHAT_CONFIG_WRITE_ERROR);
return 1;
}
static int
weechat_lua_api_constant_weechat_config_write_memory_error (lua_State *L)
{
/* make C compiler happy */
(void) L;
lua_pushnumber (lua_current_interpreter, WEECHAT_CONFIG_WRITE_MEMORY_ERROR);
return 1;
}
static int
weechat_lua_api_constant_weechat_config_option_set_ok_changed (lua_State *L)
{
/* make C compiler happy */
(void) L;
lua_pushnumber (lua_current_interpreter, WEECHAT_CONFIG_OPTION_SET_OK_CHANGED);
return 1;
}
static int
weechat_lua_api_constant_weechat_config_option_set_ok_same_value (lua_State *L)
{
/* make C compiler happy */
(void) L;
lua_pushnumber (lua_current_interpreter, WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE);
return 1;
}
static int
weechat_lua_api_constant_weechat_config_option_set_error (lua_State *L)
{
/* make C compiler happy */
(void) L;
lua_pushnumber (lua_current_interpreter, WEECHAT_CONFIG_OPTION_SET_ERROR);
return 1;
}
static int
weechat_lua_api_constant_weechat_config_option_set_option_not_found (lua_State *L)
{
/* make C compiler happy */
(void) L;
lua_pushnumber (lua_current_interpreter, WEECHAT_CONFIG_OPTION_SET_OPTION_NOT_FOUND);
return 1;
}
static int
weechat_lua_api_constant_weechat_config_option_unset_ok_no_reset (lua_State *L)
{
/* make C compiler happy */
(void) L;
lua_pushnumber (lua_current_interpreter, WEECHAT_CONFIG_OPTION_UNSET_OK_NO_RESET);
return 1;
}
static int
weechat_lua_api_constant_weechat_config_option_unset_ok_reset (lua_State *L)
{
/* make C compiler happy */
(void) L;
lua_pushnumber (lua_current_interpreter, WEECHAT_CONFIG_OPTION_UNSET_OK_RESET);
return 1;
}
static int
weechat_lua_api_constant_weechat_config_option_unset_ok_removed (lua_State *L)
{
/* make C compiler happy */
(void) L;
lua_pushnumber (lua_current_interpreter, WEECHAT_CONFIG_OPTION_UNSET_OK_REMOVED);
return 1;
}
static int
weechat_lua_api_constant_weechat_config_option_unset_error (lua_State *L)
{
/* make C compiler happy */
(void) L;
lua_pushnumber (lua_current_interpreter, WEECHAT_CONFIG_OPTION_UNSET_ERROR);
return 1;
}
static int
weechat_lua_api_constant_weechat_list_pos_sort (lua_State *L)
{
@ -4862,18 +5002,39 @@ const struct luaL_reg weechat_lua_api_funcs[] = {
{ "infolist_pointer", &weechat_lua_api_infolist_pointer },
{ "infolist_time", &weechat_lua_api_infolist_time },
{ "infolist_free", &weechat_lua_api_infolist_free },
/* define constants as function which returns values */
{ "WEECHAT_RC_OK", &weechat_lua_api_constant_weechat_rc_ok },
{ "WEECHAT_RC_ERROR", &weechat_lua_api_constant_weechat_rc_error },
{ "WEECHAT_CONFIG_READ_OK", &weechat_lua_api_constant_weechat_config_read_ok },
{ "WEECHAT_CONFIG_READ_MEMORY_ERROR", &weechat_lua_api_constant_weechat_config_read_memory_error },
{ "WEECHAT_CONFIG_READ_FILE_NOT_FOUND", &weechat_lua_api_constant_weechat_config_read_file_not_found },
{ "WEECHAT_CONFIG_WRITE_OK", &weechat_lua_api_constant_weechat_config_write_ok },
{ "WEECHAT_CONFIG_WRITE_ERROR", &weechat_lua_api_constant_weechat_config_write_error },
{ "WEECHAT_CONFIG_WRITE_MEMORY_ERROR", &weechat_lua_api_constant_weechat_config_write_memory_error },
{ "WEECHAT_CONFIG_OPTION_SET_OK_CHANGED", &weechat_lua_api_constant_weechat_config_option_set_ok_changed },
{ "WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE", &weechat_lua_api_constant_weechat_config_option_set_ok_same_value },
{ "WEECHAT_CONFIG_OPTION_SER_ERROR", &weechat_lua_api_constant_weechat_config_option_set_error },
{ "WEECHAT_CONFIG_OPTION_SET_OPTION_NOT_FOUND", &weechat_lua_api_constant_weechat_config_option_set_option_not_found },
{ "WEECHAT_CONFIG_OPTION_UNSET_OK_NO_RESET", &weechat_lua_api_constant_weechat_config_option_unset_ok_no_reset },
{ "WEECHAT_CONFIG_OPTION_UNSET_OK_RESET", &weechat_lua_api_constant_weechat_config_option_unset_ok_reset },
{ "WEECHAT_CONFIG_OPTION_UNSET_OK_REMOVED", &weechat_lua_api_constant_weechat_config_option_unset_ok_removed },
{ "WEECHAT_CONFIG_OPTION_UNSET_ERROR", &weechat_lua_api_constant_weechat_config_option_unset_error },
{ "WEECHAT_LIST_POS_SORT", &weechat_lua_api_constant_weechat_list_pos_sort },
{ "WEECHAT_LIST_POS_BEGINNING", &weechat_lua_api_constant_weechat_list_pos_beginning },
{ "WEECHAT_LIST_POS_END", &weechat_lua_api_constant_weechat_list_pos_end },
{ "WEECHAT_HOTLIST_LOW", &weechat_lua_api_constant_weechat_hotlist_low },
{ "WEECHAT_HOTLIST_MESSAGE", &weechat_lua_api_constant_weechat_hotlist_message },
{ "WEECHAT_HOTLIST_PRIVATE", &weechat_lua_api_constant_weechat_hotlist_private },
{ "WEECHAT_HOTLIST_HIGHLIGHT", &weechat_lua_api_constant_weechat_hotlist_highlight },
{ "WEECHAT_HOOK_SIGNAL_STRING", &weechat_lua_api_constant_weechat_hook_signal_string },
{ "WEECHAT_HOOK_SIGNAL_INT", &weechat_lua_api_constant_weechat_hook_signal_int },
{ "WEECHAT_HOOK_SIGNAL_POINTER", &weechat_lua_api_constant_weechat_hook_signal_pointer },
{ NULL, NULL }
};

View File

@ -3932,13 +3932,31 @@ weechat_perl_api_init (pTHX)
stash = gv_stashpv ("weechat", TRUE);
newCONSTSUB (stash, "weechat::WEECHAT_RC_OK", newSViv (WEECHAT_RC_OK));
newCONSTSUB (stash, "weechat::WEECHAT_RC_ERROR", newSViv (WEECHAT_RC_ERROR));
newCONSTSUB (stash, "weechat::WEECHAT_CONFIG_READ_OK", newSViv (WEECHAT_CONFIG_READ_OK));
newCONSTSUB (stash, "weechat::WEECHAT_CONFIG_READ_MEMORY_ERROR", newSViv (WEECHAT_CONFIG_READ_MEMORY_ERROR));
newCONSTSUB (stash, "weechat::WEECHAT_CONFIG_READ_FILE_NOT_FOUND", newSViv (WEECHAT_CONFIG_READ_FILE_NOT_FOUND));
newCONSTSUB (stash, "weechat::WEECHAT_CONFIG_WRITE_OK", newSViv (WEECHAT_CONFIG_WRITE_OK));
newCONSTSUB (stash, "weechat::WEECHAT_CONFIG_WRITE_ERROR", newSViv (WEECHAT_CONFIG_WRITE_ERROR));
newCONSTSUB (stash, "weechat::WEECHAT_CONFIG_WRITE_MEMORY_ERROR", newSViv (WEECHAT_CONFIG_WRITE_MEMORY_ERROR));
newCONSTSUB (stash, "weechat::WEECHAT_CONFIG_OPTION_SET_OK_CHANGED", newSViv (WEECHAT_CONFIG_OPTION_SET_OK_CHANGED));
newCONSTSUB (stash, "weechat::WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE", newSViv (WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE));
newCONSTSUB (stash, "weechat::WEECHAT_CONFIG_OPTION_SET_ERROR", newSViv (WEECHAT_CONFIG_OPTION_SET_ERROR));
newCONSTSUB (stash, "weechat::WEECHAT_CONFIG_OPTION_SET_OPTION_NOT_FOUND", newSViv (WEECHAT_CONFIG_OPTION_SET_OPTION_NOT_FOUND));
newCONSTSUB (stash, "weechat::WEECHAT_CONFIG_OPTION_UNSET_OK_NO_RESET", newSViv (WEECHAT_CONFIG_OPTION_UNSET_OK_NO_RESET));
newCONSTSUB (stash, "weechat::WEECHAT_CONFIG_OPTION_UNSET_OK_RESET", newSViv (WEECHAT_CONFIG_OPTION_UNSET_OK_RESET));
newCONSTSUB (stash, "weechat::WEECHAT_CONFIG_OPTION_UNSET_OK_REMOVED", newSViv (WEECHAT_CONFIG_OPTION_UNSET_OK_REMOVED));
newCONSTSUB (stash, "weechat::WEECHAT_CONFIG_OPTION_UNSET_ERROR", newSViv (WEECHAT_CONFIG_OPTION_UNSET_ERROR));
newCONSTSUB (stash, "weechat::WEECHAT_LIST_POS_SORT", newSVpv (WEECHAT_LIST_POS_SORT, PL_na));
newCONSTSUB (stash, "weechat::WEECHAT_LIST_POS_BEGINNING", newSVpv (WEECHAT_LIST_POS_BEGINNING, PL_na));
newCONSTSUB (stash, "weechat::WEECHAT_LIST_POS_END", newSVpv (WEECHAT_LIST_POS_END, PL_na));
newCONSTSUB (stash, "weechat::WEECHAT_HOTLIST_LOW", newSVpv (WEECHAT_HOTLIST_LOW, PL_na));
newCONSTSUB (stash, "weechat::WEECHAT_HOTLIST_MESSAGE", newSVpv (WEECHAT_HOTLIST_MESSAGE, PL_na));
newCONSTSUB (stash, "weechat::WEECHAT_HOTLIST_PRIVATE", newSVpv (WEECHAT_HOTLIST_PRIVATE, PL_na));
newCONSTSUB (stash, "weechat::WEECHAT_HOTLIST_HIGHLIGHT", newSVpv (WEECHAT_HOTLIST_HIGHLIGHT, PL_na));
newCONSTSUB (stash, "weechat::WEECHAT_HOOK_SIGNAL_STRING", newSVpv (WEECHAT_HOOK_SIGNAL_STRING, PL_na));
newCONSTSUB (stash, "weechat::WEECHAT_HOOK_SIGNAL_INT", newSVpv (WEECHAT_HOOK_SIGNAL_INT, PL_na));
newCONSTSUB (stash, "weechat::WEECHAT_HOOK_SIGNAL_POINTER", newSVpv (WEECHAT_HOOK_SIGNAL_POINTER, PL_na));

View File

@ -121,8 +121,8 @@ weechat_python_exec (struct t_plugin_script *script,
ret_value = NULL;
/*
ugly hack : rc = NULL while 'return weechat.PLUGIN_RC_OK ....
because of '#define PLUGIN_RC_OK 0'
ugly hack : rc = NULL while 'return weechat.WEECHAT_RC_OK ....
because of '#define WEECHAT_RC_OK 0'
*/
if (rc == NULL)
rc = PyInt_FromLong (0);
@ -336,13 +336,31 @@ weechat_python_load (char *filename)
weechat_dict = PyModule_GetDict(weechat_module);
PyDict_SetItemString(weechat_dict, "WEECHAT_RC_OK", PyInt_FromLong((long) WEECHAT_RC_OK));
PyDict_SetItemString(weechat_dict, "WEECHAT_RC_ERROR", PyInt_FromLong((long) WEECHAT_RC_ERROR));
PyDict_SetItemString(weechat_dict, "WEECHAT_CONFIG_READ_OK", PyInt_FromLong((long) WEECHAT_CONFIG_READ_OK));
PyDict_SetItemString(weechat_dict, "WEECHAT_CONFIG_READ_MEMORY_ERROR", PyInt_FromLong((long) WEECHAT_CONFIG_READ_MEMORY_ERROR));
PyDict_SetItemString(weechat_dict, "WEECHAT_CONFIG_READ_FILE_NOT_FOUND", PyInt_FromLong((long) WEECHAT_CONFIG_READ_FILE_NOT_FOUND));
PyDict_SetItemString(weechat_dict, "WEECHAT_CONFIG_WRITE_OK", PyInt_FromLong((long) WEECHAT_CONFIG_WRITE_OK));
PyDict_SetItemString(weechat_dict, "WEECHAT_CONFIG_WRITE_ERROR", PyInt_FromLong((long) WEECHAT_CONFIG_WRITE_ERROR));
PyDict_SetItemString(weechat_dict, "WEECHAT_CONFIG_WRITE_MEMORY_ERROR", PyInt_FromLong((long) WEECHAT_CONFIG_WRITE_MEMORY_ERROR));
PyDict_SetItemString(weechat_dict, "WEECHAT_CONFIG_OPTION_SET_OK_CHANGED", PyInt_FromLong((long) WEECHAT_CONFIG_OPTION_SET_OK_CHANGED));
PyDict_SetItemString(weechat_dict, "WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE", PyInt_FromLong((long) WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE));
PyDict_SetItemString(weechat_dict, "WEECHAT_CONFIG_OPTION_SET_ERROR", PyInt_FromLong((long) WEECHAT_CONFIG_OPTION_SET_ERROR));
PyDict_SetItemString(weechat_dict, "WEECHAT_CONFIG_OPTION_SET_OPTION_NOT_FOUND", PyInt_FromLong((long) WEECHAT_CONFIG_OPTION_SET_OPTION_NOT_FOUND));
PyDict_SetItemString(weechat_dict, "WEECHAT_CONFIG_OPTION_UNSET_OK_NO_RESET", PyInt_FromLong((long) WEECHAT_CONFIG_OPTION_UNSET_OK_NO_RESET));
PyDict_SetItemString(weechat_dict, "WEECHAT_CONFIG_OPTION_UNSET_OK_RESET", PyInt_FromLong((long) WEECHAT_CONFIG_OPTION_UNSET_OK_RESET));
PyDict_SetItemString(weechat_dict, "WEECHAT_CONFIG_OPTION_UNSET_OK_REMOVED", PyInt_FromLong((long) WEECHAT_CONFIG_OPTION_UNSET_OK_REMOVED));
PyDict_SetItemString(weechat_dict, "WEECHAT_CONFIG_OPTION_UNSET_ERROR", PyInt_FromLong((long) WEECHAT_CONFIG_OPTION_UNSET_ERROR));
PyDict_SetItemString(weechat_dict, "WEECHAT_LIST_POS_SORT", PyString_FromString(WEECHAT_LIST_POS_SORT));
PyDict_SetItemString(weechat_dict, "WEECHAT_LIST_POS_BEGINNING", PyString_FromString(WEECHAT_LIST_POS_BEGINNING));
PyDict_SetItemString(weechat_dict, "WEECHAT_LIST_POS_END", PyString_FromString(WEECHAT_LIST_POS_END));
PyDict_SetItemString(weechat_dict, "WEECHAT_HOTLIST_LOW", PyString_FromString(WEECHAT_HOTLIST_LOW));
PyDict_SetItemString(weechat_dict, "WEECHAT_HOTLIST_MESSAGE", PyString_FromString(WEECHAT_HOTLIST_MESSAGE));
PyDict_SetItemString(weechat_dict, "WEECHAT_HOTLIST_PRIVATE", PyString_FromString(WEECHAT_HOTLIST_PRIVATE));
PyDict_SetItemString(weechat_dict, "WEECHAT_HOTLIST_HIGHLIGHT", PyString_FromString(WEECHAT_HOTLIST_HIGHLIGHT));
PyDict_SetItemString(weechat_dict, "WEECHAT_HOOK_SIGNAL_STRING", PyString_FromString(WEECHAT_HOOK_SIGNAL_STRING));
PyDict_SetItemString(weechat_dict, "WEECHAT_HOOK_SIGNAL_INT", PyString_FromString(WEECHAT_HOOK_SIGNAL_INT));
PyDict_SetItemString(weechat_dict, "WEECHAT_HOOK_SIGNAL_POINTER", PyString_FromString(WEECHAT_HOOK_SIGNAL_POINTER));

View File

@ -4675,16 +4675,35 @@ weechat_ruby_api_init (VALUE ruby_mWeechat)
{
rb_define_const(ruby_mWeechat, "WEECHAT_RC_OK", INT2NUM(WEECHAT_RC_OK));
rb_define_const(ruby_mWeechat, "WEECHAT_RC_ERROR", INT2NUM(WEECHAT_RC_ERROR));
rb_define_const(ruby_mWeechat, "WEECHAT_CONFIG_READ_OK", INT2NUM(WEECHAT_CONFIG_READ_OK));
rb_define_const(ruby_mWeechat, "WEECHAT_CONFIG_READ_MEMORY_ERROR", INT2NUM(WEECHAT_CONFIG_READ_MEMORY_ERROR));
rb_define_const(ruby_mWeechat, "WEECHAT_CONFIG_READ_FILE_NOT_FOUND", INT2NUM(WEECHAT_CONFIG_READ_FILE_NOT_FOUND));
rb_define_const(ruby_mWeechat, "WEECHAT_CONFIG_WRITE_OK", INT2NUM(WEECHAT_CONFIG_WRITE_OK));
rb_define_const(ruby_mWeechat, "WEECHAT_CONFIG_WRITE_ERROR", INT2NUM(WEECHAT_CONFIG_WRITE_ERROR));
rb_define_const(ruby_mWeechat, "WEECHAT_CONFIG_WRITE_MEMORY_ERROR", INT2NUM(WEECHAT_CONFIG_WRITE_MEMORY_ERROR));
rb_define_const(ruby_mWeechat, "WEECHAT_CONFIG_OPTION_SET_OK_CHANGED", INT2NUM(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED));
rb_define_const(ruby_mWeechat, "WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE", INT2NUM(WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE));
rb_define_const(ruby_mWeechat, "WEECHAT_CONFIG_OPTION_SET_ERROR", INT2NUM(WEECHAT_CONFIG_OPTION_SET_ERROR));
rb_define_const(ruby_mWeechat, "WEECHAT_CONFIG_OPTION_SET_OPTION_NOT_FOUND", INT2NUM(WEECHAT_CONFIG_OPTION_SET_OPTION_NOT_FOUND));
rb_define_const(ruby_mWeechat, "WEECHAT_CONFIG_OPTION_UNSET_OK_NO_RESET", INT2NUM(WEECHAT_CONFIG_OPTION_UNSET_OK_NO_RESET));
rb_define_const(ruby_mWeechat, "WEECHAT_CONFIG_OPTION_UNSET_OK_RESET", INT2NUM(WEECHAT_CONFIG_OPTION_UNSET_OK_RESET));
rb_define_const(ruby_mWeechat, "WEECHAT_CONFIG_OPTION_UNSET_OK_REMOVED", INT2NUM(WEECHAT_CONFIG_OPTION_UNSET_OK_REMOVED));
rb_define_const(ruby_mWeechat, "WEECHAT_CONFIG_OPTION_UNSET_ERROR", INT2NUM(WEECHAT_CONFIG_OPTION_UNSET_ERROR));
rb_define_const(ruby_mWeechat, "WEECHAT_LIST_POS_SORT", rb_str_new2(WEECHAT_LIST_POS_SORT));
rb_define_const(ruby_mWeechat, "WEECHAT_LIST_POS_BEGINNING", rb_str_new2(WEECHAT_LIST_POS_BEGINNING));
rb_define_const(ruby_mWeechat, "WEECHAT_LIST_POS_END", rb_str_new2(WEECHAT_LIST_POS_END));
rb_define_const(ruby_mWeechat, "WEECHAT_HOTLIST_LOW", rb_str_new2(WEECHAT_HOTLIST_LOW));
rb_define_const(ruby_mWeechat, "WEECHAT_HOTLIST_MESSAGE", rb_str_new2(WEECHAT_HOTLIST_MESSAGE));
rb_define_const(ruby_mWeechat, "WEECHAT_HOTLIST_PRIVATE", rb_str_new2(WEECHAT_HOTLIST_PRIVATE));
rb_define_const(ruby_mWeechat, "WEECHAT_HOTLIST_HIGHLIGHT", rb_str_new2(WEECHAT_HOTLIST_HIGHLIGHT));
rb_define_const(ruby_mWeechat, "WEECHAT_HOOK_SIGNAL_STRING", rb_str_new2(WEECHAT_HOOK_SIGNAL_STRING));
rb_define_const(ruby_mWeechat, "WEECHAT_HOOK_SIGNAL_INT", rb_str_new2(WEECHAT_HOOK_SIGNAL_INT));
rb_define_const(ruby_mWeechat, "WEECHAT_HOOK_SIGNAL_POINTER", rb_str_new2(WEECHAT_HOOK_SIGNAL_POINTER));
rb_define_module_function (ruby_mWeechat, "register", &weechat_ruby_api_register, 7);
rb_define_module_function (ruby_mWeechat, "charset_set", &weechat_ruby_api_charset_set, 1);
rb_define_module_function (ruby_mWeechat, "iconv_to_internal", &weechat_ruby_api_iconv_to_internal, 2);

View File

@ -44,19 +44,41 @@ struct t_weelist;
char weechat_plugin_license[] = __license;
/* return codes for plugin functions */
#define WEECHAT_RC_ERROR -1 /* function failed with an error */
#define WEECHAT_RC_OK 0 /* function ok */
#define WEECHAT_RC_OK 0
#define WEECHAT_RC_ERROR -1
/* return codes for config read functions/callbacks */
#define WEECHAT_CONFIG_READ_OK 0
#define WEECHAT_CONFIG_READ_MEMORY_ERROR -1
#define WEECHAT_CONFIG_READ_FILE_NOT_FOUND -2
/* return codes for config write functions/callbacks */
#define WEECHAT_CONFIG_WRITE_OK 0
#define WEECHAT_CONFIG_WRITE_ERROR -1
#define WEECHAT_CONFIG_WRITE_MEMORY_ERROR -2
/* return codes for config option set */
#define WEECHAT_CONFIG_OPTION_SET_OK_CHANGED 2
#define WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE 1
#define WEECHAT_CONFIG_OPTION_SET_ERROR 0
#define WEECHAT_CONFIG_OPTION_SET_OPTION_NOT_FOUND -1
/* return codes for config option unset */
#define WEECHAT_CONFIG_OPTION_UNSET_OK_NO_RESET 0
#define WEECHAT_CONFIG_OPTION_UNSET_OK_RESET 1
#define WEECHAT_CONFIG_OPTION_UNSET_OK_REMOVED 2
#define WEECHAT_CONFIG_OPTION_UNSET_ERROR -1
/* list management (order of elements) */
#define WEECHAT_LIST_POS_SORT "sort"
#define WEECHAT_LIST_POS_BEGINNING "beginning"
#define WEECHAT_LIST_POS_END "end"
#define WEECHAT_LIST_POS_SORT "sort"
#define WEECHAT_LIST_POS_BEGINNING "beginning"
#define WEECHAT_LIST_POS_END "end"
/* buffer hotlist */
#define WEECHAT_HOTLIST_LOW "0"
#define WEECHAT_HOTLIST_MESSAGE "1"
#define WEECHAT_HOTLIST_PRIVATE "2"
#define WEECHAT_HOTLIST_HIGHLIGHT "3"
#define WEECHAT_HOTLIST_LOW "0"
#define WEECHAT_HOTLIST_MESSAGE "1"
#define WEECHAT_HOTLIST_PRIVATE "2"
#define WEECHAT_HOTLIST_HIGHLIGHT "3"
/* connect status for connection hooked */
#define WEECHAT_HOOK_CONNECT_OK 0
@ -70,9 +92,9 @@ struct t_weelist;
#define WEECHAT_HOOK_CONNECT_MEMORY_ERROR 8
/* type of data for signal hooked */
#define WEECHAT_HOOK_SIGNAL_STRING "string"
#define WEECHAT_HOOK_SIGNAL_INT "int"
#define WEECHAT_HOOK_SIGNAL_POINTER "pointer"
#define WEECHAT_HOOK_SIGNAL_STRING "string"
#define WEECHAT_HOOK_SIGNAL_INT "int"
#define WEECHAT_HOOK_SIGNAL_POINTER "pointer"
struct t_weechat_plugin
{

View File

@ -293,9 +293,6 @@ xfer_config_init ()
/*
* xfer_config_read: read xfer configuration file
* return: 0 = successful
* -1 = configuration file file not found
* -2 = error in configuration file
*/
int
@ -306,8 +303,6 @@ xfer_config_read ()
/*
* xfer_config_write: write xfer configuration file
* return: 0 if ok
* < 0 if error
*/
int