diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2007-12-07 13:12:46 +0100 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2007-12-07 13:12:46 +0100 |
commit | 495e6bd5df9163148676821d610c9ef863326f70 (patch) | |
tree | 024adc4a159a888e779dd92520f38b22c1d08ec4 /src/core | |
parent | 3c8276bc5752a607f3a16e1a4a683b5f73b3db37 (diff) | |
download | weechat-495e6bd5df9163148676821d610c9ef863326f70.zip |
Many changes in IRC plugin and plugins API
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/wee-command.c | 4 | ||||
-rw-r--r-- | src/core/wee-config-file.c | 496 | ||||
-rw-r--r-- | src/core/wee-config-file.h | 43 | ||||
-rw-r--r-- | src/core/wee-config.c | 1296 | ||||
-rw-r--r-- | src/core/wee-config.h | 4 | ||||
-rw-r--r-- | src/core/wee-hook.c | 113 | ||||
-rw-r--r-- | src/core/wee-list.c | 279 | ||||
-rw-r--r-- | src/core/wee-list.h | 26 | ||||
-rw-r--r-- | src/core/wee-log.c | 10 | ||||
-rw-r--r-- | src/core/wee-upgrade.c | 84 | ||||
-rw-r--r-- | src/core/wee-util.c | 6 | ||||
-rw-r--r-- | src/core/wee-util.h | 2 | ||||
-rw-r--r-- | src/core/weechat.c | 28 |
13 files changed, 1222 insertions, 1169 deletions
diff --git a/src/core/wee-command.c b/src/core/wee-command.c index a6e5d6d31..487527656 100644 --- a/src/core/wee-command.c +++ b/src/core/wee-command.c @@ -1341,7 +1341,7 @@ command_set (void *data, void *buffer, { number_found = 0; - number_found += command_set_display_option_list (weechat_config, + number_found += command_set_display_option_list (weechat_config_file, NULL, (argc == 2) ? argv[1] : NULL); @@ -1381,7 +1381,7 @@ command_set (void *data, void *buffer, /* set option value */ if ((argc >= 4) && (string_strcasecmp (argv[2], "=") == 0)) { - ptr_option = config_file_search_option (weechat_config, NULL, argv[1]); + ptr_option = config_file_search_option (weechat_config_file, NULL, argv[1]); if (!ptr_option) { gui_chat_printf (NULL, diff --git a/src/core/wee-config-file.c b/src/core/wee-config-file.c index dc17c332a..8568fcd71 100644 --- a/src/core/wee-config-file.c +++ b/src/core/wee-config-file.c @@ -25,6 +25,7 @@ #include <stdlib.h> #include <unistd.h> +#include <stdarg.h> #include <string.h> #include <sys/stat.h> @@ -127,8 +128,8 @@ config_file_valid_for_plugin (void *plugin, struct t_config_file *config_file) struct t_config_section * config_file_new_section (struct t_config_file *config_file, char *name, void (*callback_read)(void *, char *, char *), - void (*callback_write)(void *), - void (*callback_write_default)(void *)) + void (*callback_write)(void *, char *), + void (*callback_write_default)(void *, char *)) { struct t_config_section *new_section; @@ -179,213 +180,151 @@ config_file_search_section (struct t_config_file *config_file, } /* - * config_file_new_option_boolean: create a new option, type "boolean" - * in a config section + * config_file_section_valid_for_plugin: check if a section pointer exists for a plugin + * return 1 if section exists for plugin + * 0 if section is not found for plugin */ -struct t_config_option * -config_file_new_option_boolean (struct t_config_section *section, char *name, - char *description, int default_value, - void (*callback_change)()) +int +config_file_section_valid_for_plugin (void *plugin, + struct t_config_section *section) { - struct t_config_option *new_option; - - if (!section || !name) - return NULL; + struct t_config_file *ptr_config; + struct t_config_section *ptr_section; - new_option = (struct t_config_option *)malloc (sizeof (struct t_config_option)); - if (new_option) + for (ptr_config = config_files; ptr_config; + ptr_config = ptr_config->next_config) { - new_option->name = strdup (name); - new_option->type = CONFIG_OPTION_BOOLEAN; - new_option->description = (description) ? strdup (description) : NULL; - new_option->string_values = NULL; - new_option->min = CONFIG_BOOLEAN_FALSE; - new_option->max = CONFIG_BOOLEAN_TRUE; - default_value = (default_value) ? - CONFIG_BOOLEAN_TRUE : CONFIG_BOOLEAN_FALSE; - new_option->default_value = malloc (sizeof (char)); - *((char *)new_option->default_value) = default_value; - new_option->value = malloc (sizeof (char)); - *((char *)new_option->value) = default_value; - new_option->callback_change = callback_change; - new_option->loaded = 0; - - new_option->prev_option = section->last_option; - new_option->next_option = NULL; - if (section->options) - section->last_option->next_option = new_option; - else - section->options = new_option; - section->last_option = new_option; + if (ptr_config->plugin == (struct t_weechat_plugin *)plugin) + { + for (ptr_section = ptr_config->sections; ptr_section; + ptr_section = ptr_section->next_section) + { + if (ptr_section == section) + return 1; + } + } } - return new_option; + /* section not found */ + return 0; } /* - * config_file_new_option_integer: create a new option, type "integer" - * in a config section + * config_file_new_option: create a new option in a config section */ struct t_config_option * -config_file_new_option_integer (struct t_config_section *section, char *name, - char *description, int min, int max, - int default_value, void (*callback_change)()) +config_file_new_option (struct t_config_section *section, char *name, + char *type, char *description, char *string_values, + int min, int max, char *default_value, + void (*callback_change)()) { struct t_config_option *new_option; + int var_type, int_value, argc, i, index_value; + long number; + char *error; if (!section || !name) return NULL; - new_option = (struct t_config_option *)malloc (sizeof (struct t_config_option)); - if (new_option) + var_type = -1; + if (string_strcasecmp (type, "boolean") == 0) + var_type = CONFIG_OPTION_BOOLEAN; + if (string_strcasecmp (type, "integer") == 0) + var_type = CONFIG_OPTION_INTEGER; + if (string_strcasecmp (type, "string") == 0) + var_type = CONFIG_OPTION_STRING; + if (string_strcasecmp (type, "color") == 0) + var_type = CONFIG_OPTION_COLOR; + + if (var_type < 0) { - new_option->name = strdup (name); - new_option->type = CONFIG_OPTION_INTEGER; - new_option->description = (description) ? strdup (description) : NULL; - new_option->string_values = NULL; - new_option->min = min; - new_option->max = max; - new_option->default_value = malloc (sizeof (int)); - *((int *)new_option->default_value) = default_value; - new_option->value = malloc (sizeof (int)); - *((int *)new_option->value) = default_value; - new_option->callback_change = callback_change; - new_option->loaded = 0; - - new_option->prev_option = section->last_option; - new_option->next_option = NULL; - if (section->options) - section->last_option->next_option = new_option; - else - section->options = new_option; - section->last_option = new_option; - } - - return new_option; -} - -/* - * config_file_new_option_integer_with_string: create a new option, type "integer" - * (with string) in a config section - */ - -struct t_config_option * -config_file_new_option_integer_with_string (struct t_config_section *section, - char *name, char *description, - char *string_values, - int default_value, - void (*callback_change)()) -{ - struct t_config_option *new_option; - int argc; - - if (!section || !name || !string_values) + gui_chat_printf (NULL, "%sError: unknown option type \"%s\"", + gui_chat_prefix[GUI_CHAT_PREFIX_ERROR], + type); return NULL; - - new_option = (struct t_config_option *)malloc (sizeof (struct t_config_option)); - if (new_option) - { - new_option->name = strdup (name); - new_option->type = CONFIG_OPTION_INTEGER; - new_option->description = (description) ? strdup (description) : NULL; - new_option->string_values = string_explode (string_values, "|", 0, 0, - &argc); - new_option->min = 0; - new_option->max = (argc == 0) ? 0 : argc - 1; - new_option->default_value = malloc (sizeof (int)); - *((int *)new_option->default_value) = default_value; - new_option->value = malloc (sizeof (int)); - *((int *)new_option->value) = default_value; - new_option->callback_change = callback_change; - new_option->loaded = 0; - - new_option->prev_option = section->last_option; - new_option->next_option = NULL; - if (section->options) - section->last_option->next_option = new_option; - else - section->options = new_option; - section->last_option = new_option; } - return new_option; -} - -/* - * config_file_new_option_string: create a new option, type "string" - * in a config section - */ - -struct t_config_option * -config_file_new_option_string (struct t_config_section *section, - char *name, char *description, - int min_length, int max_length, - char *default_value, void (*callback_change)()) -{ - struct t_config_option *new_option; - - if (!section || !name) - return NULL; - - new_option = (struct t_config_option *)malloc (sizeof (struct t_config_option)); - if (new_option) - { - new_option->name = strdup (name); - new_option->type = CONFIG_OPTION_STRING; - new_option->description = (description) ? strdup (description) : NULL; - new_option->string_values = NULL; - new_option->min = min_length; - new_option->max = max_length; - new_option->default_value = (default_value) ? - strdup (default_value) : NULL; - new_option->value = strdup (default_value) ? - strdup (default_value) : NULL; - new_option->callback_change = callback_change; - new_option->loaded = 0; - - new_option->prev_option = section->last_option; - new_option->next_option = NULL; - if (section->options) - section->last_option->next_option = new_option; - else - section->options = new_option; - section->last_option = new_option; - } - - return new_option; -} - -/* - * config_file_new_option_color: create a new option, type "color" - * in a config section - */ - -struct t_config_option * -config_file_new_option_color (struct t_config_section *section, - char *name, char *description, int color_index, - char *default_value, void (*callback_change)()) -{ - struct t_config_option *new_option; - - if (!section || !name || !default_value) - return NULL; - new_option = (struct t_config_option *)malloc (sizeof (struct t_config_option)); if (new_option) { new_option->name = strdup (name); - new_option->type = CONFIG_OPTION_COLOR; + new_option->type = var_type; new_option->description = (description) ? strdup (description) : NULL; - new_option->string_values = NULL; - new_option->min = color_index; - new_option->max = color_index; - new_option->default_value = malloc (sizeof (int)); - if (!gui_color_assign (new_option->default_value, default_value)) - new_option->default_value = 0; - new_option->value = malloc (sizeof (int)); - *((int *)new_option->value) = *((int *)new_option->default_value); + argc = 0; + switch (var_type) + { + case CONFIG_OPTION_BOOLEAN: + new_option->string_values = NULL; + new_option->min = CONFIG_BOOLEAN_FALSE; + new_option->max = CONFIG_BOOLEAN_TRUE; + int_value = (config_file_string_to_boolean (default_value) == CONFIG_BOOLEAN_TRUE) ? + CONFIG_BOOLEAN_TRUE : CONFIG_BOOLEAN_FALSE; + new_option->default_value = malloc (sizeof (int)); + *((int *)new_option->default_value) = int_value; + new_option->value = malloc (sizeof (int)); + *((int *)new_option->value) = int_value; + break; + case CONFIG_OPTION_INTEGER: + if (string_values) + new_option->string_values = string_explode (string_values, + "|", 0, 0, + &argc); + if (new_option->string_values) + { + new_option->min = 0; + new_option->max = (argc == 0) ? 0 : argc - 1; + index_value = 0; + for (i = 0; i < argc; i++) + { + if (string_strcasecmp (new_option->string_values[i], + default_value) == 0) + { + index_value = i; + break; + } + } + new_option->default_value = malloc (sizeof (int)); + *((int *)new_option->default_value) = index_value; + new_option->value = malloc (sizeof (int)); + *((int *)new_option->value) = index_value; + } + else + { + new_option->string_values = NULL; + new_option->min = min; + new_option->max = max; + error = NULL; + number = strtol (default_value, &error, 10); + if (!error || (error[0] != '\0')) + number = 0; + new_option->default_value = malloc (sizeof (int)); + *((int *)new_option->default_value) = number; + new_option->value = malloc (sizeof (int)); + *((int *)new_option->value) = number; + } + break; + case CONFIG_OPTION_STRING: + new_option->string_values = NULL; + new_option->min = min; + new_option->max = max; + new_option->default_value = (default_value) ? + strdup (default_value) : NULL; + new_option->value = strdup (default_value) ? + strdup (default_value) : NULL; + break; + case CONFIG_OPTION_COLOR: + new_option->string_values = NULL; + new_option->min = min; + new_option->max = min; + new_option->default_value = malloc (sizeof (int)); + if (!gui_color_assign (new_option->default_value, default_value)) + new_option->default_value = 0; + new_option->value = malloc (sizeof (int)); + *((int *)new_option->value) = *((int *)new_option->default_value); + break; + } new_option->callback_change = callback_change; new_option->loaded = 0; @@ -477,12 +416,12 @@ config_file_option_valid_for_plugin (void *plugin, } /* - * config_file_string_boolean_value: return boolean value of string - * return -1 if error + * config_file_string_to_boolean: return boolean value of string + * return -1 if error */ int -config_file_string_boolean_value (char *text) +config_file_string_to_boolean (char *text) { if ((string_strcasecmp (text, "on") == 0) || (string_strcasecmp (text, "yes") == 0) @@ -526,12 +465,12 @@ config_file_option_set (struct t_config_option *option, char *new_value) case CONFIG_OPTION_BOOLEAN: if (!new_value) return 0; - new_value_int = config_file_string_boolean_value (new_value); + new_value_int = config_file_string_to_boolean (new_value); if (new_value_int < 0) return 0; - if (new_value_int == *((char *)option->value)) + if (new_value_int == *((int *)option->value)) return 1; - *((char *)option->value) = new_value_int; + *((int *)option->value) = new_value_int; return 2; case CONFIG_OPTION_INTEGER: if (!new_value) @@ -718,32 +657,46 @@ config_file_read (struct t_config_file *config_file) { pos = strchr (line, ']'); if (pos == NULL) + { gui_chat_printf (NULL, _("Warning: %s, line %d: invalid " "syntax, missing \"]\"\n"), filename, line_number); + } else { pos[0] = '\0'; pos = ptr_line + 1; ptr_section = config_file_search_section (config_file, pos); - if (!ptr_section) + if (ptr_section) + { + if (ptr_section->callback_read) + { + (void) (ptr_section->callback_read) (config_file, + NULL, NULL); + } + } + else + { gui_chat_printf (NULL, _("Warning: %s, line %d: unknown " "section identifier " "(\"%s\")\n"), filename, line_number, pos); + } } } else { pos = strchr (line, '='); if (pos == NULL) + { gui_chat_printf (NULL, _("Warning: %s, line %d: invalid " "syntax, missing \"=\"\n"), filename, line_number); + } else { pos[0] = '\0'; @@ -791,26 +744,25 @@ config_file_read (struct t_config_file *config_file) pos++; } } - - ptr_option = config_file_search_option (config_file, - ptr_section, - line); - if (ptr_option) + + if (ptr_section && ptr_section->callback_read) { - rc = config_file_option_set (ptr_option, pos); - ptr_option->loaded = 1; + ptr_option = NULL; + (void) (ptr_section->callback_read) (config_file, + line, pos); + rc = 1; } else { - /* option not found: use read callback */ - if (ptr_section && ptr_section->callback_read) + rc = -1; + ptr_option = config_file_search_option (config_file, + ptr_section, + line); + if (ptr_option) { - (void) (ptr_section->callback_read) (config_file, - line, pos); - rc = 1; + rc = config_file_option_set (ptr_option, pos); + ptr_option->loaded = 1; } - else - rc = -1; } switch (rc) @@ -955,14 +907,28 @@ config_file_write_option (struct t_config_file *config_file, /* * config_file_write_line: write a line in a config file + * if value is NULL, then write a section with [ ] around */ void config_file_write_line (struct t_config_file *config_file, - char *option_name, char *value) + char *option_name, char *value, ...) { - string_iconv_fprintf (config_file->file, "%s = %s\n", - option_name, value); + char buf[4096]; + va_list argptr; + + va_start (argptr, value); + vsnprintf (buf, sizeof (buf) - 1, value, argptr); + va_end (argptr); + + if (!buf[0]) + string_iconv_fprintf (config_file->file, "\n[%s]\n", + option_name); + else + { + string_iconv_fprintf (config_file->file, "%s = %s\n", + option_name, buf); + } } /* @@ -1024,28 +990,28 @@ config_file_write (struct t_config_file *config_file, int default_options) for (ptr_section = config_file->sections; ptr_section; ptr_section = ptr_section->next_section) { - /* write section name in file */ - string_iconv_fprintf (config_file->file, - "\n[%s]\n", ptr_section->name); - /* call write callback if defined for section */ - if (default_options) + if (default_options && ptr_section->callback_write_default) { - if (ptr_section->callback_write_default) - (void) (ptr_section->callback_write_default) (config_file); + (void) (ptr_section->callback_write_default) (config_file, + ptr_section->name); } - else + else if (!default_options && ptr_section->callback_write) { - if (ptr_section->callback_write) - (void) (ptr_section->callback_write) (config_file); + (void) (ptr_section->callback_write) (config_file, + ptr_section->name); } - - /* write all options for section */ - for (ptr_option = ptr_section->options; ptr_option; - ptr_option = ptr_option->next_option) + else { - config_file_write_option (config_file, ptr_option, - default_options); + /* write all options for section */ + string_iconv_fprintf (config_file->file, + "\n[%s]\n", ptr_section->name); + for (ptr_option = ptr_section->options; ptr_option; + ptr_option = ptr_option->next_option) + { + config_file_write_option (config_file, ptr_option, + default_options); + } } } @@ -1310,78 +1276,82 @@ config_file_print_log () for (ptr_config_file = config_files; ptr_config_file; ptr_config_file = ptr_config_file->next_config) { - log_printf ("\n"); - log_printf ("[config (addr:0x%X)]\n", ptr_config_file); - log_printf (" filename . . . . . . . : '%s'\n", ptr_config_file->filename); - log_printf (" sections . . . . . . . : 0x%X\n", ptr_config_file->sections); - log_printf (" last_section . . . . . : 0x%X\n", ptr_config_file->last_section); - log_printf (" prev_config. . . . . . : 0x%X\n", ptr_config_file->prev_config); - log_printf (" next_config. . . . . . : 0x%X\n", ptr_config_file->next_config); + log_printf (""); + log_printf ("[config (addr:0x%X)]", ptr_config_file); + log_printf (" plugin . . . . . . . . : 0x%X", ptr_config_file->plugin); + log_printf (" filename . . . . . . . : '%s'", ptr_config_file->filename); + log_printf (" file . . . . . . . . . : 0x%X", ptr_config_file->file); + log_printf (" sections . . . . . . . : 0x%X", ptr_config_file->sections); + log_printf (" last_section . . . . . : 0x%X", ptr_config_file->last_section); + log_printf (" prev_config. . . . . . : 0x%X", ptr_config_file->prev_config); + log_printf (" next_config. . . . . . : 0x%X", ptr_config_file->next_config); for (ptr_section = ptr_config_file->sections; ptr_section; ptr_section = ptr_section->next_section) { - log_printf ("\n"); - log_printf (" [section (addr:0x%X)]\n", ptr_section); - log_printf (" name . . . . . . . . . : '%s'\n", ptr_section->name); - log_printf (" callback_read. . . . . : 0x%X\n", ptr_section->callback_read); - log_printf (" callback_write . . . . : 0x%X\n", ptr_section->callback_write); - log_printf (" options. . . . . . . . : 0x%X\n", ptr_section->options); - log_printf (" last_option. . . . . . : 0x%X\n", ptr_section->last_option); - log_printf (" prev_item. . . . . . . : 0x%X\n", ptr_section->prev_section); - log_printf (" next_item. . . . . . . : 0x%X\n", ptr_section->next_section); + log_printf (""); + log_printf (" [section (addr:0x%X)]", ptr_section); + log_printf (" name . . . . . . . . . : '%s'", ptr_section->name); + log_printf (" callback_read. . . . . : 0x%X", ptr_section->callback_read); + log_printf (" callback_write . . . . : 0x%X", ptr_section->callback_write); + log_printf (" callback_write_default : 0x%X", ptr_section->callback_write_default); + log_printf (" options. . . . . . . . : 0x%X", ptr_section->options); + log_printf (" last_option. . . . . . : 0x%X", ptr_section->last_option); + log_printf (" prev_section . . . . . : 0x%X", ptr_section->prev_section); + log_printf (" next_section . . . . . : 0x%X", ptr_section->next_section); for (ptr_option = ptr_section->options; ptr_option; ptr_option = ptr_option->next_option) { - log_printf ("\n"); - log_printf (" [option (addr:0x%X)]\n", ptr_option); - log_printf (" name . . . . . . . . : '%s'\n", ptr_option->name); - log_printf (" type . . . . . . . . : %d\n", ptr_option->type); - log_printf (" string_values. . . . : 0x%X\n", ptr_option->string_values); - log_printf (" min. . . . . . . . . : %d\n", ptr_option->min); - log_printf (" max. . . . . . . . . : %d\n", ptr_option->max); + log_printf (""); + log_printf (" [option (addr:0x%X)]", ptr_option); + log_printf (" name . . . . . . . . : '%s'", ptr_option->name); + log_printf (" type . . . . . . . . : %d", ptr_option->type); + log_printf (" description. . . . . : '%s'", ptr_option->description); + log_printf (" string_values. . . . : 0x%X", ptr_option->string_values); + log_printf (" min. . . . . . . . . : %d", ptr_option->min); + log_printf (" max. . . . . . . . . : %d", ptr_option->max); switch (ptr_option->type) { case CONFIG_OPTION_BOOLEAN: - log_printf (" value (boolean). . . : %s\n", - (CONFIG_BOOLEAN(ptr_option) == CONFIG_BOOLEAN_TRUE) ? - "true" : "false"); - log_printf (" default value. . . . : %s\n", + log_printf (" default value. . . . : %s", (CONFIG_BOOLEAN_DEFAULT(ptr_option) == CONFIG_BOOLEAN_TRUE) ? "true" : "false"); + log_printf (" value (boolean). . . : %s", + (CONFIG_BOOLEAN(ptr_option) == CONFIG_BOOLEAN_TRUE) ? + "true" : "false"); break; case CONFIG_OPTION_INTEGER: if (ptr_option->string_values) { - log_printf (" value (integer/str). : '%s'\n", - ptr_option->string_values[CONFIG_INTEGER(ptr_option)]); - log_printf (" default value. . . . : '%s'\n", + log_printf (" default value. . . . : '%s'", ptr_option->string_values[CONFIG_INTEGER_DEFAULT(ptr_option)]); + log_printf (" value (integer/str). : '%s'", + ptr_option->string_values[CONFIG_INTEGER(ptr_option)]); } else { - log_printf (" value (integer). . . : %d\n", CONFIG_INTEGER(ptr_option)); - log_printf (" default value. . . . : %d\n", CONFIG_INTEGER_DEFAULT(ptr_option)); + log_printf (" default value. . . . : %d", CONFIG_INTEGER_DEFAULT(ptr_option)); + log_printf (" value (integer). . . : %d", CONFIG_INTEGER(ptr_option)); } break; case CONFIG_OPTION_STRING: - log_printf (" value (string) . . . : '%s'\n", CONFIG_STRING(ptr_option)); - log_printf (" default value. . . . : '%s'\n", CONFIG_STRING_DEFAULT(ptr_option)); + log_printf (" default value. . . . : '%s'", CONFIG_STRING_DEFAULT(ptr_option)); + log_printf (" value (string) . . . : '%s'", CONFIG_STRING(ptr_option)); break; case CONFIG_OPTION_COLOR: - log_printf (" value (color). . . . : %d ('%s')\n", - CONFIG_COLOR(ptr_option), - gui_color_get_name (CONFIG_COLOR(ptr_option))); - log_printf (" default value. . . . : %d ('%s')\n", + log_printf (" default value. . . . : %d ('%s')", CONFIG_COLOR_DEFAULT(ptr_option), gui_color_get_name (CONFIG_COLOR_DEFAULT(ptr_option))); + log_printf (" value (color). . . . : %d ('%s')", + CONFIG_COLOR(ptr_option), + gui_color_get_name (CONFIG_COLOR(ptr_option))); break; } - log_printf (" callback_change. . . : 0x%X\n", ptr_option->callback_change); - log_printf (" loaded . . . . . . . : %d\n", ptr_option->loaded); - log_printf (" prev_option. . . . . : 0x%X\n", ptr_option->prev_option); - log_printf (" next_option. . . . . : 0x%X\n", ptr_option->next_option); + log_printf (" callback_change. . . : 0x%X", ptr_option->callback_change); + log_printf (" loaded . . . . . . . : %d", ptr_option->loaded); + log_printf (" prev_option. . . . . : 0x%X", ptr_option->prev_option); + log_printf (" next_option. . . . . : 0x%X", ptr_option->next_option); } } } diff --git a/src/core/wee-config-file.h b/src/core/wee-config-file.h index 5cfc9a289..b27bf99da 100644 --- a/src/core/wee-config-file.h +++ b/src/core/wee-config-file.h @@ -20,8 +20,8 @@ #ifndef __WEECHAT_CONFIG_FILE_H #define __WEECHAT_CONFIG_FILE_H 1 -#define CONFIG_BOOLEAN(option) (*((char *)((option)->value))) -#define CONFIG_BOOLEAN_DEFAULT(option) (*((char *)((option)->default_value))) +#define CONFIG_BOOLEAN(option) (*((int *)((option)->value))) +#define CONFIG_BOOLEAN_DEFAULT(option) (*((int *)((option)->default_value))) #define CONFIG_INTEGER(option) (*((int *)((option)->value))) #define CONFIG_INTEGER_DEFAULT(option) (*((int *)((option)->default_value))) @@ -52,9 +52,9 @@ struct t_config_section void (*callback_read) /* called when unknown option */ (void *, char *, char *); /* is read from config file */ void (*callback_write) /* called to write special */ - (void *); /* options in config file */ + (void *, char *); /* options in config file */ void (*callback_write_default) /* called to write default */ - (void *); /* options in config file */ + (void *, char *); /* options in config file */ struct t_config_option *options; /* options in section */ struct t_config_option *last_option; /* last option in section */ struct t_config_section *prev_section; /* link to previous section */ @@ -89,43 +89,26 @@ extern int config_file_valid_for_plugin (void *, struct t_config_file *); extern struct t_config_section *config_file_new_section (struct t_config_file *, char *, void (*)(void *, char *, char *), - void (*)(void *), - void (*)(void *)); + void (*)(void *, char *), + void (*)(void *, char *)); extern struct t_config_section *config_file_search_section (struct t_config_file *, char *); -extern struct t_config_option *config_file_new_option_boolean (struct t_config_section *, - char *, char *, - int, - void (*)()); -extern struct t_config_option *config_file_new_option_integer (struct t_config_section *, - char *, char *, - int, int, int, - void (*)()); -extern struct t_config_option *config_file_new_option_integer_with_string (struct t_config_section *, - char *, - char *, - char *, - int, - void (*)()); -extern struct t_config_option *config_file_new_option_string (struct t_config_section *, - char *, char *, - int, int, - char *, void (*)()); -extern struct t_config_option *config_file_new_option_color (struct t_config_section *, - char *, char *, - int, char *, - void (*)()); +extern int config_file_section_valid_for_plugin (void *, struct t_config_section *); +extern struct t_config_option *config_file_new_option (struct t_config_section *, + char *, char *, char *, + char *, int, int, + char *, void (*)()); extern struct t_config_option *config_file_search_option (struct t_config_file *, struct t_config_section *, char *); extern int config_file_option_valid_for_plugin (void *, struct t_config_option *); -extern int config_file_string_boolean_value (char *); +extern int config_file_string_to_boolean (char *); extern int config_file_option_set (struct t_config_option *, char *); extern int config_file_option_reset (struct t_config_option *); extern int config_file_read (struct t_config_file *); extern int config_file_reload (struct t_config_file *); -extern void config_file_write_line (struct t_config_file *, char *, char *); +extern void config_file_write_line (struct t_config_file *, char *, char *, ...); extern int config_file_write (struct t_config_file *, int); extern void config_file_option_free (struct t_config_section *, struct t_config_option *); diff --git a/src/core/wee-config.c b/src/core/wee-config.c index 2f87e9ca1..b12597caa 100644 --- a/src/core/wee-config.c +++ b/src/core/wee-config.c @@ -47,7 +47,7 @@ #include "../gui/gui-window.h" -struct t_config_file *weechat_config = NULL; +struct t_config_file *weechat_config_file = NULL; /* config, look & feel section */ @@ -328,15 +328,18 @@ config_weechat_read_key (void *config_file, /* make C compiler happy */ (void) config_file; - if (value[0]) + if (option_name) { - /* bind key (overwrite any binding with same key) */ - gui_keyboard_bind (option_name, value); - } - else - { - /* unbin key if no value given */ - gui_keyboard_unbind (option_name); + if (value && value[0]) + { + /* bind key (overwrite any binding with same key) */ + gui_keyboard_bind (option_name, value); + } + else + { + /* unbin key if no value given */ + gui_keyboard_unbind (option_name); + } } } @@ -347,10 +350,12 @@ config_weechat_read_key (void *config_file, */ void -config_weechat_write_keys (void *config_file) +config_weechat_write_keys (void *config_file, char *section_name) { t_gui_key *ptr_key; - char *expanded_name, *function_name, *string; + char *expanded_name, *function_name; + + config_file_write_line (config_file, section_name, NULL); for (ptr_key = gui_keys; ptr_key; ptr_key = ptr_key->next_key) { @@ -360,41 +365,23 @@ config_weechat_write_keys (void *config_file) function_name = gui_keyboard_function_search_by_ptr (ptr_key->function); if (function_name) { - string = (char *)malloc (strlen (function_name) + 8 + - ((ptr_key->args) ? strlen (ptr_key->args) : 0)); - if (string) - { - strcpy (string, "\""); - strcat (string, function_name); - if (ptr_key->args) - { - strcat (string, " "); - strcat (string, ptr_key->args); - } - strcat (string, "\""); - config_file_write_line (config_file, - (expanded_name) ? - expanded_name : ptr_key->key, - string); - free (string); - } - } - } - else - { - string = (char *)malloc (strlen (ptr_key->command) + 4); - if (string) - { - strcpy (string, "\""); - strcat (string, ptr_key->command); - strcat (string, "\""); config_file_write_line (config_file, (expanded_name) ? expanded_name : ptr_key->key, - string); - free (string); + "\"%s%s%s\"", + function_name, + (ptr_key->args) ? " " : "", + (ptr_key->args) ? ptr_key->args : ""); } } + else + { + config_file_write_line (config_file, + (expanded_name) ? + expanded_name : ptr_key->key, + "\"%s\"", + ptr_key->command); + } if (expanded_name) free (expanded_name); } @@ -402,626 +389,649 @@ config_weechat_write_keys (void *config_file) /* * config_weechat_init: init WeeChat config structure + * return: 1 if ok, 0 if error */ -void +int config_weechat_init () { - struct t_config_section *section; + struct t_config_section *ptr_section; - weechat_config = config_file_new (NULL, WEECHAT_CONFIG_FILENAME); - if (weechat_config) - { - /* look */ - section = config_file_new_section (weechat_config, "look", + weechat_config_file = config_file_new (NULL, WEECHAT_CONFIG_FILENAME); + if (!weechat_config_file) + return 0; + + /* look */ + ptr_section = config_file_new_section (weechat_config_file, "look", NULL, NULL, NULL); - if (section) - { - config_look_color_real_white = config_file_new_option_boolean ( - section, "look_color_real_white", - N_("if set, uses real white color, disabled by default " - "for terms with white background (if you never use " - "white background, you should turn on this option to " - "see real white instead of default term foreground " - "color)"), - CONFIG_BOOLEAN_FALSE, &config_change_color); - config_look_save_on_exit = config_file_new_option_boolean ( - section, "look_save_on_exit", - N_("save configuration file on exit"), - CONFIG_BOOLEAN_TRUE, &config_change_save_on_exit); - config_look_set_title = config_file_new_option_boolean ( - section, "look_set_title", - N_("set title for window (terminal for Curses GUI) with " - "name and version"), - CONFIG_BOOLEAN_TRUE, &config_change_title); - config_look_startup_logo = config_file_new_option_boolean ( - section, "look_startup_logo", - N_("display WeeChat logo at startup"), - CONFIG_BOOLEAN_TRUE, NULL); - config_look_startup_version = config_file_new_option_boolean ( - section, "look_startup_version", - N_("display WeeChat version at startup"), - CONFIG_BOOLEAN_TRUE, NULL); - config_look_weechat_slogan = config_file_new_option_string ( - section, "look_weechat_slogan", - N_("WeeChat slogan (if empty, slogan is not used)"), - 0, 0, "the geekest IRC client!", NULL); - config_look_scroll_amount = config_file_new_option_integer ( - section, "look_scroll_amount", - N_("how many lines to scroll by with scroll_up and " - "scroll_down"), - 1, INT_MAX, 3, &config_change_buffer_content); - config_look_buffer_time_format = config_file_new_option_string ( - section, "look_buffer_time_format", - N_("time format for buffers"), - 0, 0, "[%H:%M:%S]", &config_change_buffer_time_format); - config_look_color_nicks_number = config_file_new_option_integer ( - section, "look_color_nicks_number", - N_("number of colors to use for nicks colors"), - 1, 10, 10, &config_change_nicks_colors); - config_look_nicklist = config_file_new_option_boolean ( - section, "look_nicklist", - N_("display nicklist (on buffers with nicklist enabled"), - CONFIG_BOOLEAN_TRUE, &config_change_buffers); - config_look_nicklist_position = config_file_new_option_integer_with_string ( - section, "look_nicklist_position", - N_("nicklist position (top, left, right (default), " - "bottom)"), - "left|right|top|bottom", 1, &config_change_buffers); - config_look_nicklist_min_size = config_file_new_option_integer ( - section, "look_nicklist_min_size", - N_("min size for nicklist (width or height, depending on " - "look_nicklist_position "), - 0, 100, 0, &config_change_buffers); - config_look_nicklist_max_size = config_file_new_option_integer ( - section, "look_nicklist_max_size", - N_("max size for nicklist (width or height, depending on " - "look_nicklist_position (0 = no max size; if min = max " - "and > 0, then size is fixed))"), - 0, 100, 0, &config_change_buffers); - config_look_nicklist_separator = config_file_new_option_boolean ( - section, "look_nicklist_separator", - N_("separator between chat and nicklist"), - CONFIG_BOOLEAN_TRUE, &config_change_buffers); - config_look_nickmode = config_file_new_option_boolean ( - section, "look_nickmode", - N_("display nick mode ((half)op/voice) before each nick"), - CONFIG_BOOLEAN_TRUE, &config_change_buffers); - config_look_nickmode_empty = config_file_new_option_boolean ( - section, "look_nickmode_empty", - N_("display space if nick mode is not (half)op/voice"), - CONFIG_BOOLEAN_FALSE, &config_change_buffers); - config_look_prefix[GUI_CHAT_PREFIX_INFO] = config_file_new_option_string ( - section, "look_prefix_info", - N_("prefix for info messages"), - 0, 0, "-=-", &config_change_prefix); - config_look_prefix[GUI_CHAT_PREFIX_ERROR] = config_file_new_option_string ( - section, "look_prefix_error", - N_("prefix for error messages"), - 0, 0, "=!=", &config_change_prefix); - config_look_prefix[GUI_CHAT_PREFIX_NETWORK] = config_file_new_option_string ( - section, "look_prefix_network", - N_("prefix for network messages"), - 0, 0, "-@-", &config_change_prefix); - config_look_prefix[GUI_CHAT_PREFIX_ACTION] = config_file_new_option_string ( - section, "look_prefix_action", - N_("prefix for action messages"), - 0, 0, "-*-", &config_change_prefix); - config_look_prefix[GUI_CHAT_PREFIX_JOIN] = config_file_new_option_string ( - section, "look_prefix_join", - N_("prefix for join messages"), - 0, 0, "-->", &config_change_prefix); - config_look_prefix[GUI_CHAT_PREFIX_QUIT] = config_file_new_option_string ( - section, "look_prefix_quit", - N_("prefix for quit messages"), - 0, 0, "<--", &config_change_prefix); - config_look_prefix_align = config_file_new_option_integer_with_string ( - section, "look_prefix_align", - N_("prefix alignment (none, left, right (default))"), - "none|left|right", 2, &config_change_buffers); - config_look_prefix_align_max = config_file_new_option_integer ( - section, "look_prefix_align_max", - N_("max size for prefix (0 = no max size)"), - 0, 64, 0, &config_change_buffers); - config_look_prefix_suffix = config_file_new_option_string ( - section, "look_prefix_suffix", - N_("string displayed after prefix"), - 0, 0, "|", &config_change_buffers); - config_look_nick_completor = config_file_new_option_string ( - section, "look_nick_completor", - N_("the string inserted after nick completion"), - 0, 0, ":", NULL); - config_look_nick_completion_ignore = config_file_new_option_string ( - section, "look_nick_completion_ignore", - N_("chars ignored for nick completion"), - 0, 0, "[]-^", NULL); - config_look_nick_completion_smart = config_file_new_option_boolean ( - section, "look_nick_completion_smart", - N_("smart completion for nicks (completes with last speakers first)"), - CONFIG_BOOLEAN_TRUE, NULL); - config_look_nick_complete_first = config_file_new_option_boolean ( - section, "look_nick_complete_first", - N_("complete only with first nick found"), - CONFIG_BOOLEAN_FALSE, NULL); - config_look_infobar = config_file_new_option_boolean ( - section, "look_infobar", - N_("enable info bar"), - CONFIG_BOOLEAN_TRUE, &config_change_buffers); - config_look_infobar_time_format = config_file_new_option_string ( - section, "look_infobar_time_format", - N_("time format for time in infobar"), - 0, 0, "%B, %A %d %Y", &config_change_buffer_content); - config_look_infobar_seconds = config_file_new_option_boolean ( - section, "look_infobar_seconds", - N_("display seconds in infobar time"), - CONFIG_BOOLEAN_TRUE, &config_change_buffer_content); - config_look_infobar_delay_highlight = config_file_new_option_integer ( - section, "look_infobar_delay_highlight", - N_("delay (in seconds) for highlight messages in " - "infobar (0 = disable highlight notifications in " - "infobar)"), - 0, INT_MAX, 7, NULL); - config_look_hotlist_names_count = config_file_new_option_integer ( - section, "look_hotlist_names_count", - N_("max number of names in hotlist (0 = no name " - "displayed, only buffer numbers)"), - 0, 32, 3, &config_change_buffer_content); - config_look_hotlist_names_level = config_file_new_option_integer ( - section, "look_hotlist_names_level", - N_("level for displaying names in hotlist (combination " - "of: 1=join/part, 2=message, 4=private, 8=highlight, " - "for example: 12=private+highlight)"), - 1, 15, 12, &config_change_buffer_content); - config_look_hotlist_names_length = config_file_new_option_integer ( - section, "look_hotlist_names_length", - N_("max length of names in hotlist (0 = no limit)"), - 0, 32, 0, &config_change_buffer_content); - config_look_hotlist_sort = config_file_new_option_integer_with_string ( - section, "look_hotlist_sort", - N_("hotlist sort type (group_time_asc (default), " - "group_time_desc, group_number_asc, group_number_desc, " - "number_asc, number_desc)"), - "group_time_asc|group_time_desc|group_number_asc|" - "group_number_desc|number_asc|number_desc", - 0, &config_change_hotlist); - config_look_day_change = config_file_new_option_boolean ( - section, "look_day_change", - N_("display special message when day changes"), - CONFIG_BOOLEAN_TRUE, NULL); - config_look_day_change_time_format = config_file_new_option_string ( - section, "look_day_change_time_format", - N_("time format for date displayed when day changed"), - 0, 0, "%a, %d %b %Y", NULL); - config_look_read_marker = config_file_new_option_string ( - section, "look_read_marker", - N_("use a marker on servers/channels to show first unread " - "line"), - 0, 1, " ", &config_change_read_marker); - config_look_input_format = config_file_new_option_string ( - section, "look_input_format", - N_("format for input prompt ('%c' is replaced by channel " - "or server, '%n' by nick and '%m' by nick modes)"), - 0, 0, "[%n(%m)] ", &config_change_buffer_content); - config_look_paste_max_lines = config_file_new_option_integer ( - section, "look_paste_max_lines", - N_("max number of lines for paste without asking user " - "(0 = disable this feature)"), - 0, INT_MAX, 3, NULL); - } + if (!ptr_section) + { + config_file_free (weechat_config_file); + return 0; + } + + config_look_color_real_white = config_file_new_option ( + ptr_section, "look_color_real_white", "boolean", + N_("if set, uses real white color, disabled by default " + "for terms with white background (if you never use " + "white background, you should turn on this option to " + "see real white instead of default term foreground " + "color)"), + NULL, 0, 0, "off", &config_change_color); + config_look_save_on_exit = config_file_new_option ( + ptr_section, "look_save_on_exit", "boolean", + N_("save configuration file on exit"), + NULL, 0, 0, "on", &config_change_save_on_exit); + config_look_set_title = config_file_new_option ( + ptr_section, "look_set_title", "boolean", + N_("set title for window (terminal for Curses GUI) with " + "name and version"), + NULL, 0, 0, "on", &config_change_title); + config_look_startup_logo = config_file_new_option ( + ptr_section, "look_startup_logo", "boolean", + N_("display WeeChat logo at startup"), + NULL, 0, 0, "on", NULL); + config_look_startup_version = config_file_new_option ( + ptr_section, "look_startup_version", "boolean", + N_("display WeeChat version at startup"), + NULL, 0, 0, "on", NULL); + config_look_weechat_slogan = config_file_new_option ( + ptr_section, "look_weechat_slogan", "string", + N_("WeeChat slogan (if empty, slogan is not used)"), + NULL, 0, 0, "the geekest IRC client!", NULL); + config_look_scroll_amount = config_file_new_option ( + ptr_section, "look_scroll_amount", "integer", + N_("how many lines to scroll by with scroll_up and " + "scroll_down"), + NULL, 1, INT_MAX, "3", &config_change_buffer_content); + config_look_buffer_time_format = config_file_new_option ( + ptr_section, "look_buffer_time_format", "string", + N_("time format for buffers"), + NULL, 0, 0, "[%H:%M:%S]", &config_change_buffer_time_format); + config_look_color_nicks_number = config_file_new_option ( + ptr_section, "look_color_nicks_number", "integer", + N_("number of colors to use for nicks colors"), + NULL, 1, 10, "10", &config_change_nicks_colors); + config_look_nicklist = config_file_new_option ( + ptr_section, "look_nicklist", "boolean", + N_("display nicklist (on buffers with nicklist enabled"), + NULL, 0, 0, "on", &config_change_buffers); + config_look_nicklist_position = config_file_new_option ( + ptr_section, "look_nicklist_position", "integer", + N_("nicklist position (top, left, right (default), " + "bottom)"), + "left|right|top|bottom", 0, 0, "right", &config_change_buffers); + config_look_nicklist_min_size = config_file_new_option ( + ptr_section, "look_nicklist_min_size", "integer", + N_("min size for nicklist (width or height, depending on " + "look_nicklist_position "), + NULL, 0, 100, "0", &config_change_buffers); + config_look_nicklist_max_size = config_file_new_option ( + ptr_section, "look_nicklist_max_size", "integer", + N_("max size for nicklist (width or height, depending on " + "look_nicklist_position (0 = no max size; if min = max " + "and > 0, then size is fixed))"), + NULL, 0, 100, "0", &config_change_buffers); + config_look_nicklist_separator = config_file_new_option ( + ptr_section, "look_nicklist_separator", "boolean", + N_("separator between chat and nicklist"), + NULL, 0, 0, "on", &config_change_buffers); + config_look_nickmode = config_file_new_option ( + ptr_section, "look_nickmode", "boolean", + N_("display nick mode ((half)op/voice) before each nick"), + NULL, 0, 0, "on", &config_change_buffers); + config_look_nickmode_empty = config_file_new_option ( + ptr_section, "look_nickmode_empty", "boolean", + N_("display space if nick mode is not (half)op/voice"), + NULL, 0, 0, "off", &config_change_buffers); + config_look_prefix[GUI_CHAT_PREFIX_INFO] = config_file_new_option ( + ptr_section, "look_prefix_info", "string", + N_("prefix for info messages"), + NULL, 0, 0, "-=-", &config_change_prefix); + config_look_prefix[GUI_CHAT_PREFIX_ERROR] = config_file_new_option ( + ptr_section, "look_prefix_error", "string", + N_("prefix for error messages"), + NULL, 0, 0, "=!=", &config_change_prefix); + config_look_prefix[GUI_CHAT_PREFIX_NETWORK] = config_file_new_option ( + ptr_section, "look_prefix_network", "string", + N_("prefix for network messages"), + NULL, 0, 0, "-@-", &config_change_prefix); + config_look_prefix[GUI_CHAT_PREFIX_ACTION] = config_file_new_option ( + ptr_section, "look_prefix_action", "string", + N_("prefix for action messages"), + NULL, 0, 0, "-*-", &config_change_prefix); + config_look_prefix[GUI_CHAT_PREFIX_JOIN] = config_file_new_option ( + ptr_section, "look_prefix_join", "string", + N_("prefix for join messages"), + NULL, 0, 0, "-->", &config_change_prefix); + config_look_prefix[GUI_CHAT_PREFIX_QUIT] = config_file_new_option ( + ptr_section, "look_prefix_quit", "string", + N_("prefix for quit messages"), + NULL, 0, 0, "<--", &config_change_prefix); + config_look_prefix_align = config_file_new_option ( + ptr_section, "look_prefix_align", "integer", + N_("prefix alignment (none, left, right (default))"), + "none|left|right", 0, 0, "right", &config_change_buffers); + config_look_prefix_align_max = config_file_new_option ( + ptr_section, "look_prefix_align_max", "integer", + N_("max size for prefix (0 = no max size)"), + NULL, 0, 64, "0", &config_change_buffers); + config_look_prefix_suffix = config_file_new_option ( + ptr_section, "look_prefix_suffix", "string", + N_("string displayed after prefix"), + NULL, 0, 0, "|", &config_change_buffers); + config_look_nick_completor = config_file_new_option ( + ptr_section, "look_nick_completor", "string", + N_("the string inserted after nick completion"), + NULL, 0, 0, ":", NULL); + config_look_nick_completion_ignore = config_file_new_option ( + ptr_section, "look_nick_completion_ignore", "string", + N_("chars ignored for nick completion"), + NULL, 0, 0, "[]-^", NULL); + config_look_nick_completion_smart = config_file_new_option ( + ptr_section, "look_nick_completion_smart", "boolean", + N_("smart completion for nicks (completes with last speakers first)"), + NULL, 0, 0, "on", NULL); + config_look_nick_complete_first = config_file_new_option ( + ptr_section, "look_nick_complete_first", "boolean", + N_("complete only with first nick found"), + NULL, 0, 0, "off", NULL); + config_look_infobar = config_file_new_option ( + ptr_section, "look_infobar", "boolean", + N_("enable info bar"), + NULL, 0, 0, "on", &config_change_buffers); + config_look_infobar_time_format = config_file_new_option ( + ptr_section, "look_infobar_time_format", "string", + N_("time format for time in infobar"), + NULL, 0, 0, "%B, %A %d %Y", &config_change_buffer_content); + config_look_infobar_seconds = config_file_new_option ( + ptr_section, "look_infobar_seconds", "boolean", + N_("display seconds in infobar time"), + NULL, 0, 0, "on", &config_change_buffer_content); + config_look_infobar_delay_highlight = config_file_new_option ( + ptr_section, "look_infobar_delay_highlight", "integer", + N_("delay (in seconds) for highlight messages in " + "infobar (0 = disable highlight notifications in " + "infobar)"), + NULL, 0, INT_MAX, "7", NULL); + config_look_hotlist_names_count = config_file_new_option ( + ptr_section, "look_hotlist_names_count", "integer", + N_("max number of names in hotlist (0 = no name " + "displayed, only buffer numbers)"), + NULL, 0, 32, "3", &config_change_buffer_content); + config_look_hotlist_names_level = config_file_new_option ( + ptr_section, "look_hotlist_names_level", "integer", + N_("level for displaying names in hotlist (combination " + "of: 1=join/part, 2=message, 4=private, 8=highlight, " + "for example: 12=private+highlight)"), + NULL, 1, 15, "12", &config_change_buffer_content); + config_look_hotlist_names_length = config_file_new_option ( + ptr_section, "look_hotlist_names_length", "integer", + N_("max length of names in hotlist (0 = no limit)"), + NULL, 0, 32, "0", &config_change_buffer_content); + config_look_hotlist_sort = config_file_new_option ( + ptr_section, "look_hotlist_sort", "integer", + N_("hotlist sort type (group_time_asc (default), " + "group_time_desc, group_number_asc, group_number_desc, " + "number_asc, number_desc)"), + "group_time_asc|group_time_desc|group_number_asc|" + "group_number_desc|number_asc|number_desc", + 0, 0, "group_time_asc", &config_change_hotlist); + config_look_day_change = config_file_new_option ( + ptr_section, "look_day_change", "boolean", + N_("display special message when day changes"), + NULL, 0, 0, "on", NULL); + config_look_day_change_time_format = config_file_new_option ( + ptr_section, "look_day_change_time_format", "string", + N_("time format for date displayed when day changed"), + NULL, 0, 0, "%a, %d %b %Y", NULL); + config_look_read_marker = config_file_new_option ( + ptr_section, "look_read_marker", "string", + N_("use a marker on servers/channels to show first unread " + "line"), + NULL, 0, 1, " ", &config_change_read_marker); + config_look_input_format = config_file_new_option ( + ptr_section, "look_input_format", "string", + N_("format for input prompt ('%c' is replaced by channel " + "or server, '%n' by nick and '%m' by nick modes)"), + NULL, 0, 0, "[%n(%m)] ", &config_change_buffer_content); + config_look_paste_max_lines = config_file_new_option ( + ptr_section, "look_paste_max_lines", "integer", + N_("max number of lines for paste without asking user " + "(0 = disable this feature)"), + NULL, 0, INT_MAX, "3", NULL); - /* colors */ - section = config_file_new_section (weechat_config, "colors", + /* colors */ + ptr_section = config_file_new_section (weechat_config_file, "colors", NULL, NULL, NULL); - if (section) - { - /* general color settings */ - config_color_separator = config_file_new_option_color ( - section, "color_separator", - N_("color for window separators (when splited)"), - GUI_COLOR_SEPARATOR, "blue", &config_change_color); - /* title window */ - config_color_title = config_file_new_option_color ( - section, "color_title", - N_("color for title bar"), - GUI_COLOR_TITLE, "default", &config_change_color); - config_color_title_bg = config_file_new_option_color ( - section, "color_title_bg", - N_("background color for title bar"), - -1, "blue", &config_change_color); - config_color_title_more = config_file_new_option_color ( - section, "color_title_more", - N_("color for '+' when scrolling title"), - GUI_COLOR_TITLE_MORE, "lightmagenta", &config_change_color); - /* chat window */ - config_color_chat = config_file_new_option_color ( - section, "color_chat", - N_("color for chat text"), - GUI_COLOR_CHAT, "default", &config_change_color); - config_color_chat_bg = config_file_new_option_color ( - section, "color_chat_bg", - N_("background for chat text"), - -1, "default", &config_change_color); - config_color_chat_time = config_file_new_option_color ( - section, "color_chat_time", - N_("color for time in chat window"), - GUI_COLOR_CHAT_TIME, "default", &config_change_color); - config_color_chat_time_delimiters = config_file_new_option_color ( - section, "color_chat_time_delimiters", - N_("color for time delimiters)"), - GUI_COLOR_CHAT_TIME_DELIMITERS, "brown", &config_change_color); - config_color_chat_prefix[GUI_CHAT_PREFIX_INFO] = config_file_new_option_color ( - section, "color_chat_prefix_info", - N_("color for info prefix"), - GUI_COLOR_CHAT_PREFIX_INFO, "lightcyan", &config_change_color); - config_color_chat_prefix[GUI_CHAT_PREFIX_ERROR] = config_file_new_option_color ( - section, "color_chat_prefix_error", - N_("color for error prefix"), - GUI_COLOR_CHAT_PREFIX_ERROR, "yellow", &config_change_color); - config_color_chat_prefix[GUI_CHAT_PREFIX_NETWORK] = config_file_new_option_color ( - section, "color_chat_prefix_network", - N_("color for network prefix"), - GUI_COLOR_CHAT_PREFIX_NETWORK, "lightmagenta", &config_change_color); - config_color_chat_prefix[GUI_CHAT_PREFIX_ACTION] = config_file_new_option_color ( - section, "color_chat_prefix_action", - N_("color for action prefix"), - GUI_COLOR_CHAT_PREFIX_ACTION, "white", &config_change_color); - config_color_chat_prefix[GUI_CHAT_PREFIX_JOIN] = config_file_new_option_color ( - section, "color_chat_prefix_join", - N_("color for join prefix"), - GUI_COLOR_CHAT_PREFIX_JOIN, "lightgreen", &config_change_color); - config_color_chat_prefix[GUI_CHAT_PREFIX_QUIT] = config_file_new_option_color ( - section, "color_chat_prefix_quit", - N_("color for quit prefix"), - GUI_COLOR_CHAT_PREFIX_QUIT, "lightred", &config_change_color); - config_color_chat_prefix_more = config_file_new_option_color ( - section, "color_chat_prefix_more", - N_("color for '+' when prefix is too long"), - GUI_COLOR_CHAT_PREFIX_MORE, "lightmagenta", &config_change_color); - config_color_chat_prefix_suffix = config_file_new_option_color ( - section, "color_chat_prefix_suffix", - N_("color for text after prefix"), - GUI_COLOR_CHAT_PREFIX_SUFFIX, "green", &config_change_color); - config_color_chat_buffer = config_file_new_option_color ( - section, "color_chat_buffer", - N_("color for buffer names"), - GUI_COLOR_CHAT_BUFFER, "white", &config_change_color); - config_color_chat_server = config_file_new_option_color ( - section, "color_chat_server", - N_("color for server names"), - GUI_COLOR_CHAT_SERVER, "brown", &config_change_color); - config_color_chat_channel = config_file_new_option_color ( - section, "color_chat_channel", - N_("color for channel names"), - GUI_COLOR_CHAT_CHANNEL, "white", &config_change_color); - config_color_chat_nick = config_file_new_option_color ( - section, "color_chat_nick", - N_("color for nicks"), - GUI_COLOR_CHAT_NICK, "lightcyan", &config_change_color); - config_color_chat_nick_self = config_file_new_option_color ( - section, "color_chat_nick_self", - N_("color for local nick"), - GUI_COLOR_CHAT_NICK_SELF, "white", &config_change_color); - config_color_chat_nick_other = config_file_new_option_color ( - section, "color_chat_nick_other", - N_("color for other nick in private buffer"), - GUI_COLOR_CHAT_NICK_OTHER, "default", &config_change_color); - config_color_chat_nick_colors[0] = config_file_new_option_color ( - section, "color_chat_nick_color1", - N_("color #1 for nick"), - GUI_COLOR_CHAT_NICK1, "cyan", &config_change_color); - config_color_chat_nick_colors[1] = config_file_new_option_color ( - section, "color_chat_nick_color2", - N_("color #2 for nick"), - GUI_COLOR_CHAT_NICK2, "magenta", &config_change_color); - config_color_chat_nick_colors[2] = config_file_new_option_color ( - section, "color_chat_nick_color3", - N_("color #3 for nick"), - GUI_COLOR_CHAT_NICK3, "green", &config_change_color); - config_color_chat_nick_colors[3] = config_file_new_option_color ( - section, "color_chat_nick_color4", - N_("color #4 for nick"), - GUI_COLOR_CHAT_NICK4, "brown", &config_change_color); - config_color_chat_nick_colors[4] = config_file_new_option_color ( - section, "color_chat_nick_color5", - N_("color #5 for nick"), - GUI_COLOR_CHAT_NICK5, "lightblue", &config_change_color); - config_color_chat_nick_colors[5] = config_file_new_option_color ( - section, "color_chat_nick_color6", - N_("color #6 for nick"), - GUI_COLOR_CHAT_NICK6, "default", &config_change_color); - config_color_chat_nick_colors[6] = config_file_new_option_color ( - section, "color_chat_nick_color7", - N_("color #7 for nick"), - GUI_COLOR_CHAT_NICK7, "lightcyan", &config_change_color); - config_color_chat_nick_colors[7] = config_file_new_option_color ( - section, "color_chat_nick_color8", - N_("color #8 for nick"), - GUI_COLOR_CHAT_NICK8, "lightmagenta", &config_change_color); - config_color_chat_nick_colors[8] = config_file_new_option_color ( - section, "color_chat_nick_color9", - N_("color #9 for nick"), - GUI_COLOR_CHAT_NICK9, "lightgreen", &config_change_color); - config_color_chat_nick_colors[9] = config_file_new_option_color ( - section, "color_chat_nick_color10", - N_("color #10 for nick"), - GUI_COLOR_CHAT_NICK10, "blue", &config_change_color); - config_color_chat_host = config_file_new_option_color ( - section, "color_chat_host", - N_("color for hostnames"), - GUI_COLOR_CHAT_HOST, "cyan", &config_change_color); - config_color_chat_delimiters = config_file_new_option_color ( - section, "color_chat_delimiters", - N_("color for delimiters"), - GUI_COLOR_CHAT_DELIMITERS, "green", &config_change_color); - config_color_chat_highlight = config_file_new_option_color ( - section, "color_chat_highlight", - N_("color for highlighted nick"), - GUI_COLOR_CHAT_HIGHLIGHT, "yellow", &config_change_color); - config_color_chat_read_marker = config_file_new_option_color ( - section, "color_chat_read_marker", - N_("color for unread data marker"), - GUI_COLOR_CHAT_READ_MARKER, "yellow", &config_change_color); - config_color_chat_read_marker_bg = config_file_new_option_color ( - section, "color_chat_read_marker_bg", - N_("background color for unread data marker"), - -1, "magenta", &config_change_color); - /* status window */ - config_color_status = config_file_new_option_color ( - section, "color_status", - N_("color for status bar"), - GUI_COLOR_STATUS, "default", &config_change_color); - config_color_status_bg = config_file_new_option_color ( - section, "color_status_bg", - N_("background color for status bar"), - -1, "blue", &config_change_color); - config_color_status_delimiters = config_file_new_option_color ( - section, "color_status_delimiters", - N_("color for status bar delimiters"), - GUI_COLOR_STATUS_DELIMITERS, "cyan", &config_change_color); - config_color_status_channel = config_file_new_option_color ( - section, "color_status_channel", - N_("color for current channel in status bar"), - GUI_COLOR_STATUS_CHANNEL, "white", &config_change_color); - config_color_status_data_msg = config_file_new_option_color ( - section, "color_status_data_msg", - N_("color for window with new messages (status bar)"), - GUI_COLOR_STATUS_DATA_MSG, "yellow", &config_change_color); - config_color_status_data_private = config_file_new_option_color ( - section, "color_status_data_private", - N_("color for window with private message (status bar)"), - GUI_COLOR_STATUS_DATA_PRIVATE, "lightgreen", &config_change_color); - config_color_status_data_highlight = config_file_new_option_color ( - section, "color_status_data_highlight", - N_("color for window with highlight (status bar)"), - GUI_COLOR_STATUS_DATA_HIGHLIGHT, "lightmagenta", &config_change_color); - config_color_status_data_other = config_file_new_option_color ( - section, "color_status_data_other", - N_("color for window with new data (not messages) " - "(status bar)"), - GUI_COLOR_STATUS_DATA_OTHER, "default", &config_change_color); - config_color_status_more = config_file_new_option_color ( - section, "color_status_more", - N_("color for window with new data (status bar)"), - GUI_COLOR_STATUS_MORE, "white", &config_change_color); - /* infobar window */ - config_color_infobar = config_file_new_option_color ( - section, "color_infobar", - N_("color for infobar text"), - GUI_COLOR_INFOBAR, "black", &config_change_color); - config_color_infobar_bg = config_file_new_option_color ( - section, "color_infobar_bg", - N_("background color for info bar text"), - -1, "cyan", &config_change_color); - config_color_infobar_delimiters = config_file_new_option_color ( - section, "color_infobar_delimiters", - N_("color for infobar delimiters"), - GUI_COLOR_INFOBAR_DELIMITERS, "blue", &config_change_color); - config_color_infobar_highlight = config_file_new_option_color ( - section, "color_infobar_highlight", - N_("color for infobar highlight notification"), - GUI_COLOR_INFOBAR_HIGHLIGHT, "white", &config_change_color); - /* input window */ - config_color_input = config_file_new_option_color ( - section, "color_input", - N_("color for input text"), - GUI_COLOR_INPUT, "default", &config_change_color); - config_color_input_bg = config_file_new_option_color ( - section, "color_input_bg", - N_("background color for input text"), - -1, "default", &config_change_color); - config_color_input_server = config_file_new_option_color ( - section, "color_input_server", - N_("color for input text (server name)"), - GUI_COLOR_INPUT_SERVER, "brown", &config_change_color); - config_color_input_channel = config_file_new_option_color ( - section, "color_input_channel", - N_("color for input text (channel name)"), - GUI_COLOR_INPUT_CHANNEL, "white", &config_change_color); - config_color_input_nick = config_file_new_option_color ( - section, "color_input_nick", - N_("color for input text (nick name)"), - GUI_COLOR_INPUT_NICK, "lightcyan", &config_change_color); - config_color_input_delimiters = config_file_new_option_color ( - section, "color_input_delimiters", - N_("color for input text (delimiters)"), - GUI_COLOR_INPUT_DELIMITERS, "cyan", &config_change_color); - config_color_input_text_not_found = config_file_new_option_color ( - section, "color_input_text_not_found", - N_("color for text not found"), - GUI_COLOR_INPUT_TEXT_NOT_FOUND, "red", &config_change_color); - config_color_input_actions = config_file_new_option_color ( - section, "color_input_actions", - N_("color for actions in input window"), - GUI_COLOR_INPUT_ACTIONS, "lightgreen", &config_change_color); - /* nicklist window */ - config_color_nicklist = config_file_new_option_color ( - section, "color_nicklist", - N_("color for nicklist"), - GUI_COLOR_NICKLIST, "default", &config_change_color); - config_color_nicklist_bg = config_file_new_option_color ( - section, "color_nicklist_bg", - N_("background color for nicklist"), - -1, "default", &config_change_color); - config_color_nicklist_away = config_file_new_option_color ( - section, "color_nicklist_away", - N_("color for away nicknames"), - GUI_COLOR_NICKLIST_AWAY, "cyan", &config_change_color); - config_color_nicklist_prefix1 = config_file_new_option_color ( - section, "color_nicklist_prefix1", - N_("color for prefix 1"), - GUI_COLOR_NICKLIST_PREFIX1, "lightgreen", &config_change_color); - config_color_nicklist_prefix2 = config_file_new_option_color ( - section, "color_nicklist_prefix2", - N_("color for prefix 2"), - GUI_COLOR_NICKLIST_PREFIX2, "lightmagenta", &config_change_color); - config_color_nicklist_prefix3 = config_file_new_option_color ( - section, "color_nicklist_prefix3", - N_("color for prefix 3"), - GUI_COLOR_NICKLIST_PREFIX3, "yellow", &config_change_color); - config_color_nicklist_prefix4 = config_file_new_option_color ( - section, "color_nicklist_prefix4", - N_("color for prefix 4"), - GUI_COLOR_NICKLIST_PREFIX4, "blue", &config_change_color); - config_color_nicklist_prefix5 = config_file_new_option_color ( - section, "color_nicklist_prefix5", - N_("color for prefix 5"), - GUI_COLOR_NICKLIST_PREFIX5, "brown", &config_change_color); - config_color_nicklist_more = config_file_new_option_color ( - section, "color_nicklist_more", - N_("color for '+' when scrolling nicks (nicklist)"), - GUI_COLOR_NICKLIST_MORE, "lightmagenta", &config_change_color); - config_color_nicklist_separator = config_file_new_option_color ( - section, "color_nicklist_separator", - N_("color for nicklist separator"), - GUI_COLOR_NICKLIST_SEPARATOR, "blue", &config_change_color); - /* status info */ - config_color_info = config_file_new_option_color ( - section, "color_info", - N_("color for status info"), - GUI_COLOR_INFO, "default", &config_change_color); - config_color_info_bg = config_file_new_option_color ( - section, "color_info_bg", - N_("background color for status info"), - -1, "default", &config_change_color); - config_color_info_waiting = config_file_new_option_color ( - section, "color_info_waiting", - N_("color for \"waiting\" status info"), - GUI_COLOR_INFO_WAITING, "lightcyan", &config_change_color); - config_color_info_connecting = config_file_new_option_color ( - section, "color_info_connecting", - N_("color for \"connecting\" status info"), - GUI_COLOR_INFO_CONNECTING, "yellow", &config_change_color); - config_color_info_active = config_file_new_option_color ( - section, "color_info_active", - N_("color for \"active\" status info"), - GUI_COLOR_INFO_ACTIVE, "lightblue", &config_change_color); - config_color_info_done = config_file_new_option_color ( - section, "color_info_done", - N_("color for \"done\" status info"), - GUI_COLOR_INFO_DONE, "lightgreen", &config_change_color); - config_color_info_failed = config_file_new_option_color ( - section, "color_info_failed", - N_("color for \"failed\" status info"), - GUI_COLOR_INFO_FAILED, "lightred", &config_change_color); - config_color_info_aborted = config_file_new_option_color ( - section, "color_info_aborted", - N_("color for \"aborted\" status info"), - GUI_COLOR_INFO_ABORTED, "lightred", &config_change_color); - } + if (!ptr_section) + { + config_file_free (weechat_config_file); + return 0; + } + + /* general color settings */ + config_color_separator = config_file_new_option ( + ptr_section, "color_separator", "color", + N_("color for window separators (when splited)"), + NULL, GUI_COLOR_SEPARATOR, 0, "blue", &config_change_color); + /* title window */ + config_color_title = config_file_new_option ( + ptr_section, "color_title", "color", + N_("color for title bar"), + NULL, GUI_COLOR_TITLE, 0, "default", &config_change_color); + config_color_title_bg = config_file_new_option ( + ptr_section, "color_title_bg", "color", + N_("background color for title bar"), + NULL, -1, 0, "blue", &config_change_color); + config_color_title_more = config_file_new_option ( + ptr_section, "color_title_more", "color", + N_("color for '+' when scrolling title"), + NULL, GUI_COLOR_TITLE_MORE, 0, "lightmagenta", &config_change_color); + /* chat window */ + config_color_chat = config_file_new_option ( + ptr_section, "color_chat", "color", + N_("color for chat text"), + NULL, GUI_COLOR_CHAT, 0, "default", &config_change_color); + config_color_chat_bg = config_file_new_option ( + ptr_section, "color_chat_bg", "color", + N_("background for chat text"), + NULL, -1, 0, "default", &config_change_color); + config_color_chat_time = config_file_new_option ( + ptr_section, "color_chat_time", "color", + N_("color for time in chat window"), + NULL, GUI_COLOR_CHAT_TIME, 0, "default", &config_change_color); + config_color_chat_time_delimiters = config_file_new_option ( + ptr_section, "color_chat_time_delimiters", "color", + N_("color for time delimiters)"), + NULL, GUI_COLOR_CHAT_TIME_DELIMITERS, 0, "brown", &config_change_color); + config_color_chat_prefix[GUI_CHAT_PREFIX_INFO] = config_file_new_option ( + ptr_section, "color_chat_prefix_info", "color", + N_("color for info prefix"), + NULL, GUI_COLOR_CHAT_PREFIX_INFO, 0, "lightcyan", &config_change_color); + config_color_chat_prefix[GUI_CHAT_PREFIX_ERROR] = config_file_new_option ( + ptr_section, "color_chat_prefix_error", "color", + N_("color for error prefix"), + NULL, GUI_COLOR_CHAT_PREFIX_ERROR, 0, "yellow", &config_change_color); + config_color_chat_prefix[GUI_CHAT_PREFIX_NETWORK] = config_file_new_option ( + ptr_section, "color_chat_prefix_network", "color", + N_("color for network prefix"), + NULL, GUI_COLOR_CHAT_PREFIX_NETWORK, 0, "lightmagenta", &config_change_color); + config_color_chat_prefix[GUI_CHAT_PREFIX_ACTION] = config_file_new_option ( + ptr_section, "color_chat_prefix_action", "color", + N_("color for action prefix"), + NULL, GUI_COLOR_CHAT_PREFIX_ACTION, 0, "white", &config_change_color); + config_color_chat_prefix[GUI_CHAT_PREFIX_JOIN] = config_file_new_option ( + ptr_section, "color_chat_prefix_join", "color", + N_("color for join prefix"), + NULL, GUI_COLOR_CHAT_PREFIX_JOIN, 0, "lightgreen", &config_change_color); + config_color_chat_prefix[GUI_CHAT_PREFIX_QUIT] = config_file_new_option ( + ptr_section, "color_chat_prefix_quit", "color", + N_("color for quit prefix"), + NULL, GUI_COLOR_CHAT_PREFIX_QUIT, 0, "lightred", &config_change_color); + config_color_chat_prefix_more = config_file_new_option ( + ptr_section, "color_chat_prefix_more", "color", + N_("color for '+' when prefix is too long"), + NULL, GUI_COLOR_CHAT_PREFIX_MORE, 0, "lightmagenta", &config_change_color); + config_color_chat_prefix_suffix = config_file_new_option ( + ptr_section, "color_chat_prefix_suffix", "color", + N_("color for text after prefix"), + NULL, GUI_COLOR_CHAT_PREFIX_SUFFIX, 0, "green", &config_change_color); + config_color_chat_buffer = config_file_new_option ( + ptr_section, "color_chat_buffer", "color", + N_("color for buffer names"), + NULL, GUI_COLOR_CHAT_BUFFER, 0, "white", &config_change_color); + config_color_chat_server = config_file_new_option ( + ptr_section, "color_chat_server", "color", + N_("color for server names"), + NULL, GUI_COLOR_CHAT_SERVER, 0, "brown", &config_change_color); + config_color_chat_channel = config_file_new_option ( + ptr_section, "color_chat_channel", "color", + N_("color for channel names"), + NULL, GUI_COLOR_CHAT_CHANNEL, 0, "white", &config_change_color); + config_color_chat_nick = config_file_new_option ( + ptr_section, "color_chat_nick", "color", + N_("color for nicks"), + NULL, GUI_COLOR_CHAT_NICK, 0, "lightcyan", &config_change_color); + config_color_chat_nick_self = config_file_new_option ( + ptr_section, "color_chat_nick_self", "color", + N_("color for local nick"), + NULL, GUI_COLOR_CHAT_NICK_SELF, 0, "white", &config_change_color); + config_color_chat_nick_other = config_file_new_option ( + ptr_section, "color_chat_nick_other", "color", + N_("color for other nick in private buffer"), + NULL, GUI_COLOR_CHAT_NICK_OTHER, 0, "default", &config_change_color); + config_color_chat_nick_colors[0] = config_file_new_option ( + ptr_section, "color_chat_nick_color1", "color", + N_("color #1 for nick"), + NULL, GUI_COLOR_CHAT_NICK1, 0, "cyan", &config_change_color); + config_color_chat_nick_colors[1] = config_file_new_option ( + ptr_section, "color_chat_nick_color2", "color", + N_("color #2 for nick"), + NULL, GUI_COLOR_CHAT_NICK2, 0, "magenta", &config_change_color); + config_color_chat_nick_colors[2] = config_file_new_option ( + ptr_section, "color_chat_nick_color3", "color", + N_("color #3 for nick"), + NULL, GUI_COLOR_CHAT_NICK3, 0, "green", &config_change_color); + config_color_chat_nick_colors[3] = config_file_new_option ( + ptr_section, "color_chat_nick_color4", "color", + N_("color #4 for nick"), + NULL, GUI_COLOR_CHAT_NICK4, 0, "brown", &config_change_color); + config_color_chat_nick_colors[4] = config_file_new_option ( + ptr_section, "color_chat_nick_color5", "color", + N_("color #5 for nick"), + NULL, GUI_COLOR_CHAT_NICK5, 0, "lightblue", &config_change_color); + config_color_chat_nick_colors[5] = config_file_new_option ( + ptr_section, "color_chat_nick_color6", "color", + N_("color #6 for nick"), + NULL, GUI_COLOR_CHAT_NICK6, 0, "default", &config_change_color); + config_color_chat_nick_colors[6] = config_file_new_option ( + ptr_section, "color_chat_nick_color7", "color", + N_("color #7 for nick"), + NULL, GUI_COLOR_CHAT_NICK7, 0, "lightcyan", &config_change_color); + config_color_chat_nick_colors[7] = config_file_new_option ( + ptr_section, "color_chat_nick_color8", "color", + N_("color #8 for nick"), + NULL, GUI_COLOR_CHAT_NICK8, 0, "lightmagenta", &config_change_color); + config_color_chat_nick_colors[8] = config_file_new_option ( + ptr_section, "color_chat_nick_color9", "color", + N_("color #9 for nick"), + NULL, GUI_COLOR_CHAT_NICK9, 0, "lightgreen", &config_change_color); + config_color_chat_nick_colors[9] = config_file_new_option ( + ptr_section, "color_chat_nick_color10", "color", + N_("color #10 for nick"), + NULL, GUI_COLOR_CHAT_NICK10, 0, "blue", &config_change_color); + config_color_chat_host = config_file_new_option ( + ptr_section, "color_chat_host", "color", + N_("color for hostnames"), + NULL, GUI_COLOR_CHAT_HOST, 0, "cyan", &config_change_color); + config_color_chat_delimiters = config_file_new_option ( + ptr_section, "color_chat_delimiters", "color", + N_("color for delimiters"), + NULL, GUI_COLOR_CHAT_DELIMITERS, 0, "green", &config_change_color); + config_color_chat_highlight = config_file_new_option ( + ptr_section, "color_chat_highlight", "color", + N_("color for highlighted nick"), + NULL, GUI_COLOR_CHAT_HIGHLIGHT, 0, "yellow", &config_change_color); + config_color_chat_read_marker = config_file_new_option ( + ptr_section, "color_chat_read_marker", "color", + N_("color for unread data marker"), + NULL, GUI_COLOR_CHAT_READ_MARKER, 0, "yellow", &config_change_color); + config_color_chat_read_marker_bg = config_file_new_option ( + ptr_section, "color_chat_read_marker_bg", "color", + N_("background color for unread data marker"), + NULL, -1, 0, "magenta", &config_change_color); + /* status window */ + config_color_status = config_file_new_option ( + ptr_section, "color_status", "color", + N_("color for status bar"), + NULL, GUI_COLOR_STATUS, 0, "default", &config_change_color); + config_color_status_bg = config_file_new_option ( + ptr_section, "color_status_bg", "color", + N_("background color for status bar"), + NULL, -1, 0, "blue", &config_change_color); + config_color_status_delimiters = config_file_new_option ( + ptr_section, "color_status_delimiters", "color", + N_("color for status bar delimiters"), + NULL, GUI_COLOR_STATUS_DELIMITERS, 0, "cyan", &config_change_color); + config_color_status_channel = config_file_new_option ( + ptr_section, "color_status_channel", "color", + N_("color for current channel in status bar"), + NULL, GUI_COLOR_STATUS_CHANNEL, 0, "white", &config_change_color); + config_color_status_data_msg = config_file_new_option ( + ptr_section, "color_status_data_msg", "color", + N_("color for window with new messages (status bar)"), + NULL, GUI_COLOR_STATUS_DATA_MSG, 0, "yellow", &config_change_color); + config_color_status_data_private = config_file_new_option ( + ptr_section, "color_status_data_private", "color", + N_("color for window with private message (status bar)"), + NULL, GUI_COLOR_STATUS_DATA_PRIVATE, 0, "lightgreen", &config_change_color); + config_color_status_data_highlight = config_file_new_option ( + ptr_section, "color_status_data_highlight", "color", + N_("color for window with highlight (status bar)"), + NULL, GUI_COLOR_STATUS_DATA_HIGHLIGHT, 0, "lightmagenta", &config_change_color); + config_color_status_data_other = config_file_new_option ( + ptr_section, "color_status_data_other", "color", + N_("color for window with new data (not messages) " + "(status bar)"), + NULL, GUI_COLOR_STATUS_DATA_OTHER, 0, "default", &config_change_color); + config_color_status_more = config_file_new_option ( + ptr_section, "color_status_more", "color", + N_("color for window with new data (status bar)"), + NULL, GUI_COLOR_STATUS_MORE, 0, "white", &config_change_color); + /* infobar window */ + config_color_infobar = config_file_new_option ( + ptr_section, "color_infobar", "color", + N_("color for infobar text"), + NULL, GUI_COLOR_INFOBAR, 0, "black", &config_change_color); + config_color_infobar_bg = config_file_new_option ( + ptr_section, "color_infobar_bg", "color", + N_("background color for info bar text"), + NULL, -1, 0, "cyan", &config_change_color); + config_color_infobar_delimiters = config_file_new_option ( + ptr_section, "color_infobar_delimiters", "color", + N_("color for infobar delimiters"), + NULL, GUI_COLOR_INFOBAR_DELIMITERS, 0, "blue", &config_change_color); + config_color_infobar_highlight = config_file_new_option ( + ptr_section, "color_infobar_highlight", "color", + N_("color for infobar highlight notification"), + NULL, GUI_COLOR_INFOBAR_HIGHLIGHT, 0, "white", &config_change_color); + /* input window */ + config_color_input = config_file_new_option ( + ptr_section, "color_input", "color", + N_("color for input text"), + NULL, GUI_COLOR_INPUT, 0, "default", &config_change_color); + config_color_input_bg = config_file_new_option ( + ptr_section, "color_input_bg", "color", + N_("background color for input text"), + NULL, -1, 0, "default", &config_change_color); + config_color_input_server = config_file_new_option ( + ptr_section, "color_input_server", "color", + N_("color for input text (server name)"), + NULL, GUI_COLOR_INPUT_SERVER, 0, "brown", &config_change_color); + config_color_input_channel = config_file_new_option ( + ptr_section, "color_input_channel", "color", + N_("color for input text (channel name)"), + NULL, GUI_COLOR_INPUT_CHANNEL, 0, "white", &config_change_color); + config_color_input_nick = config_file_new_option ( + ptr_section, "color_input_nick", "color", + N_("color for input text (nick name)"), + NULL, GUI_COLOR_INPUT_NICK, 0, "lightcyan", &config_change_color); + config_color_input_delimiters = config_file_new_option ( + ptr_section, "color_input_delimiters", "color", + N_("color for input text (delimiters)"), + NULL, GUI_COLOR_INPUT_DELIMITERS, 0, "cyan", &config_change_color); + config_color_input_text_not_found = config_file_new_option ( + ptr_section, "color_input_text_not_found", "color", + N_("color for text not found"), + NULL, GUI_COLOR_INPUT_TEXT_NOT_FOUND, 0, "red", &config_change_color); + config_color_input_actions = config_file_new_option ( + ptr_section, "color_input_actions", "color", + N_("color for actions in input window"), + NULL, GUI_COLOR_INPUT_ACTIONS, 0, "lightgreen", &config_change_color); + /* nicklist window */ + config_color_nicklist = config_file_new_option ( + ptr_section, "color_nicklist", "color", + N_("color for nicklist"), + NULL, GUI_COLOR_NICKLIST, 0, "default", &config_change_color); + config_color_nicklist_bg = config_file_new_option ( + ptr_section, "color_nicklist_bg", "color", + N_("background color for nicklist"), + NULL, -1, 0, "default", &config_change_color); + config_color_nicklist_away = config_file_new_option ( + ptr_section, "color_nicklist_away", "color", + N_("color for away nicknames"), + NULL, GUI_COLOR_NICKLIST_AWAY, 0, "cyan", &config_change_color); + config_color_nicklist_prefix1 = config_file_new_option ( + ptr_section, "color_nicklist_prefix1", "color", + N_("color for prefix 1"), + NULL, GUI_COLOR_NICKLIST_PREFIX1, 0, "lightgreen", &config_change_color); + config_color_nicklist_prefix2 = config_file_new_option ( + ptr_section, "color_nicklist_prefix2", "color", + N_("color for prefix 2"), + NULL, GUI_COLOR_NICKLIST_PREFIX2, 0, "lightmagenta", &config_change_color); + config_color_nicklist_prefix3 = config_file_new_option ( + ptr_section, "color_nicklist_prefix3", "color", + N_("color for prefix 3"), + NULL, GUI_COLOR_NICKLIST_PREFIX3, 0, "yellow", &config_change_color); + config_color_nicklist_prefix4 = config_file_new_option ( + ptr_section, "color_nicklist_prefix4", "color", + N_("color for prefix 4"), + NULL, GUI_COLOR_NICKLIST_PREFIX4, 0, "blue", &config_change_color); + config_color_nicklist_prefix5 = config_file_new_option ( + ptr_section, "color_nicklist_prefix5", "color", + N_("color for prefix 5"), + NULL, GUI_COLOR_NICKLIST_PREFIX5, 0, "brown", &config_change_color); + config_color_nicklist_more = config_file_new_option ( + ptr_section, "color_nicklist_more", "color", + N_("color for '+' when scrolling nicks (nicklist)"), + NULL, GUI_COLOR_NICKLIST_MORE, 0, "lightmagenta", &config_change_color); + config_color_nicklist_separator = config_file_new_option ( + ptr_section, "color_nicklist_separator", "color", + N_("color for nicklist separator"), + NULL, GUI_COLOR_NICKLIST_SEPARATOR, 0, "blue", &config_change_color); + /* status info */ + config_color_info = config_file_new_option ( + ptr_section, "color_info", "color", + N_("color for status info"), + NULL, GUI_COLOR_INFO, 0, "default", &config_change_color); + config_color_info_bg = config_file_new_option ( + ptr_section, "color_info_bg", "color", + N_("background color for status info"), + NULL, -1, 0, "default", &config_change_color); + config_color_info_waiting = config_file_new_option ( + ptr_section, "color_info_waiting", "color", + N_("color for \"waiting\" status info"), + NULL, GUI_COLOR_INFO_WAITING, 0, "lightcyan", &config_change_color); + config_color_info_connecting = config_file_new_option ( + ptr_section, "color_info_connecting", "color", + N_("color for \"connecting\" status info"), + NULL, GUI_COLOR_INFO_CONNECTING, 0, "yellow", &config_change_color); + config_color_info_active = config_file_new_option ( + ptr_section, "color_info_active", "color", + N_("color for \"active\" status info"), + NULL, GUI_COLOR_INFO_ACTIVE, 0, "lightblue", &config_change_color); + config_color_info_done = config_file_new_option ( + ptr_section, "color_info_done", "color", + N_("color for \"done\" status info"), + NULL, GUI_COLOR_INFO_DONE, 0, "lightgreen", &config_change_color); + config_color_info_failed = config_file_new_option ( + ptr_section, "color_info_failed", "color", + N_("color for \"failed\" status info"), + NULL, GUI_COLOR_INFO_FAILED, 0, "lightred", &config_change_color); + config_color_info_aborted = config_file_new_option ( + ptr_section, "color_info_aborted", "color", + N_("color for \"aborted\" status info"), + NULL, GUI_COLOR_INFO_ABORTED, 0, "lightred", &config_change_color); - /* history */ - section = config_file_new_section (weechat_config, "history", + /* history */ + ptr_section = config_file_new_section (weechat_config_file, "history", NULL, NULL, NULL); - if (section) - { - config_history_max_lines = config_file_new_option_integer ( - section, "history_max_lines", - N_("maximum number of lines in history per buffer " - "(0 = unlimited)"), - 0, INT_MAX, 4096, NULL); - config_history_max_commands = config_file_new_option_integer ( - section, "history_max_commands", - N_("maximum number of user commands in history (0 = " - "unlimited)"), - 0, INT_MAX, 100, NULL); - config_history_display_default = config_file_new_option_integer ( - section, "history_display_default", - N_("maximum number of commands to display by default in " - "history listing (0 = unlimited)"), - 0, INT_MAX, 5, NULL); - } + if (!ptr_section) + { + config_file_free (weechat_config_file); + return 0; + } + + config_history_max_lines = config_file_new_option ( + ptr_section, "history_max_lines", "integer", + N_("maximum number of lines in history per buffer " + "(0 = unlimited)"), + NULL, 0, INT_MAX, "4096", NULL); + config_history_max_commands = config_file_new_option ( + ptr_section, "history_max_commands", "integer", + N_("maximum number of user commands in history (0 = " + "unlimited)"), + NULL, 0, INT_MAX, "100", NULL); + config_history_display_default = config_file_new_option ( + ptr_section, "history_display_default", "integer", + N_("maximum number of commands to display by default in " + "history listing (0 = unlimited)"), + NULL, 0, INT_MAX, "5", NULL); - /* proxy */ - section = config_file_new_section (weechat_config, "proxy", + /* proxy */ + ptr_section = config_file_new_section (weechat_config_file, "proxy", NULL, NULL, NULL); - if (section) - { - config_proxy_use = config_file_new_option_boolean ( - section, "proxy_use", - N_("use a proxy server"), - CONFIG_BOOLEAN_FALSE, NULL); - config_proxy_type = config_file_new_option_integer_with_string ( - section, "proxy_type", - N_("proxy type (http (default), socks4, socks5)"), - "http|socks4|socks5", 0, NULL); - config_proxy_ipv6 = config_file_new_option_boolean ( - section, "proxy_ipv6", - N_("connect to proxy using ipv6"), - CONFIG_BOOLEAN_FALSE, NULL); - config_proxy_address = config_file_new_option_string ( - section, "proxy_address", - N_("proxy server address (IP or hostname)"), - 0, 0, "", NULL); - config_proxy_port = config_file_new_option_integer ( - section, "proxy_port", - N_("port for connecting to proxy server"), - 0, 65535, 3128, NULL); - config_proxy_username = config_file_new_option_string ( - section, "proxy_username", - N_("username for proxy server"), - 0, 0, "", NULL); - config_proxy_password = config_file_new_option_string ( - section, "proxy_password", - N_("password for proxy server"), - 0, 0, "", NULL); - } + if (!ptr_section) + { + config_file_free (weechat_config_file); + return 0; + } + + config_proxy_use = config_file_new_option ( + ptr_section, "proxy_use", "boolean", + N_("use a proxy server"), + NULL, 0, 0, "off", NULL); + config_proxy_type = config_file_new_option ( + ptr_section, "proxy_type", "integer", + N_("proxy type (http (default), socks4, socks5)"), + "http|socks4|socks5", 0, 0, "http", NULL); + config_proxy_ipv6 = config_file_new_option ( + ptr_section, "proxy_ipv6", "boolean", + N_("connect to proxy using ipv6"), + NULL, 0, 0, "off", NULL); + config_proxy_address = config_file_new_option ( + ptr_section, "proxy_address", "string", + N_("proxy server address (IP or hostname)"), + NULL, 0, 0, "", NULL); + config_proxy_port = config_file_new_option ( + ptr_section, "proxy_port", "integer", + N_("port for connecting to proxy server"), + NULL, 0, 65535, "3128", NULL); + config_proxy_username = config_file_new_option ( + ptr_section, "proxy_username", "string", + N_("username for proxy server"), + NULL, 0, 0, "", NULL); + config_proxy_password = config_file_new_option ( + ptr_section, "proxy_password", "string", + N_("password for proxy server"), + NULL, 0, 0, "", NULL); - /* plugins */ - section = config_file_new_section (weechat_config, "plugins", + /* plugins */ + ptr_section = config_file_new_section (weechat_config_file, "plugins", NULL, NULL, NULL); - if (section) - { - config_plugins_path = config_file_new_option_string ( - section, "plugins_path", - N_("path for searching plugins ('%h' will be replaced by " - "WeeChat home, ~/.weechat by default)"), - 0, 0, "%h/plugins", NULL); - config_plugins_autoload = config_file_new_option_string ( - section, "plugins_autoload", - N_("comma separated list of plugins to load automatically " - "at startup, \"*\" means all plugins found (names may " - "be partial, for example \"perl\" is ok for " - "\"perl.so\")"), - 0, 0, "*", NULL); - config_plugins_extension = config_file_new_option_string ( - section, "plugins_extension", - N_("standard plugins extension in filename (for example " - "\".so\" under Linux or \".dll\" under Windows)"), - 0, 0, + if (!ptr_section) + { + config_file_free (weechat_config_file); + return 0; + } + + config_plugins_path = config_file_new_option ( + ptr_section, "plugins_path", "string", + N_("path for searching plugins ('%h' will be replaced by " + "WeeChat home, ~/.weechat by default)"), + NULL, 0, 0, "%h/plugins", NULL); + config_plugins_autoload = config_file_new_option ( + ptr_section, "plugins_autoload", "string", + N_("comma separated list of plugins to load automatically " + "at startup, \"*\" means all plugins found (names may " + "be partial, for example \"perl\" is ok for " + "\"perl.so\")"), + NULL, 0, 0, "*", NULL); + config_plugins_extension = config_file_new_option ( + ptr_section, "plugins_extension", "string", + N_("standard plugins extension in filename (for example " + "\".so\" under Linux or \".dll\" under Windows)"), + NULL, 0, 0, #ifdef WIN32 - ".dll", + ".dll", #else - ".so", + ".so", #endif - NULL); - } + NULL); - /* keys */ - section = config_file_new_section (weechat_config, "keys", + /* keys */ + ptr_section = config_file_new_section (weechat_config_file, "keys", &config_weechat_read_key, &config_weechat_write_keys, &config_weechat_write_keys); + if (!ptr_section) + { + config_file_free (weechat_config_file); + return 0; } + + return 1; } /* @@ -1034,7 +1044,7 @@ config_weechat_init () int config_weechat_read () { - return config_file_read (weechat_config); + return config_file_read (weechat_config_file); } /* @@ -1051,7 +1061,7 @@ config_weechat_reload () gui_keyboard_free_all (); /* reload configuration file */ - return config_file_reload (weechat_config); + return config_file_reload (weechat_config_file); } /* @@ -1063,6 +1073,6 @@ config_weechat_reload () int config_weechat_write () { - log_printf (_("Saving WeeChat configuration to disk\n")); - return config_file_write (weechat_config, 0); + log_printf (_("Saving WeeChat configuration to disk")); + return config_file_write (weechat_config_file, 0); } diff --git a/src/core/wee-config.h b/src/core/wee-config.h index c7debced2..e30e5371e 100644 --- a/src/core/wee-config.h +++ b/src/core/wee-config.h @@ -40,7 +40,7 @@ #define CONFIG_LOOK_HOTLIST_SORT_NUMBER_ASC 4 #define CONFIG_LOOK_HOTLIST_SORT_NUMBER_DESC 5 -extern struct t_config_file *weechat_config; +extern struct t_config_file *weechat_config_file; extern struct t_config_option *config_look_color_real_white; extern struct t_config_option *config_look_save_on_exit; @@ -176,7 +176,7 @@ extern void config_change_prefix (); extern void config_change_color (); extern void config_change_nicks_colors (); -extern void config_weechat_init (); +extern int config_weechat_init (); extern int config_weechat_read (); extern int config_weechat_reload (); extern int config_weechat_write (); diff --git a/src/core/wee-hook.c b/src/core/wee-hook.c index f9d4d432e..a1db2b586 100644 --- a/src/core/wee-hook.c +++ b/src/core/wee-hook.c @@ -428,8 +428,8 @@ hook_timer_exec (struct timeval *tv_time) if ((ptr_hook->type == HOOK_TYPE_TIMER) && (!ptr_hook->running)) { - time_diff = util_get_timeval_diff (&HOOK_TIMER(ptr_hook, last_exec), - tv_time); + time_diff = util_timeval_diff (&HOOK_TIMER(ptr_hook, last_exec), + tv_time); if (time_diff >= HOOK_TIMER(ptr_hook, interval)) { ptr_hook->running = 1; @@ -923,10 +923,8 @@ unhook_all_plugin (void *plugin) while (ptr_hook) { next_hook = ptr_hook->next_hook; - if (ptr_hook->plugin == plugin) unhook (ptr_hook); - ptr_hook = next_hook; } } @@ -938,9 +936,14 @@ unhook_all_plugin (void *plugin) void unhook_all () { - while (weechat_hooks) + struct t_hook *ptr_hook, *next_hook; + + ptr_hook = weechat_hooks; + while (ptr_hook) { - unhook (weechat_hooks); + next_hook = ptr_hook->next_hook; + unhook (ptr_hook); + ptr_hook = next_hook; } } @@ -956,71 +959,71 @@ hook_print_log () for (ptr_hook = weechat_hooks; ptr_hook; ptr_hook = ptr_hook->next_hook) { - log_printf ("\n"); - log_printf ("[hook (addr:0x%X)]\n", ptr_hook); - log_printf (" plugin . . . . . . . . : 0x%X\n", ptr_hook->plugin); + log_printf (""); + log_printf ("[hook (addr:0x%X)]", ptr_hook); + log_printf (" plugin . . . . . . . . : 0x%X", ptr_hook->plugin); switch (ptr_hook->type) { case HOOK_TYPE_DELETED: - log_printf (" type . . . . . . . . . : %d (hook deleted)\n", ptr_hook->type); - log_printf (" callback_data. . . . . : 0x%X\n", ptr_hook->callback_data); - log_printf (" hook_data. . . . . . . : 0x%X\n", ptr_hook->hook_data); + log_printf (" type . . . . . . . . . : %d (hook deleted)", ptr_hook->type); + log_printf (" callback_data. . . . . : 0x%X", ptr_hook->callback_data); + log_printf (" hook_data. . . . . . . : 0x%X", ptr_hook->hook_data); break; case HOOK_TYPE_COMMAND: - log_printf (" type . . . . . . . . . : %d (command)\n", ptr_hook->type); - log_printf (" callback_data. . . . . : 0x%X\n", ptr_hook->callback_data); - log_printf (" command data:\n"); - log_printf (" callback . . . . . . : 0x%X\n", HOOK_COMMAND(ptr_hook, callback)); - log_printf (" command. . . . . . . : '%s'\n", HOOK_COMMAND(ptr_hook, command)); - log_printf (" level. . . . . . . . : %d\n", HOOK_COMMAND(ptr_hook, level)); - log_printf (" command_desc . . . . : '%s'\n", HOOK_COMMAND(ptr_hook, description)); - log_printf (" command_args . . . . : '%s'\n", HOOK_COMMAND(ptr_hook, args)); - log_printf (" command_args_desc. . : '%s'\n", HOOK_COMMAND(ptr_hook, args_description)); - log_printf (" command_completion . : '%s'\n", HOOK_COMMAND(ptr_hook, completion)); + log_printf (" type . . . . . . . . . : %d (command)", ptr_hook->type); + log_printf (" callback_data. . . . . : 0x%X", ptr_hook->callback_data); + log_printf (" command data:"); + log_printf (" callback . . . . . . : 0x%X", HOOK_COMMAND(ptr_hook, callback)); + log_printf (" command. . . . . . . : '%s'", HOOK_COMMAND(ptr_hook, command)); + log_printf (" level. . . . . . . . : %d", HOOK_COMMAND(ptr_hook, level)); + log_printf (" command_desc . . . . : '%s'", HOOK_COMMAND(ptr_hook, description)); + log_printf (" command_args . . . . : '%s'", HOOK_COMMAND(ptr_hook, args)); + log_printf (" command_args_desc. . : '%s'", HOOK_COMMAND(ptr_hook, args_description)); + log_printf (" command_completion . : '%s'", HOOK_COMMAND(ptr_hook, completion)); break; case HOOK_TYPE_TIMER: - log_printf (" type . . . . . . . . . : %d (timer)\n", ptr_hook->type); - log_printf (" callback_data. . . . . : 0x%X\n", ptr_hook->callback_data); - log_printf (" timer data:\n"); - log_printf (" callback . . . . . . : 0x%X\n", HOOK_TIMER(ptr_hook, callback)); - log_printf (" interval . . . . . . : %ld\n", HOOK_TIMER(ptr_hook, interval)); - log_printf (" last_exec.tv_sec . . : %ld\n", HOOK_TIMER(ptr_hook, last_exec.tv_sec)); - log_printf (" last_exec.tv_usec. . : %ld\n", HOOK_TIMER(ptr_hook, last_exec.tv_usec)); + log_printf (" type . . . . . . . . . : %d (timer)", ptr_hook->type); + log_printf (" callback_data. . . . . : 0x%X", ptr_hook->callback_data); + log_printf (" timer data:"); + log_printf (" callback . . . . . . : 0x%X", HOOK_TIMER(ptr_hook, callback)); + log_printf (" interval . . . . . . : %ld", HOOK_TIMER(ptr_hook, interval)); + log_printf (" last_exec.tv_sec . . : %ld", HOOK_TIMER(ptr_hook, last_exec.tv_sec)); + log_printf (" last_exec.tv_usec. . : %ld", HOOK_TIMER(ptr_hook, last_exec.tv_usec)); break; case HOOK_TYPE_FD: - log_printf (" type . . . . . . . . . : %d (fd)\n", ptr_hook->type); - log_printf (" callback_data. . . . . : 0x%X\n", ptr_hook->callback_data); - log_printf (" fd data:\n"); - log_printf (" callback . . . . . . : 0x%X\n", HOOK_FD(ptr_hook, callback)); - log_printf (" fd . . . . . . . . . : %ld\n", HOOK_FD(ptr_hook, fd)); - log_printf (" flags. . . . . . . . : %ld\n", HOOK_FD(ptr_hook, flags)); + log_printf (" type . . . . . . . . . : %d (fd)", ptr_hook->type); + log_printf (" callback_data. . . . . : 0x%X", ptr_hook->callback_data); + log_printf (" fd data:"); + log_printf (" callback . . . . . . : 0x%X", HOOK_FD(ptr_hook, callback)); + log_printf (" fd . . . . . . . . . : %ld", HOOK_FD(ptr_hook, fd)); + log_printf (" flags. . . . . . . . : %ld", HOOK_FD(ptr_hook, flags)); break; case HOOK_TYPE_PRINT: - log_printf (" type . . . . . . . . . : %d (print)\n", ptr_hook->type); - log_printf (" callback_data. . . . . : 0x%X\n", ptr_hook->callback_data); - log_printf (" print data:\n"); - log_printf (" callback . . . . . . : 0x%X\n", HOOK_PRINT(ptr_hook, callback)); - log_printf (" buffer . . . . . . . : 0x%X\n", HOOK_PRINT(ptr_hook, buffer)); - log_printf (" message. . . . . . . : '%s'\n", HOOK_PRINT(ptr_hook, message)); + log_printf (" type . . . . . . . . . : %d (print)", ptr_hook->type); + log_printf (" callback_data. . . . . : 0x%X", ptr_hook->callback_data); + log_printf (" print data:"); + log_printf (" callback . . . . . . : 0x%X", HOOK_PRINT(ptr_hook, callback)); + log_printf (" buffer . . . . . . . : 0x%X", HOOK_PRINT(ptr_hook, buffer)); + log_printf (" message. . . . . . . : '%s'", HOOK_PRINT(ptr_hook, message)); break; case HOOK_TYPE_EVENT: - log_printf (" type . . . . . . . . . : %d (event)\n", ptr_hook->type); - log_printf (" callback_data. . . . . : 0x%X\n", ptr_hook->callback_data); - log_printf (" event data:\n"); - log_printf (" callback . . . . . . : 0x%X\n", HOOK_EVENT(ptr_hook, callback)); - log_printf (" event. . . . . . . . : '%s'\n", HOOK_EVENT(ptr_hook, event)); + log_printf (" type . . . . . . . . . : %d (event)", ptr_hook->type); + log_printf (" callback_data. . . . . : 0x%X", ptr_hook->callback_data); + log_printf (" event data:"); + log_printf (" callback . . . . . . : 0x%X", HOOK_EVENT(ptr_hook, callback)); + log_printf (" event. . . . . . . . : '%s'", HOOK_EVENT(ptr_hook, event)); break; case HOOK_TYPE_CONFIG: - log_printf (" type . . . . . . . . . : %d (config)\n", ptr_hook->type); - log_printf (" callback_data. . . . . : 0x%X\n", ptr_hook->callback_data); - log_printf (" config data:\n"); - log_printf (" callback . . . . . . : 0x%X\n", HOOK_CONFIG(ptr_hook, callback)); - log_printf (" type . . . . . . . . : '%s'\n", HOOK_CONFIG(ptr_hook, type)); - log_printf (" option . . . . . . . : '%s'\n", HOOK_CONFIG(ptr_hook, option)); + log_printf (" type . . . . . . . . . : %d (config)", ptr_hook->type); + log_printf (" callback_data. . . . . : 0x%X", ptr_hook->callback_data); + log_printf (" config data:"); + log_printf (" callback . . . . . . : 0x%X", HOOK_CONFIG(ptr_hook, callback)); + log_printf (" type . . . . . . . . : '%s'", HOOK_CONFIG(ptr_hook, type)); + log_printf (" option . . . . . . . : '%s'", HOOK_CONFIG(ptr_hook, option)); break; } - log_printf (" running. . . . . . . . : %d\n", ptr_hook->running); - log_printf (" prev_hook. . . . . . . : 0x%X\n", ptr_hook->prev_hook); - log_printf (" next_hook. . . . . . . : 0x%X\n", ptr_hook->next_hook); + log_printf (" running. . . . . . . . : %d", ptr_hook->running); + log_printf (" prev_hook. . . . . . . : 0x%X", ptr_hook->prev_hook); + log_printf (" next_hook. . . . . . . : 0x%X", ptr_hook->next_hook); } } diff --git a/src/core/wee-list.c b/src/core/wee-list.c index 48269b905..b162e0300 100644 --- a/src/core/wee-list.c +++ b/src/core/wee-list.c @@ -33,59 +33,40 @@ /* - * weelist_get_size: get list size (number of elements) - */ - -int -weelist_get_size (struct t_weelist *weelist) -{ - struct t_weelist *ptr_weelist; - int count; - - count = 0; - - for (ptr_weelist = weelist; ptr_weelist; - ptr_weelist = ptr_weelist->next_weelist) - { - count++; - } - - return count; -} - -/* - * weelist_search: search data in a list + * weelist_new: create a new list */ struct t_weelist * -weelist_search (struct t_weelist *weelist, char *data) +weelist_new () { - struct t_weelist *ptr_weelist; - - for (ptr_weelist = weelist; ptr_weelist; - ptr_weelist = ptr_weelist->next_weelist) + struct t_weelist *new_weelist; + + new_weelist = (struct t_weelist *)malloc (sizeof (struct t_weelist)); + if (new_weelist) { - if (string_strcasecmp (data, ptr_weelist->data) == 0) - return ptr_weelist; + new_weelist->items = NULL; + new_weelist->size = 0; } - /* word not found in list */ - return NULL; + return new_weelist; } /* * weelist_find_pos: find position for data (keeping list sorted) */ -struct t_weelist * +struct t_weelist_item * weelist_find_pos (struct t_weelist *weelist, char *data) { - struct t_weelist *ptr_weelist; + struct t_weelist_item *ptr_item; + + if (!weelist || !data) + return NULL; - for (ptr_weelist = weelist; ptr_weelist; - ptr_weelist = ptr_weelist->next_weelist) + for (ptr_item = weelist->items; ptr_item; + ptr_item = ptr_item->next_item) { - if (string_strcasecmp (data, ptr_weelist->data) < 0) - return ptr_weelist; + if (string_strcasecmp (data, ptr_item->data) < 0) + return ptr_item; } /* position not found, best position is at the end */ return NULL; @@ -96,62 +77,65 @@ weelist_find_pos (struct t_weelist *weelist, char *data) */ void -weelist_insert (struct t_weelist **weelist, struct t_weelist **last_weelist, - struct t_weelist *element, int position) +weelist_insert (struct t_weelist *weelist, struct t_weelist_item *item, + int position) { - struct t_weelist *pos_weelist; + struct t_weelist_item *pos_item; + + if (!weelist || !item) + return; - if (*weelist) + if (weelist->items) { /* remove element if already in list */ - pos_weelist = weelist_search (*weelist, element->data); - if (pos_weelist) - weelist_remove (weelist, last_weelist, pos_weelist); + pos_item = weelist_search (weelist, item->data); + if (pos_item) + weelist_remove (weelist, pos_item); } - if (*weelist) + if (weelist->items) { /* search position for new element, according to pos asked */ - pos_weelist = NULL; + pos_item = NULL; switch (position) { case WEELIST_POS_SORT: - pos_weelist = weelist_find_pos (*weelist, element->data); + pos_item = weelist_find_pos (weelist, item->data); break; case WEELIST_POS_BEGINNING: - pos_weelist = *weelist; + pos_item = weelist->items; break; case WEELIST_POS_END: - pos_weelist = NULL; + pos_item = NULL; break; } - if (pos_weelist) + if (pos_item) { /* insert data into the list (before position found) */ - element->prev_weelist = pos_weelist->prev_weelist; - element->next_weelist = pos_weelist; - if (pos_weelist->prev_weelist) - (pos_weelist->prev_weelist)->next_weelist = element; + item->prev_item = pos_item->prev_item; + item->next_item = pos_item; + if (pos_item->prev_item) + (pos_item->prev_item)->next_item = item; else - *weelist = element; - pos_weelist->prev_weelist = element; + weelist->items = item; + pos_item->prev_item = item; } else { /* add data to the end */ - element->prev_weelist = *last_weelist; - element->next_weelist = NULL; - (*last_weelist)->next_weelist = element; - *last_weelist = element; + item->prev_item = weelist->last_item; + item->next_item = NULL; + (weelist->last_item)->next_item = item; + weelist->last_item = item; } } else { - element->prev_weelist = NULL; - element->next_weelist = NULL; - *weelist = element; - *last_weelist = element; + item->prev_item = NULL; + item->next_item = NULL; + weelist->items = item; + weelist->last_item = item; } } @@ -159,87 +143,174 @@ weelist_insert (struct t_weelist **weelist, struct t_weelist **last_weelist, * weelist_add: create new data and add it to list */ -struct t_weelist * -weelist_add (struct t_weelist **weelist, struct t_weelist **last_weelist, - char *data, int position) +struct t_weelist_item * +weelist_add (struct t_weelist *weelist, char *data, int position) { - struct t_weelist *new_weelist; + struct t_weelist_item *new_item; - if (!data || (!data[0])) + if (!weelist || !data || (!data[0])) return NULL; - if ((new_weelist = ((struct t_weelist *) malloc (sizeof (struct t_weelist))))) + if ((new_item = ((struct t_weelist_item *) malloc (sizeof (struct t_weelist_item))))) { - new_weelist->data = strdup (data); - weelist_insert (weelist, last_weelist, new_weelist, position); - return new_weelist; + new_item->data = strdup (data); + weelist_insert (weelist, new_item, position); + weelist->size++; } - /* failed to allocate new element */ + return new_item; +} + +/* + * weelist_search: search data in a list (case sensitive) + */ + +struct t_weelist_item * +weelist_search (struct t_weelist *weelist, char *data) +{ + struct t_weelist_item *ptr_item; + + if (!weelist || !data) + return NULL; + + for (ptr_item = weelist->items; ptr_item; + ptr_item = ptr_item->next_item) + { + if (string_strcasecmp (data, ptr_item->data) == 0) + return ptr_item; + } + /* data not found in list */ return NULL; } /* - * weelist_remove: remove an element from a list + * weelist_casesearch: search data in a list (case unsensitive) + */ + +struct t_weelist_item * +weelist_casesearch (struct t_weelist *weelist, char *data) +{ + struct t_weelist_item *ptr_item; + + if (!weelist || !data) + return NULL; + + for (ptr_item = weelist->items; ptr_item; + ptr_item = ptr_item->next_item) + { + if (string_strcasecmp (data, ptr_item->data) == 0) + return ptr_item; + } + /* data not found in list */ + return NULL; +} + +/* + * weelist_get: get an item in a list by position (0 is first element) + */ + +struct t_weelist_item * +weelist_get (struct t_weelist *weelist, int position) +{ + int i; + struct t_weelist_item *ptr_item; + + if (!weelist) + return NULL; + + i = 0; + ptr_item = weelist->items; + while (ptr_item) + { + if (i == position) + return ptr_item; + ptr_item = ptr_item->next_item; + i++; + } + /* item not found */ + return NULL; +} + +/* + * weelist_remove: remove an item from a list */ void -weelist_remove (struct t_weelist **weelist, struct t_weelist **last_weelist, - struct t_weelist *element) +weelist_remove (struct t_weelist *weelist, struct t_weelist_item *item) { - struct t_weelist *new_weelist; + struct t_weelist_item *new_items; - if (!element || !(*weelist)) + if (!weelist || !item) return; - /* remove element from list */ - if (*last_weelist == element) - *last_weelist = element->prev_weelist; - if (element->prev_weelist) + /* remove item from list */ + if (weelist->last_item == item) + weelist->last_item = item->prev_item; + if (item->prev_item) { - (element->prev_weelist)->next_weelist = element->next_weelist; - new_weelist = *weelist; + (item->prev_item)->next_item = item->next_item; + new_items = weelist->items; } else - new_weelist = element->next_weelist; + new_items = item->next_item; + + if (item->next_item) + (item->next_item)->prev_item = item->prev_item; - if (element->next_weelist) - (element->next_weelist)->prev_weelist = element->prev_weelist; - /* free data */ - if (element->data) - free (element->data); - free (element); - *weelist = new_weelist; + if (item->data) + free (item->data); + free (item); + weelist->items = new_items; + + weelist->size--; } /* - * weelist_remove_all: remove all elements from a list + * weelist_remove_all: remove all items from a list */ void -weelist_remove_all (struct t_weelist **weelist, struct t_weelist **last_weelist) +weelist_remove_all (struct t_weelist *weelist) { - while (*weelist) + if (!weelist) + return; + + while (weelist->items) { - weelist_remove (weelist, last_weelist, *weelist); + weelist_remove (weelist, weelist->items); } } /* + * weelist_free: free a list + */ + +void +weelist_free (struct t_weelist *weelist) +{ + if (!weelist) + return; + + weelist_remove_all (weelist); + free (weelist); +} + +/* * weelist_print_log: print weelist in log (usually for crash dump) */ void weelist_print_log (struct t_weelist *weelist, char *name) { - struct t_weelist *ptr_weelist; + struct t_weelist_item *ptr_item; + + log_printf ("[%s (addr:0x%X)]", name, weelist); - for (ptr_weelist = weelist; ptr_weelist; - ptr_weelist = ptr_weelist->next_weelist) + for (ptr_item = weelist->items; ptr_item; + ptr_item = ptr_item->next_item) { - log_printf ("[%s (addr:0x%X)]\n", name, ptr_weelist); - log_printf (" data . . . . . . . . . : '%s'\n", ptr_weelist->data); - log_printf (" prev_weelist . . . . . : 0x%X\n", ptr_weelist->prev_weelist); - log_printf (" next_weelist . . . . . : 0x%X\n", ptr_weelist->next_weelist); + log_printf (" data . . . . . . . . . : '%s'", ptr_item->data); + log_printf (" prev_item. . . . . . . : 0x%X", ptr_item->prev_item); + log_printf (" next_item. . . . . . . : 0x%X", ptr_item->next_item); } } diff --git a/src/core/wee-list.h b/src/core/wee-list.h index 7e748f1f5..c5226d701 100644 --- a/src/core/wee-list.h +++ b/src/core/wee-list.h @@ -24,18 +24,28 @@ #define WEELIST_POS_BEGINNING 1 #define WEELIST_POS_END 2 +struct t_weelist_item +{ + char *data; /* item data */ + struct t_weelist_item *prev_item; /* link to previous item */ + struct t_weelist_item *next_item; /* link to next item */ +}; + struct t_weelist { - char *data; - struct t_weelist *prev_weelist; - struct t_weelist *next_weelist; + struct t_weelist_item *items; /* items in list */ + struct t_weelist_item *last_item; /* last item in list */ + int size; /* number of items in list */ }; -extern int weelist_get_size (struct t_weelist *); -extern struct t_weelist *weelist_search (struct t_weelist *, char *); -extern struct t_weelist *weelist_add (struct t_weelist **, struct t_weelist **, char *, int); -extern void weelist_remove (struct t_weelist **, struct t_weelist **, struct t_weelist *); -extern void weelist_remove_all (struct t_weelist **, struct t_weelist **); +extern struct t_weelist *weelist_new (); +extern struct t_weelist_item *weelist_add (struct t_weelist *, char *, int); +extern struct t_weelist_item *weelist_search (struct t_weelist *, char *); +extern struct t_weelist_item *weelist_casesearch (struct t_weelist *, char *); +extern struct t_weelist_item *weelist_get (struct t_weelist *, int); +extern void weelist_remove (struct t_weelist *, struct t_weelist_item *); +extern void weelist_remove_all (struct t_weelist *); +extern void weelist_free (struct t_weelist *); extern void weelist_print_log (struct t_weelist *, char *); #endif /* wee-list.h */ diff --git a/src/core/wee-log.c b/src/core/wee-log.c index 1363c6d4a..8c43fb501 100644 --- a/src/core/wee-log.c +++ b/src/core/wee-log.c @@ -145,12 +145,14 @@ log_printf (char *message, ...) seconds = time (NULL); date_tmp = localtime (&seconds); if (date_tmp) - string_iconv_fprintf (weechat_log_file, "[%04d-%02d-%02d %02d:%02d:%02d] %s", - date_tmp->tm_year + 1900, date_tmp->tm_mon + 1, date_tmp->tm_mday, - date_tmp->tm_hour, date_tmp->tm_min, date_tmp->tm_sec, + string_iconv_fprintf (weechat_log_file, + "[%04d-%02d-%02d %02d:%02d:%02d] %s\n", + date_tmp->tm_year + 1900, date_tmp->tm_mon + 1, + date_tmp->tm_mday, date_tmp->tm_hour, + date_tmp->tm_min, date_tmp->tm_sec, buffer); else - string_iconv_fprintf (weechat_log_file, "%s", buffer); + string_iconv_fprintf (weechat_log_file, "%s\n", buffer); fflush (weechat_log_file); } diff --git a/src/core/wee-upgrade.c b/src/core/wee-upgrade.c index 0e2bc1c54..0890e14cb 100644 --- a/src/core/wee-upgrade.c +++ b/src/core/wee-upgrade.c @@ -836,14 +836,14 @@ session_load_server (FILE *file) } // use or allocate server - weechat_log_printf (_("session: loading server \"%s\"\n"), - server_name); + log_printf (_("session: loading server \"%s\""), + server_name); session_current_server = irc_server_search (server_name); if (session_current_server) - weechat_log_printf (_("server found, updating values\n")); + log_printf (_("server found, updating values")); else { - weechat_log_printf (_("server not found, creating new one\n")); + log_printf (_("server not found, creating new one")); session_current_server = irc_server_alloc (); if (!session_current_server) { @@ -1026,9 +1026,9 @@ session_load_server (FILE *file) rc = rc && (session_read_ignore_value (file)); break; default: - weechat_log_printf (_("session: warning: ignoring value from " - "server (object id: %d)\n"), - object_id); + log_printf (_("session: warning: ignoring value from " + "server (object id: %d)"), + object_id); rc = rc && (session_read_ignore_value (file)); break; } @@ -1069,8 +1069,8 @@ session_load_channel (FILE *file) } // allocate channel - weechat_log_printf (_("session: loading channel \"%s\"\n"), - channel_name); + log_printf (_("session: loading channel \"%s\""), + channel_name); session_current_channel = irc_channel_new (session_current_server, channel_type, channel_name); @@ -1129,9 +1129,9 @@ session_load_channel (FILE *file) rc = rc && (session_read_int (file, &(session_current_channel->display_creation_date))); break; default: - weechat_log_printf (_("session: warning: ignoring value from " - "channel (object id: %d)\n"), - object_id); + log_printf (_("session: warning: ignoring value from " + "channel (object id: %d)"), + object_id); rc = rc && (session_read_ignore_value (file)); break; } @@ -1200,9 +1200,9 @@ session_load_nick (FILE *file) rc = rc && (session_read_str (file, &(nick->host))); break; default: - weechat_log_printf (_("session: warning: ignoring value from " - "nick (object id: %d)\n"), - object_id); + log_printf (_("session: warning: ignoring value from " + "nick (object id: %d)"), + object_id); rc = rc && (session_read_ignore_value (file)); break; } @@ -1231,7 +1231,7 @@ session_load_dcc (FILE *file) return 0; } - weechat_log_printf (_("session: loading DCC\n")); + log_printf (_("session: loading DCC")); // read DCC values ptr_server = NULL; @@ -1364,9 +1364,9 @@ session_load_dcc (FILE *file) rc = rc && (session_read_int (file, &(dcc->child_write))); break; default: - weechat_log_printf (_("session: warning: ignoring value from " - "DCC (object id: %d)\n"), - object_id); + log_printf (_("session: warning: ignoring value from " + "DCC (object id: %d)"), + object_id); rc = rc && (session_read_ignore_value (file)); break; } @@ -1385,9 +1385,9 @@ session_load_history (FILE *file) char *text; if (session_current_buffer) - weechat_log_printf (_("session: loading buffer history\n")); + log_printf (_("session: loading buffer history")); else - weechat_log_printf (_("session: loading global history\n")); + log_printf (_("session: loading global history")); // read history values rc = 1; @@ -1415,9 +1415,9 @@ session_load_history (FILE *file) free (text); break; default: - weechat_log_printf (_("session: warning: ignoring value from " - "history (object id: %d)\n"), - object_id); + log_printf (_("session: warning: ignoring value from " + "history (object id: %d)"), + object_id); rc = rc && (session_read_ignore_value (file)); break; } @@ -1462,10 +1462,10 @@ session_load_buffer (FILE *file) } // allocate buffer - weechat_log_printf (_("session: loading buffer (server: %s, channel: %s, type: %d)\n"), - (server_name) ? server_name : "-", - (channel_name) ? channel_name : "-", - buffer_type); + log_printf (_("session: loading buffer (server: %s, channel: %s, type: %d)"), + (server_name) ? server_name : "-", + (channel_name) ? channel_name : "-", + buffer_type); ptr_server = NULL; ptr_channel = NULL; if (server_name) @@ -1519,9 +1519,9 @@ session_load_buffer (FILE *file) rc = rc && (session_read_int (file, &(session_current_buffer->all_servers))); break; default: - weechat_log_printf (_("session: warning: ignoring value from " - "buffer (object id: %d)\n"), - object_id); + log_printf (_("session: warning: ignoring value from " + "buffer (object id: %d)"), + object_id); rc = rc && (session_read_ignore_value (file)); break; } @@ -1600,9 +1600,9 @@ session_load_line (FILE *file) rc = rc && (session_read_buf (file, &(line->date), sizeof (time_t))); break; default: - weechat_log_printf (_("session: warning: ignoring value from " - "line (object id: %d)\n"), - object_id); + log_printf (_("session: warning: ignoring value from " + "line (object id: %d)"), + object_id); rc = rc && (session_read_ignore_value (file)); break; } @@ -1638,9 +1638,9 @@ session_load_uptime (FILE *file) rc = rc && (session_read_buf (file, &weechat_start_time, sizeof (time_t))); break; default: - weechat_log_printf (_("session: warning: ignoring value from " - "uptime (object id: %d)\n"), - object_id); + log_printf (_("session: warning: ignoring value from " + "uptime (object id: %d)"), + object_id); rc = rc && (session_read_ignore_value (file)); break; } @@ -1703,9 +1703,9 @@ session_load_hotlist (FILE *file) rc = rc && (session_read_buf (file, &creation_time, sizeof (struct timeval))); break; default: - weechat_log_printf (_("session: warning: ignoring value from " - "history (object id: %d)\n"), - object_id); + log_printf (_("session: warning: ignoring value from " + "history (object id: %d)"), + object_id); rc = rc && (session_read_ignore_value (file)); break; } @@ -1826,8 +1826,8 @@ session_load (char *filename) } break; default: - weechat_log_printf (_("ignoring object (id: %d)\n"), - object_id); + log_printf (_("ignoring object (id: %d)"), + object_id); if (!session_read_ignore_object (file)) { session_crash (file, _("failed to ignore object (id: %d)"), diff --git a/src/core/wee-util.c b/src/core/wee-util.c index 408998164..b9238e5d3 100644 --- a/src/core/wee-util.c +++ b/src/core/wee-util.c @@ -37,12 +37,12 @@ /* - * util_get_timeval_diff: calculates difference between two times (return in - * milliseconds) + * util_timeval_diff: calculates difference between two times (return in + * milliseconds) */ long -util_get_timeval_diff (struct timeval *tv1, struct timeval *tv2) +util_timeval_diff (struct timeval *tv1, struct timeval *tv2) { long diff_sec, diff_usec; diff --git a/src/core/wee-util.h b/src/core/wee-util.h index 0652ff0c7..db61830f4 100644 --- a/src/core/wee-util.h +++ b/src/core/wee-util.h @@ -20,7 +20,7 @@ #ifndef __WEECHAT_UTIL_H #define __WEECHAT_UTIL_H 1 -extern long util_get_timeval_diff (struct timeval *, struct timeval *); +extern long util_timeval_diff (struct timeval *, struct timeval *); extern int util_get_time_length (char *); extern int util_create_dir (char *, int); extern void util_exec_on_files (char *, int (*)(char *)); diff --git a/src/core/weechat.c b/src/core/weechat.c index 30aa88852..8e8eca7de 100644 --- a/src/core/weechat.c +++ b/src/core/weechat.c @@ -129,7 +129,7 @@ weechat_display_config_options () /* TRANSLATORS: %s is "WeeChat" */ _("%s configuration options:\n"), PACKAGE_NAME); - config_file_print_stdout (weechat_config); + config_file_print_stdout (weechat_config_file); } /* @@ -457,7 +457,7 @@ weechat_welcome_message () "%s-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-", GUI_COLOR(GUI_COLOR_CHAT_NICK)); - log_printf ("%s (%s %s %s)\n", + log_printf ("%s (%s %s %s)", PACKAGE_STRING, _("compiled on"), __DATE__, __TIME__); } @@ -496,19 +496,19 @@ weechat_dump (int crash) if (crash) { sigsegv = 1; - log_printf ("Very bad, WeeChat is crashing (SIGSEGV received)...\n"); + log_printf ("Very bad, WeeChat is crashing (SIGSEGV received)..."); } - log_printf ("\n"); + log_printf (""); if (crash) { - log_printf ("****** WeeChat CRASH DUMP ******\n"); - log_printf ("****** Please send this file to WeeChat developers ******\n"); - log_printf ("****** and explain when this crash happened ******\n"); + log_printf ("****** WeeChat CRASH DUMP ******"); + log_printf ("****** Please send this file to WeeChat developers ******"); + log_printf ("****** and explain when this crash happened ******"); } else { - log_printf ("****** WeeChat dump request ******\n"); + log_printf ("****** WeeChat dump request ******"); } gui_window_print_log (); @@ -517,11 +517,13 @@ weechat_dump (int crash) hook_print_log (); + config_file_print_log (); + plugin_print_log (); - log_printf ("\n"); - log_printf ("****** End of dump ******\n"); - log_printf ("\n"); + log_printf (""); + log_printf ("****** End of dump ******"); + log_printf (""); } /* @@ -533,6 +535,7 @@ void weechat_sigsegv () { weechat_dump (1); + unhook_all (); gui_main_end (); string_iconv_fprintf (stderr, "\n"); @@ -585,7 +588,8 @@ main (int argc, char *argv[]) weechat_init_vars (); /* initialize some variables */ command_init (); /* initialize WeeChat commands */ gui_keyboard_init (); /* init keyb. (default key bindings)*/ - config_weechat_init (); /* init options with default values */ + if (!config_weechat_init ()) /* init options with default values */ + exit (EXIT_FAILURE); weechat_parse_args (argc, argv); /* parse command line args */ weechat_create_home_dirs (); /* create WeeChat directories */ log_init (); /* init log file */ |