summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2007-12-01 00:35:57 +0100
committerSebastien Helleu <flashcode@flashtux.org>2007-12-01 00:35:57 +0100
commit59fb878b77320844d7d2150c95ce22c253ffb4e6 (patch)
treedbb9ee486748b0c64fcf558732ae643474e33b3f /src/core
parent32cc6ae5d8a2c0753eb2ef8ecb7194f0afff4302 (diff)
downloadweechat-59fb878b77320844d7d2150c95ce22c253ffb4e6.zip
New config functions, almost entirely rewritten from scratch
Diffstat (limited to 'src/core')
-rw-r--r--src/core/CMakeLists.txt7
-rw-r--r--src/core/Makefile.am2
-rw-r--r--src/core/wee-alias.c1
-rw-r--r--src/core/wee-command.c124
-rw-r--r--src/core/wee-config-file.c1094
-rw-r--r--src/core/wee-config-file.h122
-rw-r--r--src/core/wee-config-option.c569
-rw-r--r--src/core/wee-config-option.h68
-rw-r--r--src/core/wee-config.c1875
-rw-r--r--src/core/wee-config.h336
-rw-r--r--src/core/wee-input.c1
-rw-r--r--src/core/wee-util.c10
-rw-r--r--src/core/weechat.c32
13 files changed, 2036 insertions, 2205 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
index 0e20941dc..f850d1948 100644
--- a/src/core/CMakeLists.txt
+++ b/src/core/CMakeLists.txt
@@ -16,10 +16,9 @@
SET(LIB_CORE_SRC weechat.c weechat.h wee-alias.c wee-alias.h wee-backtrace.c
wee-backtrace.h wee-command.c wee-command.h wee-config.c wee-config.h
-wee-config-file.c wee-config-file.h wee-config-option.c wee-config-option.h
-wee-hook.c wee-hook.h wee-input.c wee-input.h wee-list.c wee-list.h wee-log.c
-wee-log.h wee-string.c wee-string.h wee-upgrade.c wee-upgrade.h wee-utf8.c
-wee-utf8.h wee-util.c wee-util.h)
+wee-config-file.c wee-config-file.h wee-hook.c wee-hook.h wee-input.c
+wee-input.h wee-list.c wee-list.h wee-log.c wee-log.h wee-string.c wee-string.h
+wee-upgrade.c wee-upgrade.h wee-utf8.c wee-utf8.h wee-util.c wee-util.h)
# Check for flock support
INCLUDE(CheckSymbolExists)
diff --git a/src/core/Makefile.am b/src/core/Makefile.am
index 043dba416..487c5693f 100644
--- a/src/core/Makefile.am
+++ b/src/core/Makefile.am
@@ -30,8 +30,6 @@ lib_weechat_core_a_SOURCES = weechat.c \
wee-config.h \
wee-config-file.c \
wee-config-file.h \
- wee-config-option.c \
- wee-config-option.h \
wee-hook.c \
wee-hook.h \
wee-input.c \
diff --git a/src/core/wee-alias.c b/src/core/wee-alias.c
index d801c4ce8..992e30d5c 100644
--- a/src/core/wee-alias.c
+++ b/src/core/wee-alias.c
@@ -30,6 +30,7 @@
#include "wee-alias.h"
#include "wee-config.h"
#include "wee-string.h"
+#include "../gui/gui-chat.h"
struct alias *weechat_alias = NULL;
diff --git a/src/core/wee-command.c b/src/core/wee-command.c
index a8d458157..acaf8bbb2 100644
--- a/src/core/wee-command.c
+++ b/src/core/wee-command.c
@@ -40,6 +40,7 @@
#include "wee-utf8.h"
#include "wee-list.h"
#include "../gui/gui-chat.h"
+#include "../gui/gui-color.h"
#include "../gui/gui-history.h"
#include "../gui/gui-input.h"
#include "../gui/gui-keyboard.h"
@@ -1011,7 +1012,7 @@ command_history (struct t_gui_buffer *buffer,
/* make C compiler happy */
(void) argv_eol;
- n_user = cfg_history_display_default;
+ n_user = CONFIG_INTEGER(config_history_display_default);
if (argc == 1)
{
@@ -1529,7 +1530,7 @@ command_save (struct t_gui_buffer *buffer,
(void) argv_eol;
/* save WeeChat configuration */
- if (weechat_config_write () == 0)
+ if (config_weechat_write () == 0)
gui_chat_printf (NULL,
_("%sWeeChat configuration file saved"),
gui_chat_prefix[GUI_CHAT_PREFIX_INFO]);
@@ -1562,35 +1563,46 @@ command_set_display_option (struct t_config_option *option, char *prefix,
switch (option->type)
{
- case OPTION_TYPE_BOOLEAN:
+ case CONFIG_OPTION_BOOLEAN:
gui_chat_printf (NULL, "%s%s%s%s = %s%s",
prefix,
(message) ? message : " ",
option->name,
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS),
GUI_COLOR(GUI_COLOR_CHAT_HOST),
- (*((int *)(option->ptr_int))) ? "ON" : "OFF");
+ (CONFIG_BOOLEAN(option) == CONFIG_BOOLEAN_TRUE) ?
+ "ON" : "OFF");
break;
- case OPTION_TYPE_INT:
- gui_chat_printf (NULL, "%s%s%s%s = %s%d",
- prefix,
- (message) ? message : " ",
- option->name,
- GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS),
- GUI_COLOR(GUI_COLOR_CHAT_HOST),
- *((int *)(option->ptr_int)));
+ case CONFIG_OPTION_INTEGER:
+ if (option->string_values)
+ gui_chat_printf (NULL, "%s%s%s%s = %s%s",
+ prefix,
+ (message) ? message : " ",
+ option->name,
+ GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS),
+ GUI_COLOR(GUI_COLOR_CHAT_HOST),
+ option->string_values[CONFIG_INTEGER(option)]);
+ else
+ gui_chat_printf (NULL, "%s%s%s%s = %s%d",
+ prefix,
+ (message) ? message : " ",
+ option->name,
+ GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS),
+ GUI_COLOR(GUI_COLOR_CHAT_HOST),
+ CONFIG_INTEGER(option));
break;
- case OPTION_TYPE_INT_WITH_STRING:
- gui_chat_printf (NULL, "%s%s%s%s = %s%s",
+ case CONFIG_OPTION_STRING:
+ gui_chat_printf (NULL, "%s%s%s%s = \"%s%s%s\"",
prefix,
(message) ? message : " ",
option->name,
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS),
GUI_COLOR(GUI_COLOR_CHAT_HOST),
- option->array_values[*((int *)(option->ptr_int))]);
+ (option->value) ? CONFIG_STRING(option) : "",
+ GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS));
break;
- case OPTION_TYPE_COLOR:
- color_name = gui_color_get_name (*((int *)(option->ptr_int)));
+ case CONFIG_OPTION_COLOR:
+ color_name = gui_color_get_name (CONFIG_COLOR(option));
gui_chat_printf (NULL, "%s%s%s%s = %s%s",
prefix,
(message) ? message : " ",
@@ -1599,53 +1611,39 @@ command_set_display_option (struct t_config_option *option, char *prefix,
GUI_COLOR(GUI_COLOR_CHAT_HOST),
(color_name) ? color_name : _("(unknown)"));
break;
- case OPTION_TYPE_STRING:
- if (*((char **)(option->ptr_string)))
- gui_chat_printf (NULL, "%s%s%s%s = \"%s%s%s\"",
- prefix,
- (message) ? message : " ",
- option->name,
- GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS),
- GUI_COLOR(GUI_COLOR_CHAT_HOST),
- *(option->ptr_string),
- GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS));
- else
- gui_chat_printf (NULL, "%s%s%s%s = \"\"",
- prefix,
- (message) ? message : " ",
- option->name,
- GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS));
- break;
}
}
/*
* command_set_display_option_list: display list of options
- * Return: number of options displayed
+ * return: number of options displayed
*/
int
-command_set_display_option_list (char **config_sections,
- struct t_config_option **config_options,
+command_set_display_option_list (struct t_config_file *config_file,
char *message, char *search)
{
- int i, j, number_found, section_displayed;
+ int number_found, section_displayed;
+ struct t_config_section *ptr_section;
+ struct t_config_option *ptr_option;
- if (!config_sections || !config_options)
+ if (!config_file)
return 0;
number_found = 0;
- for (i = 0; config_sections[i]; i++)
+ for (ptr_section = config_file->sections; ptr_section;
+ ptr_section = ptr_section->next_section)
{
- if (config_options[i])
+ if (ptr_section->options)
{
section_displayed = 0;
- for (j = 0; config_options[i][j].name; j++)
+ for (ptr_option = ptr_section->options; ptr_option;
+ ptr_option = ptr_option->next_option)
{
if ((!search) ||
((search) && (search[0])
- && (string_strcasestr (config_options[i][j].name, search))))
+ && (string_strcasestr (ptr_option->name, search))))
{
if (!section_displayed)
{
@@ -1653,12 +1651,11 @@ command_set_display_option_list (char **config_sections,
gui_chat_printf (NULL, "%s[%s%s%s]",
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS),
GUI_COLOR(GUI_COLOR_CHAT_BUFFER),
- config_sections[i],
+ ptr_section->name,
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS));
section_displayed = 1;
}
- command_set_display_option (&config_options[i][j],
- "", message);
+ command_set_display_option (ptr_option, "", message);
number_found++;
}
}
@@ -1688,10 +1685,10 @@ command_set (struct t_gui_buffer *buffer,
{
number_found = 0;
- number_found += command_set_display_option_list (weechat_config_sections,
- weechat_config_options,
+ number_found += command_set_display_option_list (weechat_config,
NULL,
- (argc == 1) ? argv[0] : NULL);
+ (argc == 1) ?
+ argv[0] : NULL);
if (number_found == 0)
{
@@ -1728,9 +1725,7 @@ command_set (struct t_gui_buffer *buffer,
/* set option value */
if ((argc >= 3) && (string_strcasecmp (argv[1], "=") == 0))
{
- ptr_option = config_option_section_option_search (weechat_config_sections,
- weechat_config_options,
- argv[0]);
+ ptr_option = config_file_search_option (weechat_config, NULL, argv[0]);
if (!ptr_option)
{
gui_chat_printf (NULL,
@@ -1740,27 +1735,18 @@ command_set (struct t_gui_buffer *buffer,
argv[0]);
return -1;
}
- if (!ptr_option->handler_change)
- {
- gui_chat_printf (NULL,
- _("%sError: option \"%s\" can not be "
- "changed while WeeChat is "
- "running"),
- gui_chat_prefix[GUI_CHAT_PREFIX_ERROR],
- argv[0]);
- return -1;
- }
value = string_remove_quotes (argv_eol[2], "'\"");
- rc = config_option_set (ptr_option,
- (value) ? value : argv_eol[2]);
+ rc = config_file_option_set (ptr_option,
+ (value) ? value : argv_eol[2]);
if (value)
free (value);
- if (rc == 0)
+ if (rc > 0)
{
command_set_display_option (ptr_option,
gui_chat_prefix[GUI_CHAT_PREFIX_INFO],
_("Option changed: "));
- (void) (ptr_option->handler_change());
+ if ((rc == 2) && (ptr_option->callback_change))
+ (void) (ptr_option->callback_change) ();
}
else
{
@@ -1785,7 +1771,7 @@ command_setp (struct t_gui_buffer *buffer,
int argc, char **argv, char **argv_eol)
{
char *pos, *ptr_name, *value;
- struct t_plugin_option *ptr_option;
+ struct t_config_option *ptr_option;
int number_found;
/* make C compiler happy */
@@ -1808,7 +1794,7 @@ command_setp (struct t_gui_buffer *buffer,
ptr_option->name,
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS),
GUI_COLOR(GUI_COLOR_CHAT_HOST),
- ptr_option->value,
+ (char *)ptr_option->value,
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS));
number_found++;
}
@@ -2009,7 +1995,7 @@ command_upgrade (struct t_gui_buffer *buffer,
/* unload plugins, save config, then upgrade */
plugin_end ();
- /*if (cfg_look_save_on_exit)
+ /*if (CONFIG_BOOLEAN(config_look_save_on_exit))
(void) config_write (NULL);
gui_main_end ();
fifo_remove ();
diff --git a/src/core/wee-config-file.c b/src/core/wee-config-file.c
index 5a0cc431e..a29e3ba97 100644
--- a/src/core/wee-config-file.c
+++ b/src/core/wee-config-file.c
@@ -16,7 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/* wee-config-file.c: I/O functions to read/write options in a config file */
+/* wee-config-file.c: manages options in config files */
#ifdef HAVE_CONFIG_H
@@ -25,64 +25,486 @@
#include <stdlib.h>
#include <unistd.h>
-#include <errno.h>
-#include <stdio.h>
#include <string.h>
-#include <limits.h>
-#include <time.h>
-#include <pwd.h>
-#include <sys/types.h>
#include <sys/stat.h>
#include "weechat.h"
#include "wee-config-file.h"
-#include "wee-config-option.h"
#include "wee-log.h"
#include "wee-string.h"
-#include "wee-utf8.h"
-#include "../gui/gui-chat.h"
#include "../gui/gui-color.h"
+#include "../gui/gui-chat.h"
+
+
+struct t_config_file *config_files = NULL;
+struct t_config_file *last_config_file = NULL;
/*
- * config_file_read_option: read an option for a section in config file
- * This function is called when a new section begins
- * or for an option of a section
- * if options == NULL, then option is out of section
- * if option_name == NULL, it's beginning of section
- * otherwise it's an option for a section
- * Return: 0 = successful
- * -1 = option not found
- * -2 = bad format/value
+ * config_file_new: create new config options structure
*/
-int
-config_file_read_option (struct t_config_option *options,
- char *option_name, char *value)
+struct t_config_file *
+config_file_new (char *filename)
{
- struct t_config_option *ptr_option;
+ struct t_config_file *new_config_file;
+
+ if (!filename)
+ return NULL;
- if (option_name)
+ new_config_file = (struct t_config_file *)malloc (sizeof (struct t_config_file));
+ if (new_config_file)
{
- /* no option allowed outside a section by default */
- if (!options)
- return -1;
+ new_config_file->filename = strdup (filename);
+ new_config_file->file = NULL;
+ new_config_file->sections = NULL;
+ new_config_file->last_section = NULL;
- /* search option in list of options for section */
- ptr_option = config_option_search (options, option_name);
- if (!ptr_option)
- return -1;
+ new_config_file->prev_config = last_config_file;
+ new_config_file->next_config = NULL;
+ if (config_files)
+ last_config_file->next_config = new_config_file;
+ else
+ config_files = new_config_file;
+ last_config_file = new_config_file;
+ }
+
+ return new_config_file;
+}
+
+/*
+ * config_file_new_section: create a new section in a config
+ */
+
+struct t_config_section *
+config_file_new_section (struct t_config_file *config_file, char *name,
+ void (*callback_read)(struct t_config_file *, char *, char *),
+ void (*callback_write)(struct t_config_file *),
+ void (*callback_write_default)(struct t_config_file *))
+{
+ struct t_config_section *new_section;
+
+ if (!config_file || !name)
+ return NULL;
+
+ new_section = (struct t_config_section *)malloc (sizeof (struct t_config_section));
+ if (new_section)
+ {
+ new_section->name = strdup (name);
+ new_section->callback_read = callback_read;
+ new_section->callback_write = callback_write;
+ new_section->callback_write_default = callback_write_default;
+ new_section->options = NULL;
+ new_section->last_option = NULL;
+
+ new_section->prev_section = config_file->last_section;
+ new_section->next_section = NULL;
+ if (config_file->sections)
+ config_file->last_section->next_section = new_section;
+ else
+ config_file->sections = new_section;
+ config_file->last_section = new_section;
+ }
+
+ return new_section;
+}
+
+/*
+ * config_file_search_section: search a section in a config structure
+ */
+
+struct t_config_section *
+config_file_search_section (struct t_config_file *config_file,
+ char *section_name)
+{
+ struct t_config_section *ptr_section;
+
+ for (ptr_section = config_file->sections; ptr_section;
+ ptr_section = ptr_section->next_section)
+ {
+ if (string_strcasecmp (ptr_section->name, section_name) == 0)
+ return ptr_section;
+ }
+
+ /* section not found */
+ return NULL;
+}
+
+/*
+ * config_file_new_option_boolean: create a new option, type "boolean"
+ * in a config section
+ */
+
+struct t_config_option *
+config_file_new_option_boolean (struct t_config_section *section, char *name,
+ char *description, int 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_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;
- /* set value for option found */
- if (config_option_set (ptr_option, value) < 0)
- return -2;
+ 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;
}
- else
+
+ return new_option;
+}
+
+/*
+ * config_file_new_option_integer: create a new option, type "integer"
+ * 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)())
+{
+ 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)
{
- /* by default, does nothing for a new section */
+ 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->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)
+ 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->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->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->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);
+ new_option->callback_change = callback_change;
+
+ 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_search_option: search an option in a config or section
+ */
+
+struct t_config_option *
+config_file_search_option (struct t_config_file *config_file,
+ struct t_config_section *section,
+ char *option_name)
+{
+ struct t_config_section *ptr_section;
+ struct t_config_option *ptr_option;
+
+ if (section)
+ {
+ for (ptr_option = section->options; ptr_option;
+ ptr_option = ptr_option->next_option)
+ {
+ if (string_strcasecmp (ptr_option->name, option_name) == 0)
+ return ptr_option;
+ }
+ }
+ else if (config_file)
+ {
+ for (ptr_section = config_file->sections; ptr_section;
+ ptr_section = ptr_section->next_section)
+ {
+ for (ptr_option = ptr_section->options; ptr_option;
+ ptr_option = ptr_option->next_option)
+ {
+ if (string_strcasecmp (ptr_option->name, option_name) == 0)
+ return ptr_option;
+ }
+ }
+ }
+
+ /* option not found */
+ return NULL;
+}
+
+/*
+ * config_file_string_boolean_value: return boolean value of string
+ * return -1 if error
+ */
+
+int
+config_file_string_boolean_value (char *text)
+{
+ if ((string_strcasecmp (text, "on") == 0)
+ || (string_strcasecmp (text, "yes") == 0)
+ || (string_strcasecmp (text, "y") == 0)
+ || (string_strcasecmp (text, "true") == 0)
+ || (string_strcasecmp (text, "t") == 0)
+ || (string_strcasecmp (text, "1") == 0))
+ return CONFIG_BOOLEAN_TRUE;
+
+ if ((string_strcasecmp (text, "off") == 0)
+ || (string_strcasecmp (text, "no") == 0)
+ || (string_strcasecmp (text, "n") == 0)
+ || (string_strcasecmp (text, "false") == 0)
+ || (string_strcasecmp (text, "f") == 0)
+ || (string_strcasecmp (text, "0") == 0))
+ return CONFIG_BOOLEAN_FALSE;
+
+ /* invalid text */
+ return -1;
+}
+
+/*
+ * config_file_option_set: set value for an option
+ * return: 2 if ok (value changed)
+ * 1 if ok (value is the same)
+ * 0 if failed
+ */
+
+int
+config_file_option_set (struct t_config_option *option, char *new_value)
+{
+ int new_value_int, i, rc;
+ long number;
+ char *error;
+
+ if (!option)
+ return 0;
+
+ switch (option->type)
+ {
+ case CONFIG_OPTION_BOOLEAN:
+ if (!new_value)
+ return 0;
+ new_value_int = config_file_string_boolean_value (new_value);
+ if (new_value_int < 0)
+ return 0;
+ if (new_value_int == *((char *)option->value))
+ return 1;
+ *((char *)option->value) = new_value_int;
+ return 2;
+ case CONFIG_OPTION_INTEGER:
+ if (!new_value)
+ return 0;
+ if (option->string_values)
+ {
+ new_value_int = -1;
+ for (i = 0; option->string_values[i]; i++)
+ {
+ if (string_strcasecmp (option->string_values[i],
+ new_value) == 0)
+ {
+ new_value_int = i;
+ break;
+ }
+ }
+ if (new_value_int < 0)
+ return 0;
+ if (new_value_int == *((int *)option->value))
+ return 1;
+ *((int *)option->value) = new_value_int;
+ return 2;
+ }
+ else
+ {
+ error = NULL;
+ number = strtol (new_value, &error, 10);
+ if (error && (error[0] == '\0'))
+ {
+ if (number == *((int *)option->value))
+ return 1;
+ *((int *)option->value) = number;
+ return 2;
+ }
+ }
+ break;
+ case CONFIG_OPTION_STRING:
+ rc = 1;
+ if ((!option->value && new_value)
+ || (option->value && !new_value)
+ || (strcmp ((char *)option->value, new_value) != 0))
+ rc = 2;
+ if (option->value)
+ free (option->value);
+ if (new_value)
+ {
+ option->value = strdup (new_value);
+ if (!option->value)
+ return 0;
+ }
+ else
+ option->value = NULL;
+ return rc;
+ case CONFIG_OPTION_COLOR:
+ if (!gui_color_assign (&new_value_int, new_value))
+ return 0;
+ if (new_value_int == *((int *)option->value))
+ return 1;
+ *((int *)option->value) = new_value_int;
+ return 2;
}
- /* all ok */
return 0;
}
@@ -94,36 +516,27 @@ config_file_read_option (struct t_config_option *options,
*/
int
-config_file_read (char **config_sections, struct t_config_option **options,
- t_config_func_read_option **read_functions,
- t_config_func_read_option *read_function_default,
- t_config_func_write_options **write_default_functions,
- char *config_filename)
+config_file_read (struct t_config_file *config_file)
{
- int filename_length;
+ int filename_length, line_number, rc;
char *filename;
- FILE *file;
- int section, line_number, rc;
+ struct t_config_section *ptr_section;
+ struct t_config_option *ptr_option;
char line[1024], *ptr_line, *ptr_line2, *pos, *pos2;
- filename_length = strlen (weechat_home) + strlen (config_filename) + 2;
+ if (!config_file)
+ return -1;
+
+ filename_length = strlen (weechat_home) + strlen (config_file->filename) + 2;
filename = (char *) malloc (filename_length * sizeof (char));
if (!filename)
return -2;
snprintf (filename, filename_length, "%s%s%s",
- weechat_home, DIR_SEPARATOR, config_filename);
- if ((file = fopen (filename, "r")) == NULL)
+ weechat_home, DIR_SEPARATOR, config_file->filename);
+ if ((config_file->file = fopen (filename, "r")) == NULL)
{
- /* if no default write functions provided and that config file
- is not here, then return without doing anything */
- if (!write_default_functions)
- return 0;
-
- /* create default config, then go on with reading */
- config_file_write_default (config_sections, options,
- write_default_functions,
- config_filename);
- if ((file = fopen (filename, "r")) == NULL)
+ config_file_write (config_file, 1);
+ if ((config_file->file = fopen (filename, "r")) == NULL)
{
gui_chat_printf (NULL,
_("Warning: config file \"%s\" not found.\n"),
@@ -133,13 +546,11 @@ config_file_read (char **config_sections, struct t_config_option **options,
}
}
- config_option_section_option_set_default_values (config_sections, options);
-
- section = -1;
+ ptr_section = NULL;
line_number = 0;
- while (!feof (file))
+ while (!feof (config_file->file))
{
- ptr_line = fgets (line, sizeof (line) - 1, file);
+ ptr_line = fgets (line, sizeof (line) - 1, config_file->file);
line_number++;
if (ptr_line)
{
@@ -164,29 +575,21 @@ config_file_read (char **config_sections, struct t_config_option **options,
pos = strchr (line, ']');
if (pos == NULL)
gui_chat_printf (NULL,
- _("Warning: %s, line %d: invalid syntax, "
- "missing \"]\"\n"),
+ _("Warning: %s, line %d: invalid "
+ "syntax, missing \"]\"\n"),
filename, line_number);
else
{
pos[0] = '\0';
pos = ptr_line + 1;
- section = config_option_section_get_index (config_sections, pos);
- if (section < 0)
+ ptr_section = config_file_search_section (config_file,
+ pos);
+ if (!ptr_section)
gui_chat_printf (NULL,
- _("Warning: %s, line %d: unknown section "
- "identifier (\"%s\")\n"),
+ _("Warning: %s, line %d: unknown "
+ "section identifier "
+ "(\"%s\")\n"),
filename, line_number, pos);
- else
- {
- rc = ((int) (read_functions[section]) (options[section],
- NULL, NULL));
- if (rc < 0)
- gui_chat_printf (NULL,
- _("Warning: %s, line %d: error "
- "reading new section \"%s\"\n"),
- filename, line_number, pos);
- }
}
}
else
@@ -194,8 +597,8 @@ config_file_read (char **config_sections, struct t_config_option **options,
pos = strchr (line, '=');
if (pos == NULL)
gui_chat_printf (NULL,
- _("Warning: %s, line %d: invalid syntax, "
- "missing \"=\"\n"),
+ _("Warning: %s, line %d: invalid "
+ "syntax, missing \"=\"\n"),
filename, line_number);
else
{
@@ -245,37 +648,54 @@ config_file_read (char **config_sections, struct t_config_option **options,
}
}
- if (section < 0)
- rc = ((int) (read_function_default) (NULL, line, pos));
+ ptr_option = config_file_search_option (config_file,
+ ptr_section,
+ line);
+ if (ptr_option)
+ rc = config_file_option_set (ptr_option, pos);
else
- rc = ((int) (read_functions[section]) (options[section],
- line, pos));
- if (rc < 0)
{
- switch (rc)
+ /* option not found: use read callback */
+ if (ptr_section && ptr_section->callback_read)
{
- case -1:
- if (section < 0)
- gui_chat_printf (NULL,
- _("Warning: %s, line %d: unknown "
- "option \"%s\" "
- "(outside a section)\n"),
- filename, line_number, line);
- else
- gui_chat_printf (NULL,
- _("Warning: %s, line %d: option "
- "\"%s\" unknown for "
- "section \"%s\"\n"),
- filename, line_number, line,
- config_sections[section]);
- break;
- case -2:
- gui_chat_printf (NULL,
- _("Warning: %s, line %d: invalid "
- "value for option \"%s\"\n"),
- filename, line_number, line);
- break;
+ (void) (ptr_section->callback_read) (config_file,
+ line, pos);
+ rc = 1;
}
+ else
+ rc = -1;
+ }
+
+ switch (rc)
+ {
+ case -1:
+ if (ptr_section)
+ gui_chat_printf (NULL,
+ _("Warning: %s, line %d: "
+ "option \"%s\" "
+ "unknown for "
+ "section \"%s\"\n"),
+ filename, line_number,
+ line, ptr_section->name);
+ else
+ gui_chat_printf (NULL,
+ _("Warning: %s, line %d: "
+ "unknown option \"%s\" "
+ "(outside a section)\n"),
+ filename, line_number,
+ line);
+ break;
+ case 0:
+ gui_chat_printf (NULL,
+ _("Warning: %s, line %d: "
+ "invalid value for option "
+ "\"%s\"\n"),
+ filename, line_number, line);
+ break;
+ case 2:
+ if (ptr_option && ptr_option->callback_change)
+ (void) (ptr_option->callback_change) ();
+ break;
}
}
}
@@ -283,218 +703,99 @@ config_file_read (char **config_sections, struct t_config_option **options,
}
}
- fclose (file);
+ fclose (config_file->file);
+ config_file->file = NULL;
free (filename);
return 0;
}
/*
- * config_file_write_options: write a section with options in a config file
- * This function is called when config is saved,
- * for a section with standard options
- * Return: 0 = successful
- * -1 = write error
+ * config_file_write_option: write an option in a config file
*/
-int
-config_file_write_options (FILE *file, char *section_name,
- struct t_config_option *options)
+void
+config_file_write_option (struct t_config_file *config_file,
+ struct t_config_option *option,
+ int default_value)
{
- int i;
-
- string_iconv_fprintf (file, "\n[%s]\n", section_name);
+ void *value;
- for (i = 0; options[i].name; i++)
- {
- switch (options[i].type)
- {
- case OPTION_TYPE_BOOLEAN:
- string_iconv_fprintf (file, "%s = %s\n",
- options[i].name,
- (options[i].ptr_int &&
- *options[i].ptr_int) ?
- "on" : "off");
- break;
- case OPTION_TYPE_INT:
- string_iconv_fprintf (file, "%s = %d\n",
- options[i].name,
- (options[i].ptr_int) ?
- *options[i].ptr_int :
- options[i].default_int);
- break;
- case OPTION_TYPE_INT_WITH_STRING:
- string_iconv_fprintf (file, "%s = %s\n",
- options[i].name,
- (options[i].ptr_int) ?
- options[i].array_values[*options[i].ptr_int] :
- options[i].array_values[options[i].default_int]);
- break;
- case OPTION_TYPE_COLOR:
- string_iconv_fprintf (file, "%s = %s\n",
- options[i].name,
- (options[i].ptr_int) ?
- gui_color_get_name (*options[i].ptr_int) :
- options[i].default_string);
- break;
- case OPTION_TYPE_STRING:
- string_iconv_fprintf (file, "%s = \"%s\"\n",
- options[i].name,
- (options[i].ptr_string) ?
- *options[i].ptr_string :
- options[i].default_string);
- break;
- }
- }
-
- /* all ok */
- return 0;
-}
-
-/*
- * config_file_write_options_default_values: write a section with options in a config file
- * This function is called when new config file
- * is created, with default values, for a
- * section with standard options
- * Return: 0 = successful
- * -1 = write error
- */
-
-int
-config_file_write_options_default_values (FILE *file, char *section_name,
- struct t_config_option *options)
-{
- int i;
+ if (!config_file || !config_file->file || !option)
+ return;
- string_iconv_fprintf (file, "\n[%s]\n", section_name);
+ value = (default_value) ? option->default_value : option->value;
- for (i = 0; options[i].name; i++)
+ switch (option->type)
{
- switch (options[i].type)
- {
- case OPTION_TYPE_BOOLEAN:
- string_iconv_fprintf (file, "%s = %s\n",
- options[i].name,
- (options[i].default_int) ?
- "on" : "off");
- break;
- case OPTION_TYPE_INT:
- string_iconv_fprintf (file, "%s = %d\n",
- options[i].name,
- options[i].default_int);
- break;
- case OPTION_TYPE_INT_WITH_STRING:
- case OPTION_TYPE_COLOR:
- string_iconv_fprintf (file, "%s = %s\n",
- options[i].name,
- options[i].default_string);
- break;
- case OPTION_TYPE_STRING:
- string_iconv_fprintf (file, "%s = \"%s\"\n",
- options[i].name,
- options[i].default_string);
- break;
- }
+ case CONFIG_OPTION_BOOLEAN:
+ string_iconv_fprintf (config_file->file, "%s = %s\n",
+ option->name,
+ (*((int *)value)) == CONFIG_BOOLEAN_TRUE ?
+ "on" : "off");
+ break;
+ case CONFIG_OPTION_INTEGER:
+ if (option->string_values)
+ string_iconv_fprintf (config_file->file, "%s = %s\n",
+ option->name,
+ option->string_values[*((int *)value)]);
+ else
+ string_iconv_fprintf (config_file->file, "%s = %d\n",
+ option->name,
+ *((int *)value));
+ break;
+ case CONFIG_OPTION_STRING:
+ string_iconv_fprintf (config_file->file, "%s = \"%s\"\n",
+ option->name,
+ (char *)value);
+ break;
+ case CONFIG_OPTION_COLOR:
+ string_iconv_fprintf (config_file->file, "%s = %s\n",
+ option->name,
+ gui_color_get_name (*((int *)value)));
+ break;
}
-
- /* all ok */
- return 0;
}
/*
- * config_file_write_header: write header in a config file
+ * config_file_write_line: write a line in a config file
*/
void
-config_file_write_header (FILE *file)
+config_file_write_line (struct t_config_file *config_file,
+ char *option_name, char *value)
{
- time_t current_time;
-
- current_time = time (NULL);
- string_iconv_fprintf (file, _("#\n# %s configuration file, created by "
- "%s v%s on %s"),
- PACKAGE_NAME, PACKAGE_NAME, PACKAGE_VERSION,
- ctime (&current_time));
- string_iconv_fprintf (file, _("# WARNING! Be careful when editing this file, "
- "WeeChat may write it at any time.\n#\n"));
+ string_iconv_fprintf (config_file->file, "%s = %s\n",
+ option_name, value);
}
/*
- * config_file_write_default: create a default configuration file
- * return: 0 if ok
- * < 0 if error
- */
-
-int
-config_file_write_default (char **config_sections, struct t_config_option **options,
- t_config_func_write_options **write_functions,
- char *config_filename)
-{
- int filename_length, i, rc;
- char *filename;
- FILE *file;
-
- filename_length = strlen (weechat_home) +
- strlen (config_filename) + 2;
- filename =
- (char *) malloc (filename_length * sizeof (char));
- if (!filename)
- return -2;
- snprintf (filename, filename_length, "%s%s%s",
- weechat_home, DIR_SEPARATOR, config_filename);
- if ((file = fopen (filename, "w")) == NULL)
- {
- gui_chat_printf (NULL,
- _("Error: cannot create file \"%s\"\n"),
- filename);
- free (filename);
- return -1;
- }
-
- string_iconv_fprintf (stdout,
- _("%s: creating default config file \"%s\"...\n"),
- PACKAGE_NAME,
- config_filename);
- log_printf (_("Creating default config file \"%s\"\n"),
- config_filename);
-
- config_file_write_header (file);
-
- for (i = 0; config_sections[i]; i++)
- {
- rc = ((int) (write_functions[i]) (file, config_sections[i],
- options[i]));
- }
-
- fclose (file);
- chmod (filename, 0600);
- free (filename);
- return 0;
-}
-
-/*
- * config_file_write: write a configurtion file
+ * config_file_write: write a configuration file
* return: 0 if ok
- * < 0 if error
+ * -1 if error writing file
+ * -2 if not enough memory
*/
int
-config_file_write (char **config_sections, struct t_config_option **options,
- t_config_func_write_options **write_functions,
- char *config_filename)
+config_file_write (struct t_config_file *config_file, int default_options)
{
- int filename_length, i, rc;
+ int filename_length, rc;
char *filename, *filename2;
- FILE *file;
+ time_t current_time;
+ struct t_config_section *ptr_section;
+ struct t_config_option *ptr_option;
+
+ if (!config_file)
+ return -1;
filename_length = strlen (weechat_home) +
- strlen (config_filename) + 2;
+ strlen (config_file->filename) + 2;
filename =
(char *) malloc (filename_length * sizeof (char));
if (!filename)
return -2;
snprintf (filename, filename_length, "%s%s%s",
- weechat_home, DIR_SEPARATOR, config_filename);
+ weechat_home, DIR_SEPARATOR, config_file->filename);
filename2 = (char *) malloc ((filename_length + 32) * sizeof (char));
if (!filename2)
@@ -504,7 +805,7 @@ config_file_write (char **config_sections, struct t_config_option **options,
}
snprintf (filename2, filename_length + 32, "%s.weechattmp", filename);
- if ((file = fopen (filename2, "w")) == NULL)
+ if ((config_file->file = fopen (filename2, "w")) == NULL)
{
gui_chat_printf (NULL,
_("Error: cannot create file \"%s\"\n"),
@@ -514,15 +815,46 @@ config_file_write (char **config_sections, struct t_config_option **options,
return -1;
}
- config_file_write_header (file);
-
- for (i = 0; config_sections[i]; i++)
+ current_time = time (NULL);
+ string_iconv_fprintf (config_file->file,
+ _("#\n# %s configuration file, created by "
+ "%s v%s on %s"),
+ PACKAGE_NAME, PACKAGE_NAME, PACKAGE_VERSION,
+ ctime (&current_time));
+ string_iconv_fprintf (config_file->file,
+ _("# WARNING! Be careful when editing this file, "
+ "WeeChat may write it at any time.\n#\n"));
+
+ for (ptr_section = config_file->sections; ptr_section;
+ ptr_section = ptr_section->next_section)
{
- rc = ((int) (write_functions[i]) (file, config_sections[i],
- options[i]));
+ /* 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 (ptr_section->callback_write_default)
+ (void) (ptr_section->callback_write_default) (config_file);
+ }
+ else
+ {
+ if (ptr_section->callback_write)
+ (void) (ptr_section->callback_write) (config_file);
+ }
+
+ /* write all options for section */
+ for (ptr_option = ptr_section->options; ptr_option;
+ ptr_option = ptr_option->next_option)
+ {
+ config_file_write_option (config_file, ptr_option,
+ default_options);
+ }
}
- fclose (file);
+ fclose (config_file->file);
+ config_file->file = NULL;
chmod (filename2, 0600);
unlink (filename);
rc = rename (filename2, filename);
@@ -532,3 +864,185 @@ config_file_write (char **config_sections, struct t_config_option **options,
return -1;
return 0;
}
+
+/*
+ * config_file_print_stdout: print options on standard output
+ */
+
+void
+config_file_print_stdout (struct t_config_file *config_file)
+{
+ struct t_config_section *ptr_section;
+ struct t_config_option *ptr_option;
+ char *color_name;
+ int i;
+
+ for (ptr_section = config_file->sections; ptr_section;
+ ptr_section = ptr_section->next_section)
+ {
+ for (ptr_option = ptr_section->options; ptr_option;
+ ptr_option = ptr_option->next_option)
+ {
+ string_iconv_fprintf (stdout,
+ "* %s:\n",
+ ptr_option->name);
+ switch (ptr_option->type)
+ {
+ case CONFIG_OPTION_BOOLEAN:
+ string_iconv_fprintf (stdout, _(" . type: boolean\n"));
+ string_iconv_fprintf (stdout, _(" . values: 'on' or 'off'\n"));
+ string_iconv_fprintf (stdout, _(" . default value: '%s'\n"),
+ (CONFIG_BOOLEAN_DEFAULT(ptr_option) == CONFIG_BOOLEAN_TRUE) ?
+ "on" : "off");
+ break;
+ case CONFIG_OPTION_INTEGER:
+ if (ptr_option->string_values)
+ {
+ string_iconv_fprintf (stdout, _(" . type: string\n"));
+ string_iconv_fprintf (stdout, _(" . values: "));
+ i = 0;
+ while (ptr_option->string_values[i])
+ {
+ string_iconv_fprintf (stdout, "'%s'",
+ ptr_option->string_values[i]);
+ if (ptr_option->string_values[i + 1])
+ string_iconv_fprintf (stdout, ", ");
+ i++;
+ }
+ string_iconv_fprintf (stdout, "\n");
+ string_iconv_fprintf (stdout, _(" . default value: '%s'\n"),
+ ptr_option->string_values[CONFIG_INTEGER_DEFAULT(ptr_option)]);
+ }
+ else
+ {
+ string_iconv_fprintf (stdout, _(" . type: integer\n"));
+ string_iconv_fprintf (stdout, _(" . values: between %d and %d\n"),
+ ptr_option->min,
+ ptr_option->max);
+ string_iconv_fprintf (stdout, _(" . default value: %d\n"),
+ CONFIG_INTEGER_DEFAULT(ptr_option));
+ }
+ break;
+ case CONFIG_OPTION_STRING:
+ switch (ptr_option->max)
+ {
+ case 0:
+ string_iconv_fprintf (stdout, _(" . type: string\n"));
+ string_iconv_fprintf (stdout, _(" . values: any string\n"));
+ break;
+ case 1:
+ string_iconv_fprintf (stdout, _(" . type: char\n"));
+ string_iconv_fprintf (stdout, _(" . values: any char\n"));
+ break;
+ default:
+ string_iconv_fprintf (stdout, _(" . type: string\n"));
+ string_iconv_fprintf (stdout, _(" . values: any string (limit: %d chars)\n"),
+ ptr_option->max);
+ break;
+ }
+ string_iconv_fprintf (stdout, _(" . default value: '%s'\n"),
+ CONFIG_STRING_DEFAULT(ptr_option));
+ break;
+ case CONFIG_OPTION_COLOR:
+ color_name = gui_color_get_name (CONFIG_COLOR_DEFAULT(ptr_option));
+ string_iconv_fprintf (stdout, _(" . type: color\n"));
+ string_iconv_fprintf (stdout, _(" . values: color (depends on GUI used)\n"));
+ string_iconv_fprintf (stdout, _(" . default value: '%s'\n"),
+ color_name);
+ break;
+ }
+ string_iconv_fprintf (stdout, _(" . description: %s\n"),
+ _(ptr_option->description));
+ string_iconv_fprintf (stdout, "\n");
+ }
+ }
+}
+
+/*
+ * config_file_print_log: print config in log (usually for crash dump)
+ */
+
+void
+config_file_print_log ()
+{
+ struct t_config_file *ptr_config_file;
+ struct t_config_section *ptr_section;
+ struct t_config_option *ptr_option;
+
+ 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);
+
+ 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);
+
+ 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);
+ switch (ptr_option->type)
+ {
+ case CONFIG_OPTION_BOOLEAN:
+ log_printf (" value (boolean). . . : %s\n",
+ (*((int *)ptr_option->value) == CONFIG_BOOLEAN_TRUE) ?
+ "true" : "false");
+ log_printf (" default value. . . . : %s\n",
+ (*((int *)ptr_option->default_value) == 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[*((int *)ptr_option->value)]);
+ log_printf (" default value. . . . : '%s'\n",
+ ptr_option->string_values[*((int *)ptr_option->default_value)]);
+ }
+ else
+ {
+ log_printf (" value (integer). . . : %d\n", *((int *)ptr_option->value));
+ log_printf (" default value. . . . : %d\n", *((int *)ptr_option->default_value));
+ }
+ break;
+ case CONFIG_OPTION_STRING:
+ log_printf (" value (string) . . . : '%s'\n", (char *)ptr_option->value);
+ log_printf (" default value. . . . : '%s'\n", (char *)ptr_option->default_value);
+ break;
+ case CONFIG_OPTION_COLOR:
+ log_printf (" value (color). . . . : %d ('%s')\n",
+ *((int *)ptr_option->value),
+ gui_color_get_name (*((int *)ptr_option->value)));
+ log_printf (" default value. . . . : %d ('%s')\n",
+ *((int *)ptr_option->default_value),
+ gui_color_get_name (*((int *)ptr_option->default_value)));
+ break;
+ }
+ log_printf (" prev_option. . . . . : 0x%X\n", ptr_option->prev_option);
+ log_printf (" next_option. . . . . : 0x%X\n", ptr_option->next_option);
+ }
+ }
+ }
+}
diff --git a/src/core/wee-config-file.h b/src/core/wee-config-file.h
index cde80def3..d7876b6d7 100644
--- a/src/core/wee-config-file.h
+++ b/src/core/wee-config-file.h
@@ -20,24 +20,108 @@
#ifndef __WEECHAT_CONFIG_FILE_H
#define __WEECHAT_CONFIG_FILE_H 1
-#include "wee-config-option.h"
-
-typedef int (t_config_func_read_option) (struct t_config_option *, char *, char *);
-typedef int (t_config_func_write_options) (FILE *, char *, struct t_config_option *);
-
-extern int config_file_read_option (struct t_config_option *, char *, char *);
-extern int config_file_read (char **, struct t_config_option **,
- t_config_func_read_option **,
- t_config_func_read_option *,
- t_config_func_write_options **,
- char *);
-
-extern int config_file_write_options (FILE *, char *, struct t_config_option *);
-extern int config_file_write_options_default_values (FILE *, char *,
- struct t_config_option *);
-extern int config_file_write_default (char **, struct t_config_option **,
- t_config_func_write_options **, char *);
-extern int config_file_write (char **, struct t_config_option **,
- t_config_func_write_options **, char *);
+#define CONFIG_BOOLEAN(option) (*((char *)((option)->value)))
+#define CONFIG_BOOLEAN_DEFAULT(option) (*((char *)((option)->default_value)))
+
+#define CONFIG_INTEGER(option) (*((int *)((option)->value)))
+#define CONFIG_INTEGER_DEFAULT(option) (*((int *)((option)->default_value)))
+
+#define CONFIG_STRING(option) ((char *)((option)->value))
+#define CONFIG_STRING_DEFAULT(option) ((char *)((option)->default_value))
+
+#define CONFIG_COLOR(option) (*((int *)((option)->value)))
+#define CONFIG_COLOR_DEFAULT(option) (*((int *)((option)->default_value)))
+
+#define CONFIG_BOOLEAN_FALSE 0
+#define CONFIG_BOOLEAN_TRUE 1
+
+struct t_config_file
+{
+ char *filename; /* config filename (without path)*/
+ FILE *file; /* file pointer */
+ struct t_config_section *sections; /* config sections */
+ struct t_config_section *last_section; /* last config section */
+ struct t_config_file *prev_config; /* link to previous config file */
+ struct t_config_file *next_config; /* link to next config file */
+};
+
+struct t_config_section
+{
+ char *name; /* section name */
+ void (*callback_read) /* called when unknown option */
+ (struct t_config_file *, /* is read from config file */
+ char *, char *);
+ void (*callback_write) /* called to write special */
+ (struct t_config_file *); /* options in config file */
+ void (*callback_write_default) /* called to write default */
+ (struct t_config_file *); /* 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 */
+ struct t_config_section *next_section; /* link to next section */
+};
+
+enum t_config_option_type
+{
+ CONFIG_OPTION_BOOLEAN = 0,
+ CONFIG_OPTION_INTEGER,
+ CONFIG_OPTION_STRING,
+ CONFIG_OPTION_COLOR,
+};
+
+struct t_config_option
+{
+ char *name; /* name */
+ enum t_config_option_type type; /* type */
+ char *description; /* description */
+ char **string_values; /* allowed string values */
+ int min, max; /* min and max for value */
+ void *default_value; /* default value */
+ void *value; /* value */
+ void (*callback_change)(); /* called when value is changed */
+ struct t_config_option *prev_option; /* link to previous option */
+ struct t_config_option *next_option; /* link to next option */
+};
+
+extern struct t_config_file *config_file_new (char *);
+extern struct t_config_section *config_file_new_section (struct t_config_file *,
+ char *,
+ void (*)(struct t_config_file *, char *, char *),
+ void (*)(struct t_config_file *),
+ void (*)(struct t_config_file *));
+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 struct t_config_option *config_file_search_option (struct t_config_file *,
+ struct t_config_section *,
+ char *);
+extern int config_file_option_set (struct t_config_option *, char *);
+
+extern int config_file_read (struct t_config_file *);
+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_print_stdout (struct t_config_file *);
+extern void config_file_print_log ();
#endif /* wee-config-file.h */
diff --git a/src/core/wee-config-option.c b/src/core/wee-config-option.c
deleted file mode 100644
index 6b15b39d6..000000000
--- a/src/core/wee-config-option.c
+++ /dev/null
@@ -1,569 +0,0 @@
-/*
- * Copyright (c) 2003-2007 by FlashCode <flashcode@flashtux.org>
- * See README for License detail, AUTHORS for developers list.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-/* wee-config-option.c: manages WeeChat/protocols options */
-
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <stdlib.h>
-#include <unistd.h>
-#include <errno.h>
-#include <stdio.h>
-#include <string.h>
-#include <limits.h>
-#include <time.h>
-#include <pwd.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-
-#include "weechat.h"
-#include "wee-config-option.h"
-#include "wee-hook.h"
-#include "wee-string.h"
-#include "wee-utf8.h"
-#include "../gui/gui-chat.h"
-#include "../gui/gui-color.h"
-
-
-/*
- * config_option_get_pos_array_values: return position of a string in an array of values
- * return -1 if not found, otherwise position
- */
-
-int
-config_option_get_pos_array_values (char **array, char *string)
-{
- int i;
-
- i = 0;
- while (array[i])
- {
- if (string_strcasecmp (array[i], string) == 0)
- return i;
- i++;
- }
-
- /* string not found in array */
- return -1;
-}
-
-/*
- * config_option_list_remove: remove an item from a list for an option
- * (for options with value like: "abc:1,def:blabla")
- */
-
-void
-config_option_list_remove (char **string, char *item)
-{
- char *name, *pos, *pos2;
-
- if (!string || !(*string))
- return;
-
- name = (char *) malloc (strlen (item) + 2);
- strcpy (name, item);
- strcat (name, ":");
- pos = string_strcasestr (*string, name);
- free (name);
- if (pos)
- {
- pos2 = pos + strlen (item);
- if (pos2[0] == ':')
- {
- pos2++;
- if (pos2[0])
- {
- while (pos2[0] && (pos2[0] != ','))
- pos2++;
- if (pos2[0] == ',')
- pos2++;
- if (!pos2[0] && (pos != (*string)))
- pos--;
- strcpy (pos, pos2);
- if (!(*string)[0])
- {
- free (*string);
- *string = NULL;
- }
- else
- (*string) = (char *) realloc (*string, strlen (*string) + 1);
- }
- }
- }
-}
-
-/*
- * config_option_list_set: set an item from a list for an option
- * (for options with value like: "abc:1,def:blabla")
- */
-
-void
-config_option_list_set (char **string, char *item, char *value)
-{
- config_option_list_remove (string, item);
-
- if (!(*string))
- {
- (*string) = (char *) malloc (strlen (item) + 1 + strlen (value) + 1);
- (*string)[0] = '\0';
- }
- else
- (*string) = (char *) realloc (*string,
- strlen (*string) + 1 +
- strlen (item) + 1 + strlen (value) + 1);
-
- if ((*string)[0])
- strcat (*string, ",");
- strcat (*string, item);
- strcat (*string, ":");
- strcat (*string, value);
-}
-
-/*
- * config_option_list_get_value: return position of item value in the list
- * (for options with value like: "abc:1,def:blabla")
- */
-
-void
-config_option_list_get_value (char **string, char *item,
- char **pos_found, int *length)
-{
- char *name, *pos, *pos2, *pos_comma;
-
- *pos_found = NULL;
- *length = 0;
-
- if (!string || !(*string))
- return;
-
- name = (char *) malloc (strlen (item) + 2);
- strcpy (name, item);
- strcat (name, ":");
- pos = string_strcasestr (*string, name);
- free (name);
- if (pos)
- {
- pos2 = pos + strlen (item);
- if (pos2[0] == ':')
- {
- pos2++;
- *pos_found = pos2;
- pos_comma = strchr (pos2, ',');
- if (pos_comma)
- *length = pos_comma - pos2;
- else
- *length = strlen (pos2);
- }
- }
-}
-
-/*
- * config_option_option_get_boolean_value: get boolean value with user text
- * return: BOOL_FALSE or BOOL_TRUE
- */
-
-int
-config_option_option_get_boolean_value (char *text)
-{
- if ((string_strcasecmp (text, "on") == 0)
- || (string_strcasecmp (text, "yes") == 0)
- || (string_strcasecmp (text, "y") == 0)
- || (string_strcasecmp (text, "true") == 0)
- || (string_strcasecmp (text, "t") == 0)
- || (string_strcasecmp (text, "1") == 0))
- return BOOL_TRUE;
-
- if ((string_strcasecmp (text, "off") == 0)
- || (string_strcasecmp (text, "no") == 0)
- || (string_strcasecmp (text, "n") == 0)
- || (string_strcasecmp (text, "false") == 0)
- || (string_strcasecmp (text, "f") == 0)
- || (string_strcasecmp (text, "0") == 0))
- return BOOL_FALSE;
-
- /* invalid text */
- return -1;
-}
-
-/*
- * config_option_set: set new value for an option
- * return: 0 if success
- * -1 if error (bad value)
- */
-
-int
-config_option_set (struct t_config_option *option, char *value)
-{
- int int_value;
-
- switch (option->type)
- {
- case OPTION_TYPE_BOOLEAN:
- int_value = config_option_option_get_boolean_value (value);
- switch (int_value)
- {
- case BOOL_TRUE:
- *(option->ptr_int) = BOOL_TRUE;
- break;
- case BOOL_FALSE:
- *(option->ptr_int) = BOOL_FALSE;
- break;
- default:
- return -1;
- }
- break;
- case OPTION_TYPE_INT:
- int_value = atoi (value);
- if ((int_value < option->min) || (int_value > option->max))
- return -1;
- *(option->ptr_int) = int_value;
- break;
- case OPTION_TYPE_INT_WITH_STRING:
- int_value = config_option_get_pos_array_values (option->array_values,
- value);
- if (int_value < 0)
- return -1;
- *(option->ptr_int) = int_value;
- break;
- case OPTION_TYPE_STRING:
- if ((option->max > 0) && (utf8_strlen (value) > option->max))
- return -1;
- if (*(option->ptr_string))
- free (*(option->ptr_string));
- *(option->ptr_string) = strdup (value);
- break;
- case OPTION_TYPE_COLOR:
- if (!gui_color_assign (option->ptr_int, value))
- return -1;
- break;
- }
-
- hook_config_exec ("weechat", option->name, value);
-
- return 0;
-}
-
-/*
- * config_option_search: look for an option in a section and
- * return pointer to this option
- * If option is not found, NULL is returned
- */
-
-struct t_config_option *
-config_option_search (struct t_config_option *config_options, char *option_name)
-{
- int i;
-
- for (i = 0; config_options[i].name; i++)
- {
- /* if option found, return pointer */
- if (string_strcasecmp (config_options[i].name, option_name) == 0)
- return &config_options[i];
- }
-
- /* option not found */
- return NULL;
-}
-
-/*
- * config_option_section_option_search: look for an option and return pointer to this option
- * if option is not found, NULL is returned
- */
-
-struct t_config_option *
-config_option_section_option_search (char **config_sections,
- struct t_config_option **config_options,
- char *option_name)
-{
- int i;
- struct t_config_option *ptr_option;
-
- for (i = 0; config_sections[i]; i++)
- {
- if (config_options[i])
- {
- ptr_option = config_option_search (config_options[i],
- option_name);
- if (ptr_option)
- return ptr_option;
- }
- }
-
- /* option not found */
- return NULL;
-}
-
-/*
- * config_option_section_option_search_get_value: look for type and value of an option
- * if option is not found, NULL is returned
- */
-
-void
-config_option_section_option_search_get_value (char **config_sections,
- struct t_config_option **config_options,
- char *option_name,
- struct t_config_option **output_option,
- void **output_option_value)
-{
- struct t_config_option *ptr_option;
- void *ptr_value;
-
- ptr_option = NULL;
- ptr_value = NULL;
-
- ptr_option = config_option_section_option_search (config_sections,
- config_options,
- option_name);
- if (ptr_option)
- {
- switch (ptr_option->type)
- {
- case OPTION_TYPE_BOOLEAN:
- case OPTION_TYPE_INT:
- case OPTION_TYPE_INT_WITH_STRING:
- case OPTION_TYPE_COLOR:
- ptr_value = (void *)(ptr_option->ptr_int);
- break;
- case OPTION_TYPE_STRING:
- ptr_value = (void *)(ptr_option->ptr_string);
- break;
- }
- if (ptr_option)
- {
- *output_option = ptr_option;
- *output_option_value = ptr_value;
- }
- }
-}
-
-/*
- * config_option_section_option_set_value_by_name: set new value for an option (found by name)
- * return: 0 if success
- * -1 if bad value for option
- * -2 if option is not found
- */
-
-int
-config_option_section_option_set_value_by_name (char **config_sections,
- struct t_config_option **config_options,
- char *option_name, char *value)
-{
- struct t_config_option *ptr_option;
-
- ptr_option = config_option_section_option_search (config_sections,
- config_options,
- option_name);
- if (ptr_option)
- return config_option_set (ptr_option, value);
- else
- return -2;
-}
-
-/*
- * config_option_section_get_index: get section index by name
- * return -1 if section is not found
- */
-
-int
-config_option_section_get_index (char **config_sections, char *section_name)
-{
- int i;
-
- for (i = 0; config_sections[i]; i++)
- {
- if (string_strcasecmp (config_sections[i], section_name) == 0)
- return i;
- }
-
- /* option not found */
- return -1;
-}
-
-/*
- * config_option_section_get_name: get section name by option pointer
- */
-
-char *
-config_option_section_get_name (char **config_sections,
- struct t_config_option **config_options,
- struct t_config_option *ptr_option)
-{
- int i, j;
-
- for (i = 0; config_sections[i]; i++)
- {
- for (j = 0; config_options[i][j].name; j++)
- {
- /* if option found, return pointer to section name */
- if (ptr_option == &config_options[i][j])
- return config_sections[i];
- }
- }
-
- /* option not found */
- return NULL;
-}
-
-/*
- * config_option_section_option_set_default_values: initialize config options
- * with default values
- */
-
-void
-config_option_section_option_set_default_values (char **config_sections,
- struct t_config_option **config_options)
-{
- int i, j, int_value;
-
- for (i = 0; config_sections[i]; i++)
- {
- if (config_options[i])
- {
- for (j = 0; config_options[i][j].name; j++)
- {
- switch (config_options[i][j].type)
- {
- case OPTION_TYPE_BOOLEAN:
- case OPTION_TYPE_INT:
- *config_options[i][j].ptr_int =
- config_options[i][j].default_int;
- break;
- case OPTION_TYPE_INT_WITH_STRING:
- int_value = config_option_get_pos_array_values (
- config_options[i][j].array_values,
- config_options[i][j].default_string);
- if (int_value < 0)
- gui_chat_printf (NULL,
- _("Warning: unable to assign default int with "
- "string (\"%s\")\n"),
- config_options[i][j].default_string);
- else
- *config_options[i][j].ptr_int = int_value;
- break;
- case OPTION_TYPE_STRING:
- *config_options[i][j].ptr_string =
- strdup (config_options[i][j].default_string);
- break;
- case OPTION_TYPE_COLOR:
- if (!gui_color_assign (config_options[i][j].ptr_int,
- config_options[i][j].default_string))
- gui_chat_printf (NULL,
- _("Warning: unable to assign default color "
- "(\"%s\")\n"),
- config_options[i][j].default_string);
- break;
- }
- }
- }
- }
-}
-
-/*
- * config_option_print_stdout: print options on standard output
- */
-
-void
-config_option_print_stdout (char **config_sections,
- struct t_config_option **config_options)
-{
- int i, j, k;
-
- for (i = 0; config_sections[i]; i++)
- {
- if (config_options[i])
- {
- j = 0;
- while (config_options[i][j].name)
- {
- string_iconv_fprintf (stdout,
- "* %s:\n",
- config_options[i][j].name);
- switch (config_options[i][j].type)
- {
- case OPTION_TYPE_BOOLEAN:
- string_iconv_fprintf (stdout, _(" . type: boolean\n"));
- string_iconv_fprintf (stdout, _(" . values: 'on' or 'off'\n"));
- string_iconv_fprintf (stdout, _(" . default value: '%s'\n"),
- (config_options[i][j].default_int == BOOL_TRUE) ?
- "on" : "off");
- break;
- case OPTION_TYPE_INT:
- string_iconv_fprintf (stdout, _(" . type: integer\n"));
- string_iconv_fprintf (stdout, _(" . values: between %d and %d\n"),
- config_options[i][j].min,
- config_options[i][j].max);
- string_iconv_fprintf (stdout, _(" . default value: %d\n"),
- config_options[i][j].default_int);
- break;
- case OPTION_TYPE_INT_WITH_STRING:
- string_iconv_fprintf (stdout, _(" . type: string\n"));
- string_iconv_fprintf (stdout, _(" . values: "));
- k = 0;
- while (config_options[i][j].array_values[k])
- {
- string_iconv_fprintf (stdout, "'%s'",
- config_options[i][j].array_values[k]);
- if (config_options[i][j].array_values[k + 1])
- string_iconv_fprintf (stdout, ", ");
- k++;
- }
- string_iconv_fprintf (stdout, "\n");
- string_iconv_fprintf (stdout, _(" . default value: '%s'\n"),
- (config_options[i][j].default_string) ?
- config_options[i][j].default_string : _("empty"));
- break;
- case OPTION_TYPE_STRING:
- switch (config_options[i][j].max)
- {
- case 0:
- string_iconv_fprintf (stdout, _(" . type: string\n"));
- string_iconv_fprintf (stdout, _(" . values: any string\n"));
- break;
- case 1:
- string_iconv_fprintf (stdout, _(" . type: char\n"));
- string_iconv_fprintf (stdout, _(" . values: any char\n"));
- break;
- default:
- string_iconv_fprintf (stdout, _(" . type: string\n"));
- string_iconv_fprintf (stdout, _(" . values: any string (limit: %d chars)\n"),
- config_options[i][j].max);
- break;
- }
- string_iconv_fprintf (stdout, _(" . default value: '%s'\n"),
- (config_options[i][j].default_string) ?
- config_options[i][j].default_string : _("empty"));
- break;
- case OPTION_TYPE_COLOR:
- string_iconv_fprintf (stdout, _(" . type: color\n"));
- string_iconv_fprintf (stdout, _(" . values: color (depends on GUI used)\n"));
- string_iconv_fprintf (stdout, _(" . default value: '%s'\n"),
- (config_options[i][j].default_string) ?
- config_options[i][j].default_string : _("empty"));
- break;
- }
- string_iconv_fprintf (stdout, _(" . description: %s\n"),
- _(config_options[i][j].description));
- string_iconv_fprintf (stdout, "\n");
- j++;
- }
- }
- }
-}
diff --git a/src/core/wee-config-option.h b/src/core/wee-config-option.h
deleted file mode 100644
index 652c7d916..000000000
--- a/src/core/wee-config-option.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright (c) 2003-2007 by FlashCode <flashcode@flashtux.org>
- * See README for License detail, AUTHORS for developers list.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-
-#ifndef __WEECHAT_CONFIG_OPTION_H
-#define __WEECHAT_CONFIG_OPTION_H 1
-
-#define OPTION_TYPE_BOOLEAN 1 /* values: on/off */
-#define OPTION_TYPE_INT 2 /* values: from min to max */
-#define OPTION_TYPE_INT_WITH_STRING 3 /* values: one from **array_values */
-#define OPTION_TYPE_STRING 4 /* values: any string, may be empty */
-#define OPTION_TYPE_COLOR 5 /* values: a color struct */
-
-
-#define BOOL_FALSE 0
-#define BOOL_TRUE 1
-
-struct t_config_option
-{
- char *name;
- char *description;
- int type;
- int min, max;
- int default_int;
- char *default_string;
- char **array_values;
- int *ptr_int;
- char **ptr_string;
- void (*handler_change)();
-};
-
-extern int config_option_get_pos_array_values (char **, char *);
-extern void config_option_list_remove (char **, char *);
-extern void config_option_list_set (char **, char *, char *);
-extern void config_option_list_get_value (char **, char *, char **, int *);
-extern int config_option_option_get_boolean_value (char *);
-extern int config_option_set (struct t_config_option *, char *);
-extern struct t_config_option *config_option_search (struct t_config_option *, char *);
-extern struct t_config_option *config_option_section_option_search (char **,
- struct t_config_option **,
- char *);
-extern void config_option_section_option_search_get_value (char **, struct t_config_option **,
- char *, struct t_config_option **,
- void **);
-extern int config_option_section_option_set_value_by_name (char **,
- struct t_config_option **,
- char *, char *);
-extern int config_option_section_get_index (char **, char *);
-extern void config_option_section_option_set_default_values (char **,
- struct t_config_option **);
-extern void config_option_print_stdout (char **, struct t_config_option **);
-
-#endif /* wee-config-option.h */
diff --git a/src/core/wee-config.c b/src/core/wee-config.c
index fe1a7fa84..4de2f29c2 100644
--- a/src/core/wee-config.c
+++ b/src/core/wee-config.c
@@ -35,816 +35,160 @@
#include "weechat.h"
#include "wee-config.h"
+#include "wee-config-file.h"
#include "wee-alias.h"
#include "wee-command.h"
-#include "wee-config-file.h"
-#include "wee-list.h"
#include "wee-log.h"
-#include "wee-string.h"
#include "wee-util.h"
+#include "wee-list.h"
#include "../gui/gui-chat.h"
+#include "../gui/gui-color.h"
#include "../gui/gui-hotlist.h"
#include "../gui/gui-keyboard.h"
#include "../gui/gui-status.h"
#include "../gui/gui-window.h"
-/* config, look & feel section */
+struct t_config_file *weechat_config = NULL;
-int cfg_look_color_real_white;
-int cfg_look_save_on_exit;
-int cfg_look_set_title;
-int cfg_look_startup_logo;
-int cfg_look_startup_version;
-char *cfg_look_weechat_slogan;
-int cfg_look_scroll_amount;
-char *cfg_look_buffer_time_format;
-int cfg_look_color_nicks_number;
-int cfg_look_color_actions;
-int cfg_look_nicklist;
-int cfg_look_nicklist_position;
-char *cfg_look_nicklist_position_values[] =
-{ "left", "right", "top", "bottom", NULL };
-int cfg_look_nicklist_min_size;
-int cfg_look_nicklist_max_size;
-int cfg_look_nicklist_separator;
-int cfg_look_nickmode;
-int cfg_look_nickmode_empty;
-char *cfg_look_no_nickname;
-char *cfg_look_prefix[GUI_CHAT_PREFIX_NUMBER];
-int cfg_look_prefix_align;
-char *cfg_look_prefix_align_values[] =
-{ "none", "left", "right", NULL };
-int cfg_look_prefix_align_max;
-char *cfg_look_prefix_suffix;
-int cfg_look_align_text_offset;
-char *cfg_look_nick_completor;
-char *cfg_look_nick_completion_ignore;
-int cfg_look_nick_completion_smart;
-int cfg_look_nick_complete_first;
-int cfg_look_infobar;
-char *cfg_look_infobar_time_format;
-int cfg_look_infobar_seconds;
-int cfg_look_infobar_delay_highlight;
-int cfg_look_hotlist_names_count;
-int cfg_look_hotlist_names_level;
-int cfg_look_hotlist_names_length;
-int cfg_look_hotlist_sort;
-char *cfg_look_hotlist_sort_values[] =
-{ "group_time_asc", "group_time_desc",
- "group_number_asc", "group_number_desc",
- "number_asc", "number_desc" };
-int cfg_look_day_change;
-char *cfg_look_day_change_time_format;
-char *cfg_look_read_marker;
-char *cfg_look_input_format;
-int cfg_look_paste_max_lines;
+/* config, look & feel section */
-struct t_config_option weechat_options_look[] =
-{ { "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)"),
- OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_FALSE, NULL, NULL,
- &cfg_look_color_real_white, NULL, weechat_config_change_color },
- { "look_save_on_exit",
- N_("save configuration file on exit"),
- OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, NULL, NULL,
- &cfg_look_save_on_exit, NULL, weechat_config_change_save_on_exit },
- { "look_set_title",
- N_("set title for window (terminal for Curses GUI) with name and version"),
- OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, NULL, NULL,
- &cfg_look_set_title, NULL, weechat_config_change_title },
- { "look_startup_logo",
- N_("display WeeChat logo at startup"),
- OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, NULL, NULL,
- &cfg_look_startup_logo, NULL, weechat_config_change_noop },
- { "look_startup_version",
- N_("display WeeChat version at startup"),
- OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, NULL, NULL,
- &cfg_look_startup_version, NULL, weechat_config_change_noop },
- { "look_weechat_slogan",
- N_("WeeChat slogan (if empty, slogan is not used)"),
- OPTION_TYPE_STRING, 0, 0, 0, "the geekest IRC client!", NULL,
- NULL, &cfg_look_weechat_slogan, weechat_config_change_noop },
- { "look_scroll_amount",
- N_("how many lines to scroll by with scroll_up and scroll_down"),
- OPTION_TYPE_INT, 1, INT_MAX, 3, NULL, NULL,
- &cfg_look_scroll_amount, NULL, weechat_config_change_buffer_content },
- { "look_buffer_time_format",
- N_("time format for buffers"),
- OPTION_TYPE_STRING, 0, 0, 0, "[%H:%M:%S]", NULL,
- NULL, &cfg_look_buffer_time_format, weechat_config_change_buffer_time_format },
- { "look_color_nicks_number",
- N_("number of colors to use for nicks colors"),
- OPTION_TYPE_INT, 1, 10, 10, NULL, NULL,
- &cfg_look_color_nicks_number, NULL, weechat_config_change_nicks_colors },
- { "look_color_actions",
- N_("display actions with different colors"),
- OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, NULL, NULL,
- &cfg_look_color_actions, NULL, weechat_config_change_noop },
- { "look_nicklist",
- N_("display nicklist window (for channel windows)"),
- OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, NULL, NULL,
- &cfg_look_nicklist, NULL, weechat_config_change_buffers },
- { "look_nicklist_position",
- N_("nicklist position (top, left, right (default), bottom)"),
- OPTION_TYPE_INT_WITH_STRING, 0, 0, 0, "right", cfg_look_nicklist_position_values,
- &cfg_look_nicklist_position, NULL, weechat_config_change_buffers },
- { "look_nicklist_min_size",
- N_("min size for nicklist (width or height, depending on look_nicklist_position "
- "(0 = no min size))"),
- OPTION_TYPE_INT, 0, 100, 0, NULL, NULL,
- &cfg_look_nicklist_min_size, NULL, weechat_config_change_buffers },
- { "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))"),
- OPTION_TYPE_INT, 0, 100, 0, NULL, NULL,
- &cfg_look_nicklist_max_size, NULL, weechat_config_change_buffers },
- { "look_nicklist_separator",
- N_("separator between chat and nicklist"),
- OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, NULL, NULL,
- &cfg_look_nicklist_separator, NULL, weechat_config_change_buffers },
- { "look_no_nickname",
- N_("text to display instead of nick when not connected"),
- OPTION_TYPE_STRING, 0, 0, 0, "-cmd-", NULL,
- NULL, &cfg_look_no_nickname, weechat_config_change_buffer_content },
- { "look_nickmode",
- N_("display nick mode ((half)op/voice) before each nick"),
- OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, NULL, NULL,
- &cfg_look_nickmode, NULL, weechat_config_change_buffers },
- { "look_nickmode_empty",
- N_("display space if nick mode is not (half)op/voice"),
- OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_FALSE, NULL, NULL,
- &cfg_look_nickmode_empty, NULL, weechat_config_change_buffers },
- { "look_prefix_info",
- N_("prefix for info messages"),
- OPTION_TYPE_STRING, 0, 0, 0, "-=-", NULL,
- NULL, &cfg_look_prefix[GUI_CHAT_PREFIX_INFO], weechat_config_change_prefix },
- { "look_prefix_error",
- N_("prefix for error messages"),
- OPTION_TYPE_STRING, 0, 0, 0, "=!=", NULL,
- NULL, &cfg_look_prefix[GUI_CHAT_PREFIX_ERROR], weechat_config_change_prefix },
- { "look_prefix_network",
- N_("prefix for network messages"),
- OPTION_TYPE_STRING, 0, 0, 0, "-@-", NULL,
- NULL, &cfg_look_prefix[GUI_CHAT_PREFIX_NETWORK], weechat_config_change_prefix },
- { "look_prefix_action",
- N_("prefix for action messages"),
- OPTION_TYPE_STRING, 0, 0, 0, "-*-", NULL,
- NULL, &cfg_look_prefix[GUI_CHAT_PREFIX_ACTION], weechat_config_change_prefix },
- { "look_prefix_join",
- N_("prefix for join messages"),
- OPTION_TYPE_STRING, 0, 0, 0, "-->", NULL,
- NULL, &cfg_look_prefix[GUI_CHAT_PREFIX_JOIN], weechat_config_change_prefix },
- { "look_prefix_quit",
- N_("prefix for quit messages"),
- OPTION_TYPE_STRING, 0, 0, 0, "<--", NULL,
- NULL, &cfg_look_prefix[GUI_CHAT_PREFIX_QUIT], weechat_config_change_prefix },
- { "look_prefix_align",
- N_("prefix alignment (none, left, right))"),
- OPTION_TYPE_INT_WITH_STRING, 0, 0, 0, "right", cfg_look_prefix_align_values,
- &cfg_look_prefix_align, NULL, weechat_config_change_buffers },
- { "look_prefix_align_max",
- N_("max size for prefix (0 = no max size)"),
- OPTION_TYPE_INT, 0, 64, 0, NULL, NULL,
- &cfg_look_prefix_align_max, NULL, weechat_config_change_buffers },
- { "look_prefix_suffix",
- N_("string displayed after prefix"),
- OPTION_TYPE_STRING, 0, 0, 0, "|", NULL,
- NULL, &cfg_look_prefix_suffix, weechat_config_change_buffers },
- { "look_align_text_offset",
- N_("offset for aligning lines of messages (except first lines), default "
- "is -1 (align after prefix), a null or positive value is offset after "
- "beginning of line"),
- OPTION_TYPE_INT, -1, 64, -1, NULL, NULL,
- &cfg_look_align_text_offset, NULL, weechat_config_change_buffers },
- { "look_nick_completor",
- N_("the string inserted after nick completion"),
- OPTION_TYPE_STRING, 0, 0, 0, ":", NULL,
- NULL, &cfg_look_nick_completor, weechat_config_change_noop },
- { "look_nick_completion_ignore",
- N_("chars ignored for nick completion"),
- OPTION_TYPE_STRING, 0, 0, 0, "[]-^", NULL,
- NULL, &cfg_look_nick_completion_ignore, weechat_config_change_noop },
- { "look_nick_completion_smart",
- N_("smart completion for nicks (completes with last speakers first)"),
- OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, NULL, NULL,
- &cfg_look_nick_completion_smart, NULL, weechat_config_change_noop },
- { "look_nick_complete_first",
- N_("complete only with first nick found"),
- OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_FALSE, NULL, NULL,
- &cfg_look_nick_complete_first, NULL, weechat_config_change_noop },
- { "look_infobar",
- N_("enable info bar"),
- OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, NULL, NULL,
- &cfg_look_infobar, NULL, weechat_config_change_buffers },
- { "look_infobar_time_format",
- N_("time format for time in infobar"),
- OPTION_TYPE_STRING, 0, 0, 0, "%B, %A %d %Y", NULL,
- NULL, &cfg_look_infobar_time_format, weechat_config_change_buffer_content },
- { "look_infobar_seconds",
- N_("display seconds in infobar time"),
- OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, NULL, NULL,
- &cfg_look_infobar_seconds, NULL, weechat_config_change_buffer_content },
- { "look_infobar_delay_highlight",
- N_("delay (in seconds) for highlight messages in infobar "
- "(0 = disable highlight notifications in infobar)"),
- OPTION_TYPE_INT, 0, INT_MAX, 7, NULL, NULL,
- &cfg_look_infobar_delay_highlight, NULL, weechat_config_change_noop },
- { "look_hotlist_names_count",
- N_("max number of names in hotlist (0 = no name displayed, only buffer numbers)"),
- OPTION_TYPE_INT, 0, 32, 3, NULL, NULL,
- &cfg_look_hotlist_names_count, NULL, weechat_config_change_buffer_content },
- { "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)"),
- OPTION_TYPE_INT, 1, 15, 12, NULL, NULL,
- &cfg_look_hotlist_names_level, NULL, weechat_config_change_buffer_content },
- { "look_hotlist_names_length",
- N_("max length of names in hotlist (0 = no limit)"),
- OPTION_TYPE_INT, 0, 32, 0, NULL, NULL,
- &cfg_look_hotlist_names_length, NULL, weechat_config_change_buffer_content },
- { "look_hotlist_sort",
- N_("hotlist sort type (group_time_asc (default), group_time_desc, "
- "group_number_asc, group_number_desc, number_asc, number_desc)"),
- OPTION_TYPE_INT_WITH_STRING, 0, 0, 0, "group_time_asc", cfg_look_hotlist_sort_values,
- &cfg_look_hotlist_sort, NULL, weechat_config_change_hotlist },
- { "look_day_change",
- N_("display special message when day changes"),
- OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, NULL, NULL,
- &cfg_look_day_change, NULL, weechat_config_change_noop },
- { "look_day_change_time_format",
- N_("time format for date displayed when day changed"),
- OPTION_TYPE_STRING, 0, 0, 0, "%a, %d %b %Y", NULL,
- NULL, &cfg_look_day_change_time_format, weechat_config_change_noop },
- { "look_read_marker",
- N_("use a marker on servers/channels to show first unread line"),
- OPTION_TYPE_STRING, 0, 1, 0, " ", NULL,
- NULL, &cfg_look_read_marker, weechat_config_change_read_marker },
- { "look_input_format",
- N_("format for input prompt ('%c' is replaced by channel or server, "
- "'%n' by nick and '%m' by nick modes)"),
- OPTION_TYPE_STRING, 0, 0, 0, "[%n(%m)] ", NULL,
- NULL, &cfg_look_input_format, weechat_config_change_buffer_content },
- { "look_paste_max_lines",
- N_("max number of lines for paste without asking user (0 = disable this feature)"),
- OPTION_TYPE_INT, 0, INT_MAX, 3, NULL, NULL,
- &cfg_look_paste_max_lines, NULL, weechat_config_change_noop },
- { NULL, NULL, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL }
-};
+struct t_config_option *config_look_color_real_white;
+struct t_config_option *config_look_save_on_exit;
+struct t_config_option *config_look_set_title;
+struct t_config_option *config_look_startup_logo;
+struct t_config_option *config_look_startup_version;
+struct t_config_option *config_look_weechat_slogan;
+struct t_config_option *config_look_scroll_amount;
+struct t_config_option *config_look_buffer_time_format;
+struct t_config_option *config_look_color_nicks_number;
+struct t_config_option *config_look_nicklist;
+struct t_config_option *config_look_nicklist_position;
+struct t_config_option *config_look_nicklist_min_size;
+struct t_config_option *config_look_nicklist_max_size;
+struct t_config_option *config_look_nicklist_separator;
+struct t_config_option *config_look_nickmode;
+struct t_config_option *config_look_nickmode_empty;
+struct t_config_option *config_look_no_nickname;
+struct t_config_option *config_look_prefix[GUI_CHAT_PREFIX_NUMBER];
+struct t_config_option *config_look_prefix_align;
+struct t_config_option *config_look_prefix_align_max;
+struct t_config_option *config_look_prefix_suffix;
+struct t_config_option *config_look_nick_completor;
+struct t_config_option *config_look_nick_completion_ignore;
+struct t_config_option *config_look_nick_completion_smart;
+struct t_config_option *config_look_nick_complete_first;
+struct t_config_option *config_look_infobar;
+struct t_config_option *config_look_infobar_time_format;
+struct t_config_option *config_look_infobar_seconds;
+struct t_config_option *config_look_infobar_delay_highlight;
+struct t_config_option *config_look_hotlist_names_count;
+struct t_config_option *config_look_hotlist_names_level;
+struct t_config_option *config_look_hotlist_names_length;
+struct t_config_option *config_look_hotlist_sort;
+struct t_config_option *config_look_day_change;
+struct t_config_option *config_look_day_change_time_format;
+struct t_config_option *config_look_read_marker;
+struct t_config_option *config_look_input_format;
+struct t_config_option *config_look_paste_max_lines;
/* config, colors section */
-int cfg_col_separator;
-int cfg_col_title;
-int cfg_col_title_bg;
-int cfg_col_title_more;
-int cfg_col_chat;
-int cfg_col_chat_bg;
-int cfg_col_chat_time;
-int cfg_col_chat_time_delimiters;
-int cfg_col_chat_prefix[GUI_CHAT_PREFIX_NUMBER];
-int cfg_col_chat_prefix_more;
-int cfg_col_chat_prefix_suffix;
-int cfg_col_chat_buffer;
-int cfg_col_chat_server;
-int cfg_col_chat_channel;
-int cfg_col_chat_nick;
-int cfg_col_chat_nick_self;
-int cfg_col_chat_nick_other;
-int cfg_col_chat_nick_colors[GUI_COLOR_NICK_NUMBER];
-int cfg_col_chat_host;
-int cfg_col_chat_delimiters;
-int cfg_col_chat_highlight;
-int cfg_col_chat_read_marker;
-int cfg_col_chat_read_marker_bg;
-int cfg_col_status;
-int cfg_col_status_bg;
-int cfg_col_status_delimiters;
-int cfg_col_status_channel;
-int cfg_col_status_data_msg;
-int cfg_col_status_data_private;
-int cfg_col_status_data_highlight;
-int cfg_col_status_data_other;
-int cfg_col_status_more;
-int cfg_col_infobar;
-int cfg_col_infobar_bg;
-int cfg_col_infobar_delimiters;
-int cfg_col_infobar_highlight;
-int cfg_col_infobar_bg;
-int cfg_col_input;
-int cfg_col_input_bg;
-int cfg_col_input_server;
-int cfg_col_input_channel;
-int cfg_col_input_nick;
-int cfg_col_input_delimiters;
-int cfg_col_input_text_not_found;
-int cfg_col_input_actions;
-int cfg_col_nicklist;
-int cfg_col_nicklist_bg;
-int cfg_col_nicklist_away;
-int cfg_col_nicklist_prefix1;
-int cfg_col_nicklist_prefix2;
-int cfg_col_nicklist_prefix3;
-int cfg_col_nicklist_prefix4;
-int cfg_col_nicklist_prefix5;
-int cfg_col_nicklist_more;
-int cfg_col_nicklist_separator;
-int cfg_col_info;
-int cfg_col_info_bg;
-int cfg_col_info_waiting;
-int cfg_col_info_connecting;
-int cfg_col_info_active;
-int cfg_col_info_done;
-int cfg_col_info_failed;
-int cfg_col_info_aborted;
-
-struct t_config_option weechat_options_colors[] =
-{ /* general color settings */
- { "col_separator",
- N_("color for window separators (when splited)"),
- OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_SEPARATOR, "blue", NULL,
- &cfg_col_separator, NULL, weechat_config_change_color },
-
- /* title window */
- { "col_title",
- N_("color for title bar"),
- OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_TITLE, "default", NULL,
- &cfg_col_title, NULL, weechat_config_change_color },
- { "col_title_bg",
- N_("background color for title bar"),
- OPTION_TYPE_COLOR, 0, 0, -1, "blue", NULL,
- &cfg_col_title_bg, NULL, weechat_config_change_color },
- { "col_title_more",
- N_("color for '+' when scrolling title"),
- OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_TITLE_MORE, "lightmagenta", NULL,
- &cfg_col_title_more, NULL, weechat_config_change_color },
-
- /* chat window */
- { "col_chat",
- N_("color for chat text"),
- OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT, "default", NULL,
- &cfg_col_chat, NULL, weechat_config_change_color },
- { "col_chat_bg",
- N_("background for chat text"),
- OPTION_TYPE_COLOR, 0, 0, -1, "default", NULL,
- &cfg_col_chat_bg, NULL, weechat_config_change_color },
- { "col_chat_time",
- N_("color for time in chat window"),
- OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT_TIME, "default", NULL,
- &cfg_col_chat_time, NULL, weechat_config_change_color },
- { "col_chat_time_delimiters",
- N_("color for time delimiters)"),
- OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT_TIME_DELIMITERS, "brown", NULL,
- &cfg_col_chat_time_delimiters, NULL, weechat_config_change_color },
- { "col_chat_prefix_info",
- N_("color for info prefix"),
- OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT_PREFIX_INFO, "lightcyan", NULL,
- &cfg_col_chat_prefix[GUI_CHAT_PREFIX_INFO], NULL, weechat_config_change_color },
- { "col_chat_prefix_error",
- N_("color for error prefix"),
- OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT_PREFIX_ERROR, "yellow", NULL,
- &cfg_col_chat_prefix[GUI_CHAT_PREFIX_ERROR], NULL, weechat_config_change_color },
- { "col_chat_prefix_network",
- N_("color for network prefix"),
- OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT_PREFIX_NETWORK, "lightmagenta", NULL,
- &cfg_col_chat_prefix[GUI_CHAT_PREFIX_NETWORK], NULL, weechat_config_change_color },
- { "col_chat_prefix_action",
- N_("color for action prefix"),
- OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT_PREFIX_ACTION, "white", NULL,
- &cfg_col_chat_prefix[GUI_CHAT_PREFIX_ACTION], NULL, weechat_config_change_color },
- { "col_chat_prefix_join",
- N_("color for join prefix"),
- OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT_PREFIX_JOIN, "lightgreen", NULL,
- &cfg_col_chat_prefix[GUI_CHAT_PREFIX_JOIN], NULL, weechat_config_change_color },
- { "col_chat_prefix_quit",
- N_("color for quit prefix"),
- OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT_PREFIX_QUIT, "lightred", NULL,
- &cfg_col_chat_prefix[GUI_CHAT_PREFIX_QUIT], NULL, weechat_config_change_color },
- { "col_chat_prefix_more",
- N_("color for '+' when prefix is too long"),
- OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT_PREFIX_MORE, "lightmagenta", NULL,
- &cfg_col_chat_prefix_more, NULL, weechat_config_change_color },
- { "col_chat_prefix_suffix",
- N_("color for text after prefix"),
- OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT_PREFIX_SUFFIX, "green", NULL,
- &cfg_col_chat_prefix_suffix, NULL, weechat_config_change_color },
- { "col_chat_buffer",
- N_("color for buffer names"),
- OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT_BUFFER, "white", NULL,
- &cfg_col_chat_buffer, NULL, weechat_config_change_color },
- { "col_chat_server",
- N_("color for server names"),
- OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT_SERVER, "brown", NULL,
- &cfg_col_chat_server, NULL, weechat_config_change_color },
- { "col_chat_channel",
- N_("color for channel names"),
- OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT_CHANNEL, "white", NULL,
- &cfg_col_chat_channel, NULL, weechat_config_change_color },
- { "col_chat_nick",
- N_("color for nicks"),
- OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT_NICK, "lightcyan", NULL,
- &cfg_col_chat_nick, NULL, weechat_config_change_color },
- { "col_chat_nick_self",
- N_("color for local nick"),
- OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT_NICK_SELF, "white", NULL,
- &cfg_col_chat_nick_self, NULL, weechat_config_change_color },
- { "col_chat_nick_other",
- N_("color for other nick in private buffer"),
- OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT_NICK_OTHER, "default", NULL,
- &cfg_col_chat_nick_other, NULL, weechat_config_change_color },
- { "col_chat_nick_color1",
- N_("color #1 for nick"),
- OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT_NICK1, "cyan", NULL,
- &cfg_col_chat_nick_colors[0], NULL, weechat_config_change_color },
- { "col_chat_nick_color2",
- N_("color #2 for nick"),
- OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT_NICK2, "magenta", NULL,
- &cfg_col_chat_nick_colors[1], NULL, weechat_config_change_color },
- { "col_chat_nick_color3",
- N_("color #3 for nick"),
- OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT_NICK3, "green", NULL,
- &cfg_col_chat_nick_colors[2], NULL, weechat_config_change_color },
- { "col_chat_nick_color4",
- N_("color #4 for nick"),
- OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT_NICK4, "brown", NULL,
- &cfg_col_chat_nick_colors[3], NULL, weechat_config_change_color },
- { "col_chat_nick_color5",
- N_("color #5 for nick"),
- OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT_NICK5, "lightblue", NULL,
- &cfg_col_chat_nick_colors[4], NULL, weechat_config_change_color },
- { "col_chat_nick_color6",
- N_("color #6 for nick"),
- OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT_NICK6, "default", NULL,
- &cfg_col_chat_nick_colors[5], NULL, weechat_config_change_color },
- { "col_chat_nick_color7",
- N_("color #7 for nick"),
- OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT_NICK7, "lightcyan", NULL,
- &cfg_col_chat_nick_colors[6], NULL, weechat_config_change_color },
- { "col_chat_nick_color8",
- N_("color #8 for nick"),
- OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT_NICK8, "lightmagenta", NULL,
- &cfg_col_chat_nick_colors[7], NULL, weechat_config_change_color },
- { "col_chat_nick_color9",
- N_("color #9 for nick"),
- OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT_NICK9, "lightgreen", NULL,
- &cfg_col_chat_nick_colors[8], NULL, weechat_config_change_color },
- { "col_chat_nick_color10",
- N_("color #10 for nick"),
- OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT_NICK10, "blue", NULL,
- &cfg_col_chat_nick_colors[9], NULL, weechat_config_change_color },
- { "col_chat_host",
- N_("color for hostnames"),
- OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT_HOST, "cyan", NULL,
- &cfg_col_chat_host, NULL, weechat_config_change_color },
- { "col_chat_delimiters",
- N_("color for delimiters"),
- OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT_DELIMITERS, "green", NULL,
- &cfg_col_chat_delimiters, NULL, weechat_config_change_color },
- { "col_chat_highlight",
- N_("color for highlighted nick"),
- OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT_HIGHLIGHT, "yellow", NULL,
- &cfg_col_chat_highlight, NULL, weechat_config_change_color },
- { "col_chat_read_marker",
- N_("color for unread data marker"),
- OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT_READ_MARKER, "yellow", NULL,
- &cfg_col_chat_read_marker, NULL, weechat_config_change_color },
- { "col_chat_read_marker_bg",
- N_("background color for unread data marker"),
- OPTION_TYPE_COLOR, 0, 0, -1, "magenta", NULL,
- &cfg_col_chat_read_marker_bg, NULL, weechat_config_change_color },
-
- /* status window */
- { "col_status",
- N_("color for status bar"),
- OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_STATUS, "default", NULL,
- &cfg_col_status, NULL, weechat_config_change_color },
- { "col_status_bg",
- N_("background color for status bar"),
- OPTION_TYPE_COLOR, 0, 0, -1, "blue", NULL,
- &cfg_col_status_bg, NULL, weechat_config_change_color },
- { "col_status_delimiters",
- N_("color for status bar delimiters"),
- OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_STATUS_DELIMITERS, "cyan", NULL,
- &cfg_col_status_delimiters, NULL, weechat_config_change_color },
- { "col_status_channel",
- N_("color for current channel in status bar"),
- OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_STATUS_CHANNEL, "white", NULL,
- &cfg_col_status_channel, NULL, weechat_config_change_color },
- { "col_status_data_msg",
- N_("color for window with new messages (status bar)"),
- OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_STATUS_DATA_MSG, "yellow", NULL,
- &cfg_col_status_data_msg, NULL, weechat_config_change_color },
- { "col_status_data_private",
- N_("color for window with private message (status bar)"),
- OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_STATUS_DATA_PRIVATE, "lightmagenta", NULL,
- &cfg_col_status_data_private, NULL, weechat_config_change_color },
- { "col_status_data_highlight",
- N_("color for window with highlight (status bar)"),
- OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_STATUS_DATA_HIGHLIGHT, "lightred", NULL,
- &cfg_col_status_data_highlight, NULL, weechat_config_change_color },
- { "col_status_data_other",
- N_("color for window with new data (not messages) (status bar)"),
- OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_STATUS_DATA_OTHER, "default", NULL,
- &cfg_col_status_data_other, NULL, weechat_config_change_color },
- { "col_status_more",
- N_("color for window with new data (status bar)"),
- OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_STATUS_MORE, "white", NULL,
- &cfg_col_status_more, NULL, weechat_config_change_color },
-
- /* infobar window */
- { "col_infobar",
- N_("color for info bar text"),
- OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_INFOBAR, "black", NULL,
- &cfg_col_infobar, NULL, weechat_config_change_color },
- { "col_infobar_bg",
- N_("background color for info bar text"),
- OPTION_TYPE_COLOR, 0, 0, -1, "cyan", NULL,
- &cfg_col_infobar_bg, NULL, weechat_config_change_color },
- { "col_infobar_delimiters",
- N_("color for infobar delimiters"),
- OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_INFOBAR_DELIMITERS, "blue", NULL,
- &cfg_col_infobar_delimiters, NULL, weechat_config_change_color },
- { "col_infobar_highlight",
- N_("color for info bar highlight notification"),
- OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_INFOBAR_HIGHLIGHT, "white", NULL,
- &cfg_col_infobar_highlight, NULL, weechat_config_change_color },
-
- /* input window */
- { "col_input",
- N_("color for input text"),
- OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_INPUT, "default", NULL,
- &cfg_col_input, NULL, weechat_config_change_color },
- { "col_input_bg",
- N_("background color for input text"),
- OPTION_TYPE_COLOR, 0, 0, -1, "default", NULL,
- &cfg_col_input_bg, NULL, weechat_config_change_color },
- { "col_input_server",
- N_("color for input text (server name)"),
- OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_INPUT_SERVER, "brown", NULL,
- &cfg_col_input_server, NULL, weechat_config_change_color },
- { "col_input_channel",
- N_("color for input text (channel name)"),
- OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_INPUT_CHANNEL, "white", NULL,
- &cfg_col_input_channel, NULL, weechat_config_change_color },
- { "col_input_nick",
- N_("color for input text (nick name)"),
- OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_INPUT_NICK, "lightcyan", NULL,
- &cfg_col_input_nick, NULL, weechat_config_change_color },
- { "col_input_delimiters",
- N_("color for input text (delimiters)"),
- OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_INPUT_DELIMITERS, "cyan", NULL,
- &cfg_col_input_delimiters, NULL, weechat_config_change_color },
- { "col_input_text_not_found",
- N_("color for text not found"),
- OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_INPUT_TEXT_NOT_FOUND, "red", NULL,
- &cfg_col_input_text_not_found, NULL, weechat_config_change_color },
- { "col_input_actions",
- N_("color for actions in input window"),
- OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_INPUT_ACTIONS, "lightgreen", NULL,
- &cfg_col_input_actions, NULL, weechat_config_change_color },
-
- /* nicklist window */
- { "col_nicklist",
- N_("color for nicklist"),
- OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_NICKLIST, "default", NULL,
- &cfg_col_nicklist, NULL, weechat_config_change_color },
- { "col_nicklist_bg",
- N_("background color for nicklist"),
- OPTION_TYPE_COLOR, 0, 0, -1, "default", NULL,
- &cfg_col_nicklist_bg, NULL, weechat_config_change_color },
- { "col_nicklist_away",
- N_("color for away nicknames"),
- OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_NICKLIST_AWAY, "cyan", NULL,
- &cfg_col_nicklist_away, NULL, weechat_config_change_color },
- { "col_nicklist_prefix1",
- N_("color for prefix 1"),
- OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_NICKLIST_PREFIX1, "lightgreen", NULL,
- &cfg_col_nicklist_prefix1, NULL, weechat_config_change_color },
- { "col_nicklist_prefix2",
- N_("color for prefix 2"),
- OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_NICKLIST_PREFIX2, "lightmagenta", NULL,
- &cfg_col_nicklist_prefix2, NULL, weechat_config_change_color },
- { "col_nicklist_prefix3",
- N_("color for prefix 3"),
- OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_NICKLIST_PREFIX3, "yellow", NULL,
- &cfg_col_nicklist_prefix3, NULL, weechat_config_change_color },
- { "col_nicklist_prefix4",
- N_("color for prefix 4"),
- OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_NICKLIST_PREFIX4, "blue", NULL,
- &cfg_col_nicklist_prefix4, NULL, weechat_config_change_color },
- { "col_nicklist_prefix5",
- N_("color for prefix 5"),
- OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_NICKLIST_PREFIX5, "brown", NULL,
- &cfg_col_nicklist_prefix5, NULL, weechat_config_change_color },
- { "col_nicklist_more",
- N_("color for '+' when scrolling nicks (nicklist)"),
- OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_NICKLIST_MORE, "lightmagenta", NULL,
- &cfg_col_nicklist_more, NULL, weechat_config_change_color },
- { "col_nicklist_separator",
- N_("color for nicklist separator"),
- OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_NICKLIST_SEPARATOR, "blue", NULL,
- &cfg_col_nicklist_separator, NULL, weechat_config_change_color },
-
- /* status info (for example: file transfers) */
- { "col_info",
- N_("color for status info"),
- OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_INFO, "default", NULL,
- &cfg_col_info, NULL, weechat_config_change_color },
- { "col_info_bg",
- N_("background color for status info"),
- OPTION_TYPE_COLOR, 0, 0, -1, "default", NULL,
- &cfg_col_info_bg, NULL, weechat_config_change_color },
- { "col_info_waiting",
- N_("color for \"waiting\" status info"),
- OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_INFO_WAITING, "lightcyan", NULL,
- &cfg_col_info_waiting, NULL, weechat_config_change_color },
- { "col_info_connecting",
- N_("color for \"connecting\" status info"),
- OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_INFO_CONNECTING, "yellow", NULL,
- &cfg_col_info_connecting, NULL, weechat_config_change_color },
- { "col_info_active",
- N_("color for \"active\" status info"),
- OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_INFO_ACTIVE, "lightblue", NULL,
- &cfg_col_info_active, NULL, weechat_config_change_color },
- { "col_info_done",
- N_("color for \"done\" status info"),
- OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_INFO_DONE, "lightgreen", NULL,
- &cfg_col_info_done, NULL, weechat_config_change_color },
- { "col_info_failed",
- N_("color for \"failed\" status info"),
- OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_INFO_FAILED, "lightred", NULL,
- &cfg_col_info_failed, NULL, weechat_config_change_color },
- { "col_info_aborted",
- N_("color for \"aborted\" status info"),
- OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_INFO_ABORTED, "lightred", NULL,
- &cfg_col_info_aborted, NULL, weechat_config_change_color },
-
- { NULL, NULL, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL }
-};
+struct t_config_option *config_color_separator;
+struct t_config_option *config_color_title;
+struct t_config_option *config_color_title_bg;
+struct t_config_option *config_color_title_more;
+struct t_config_option *config_color_chat;
+struct t_config_option *config_color_chat_bg;
+struct t_config_option *config_color_chat_time;
+struct t_config_option *config_color_chat_time_delimiters;
+struct t_config_option *config_color_chat_prefix[GUI_CHAT_PREFIX_NUMBER];
+struct t_config_option *config_color_chat_prefix_more;
+struct t_config_option *config_color_chat_prefix_suffix;
+struct t_config_option *config_color_chat_buffer;
+struct t_config_option *config_color_chat_server;
+struct t_config_option *config_color_chat_channel;
+struct t_config_option *config_color_chat_nick;
+struct t_config_option *config_color_chat_nick_self;
+struct t_config_option *config_color_chat_nick_other;
+struct t_config_option *config_color_chat_nick_colors[GUI_COLOR_NICK_NUMBER];
+struct t_config_option *config_color_chat_host;
+struct t_config_option *config_color_chat_delimiters;
+struct t_config_option *config_color_chat_highlight;
+struct t_config_option *config_color_chat_read_marker;
+struct t_config_option *config_color_chat_read_marker_bg;
+struct t_config_option *config_color_status;
+struct t_config_option *config_color_status_bg;
+struct t_config_option *config_color_status_delimiters;
+struct t_config_option *config_color_status_channel;
+struct t_config_option *config_color_status_data_msg;
+struct t_config_option *config_color_status_data_private;
+struct t_config_option *config_color_status_data_highlight;
+struct t_config_option *config_color_status_data_other;
+struct t_config_option *config_color_status_more;
+struct t_config_option *config_color_infobar;
+struct t_config_option *config_color_infobar_bg;
+struct t_config_option *config_color_infobar_delimiters;
+struct t_config_option *config_color_infobar_highlight;
+struct t_config_option *config_color_infobar_bg;
+struct t_config_option *config_color_input;
+struct t_config_option *config_color_input_bg;
+struct t_config_option *config_color_input_server;
+struct t_config_option *config_color_input_channel;
+struct t_config_option *config_color_input_nick;
+struct t_config_option *config_color_input_delimiters;
+struct t_config_option *config_color_input_text_not_found;
+struct t_config_option *config_color_input_actions;
+struct t_config_option *config_color_nicklist;
+struct t_config_option *config_color_nicklist_bg;
+struct t_config_option *config_color_nicklist_away;
+struct t_config_option *config_color_nicklist_prefix1;
+struct t_config_option *config_color_nicklist_prefix2;
+struct t_config_option *config_color_nicklist_prefix3;
+struct t_config_option *config_color_nicklist_prefix4;
+struct t_config_option *config_color_nicklist_prefix5;
+struct t_config_option *config_color_nicklist_more;
+struct t_config_option *config_color_nicklist_separator;
+struct t_config_option *config_color_info;
+struct t_config_option *config_color_info_bg;
+struct t_config_option *config_color_info_waiting;
+struct t_config_option *config_color_info_connecting;
+struct t_config_option *config_color_info_active;
+struct t_config_option *config_color_info_done;
+struct t_config_option *config_color_info_failed;
+struct t_config_option *config_color_info_aborted;
/* config, history section */
-int cfg_history_max_lines;
-int cfg_history_max_commands;
-int cfg_history_display_default;
-
-struct t_config_option weechat_options_history[] =
-{ { "history_max_lines",
- N_("maximum number of lines in history "
- "for one server/channel/private window (0 = unlimited)"),
- OPTION_TYPE_INT, 0, INT_MAX, 4096, NULL, NULL,
- &cfg_history_max_lines, NULL, weechat_config_change_noop },
- { "history_max_commands",
- N_("maximum number of user commands in history (0 = unlimited)"),
- OPTION_TYPE_INT, 0, INT_MAX, 100, NULL, NULL,
- &cfg_history_max_commands, NULL, weechat_config_change_noop },
- { "history_display_default",
- N_("maximum number of commands to display by default in history listing "
- "(0 = unlimited)"),
- OPTION_TYPE_INT, 0, INT_MAX, 5, NULL, NULL,
- &cfg_history_display_default, NULL, weechat_config_change_noop },
- { NULL, NULL, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL }
-};
+struct t_config_option *config_history_max_lines;
+struct t_config_option *config_history_max_commands;
+struct t_config_option *config_history_display_default;
/* config, proxy section */
-int cfg_proxy_use;
-int cfg_proxy_type;
-int cfg_proxy_ipv6;
-char *cfg_proxy_type_values[] =
-{ "http", "socks4", "socks5", NULL };
-char *cfg_proxy_address;
-int cfg_proxy_port;
-char *cfg_proxy_username;
-char *cfg_proxy_password;
-
-struct t_config_option weechat_options_proxy[] =
-{ { "proxy_use",
- N_("use a proxy server to connect to irc server"),
- OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_FALSE, NULL, NULL,
- &cfg_proxy_use, NULL, weechat_config_change_noop },
- { "proxy_type",
- N_("proxy type (http (default), socks4, socks5)"),
- OPTION_TYPE_INT_WITH_STRING, 0, 0, 0, "http", cfg_proxy_type_values,
- &cfg_proxy_type, NULL, weechat_config_change_noop },
- { "proxy_ipv6",
- N_("connect to proxy in ipv6"),
- OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_FALSE, NULL, NULL,
- &cfg_proxy_ipv6, NULL, weechat_config_change_noop },
- { "proxy_address",
- N_("proxy server address (IP or hostname)"),
- OPTION_TYPE_STRING, 0, 0, 0, "", NULL,
- NULL, &cfg_proxy_address, weechat_config_change_noop },
- { "proxy_port",
- N_("port for connecting to proxy server"),
- OPTION_TYPE_INT, 0, 65535, 3128, NULL, NULL,
- &cfg_proxy_port, NULL, weechat_config_change_noop },
- { "proxy_username",
- N_("username for proxy server"),
- OPTION_TYPE_STRING, 0, 0, 0, "", NULL,
- NULL, &cfg_proxy_username, weechat_config_change_noop },
- { "proxy_password",
- N_("password for proxy server"),
- OPTION_TYPE_STRING, 0, 0, 0, "", NULL,
- NULL, &cfg_proxy_password, weechat_config_change_noop },
- { NULL, NULL, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL }
-};
+struct t_config_option *config_proxy_use;
+struct t_config_option *config_proxy_type;
+struct t_config_option *config_proxy_ipv6;
+struct t_config_option *config_proxy_address;
+struct t_config_option *config_proxy_port;
+struct t_config_option *config_proxy_username;
+struct t_config_option *config_proxy_password;
/* config, plugins section */
-char *cfg_plugins_path;
-char *cfg_plugins_autoload;
-char *cfg_plugins_extension;
-
-struct t_config_option weechat_options_plugins[] =
-{ { "plugins_path",
- N_("path for searching plugins ('%h' will be replaced by WeeChat home, "
- "~/.weechat by default)"),
- OPTION_TYPE_STRING, 0, 0, 0, "%h/plugins", NULL,
- NULL, &cfg_plugins_path, weechat_config_change_noop },
- { "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\")"),
- OPTION_TYPE_STRING, 0, 0, 0, "*", NULL,
- NULL, &cfg_plugins_autoload, weechat_config_change_noop },
- { "plugins_extension",
- N_("standard plugins extension in filename, used for autoload "
- "(if empty, then all files are loaded when autoload is \"*\")"),
- OPTION_TYPE_STRING, 0, 0, 0,
-#ifdef WIN32
- ".dll",
-#else
- ".so",
-#endif
- NULL,
- NULL, &cfg_plugins_extension, weechat_config_change_noop },
- { NULL, NULL, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL }
-};
-
-char *weechat_config_sections[] =
-{ "look", "colors",
- "history", "proxy",
- "plugins", "alias",
- "keys",
- NULL
-};
-
-struct t_config_option *weechat_config_options[] =
-{ weechat_options_look, weechat_options_colors,
- weechat_options_history, weechat_options_proxy,
- weechat_options_plugins, NULL,
- NULL,
- NULL
-};
-
-t_config_func_read_option *weechat_config_read_functions[] =
-{ config_file_read_option, config_file_read_option,
- config_file_read_option, config_file_read_option,
- config_file_read_option, weechat_config_read_alias,
- weechat_config_read_key,
- NULL
-};
+struct t_config_option *config_plugins_path;
+struct t_config_option *config_plugins_autoload;
+struct t_config_option *config_plugins_extension;
-t_config_func_write_options *weechat_config_write_functions[] =
-{ config_file_write_options, config_file_write_options,
- config_file_write_options, config_file_write_options,
- config_file_write_options, weechat_config_write_alias,
- weechat_config_write_keys,
- NULL
-};
-
-t_config_func_write_options *weechat_config_write_default_functions[] =
-{ config_file_write_options_default_values, config_file_write_options_default_values,
- config_file_write_options_default_values, config_file_write_options_default_values,
- config_file_write_options_default_values, weechat_config_write_alias_default_values,
- weechat_config_write_keys_default_values,
- NULL
-};
-
-
-/*
- * weechat_config_change_noop: called when an option is changed by /set command
- * and that no special action is needed after that
- */
-
-void
-weechat_config_change_noop ()
-{
- /* do nothing */
-}
/*
- * weechat_config_change_save_on_exit: called when "save_on_exit" flag is changed
+ * config_change_save_on_exit: called when "save_on_exit" flag is changed
*/
void
-weechat_config_change_save_on_exit ()
+config_change_save_on_exit ()
{
- if (!cfg_look_save_on_exit)
+ if (!config_look_save_on_exit)
{
gui_chat_printf (NULL, "\n");
gui_chat_printf (NULL,
@@ -854,77 +198,77 @@ weechat_config_change_save_on_exit ()
}
/*
- * weechat_config_change_title: called when title is changed
+ * config_change_title: called when title is changed
*/
void
-weechat_config_change_title ()
+config_change_title ()
{
- if (cfg_look_set_title)
+ if (config_look_set_title)
gui_window_title_set ();
else
gui_window_title_reset ();
}
/*
- * weechat_config_change_buffers: called when buffers change (for example nicklist)
+ * config_change_buffers: called when buffers change (for example nicklist)
*/
void
-weechat_config_change_buffers ()
+config_change_buffers ()
{
gui_window_refresh_windows ();
}
/*
- * weechat_config_change_buffer_content: called when content of a buffer changes
+ * config_change_buffer_content: called when content of a buffer changes
*/
void
-weechat_config_change_buffer_content ()
+config_change_buffer_content ()
{
gui_window_redraw_buffer (gui_current_window->buffer);
}
/*
- * weechat_config_change_buffer_time_format: called when buffer time format changes
+ * config_change_buffer_time_format: called when buffer time format changes
*/
void
-weechat_config_change_buffer_time_format ()
+config_change_buffer_time_format ()
{
- gui_chat_time_length = util_get_time_length (cfg_look_buffer_time_format);
+ gui_chat_time_length = util_get_time_length (CONFIG_STRING(config_look_buffer_time_format));
gui_chat_change_time_format ();
gui_window_redraw_buffer (gui_current_window->buffer);
}
/*
- * weechat_config_change_hotlist: called when hotlist changes
+ * config_change_hotlist: called when hotlist changes
*/
void
-weechat_config_change_hotlist ()
+config_change_hotlist ()
{
gui_hotlist_resort ();
gui_status_draw (gui_current_window->buffer, 1);
}
/*
- * weechat_config_change_read_marker: called when read marker is changed
+ * config_change_read_marker: called when read marker is changed
*/
void
-weechat_config_change_read_marker ()
+config_change_read_marker ()
{
gui_window_redraw_all_buffers ();
}
/*
- * weechat_config_change_prefix: called when a prefix is changed
+ * config_change_prefix: called when a prefix is changed
*/
void
-weechat_config_change_prefix ()
+config_change_prefix ()
{
int i;
@@ -937,23 +281,26 @@ weechat_config_change_prefix ()
}
/*
- * weechat_config_change_color: called when a color is changed by /set command
+ * config_change_color: called when a color is changed by /set command
*/
void
-weechat_config_change_color ()
+config_change_color ()
{
- gui_color_init_pairs ();
- gui_color_rebuild_weechat ();
- gui_window_refresh_windows ();
+ if (gui_ok)
+ {
+ gui_color_init_pairs ();
+ gui_color_rebuild_weechat ();
+ gui_window_refresh_windows ();
+ }
}
/*
- * weechat_config_change_nicks_colors: called when number of nicks color changed
+ * config_change_nicks_colors: called when number of nicks color changed
*/
void
-weechat_config_change_nicks_colors ()
+config_change_nicks_colors ()
{
struct t_gui_buffer *ptr_buffer;
struct t_gui_nick *ptr_nick;
@@ -973,137 +320,121 @@ weechat_config_change_nicks_colors ()
}
/*
- * weechat_config_read_alias: read an alias in configuration file
- * Return: 0 = successful
- * -1 = option not found
- * -2 = bad format/value
+ * config_weechat_read_alias: read an alias in configuration file
*/
-int
-weechat_config_read_alias (struct t_config_option *options,
+void
+config_weechat_read_alias (struct t_config_file *config_file,
char *option_name, char *value)
{
/* make C compiler happy */
- (void) options;
-
- if (option_name)
- {
- /* create new alias */
- if (alias_new (option_name, value))
- weelist_add (&weechat_index_commands,
- &weechat_last_index_command,
- option_name,
- WEELIST_POS_SORT);
- else
- return -2;
- }
- else
- {
- /* does nothing for new [alias] section */
- }
+ (void) config_file;
- /* all ok */
- return 0;
+ /* create new alias */
+ if (alias_new (option_name, value))
+ weelist_add (&weechat_index_commands,
+ &weechat_last_index_command,
+ option_name,
+ WEELIST_POS_SORT);
}
/*
- * weechat_config_read_key: read a key in configuration file
- * Return: 0 = successful
- * -1 = option not found
- * -2 = bad format/value
+ * config_weechat_read_key: read a key in configuration file
*/
-int
-weechat_config_read_key (struct t_config_option *options,
+void
+config_weechat_read_key (struct t_config_file *config_file,
char *option_name, char *value)
{
/* make C compiler happy */
- (void) options;
+ (void) config_file;
- if (option_name)
+ if (value[0])
{
- if (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);
- }
+ /* bind key (overwrite any binding with same key) */
+ gui_keyboard_bind (option_name, value);
}
else
{
- /* does nothing for new [key] section */
+ /* unbin key if no value given */
+ gui_keyboard_unbind (option_name);
}
-
- /* all ok */
- return 0;
}
/*
- * weechat_config_read: read WeeChat configuration file
- * return: 0 = successful
- * -1 = configuration file file not found
- * -2 = error in configuration file
- */
-
-int
-weechat_config_read ()
-{
- return config_file_read (weechat_config_sections, weechat_config_options,
- weechat_config_read_functions,
- config_file_read_option,
- weechat_config_write_default_functions,
- WEECHAT_CONFIG_NAME);
-}
-
-/*
- * weechat_config_write_alias: write alias section in configuration file
+ * config_weechat_write_alias: write alias section in configuration file
* Return: 0 = successful
* -1 = write error
*/
-int
-weechat_config_write_alias (FILE *file, char *section_name,
- struct t_config_option *options)
+void
+config_weechat_write_alias (struct t_config_file *config_file)
{
struct alias *ptr_alias;
-
- /* make C compiler happy */
- (void) options;
-
- string_iconv_fprintf (file, "\n[%s]\n", section_name);
+ char *string;
for (ptr_alias = weechat_alias; ptr_alias;
ptr_alias = ptr_alias->next_alias)
{
- string_iconv_fprintf (file, "%s = \"%s\"\n",
- ptr_alias->name, ptr_alias->command);
+ string = (char *)malloc (strlen (ptr_alias->command) + 4);
+ if (string)
+ {
+ strcpy (string, "\"");
+ strcat (string, ptr_alias->command);
+ strcat (string, "\"");
+ config_file_write_line (config_file,
+ ptr_alias->name,
+ string);
+ free (string);
+ }
}
-
- /* all ok */
- return 0;
}
/*
- * weechat_config_write_keys: write alias section in configuration file
+ * config_weechat_write_alias_default_values: write alias section with default values
+ * in configuration file
+ */
+
+void
+config_weechat_write_alias_default_values (struct t_config_file *config_file)
+{
+ config_file_write_line (config_file, "SAY", "\"msg *\"");
+ config_file_write_line (config_file, "BYE", "\"quit\"");
+ config_file_write_line (config_file, "EXIT", "\"quit\"");
+ config_file_write_line (config_file, "SIGNOFF", "\"quit\"");
+ config_file_write_line (config_file, "C", "\"clear\"");
+ config_file_write_line (config_file, "CL", "\"clear\"");
+ config_file_write_line (config_file, "CLOSE", "\"buffer close\"");
+ config_file_write_line (config_file, "CHAT", "\"dcc chat\"");
+ config_file_write_line (config_file, "IG", "\"ignore\"");
+ config_file_write_line (config_file, "J", "\"join\"");
+ config_file_write_line (config_file, "K", "\"kick\"");
+ config_file_write_line (config_file, "KB", "\"kickban\"");
+ config_file_write_line (config_file, "LEAVE", "\"part\"");
+ config_file_write_line (config_file, "M", "\"msg\"");
+ config_file_write_line (config_file, "MUB", "\"unban *\"");
+ config_file_write_line (config_file, "N", "\"names\"");
+ config_file_write_line (config_file, "Q", "\"query\"");
+ config_file_write_line (config_file, "T", "\"topic\"");
+ config_file_write_line (config_file, "UB", "\"unban\"");
+ config_file_write_line (config_file, "UNIG", "\"unignore\"");
+ config_file_write_line (config_file, "W", "\"who\"");
+ config_file_write_line (config_file, "WC", "\"window merge\"");
+ config_file_write_line (config_file, "WI", "\"whois\"");
+ config_file_write_line (config_file, "WW", "\"whowas\"");
+}
+
+/*
+ * config_weechat_write_keys: write alias section in configuration file
* Return: 0 = successful
* -1 = write error
*/
-int
-weechat_config_write_keys (FILE *file, char *section_name,
- struct t_config_option *options)
+void
+config_weechat_write_keys (struct t_config_file *config_file)
{
t_gui_key *ptr_key;
- char *expanded_name, *function_name;
-
- /* make C compiler happy */
- (void) options;
-
- string_iconv_fprintf (file, "\n[%s]\n", section_name);
+ char *expanded_name, *function_name, *string;
for (ptr_key = gui_keys; ptr_key; ptr_key = ptr_key->next_key)
{
@@ -1112,135 +443,699 @@ weechat_config_write_keys (FILE *file, char *section_name,
{
function_name = gui_keyboard_function_search_by_ptr (ptr_key->function);
if (function_name)
- string_iconv_fprintf (file, "%s = \"%s%s%s\"\n",
- (expanded_name) ? expanded_name : ptr_key->key,
- function_name,
- (ptr_key->args) ? " " : "",
- (ptr_key->args) ? ptr_key->args : "");
+ {
+ 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_iconv_fprintf (file, "%s = \"%s\"\n",
- (expanded_name) ? expanded_name : ptr_key->key,
- ptr_key->command);
+ {
+ 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);
+ }
+ }
if (expanded_name)
free (expanded_name);
}
-
- /* all ok */
- return 0;
}
/*
- * weechat_config_write_alias_default_values: write alias section with default values
- * in configuration file
- * Return: 0 = successful
- * -1 = write error
+ * config_weechat_init: init options with default values
*/
-int
-weechat_config_write_alias_default_values (FILE *file, char *section_name,
- struct t_config_option *options)
+void
+config_weechat_init ()
{
- /* make C compiler happy */
- (void) options;
+ struct t_config_section *section;
- string_iconv_fprintf (file, "\n[%s]\n", section_name);
-
- string_iconv_fprintf (file, "SAY = \"msg *\"\n");
- string_iconv_fprintf (file, "BYE = \"quit\"\n");
- string_iconv_fprintf (file, "EXIT = \"quit\"\n");
- string_iconv_fprintf (file, "SIGNOFF = \"quit\"\n");
- string_iconv_fprintf (file, "C = \"clear\"\n");
- string_iconv_fprintf (file, "CL = \"clear\"\n");
- string_iconv_fprintf (file, "CLOSE = \"buffer close\"\n");
- string_iconv_fprintf (file, "CHAT = \"dcc chat\"\n");
- string_iconv_fprintf (file, "IG = \"ignore\"\n");
- string_iconv_fprintf (file, "J = \"join\"\n");
- string_iconv_fprintf (file, "K = \"kick\"\n");
- string_iconv_fprintf (file, "KB = \"kickban\"\n");
- string_iconv_fprintf (file, "LEAVE = \"part\"\n");
- string_iconv_fprintf (file, "M = \"msg\"\n");
- string_iconv_fprintf (file, "MUB = \"unban *\"\n");
- string_iconv_fprintf (file, "N = \"names\"\n");
- string_iconv_fprintf (file, "Q = \"query\"\n");
- string_iconv_fprintf (file, "T = \"topic\"\n");
- string_iconv_fprintf (file, "UB = \"unban\"\n");
- string_iconv_fprintf (file, "UNIG = \"unignore\"\n");
- string_iconv_fprintf (file, "W = \"who\"\n");
- string_iconv_fprintf (file, "WC = \"window merge\"\n");
- string_iconv_fprintf (file, "WI = \"whois\"\n");
- string_iconv_fprintf (file, "WW = \"whowas\"\n");
-
- /* all ok */
- return 0;
-}
+ weechat_config = config_file_new (WEECHAT_CONFIG_FILENAME);
+ if (weechat_config)
+ {
+ /* look */
+ section = config_file_new_section (weechat_config, "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);
+ }
+
+ /* colors */
+ section = config_file_new_section (weechat_config, "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);
+ }
-/*
- * weechat_config_write_keys_default_values: write keys section with default values
- * in configuration file
- * Return: 0 = successful
- * -1 = write error
- */
+ /* history */
+ section = config_file_new_section (weechat_config, "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);
+ }
-int
-weechat_config_write_keys_default_values (FILE *file, char *section_name,
- struct t_config_option *options)
-{
- t_gui_key *ptr_key;
- char *expanded_name, *function_name;
-
- /* make C compiler happy */
- (void) options;
-
- string_iconv_fprintf (file, "\n[%s]\n", section_name);
-
- for (ptr_key = gui_keys; ptr_key; ptr_key = ptr_key->next_key)
- {
- expanded_name = gui_keyboard_get_expanded_name (ptr_key->key);
- if (ptr_key->function)
+ /* proxy */
+ section = config_file_new_section (weechat_config, "proxy",
+ NULL, NULL, NULL);
+ if (section)
{
- function_name = gui_keyboard_function_search_by_ptr (ptr_key->function);
- if (function_name)
- string_iconv_fprintf (file, "%s = \"%s%s%s\"\n",
- (expanded_name) ? expanded_name : ptr_key->key,
- function_name,
- (ptr_key->args) ? " " : "",
- (ptr_key->args) ? ptr_key->args : "");
+ 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);
}
- else
- string_iconv_fprintf (file, "%s = \"%s\"\n",
- (expanded_name) ? expanded_name : ptr_key->key,
- ptr_key->command);
- if (expanded_name)
- free (expanded_name);
+
+ /* plugins */
+ section = config_file_new_section (weechat_config, "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,
+#ifdef WIN32
+ ".dll",
+#else
+ ".so",
+#endif
+ NULL);
+ }
+
+ /* alias */
+ section = config_file_new_section (weechat_config, "alias",
+ &config_weechat_read_alias,
+ &config_weechat_write_alias,
+ &config_weechat_write_alias_default_values);
+
+ /* keys */
+ section = config_file_new_section (weechat_config, "keys",
+ &config_weechat_read_key,
+ &config_weechat_write_keys,
+ &config_weechat_write_keys);
}
-
- /* all ok */
- return 0;
}
/*
- * weechat_config_write: write WeeChat configuration file
- * return: 0 if ok
- * < 0 if error
+ * config_weechat_read: read WeeChat configuration file
+ * return: 0 = successful
+ * -1 = configuration file file not found
+ * -2 = error in configuration file
*/
int
-weechat_config_write ()
+config_weechat_read ()
{
- log_printf (_("Saving WeeChat configuration to disk\n"));
- return config_file_write (weechat_config_sections, weechat_config_options,
- weechat_config_write_functions,
- WEECHAT_CONFIG_NAME);
+ return config_file_read (weechat_config);
}
/*
- * weechat_config_print_stdout: print WeeChat options on standard output
+ * config_weechat_write: write WeeChat configuration file
+ * return: 0 if ok
+ * < 0 if error
*/
-void
-weechat_config_print_stdout ()
+int
+config_weechat_write ()
{
- config_option_print_stdout (weechat_config_sections,
- weechat_config_options);
+ log_printf (_("Saving WeeChat configuration to disk\n"));
+ return config_file_write (weechat_config, 0);
}
diff --git a/src/core/wee-config.h b/src/core/wee-config.h
index ac62dbe32..d7ac9748a 100644
--- a/src/core/wee-config.h
+++ b/src/core/wee-config.h
@@ -20,183 +20,165 @@
#ifndef __WEECHAT_CONFIG_H
#define __WEECHAT_CONFIG_H 1
-#include "wee-config-option.h"
#include "wee-config-file.h"
-#include "../gui/gui-chat.h"
-#include "../gui/gui-color.h"
-
-#define WEECHAT_CONFIG_NAME "weechat.rc"
-
-#define CFG_LOOK_NICKLIST_LEFT 0
-#define CFG_LOOK_NICKLIST_RIGHT 1
-#define CFG_LOOK_NICKLIST_TOP 2
-#define CFG_LOOK_NICKLIST_BOTTOM 3
-
-#define CFG_LOOK_PREFIX_ALIGN_NONE 0
-#define CFG_LOOK_PREFIX_ALIGN_LEFT 1
-#define CFG_LOOK_PREFIX_ALIGN_RIGHT 2
-
-#define CFG_LOOK_HOTLIST_SORT_GROUP_TIME_ASC 0
-#define CFG_LOOK_HOTLIST_SORT_GROUP_TIME_DESC 1
-#define CFG_LOOK_HOTLIST_SORT_GROUP_NUMBER_ASC 2
-#define CFG_LOOK_HOTLIST_SORT_GROUP_NUMBER_DESC 3
-#define CFG_LOOK_HOTLIST_SORT_NUMBER_ASC 4
-#define CFG_LOOK_HOTLIST_SORT_NUMBER_DESC 5
-
-extern struct t_config_option weechat_options_look[];
-extern int cfg_look_color_real_white;
-extern int cfg_look_save_on_exit;
-extern int cfg_look_set_title;
-extern int cfg_look_startup_logo;
-extern int cfg_look_startup_version;
-extern char *cfg_look_weechat_slogan;
-extern int cfg_look_one_server_buffer;
-extern int cfg_look_open_near_server;
-extern int cfg_look_scroll_amount;
-extern char *cfg_look_buffer_time_format;
-extern int cfg_look_color_nicks_number;
-extern int cfg_look_color_actions;
-extern int cfg_look_nicklist;
-extern int cfg_look_nicklist_position;
-extern int cfg_look_nicklist_min_size;
-extern int cfg_look_nicklist_max_size;
-extern int cfg_look_nicklist_separator;
-extern int cfg_look_nickmode;
-extern int cfg_look_nickmode_empty;
-extern char *cfg_look_no_nickname;
-extern char *cfg_look_prefix[GUI_CHAT_PREFIX_NUMBER];
-extern int cfg_look_prefix_align;
-extern int cfg_look_prefix_align_max;
-extern char *cfg_look_prefix_suffix;
-extern int cfg_look_align_text_offset;
-extern char *cfg_look_nick_completor;
-extern char *cfg_look_nick_completion_ignore;
-extern int cfg_look_nick_completion_smart;
-extern int cfg_look_nick_complete_first;
-extern int cfg_look_infobar;
-extern char *cfg_look_infobar_time_format;
-extern int cfg_look_infobar_seconds;
-extern int cfg_look_infobar_delay_highlight;
-extern int cfg_look_hotlist_names_count;
-extern int cfg_look_hotlist_names_level;
-extern int cfg_look_hotlist_names_length;
-extern int cfg_look_hotlist_sort;
-extern int cfg_look_day_change;
-extern char *cfg_look_day_change_time_format;
-extern char *cfg_look_read_marker;
-extern char *cfg_look_input_format;
-extern int cfg_look_paste_max_lines;
-
-extern struct t_config_option weechat_options_colors[];
-extern int cfg_col_separator;
-extern int cfg_col_title;
-extern int cfg_col_title_bg;
-extern int cfg_col_title_more;
-extern int cfg_col_chat;
-extern int cfg_col_chat_bg;
-extern int cfg_col_chat_time;
-extern int cfg_col_chat_time_delimiters;
-extern int cfg_col_chat_prefix[GUI_CHAT_PREFIX_NUMBER];
-extern int cfg_col_chat_prefix_more;
-extern int cfg_col_chat_prefix_suffix;
-extern int cfg_col_chat_buffer;
-extern int cfg_col_chat_server;
-extern int cfg_col_chat_channel;
-extern int cfg_col_chat_nick;
-extern int cfg_col_chat_nick_self;
-extern int cfg_col_chat_nick_other;
-extern int cfg_col_chat_nick_colors[GUI_COLOR_NICK_NUMBER];
-extern int cfg_col_chat_host;
-extern int cfg_col_chat_delimiters;
-extern int cfg_col_chat_highlight;
-extern int cfg_col_chat_read_marker;
-extern int cfg_col_chat_read_marker_bg;
-extern int cfg_col_status;
-extern int cfg_col_status_bg;
-extern int cfg_col_status_delimiters;
-extern int cfg_col_status_channel;
-extern int cfg_col_status_data_msg;
-extern int cfg_col_status_data_private;
-extern int cfg_col_status_data_highlight;
-extern int cfg_col_status_data_other;
-extern int cfg_col_status_more;
-extern int cfg_col_infobar;
-extern int cfg_col_infobar_bg;
-extern int cfg_col_infobar_delimiters;
-extern int cfg_col_infobar_highlight;
-extern int cfg_col_infobar_bg;
-extern int cfg_col_input;
-extern int cfg_col_input_bg;
-extern int cfg_col_input_server;
-extern int cfg_col_input_channel;
-extern int cfg_col_input_nick;
-extern int cfg_col_input_delimiters;
-extern int cfg_col_input_text_not_found;
-extern int cfg_col_input_actions;
-extern int cfg_col_nicklist;
-extern int cfg_col_nicklist_bg;
-extern int cfg_col_nicklist_away;
-extern int cfg_col_nicklist_prefix1;
-extern int cfg_col_nicklist_prefix2;
-extern int cfg_col_nicklist_prefix3;
-extern int cfg_col_nicklist_prefix4;
-extern int cfg_col_nicklist_prefix5;
-extern int cfg_col_nicklist_more;
-extern int cfg_col_nicklist_separator;
-extern int cfg_col_info;
-extern int cfg_col_info_bg;
-extern int cfg_col_info_waiting;
-extern int cfg_col_info_connecting;
-extern int cfg_col_info_active;
-extern int cfg_col_info_done;
-extern int cfg_col_info_failed;
-extern int cfg_col_info_aborted;
-
-extern struct t_config_option weechat_options_history[];
-extern int cfg_history_max_lines;
-extern int cfg_history_max_commands;
-extern int cfg_history_display_default;
-
-extern struct t_config_option weechat_options_proxy[];
-extern int cfg_proxy_use;
-extern int cfg_proxy_type;
-extern char *cfg_proxy_type_values[];
-extern int cfg_proxy_ipv6;
-extern char *cfg_proxy_address;
-extern int cfg_proxy_port;
-extern char *cfg_proxy_username;
-extern char *cfg_proxy_password;
-
-extern struct t_config_option weechat_options_plugins[];
-extern char *cfg_plugins_path;
-extern char *cfg_plugins_autoload;
-extern char *cfg_plugins_extension;
-
-extern char *weechat_config_sections[];
-extern struct t_config_option *weechat_config_options[];
-
-extern void weechat_config_change_noop ();
-extern void weechat_config_change_save_on_exit ();
-extern void weechat_config_change_title ();
-extern void weechat_config_change_buffers ();
-extern void weechat_config_change_buffer_content ();
-extern void weechat_config_change_buffer_time_format ();
-extern void weechat_config_change_hotlist ();
-extern void weechat_config_change_read_marker ();
-extern void weechat_config_change_prefix ();
-extern void weechat_config_change_color ();
-extern void weechat_config_change_nicks_colors ();
-
-extern int weechat_config_read_alias (struct t_config_option *, char *, char *);
-extern int weechat_config_read_key (struct t_config_option *, char *, char *);
-extern int weechat_config_read ();
-extern int weechat_config_write_alias (FILE *, char *, struct t_config_option *);
-extern int weechat_config_write_keys (FILE *, char *, struct t_config_option *);
-extern int weechat_config_write_alias_default_values (FILE *, char *,
- struct t_config_option *);
-extern int weechat_config_write_keys_default_values (FILE *, char *,
- struct t_config_option *);
-extern int weechat_config_write ();
-extern void weechat_config_print_stdout ();
+
+#define WEECHAT_CONFIG_FILENAME "weechat.rc"
+
+#define CONFIG_LOOK_NICKLIST_LEFT 0
+#define CONFIG_LOOK_NICKLIST_RIGHT 1
+#define CONFIG_LOOK_NICKLIST_TOP 2
+#define CONFIG_LOOK_NICKLIST_BOTTOM 3
+
+#define CONFIG_LOOK_PREFIX_ALIGN_NONE 0
+#define CONFIG_LOOK_PREFIX_ALIGN_LEFT 1
+#define CONFIG_LOOK_PREFIX_ALIGN_RIGHT 2
+
+#define CONFIG_LOOK_HOTLIST_SORT_GROUP_TIME_ASC 0
+#define CONFIG_LOOK_HOTLIST_SORT_GROUP_TIME_DESC 1
+#define CONFIG_LOOK_HOTLIST_SORT_GROUP_NUMBER_ASC 2
+#define CONFIG_LOOK_HOTLIST_SORT_GROUP_NUMBER_DESC 3
+#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_option *config_look_color_real_white;
+extern struct t_config_option *config_look_save_on_exit;
+extern struct t_config_option *config_look_set_title;
+extern struct t_config_option *config_look_startup_logo;
+extern struct t_config_option *config_look_startup_version;
+extern struct t_config_option *config_look_weechat_slogan;
+extern struct t_config_option *config_look_one_server_buffer;
+extern struct t_config_option *config_look_open_near_server;
+extern struct t_config_option *config_look_scroll_amount;
+extern struct t_config_option *config_look_buffer_time_format;
+extern struct t_config_option *config_look_color_nicks_number;
+extern struct t_config_option *config_look_color_actions;
+extern struct t_config_option *config_look_nicklist;
+extern struct t_config_option *config_look_nicklist_position;
+extern struct t_config_option *config_look_nicklist_min_size;
+extern struct t_config_option *config_look_nicklist_max_size;
+extern struct t_config_option *config_look_nicklist_separator;
+extern struct t_config_option *config_look_nickmode;
+extern struct t_config_option *config_look_nickmode_empty;
+extern struct t_config_option *config_look_no_nickname;
+extern struct t_config_option *config_look_prefix[];
+extern struct t_config_option *config_look_prefix_align;
+extern struct t_config_option *config_look_prefix_align_max;
+extern struct t_config_option *config_look_prefix_suffix;
+extern struct t_config_option *config_look_nick_completor;
+extern struct t_config_option *config_look_nick_completion_ignore;
+extern struct t_config_option *config_look_nick_completion_smart;
+extern struct t_config_option *config_look_nick_complete_first;
+extern struct t_config_option *config_look_infobar;
+extern struct t_config_option *config_look_infobar_time_format;
+extern struct t_config_option *config_look_infobar_seconds;
+extern struct t_config_option *config_look_infobar_delay_highlight;
+extern struct t_config_option *config_look_hotlist_names_count;
+extern struct t_config_option *config_look_hotlist_names_level;
+extern struct t_config_option *config_look_hotlist_names_length;
+extern struct t_config_option *config_look_hotlist_sort;
+extern struct t_config_option *config_look_day_change;
+extern struct t_config_option *config_look_day_change_time_format;
+extern struct t_config_option *config_look_read_marker;
+extern struct t_config_option *config_look_input_format;
+extern struct t_config_option *config_look_paste_max_lines;
+
+extern struct t_config_option *config_color_separator;
+extern struct t_config_option *config_color_title;
+extern struct t_config_option *config_color_title_bg;
+extern struct t_config_option *config_color_title_more;
+extern struct t_config_option *config_color_chat;
+extern struct t_config_option *config_color_chat_bg;
+extern struct t_config_option *config_color_chat_time;
+extern struct t_config_option *config_color_chat_time_delimiters;
+extern struct t_config_option *config_color_chat_prefix[];
+extern struct t_config_option *config_color_chat_prefix_more;
+extern struct t_config_option *config_color_chat_prefix_suffix;
+extern struct t_config_option *config_color_chat_buffer;
+extern struct t_config_option *config_color_chat_server;
+extern struct t_config_option *config_color_chat_channel;
+extern struct t_config_option *config_color_chat_nick;
+extern struct t_config_option *config_color_chat_nick_self;
+extern struct t_config_option *config_color_chat_nick_other;
+extern struct t_config_option *config_color_chat_nick_colors[];
+extern struct t_config_option *config_color_chat_host;
+extern struct t_config_option *config_color_chat_delimiters;
+extern struct t_config_option *config_color_chat_highlight;
+extern struct t_config_option *config_color_chat_read_marker;
+extern struct t_config_option *config_color_chat_read_marker_bg;
+extern struct t_config_option *config_color_status;
+extern struct t_config_option *config_color_status_bg;
+extern struct t_config_option *config_color_status_delimiters;
+extern struct t_config_option *config_color_status_channel;
+extern struct t_config_option *config_color_status_data_msg;
+extern struct t_config_option *config_color_status_data_private;
+extern struct t_config_option *config_color_status_data_highlight;
+extern struct t_config_option *config_color_status_data_other;
+extern struct t_config_option *config_color_status_more;
+extern struct t_config_option *config_color_infobar;
+extern struct t_config_option *config_color_infobar_bg;
+extern struct t_config_option *config_color_infobar_delimiters;
+extern struct t_config_option *config_color_infobar_highlight;
+extern struct t_config_option *config_color_infobar_bg;
+extern struct t_config_option *config_color_input;
+extern struct t_config_option *config_color_input_bg;
+extern struct t_config_option *config_color_input_server;
+extern struct t_config_option *config_color_input_channel;
+extern struct t_config_option *config_color_input_nick;
+extern struct t_config_option *config_color_input_delimiters;
+extern struct t_config_option *config_color_input_text_not_found;
+extern struct t_config_option *config_color_input_actions;
+extern struct t_config_option *config_color_nicklist;
+extern struct t_config_option *config_color_nicklist_bg;
+extern struct t_config_option *config_color_nicklist_away;
+extern struct t_config_option *config_color_nicklist_prefix1;
+extern struct t_config_option *config_color_nicklist_prefix2;
+extern struct t_config_option *config_color_nicklist_prefix3;
+extern struct t_config_option *config_color_nicklist_prefix4;
+extern struct t_config_option *config_color_nicklist_prefix5;
+extern struct t_config_option *config_color_nicklist_more;
+extern struct t_config_option *config_color_nicklist_separator;
+extern struct t_config_option *config_color_info;
+extern struct t_config_option *config_color_info_bg;
+extern struct t_config_option *config_color_info_waiting;
+extern struct t_config_option *config_color_info_connecting;
+extern struct t_config_option *config_color_info_active;
+extern struct t_config_option *config_color_info_done;
+extern struct t_config_option *config_color_info_failed;
+extern struct t_config_option *config_color_info_aborted;
+
+extern struct t_config_option *config_history_max_lines;
+extern struct t_config_option *config_history_max_commands;
+extern struct t_config_option *config_history_display_default;
+
+extern struct t_config_option *config_proxy_use;
+extern struct t_config_option *config_proxy_type;
+extern struct t_config_option *config_proxy_ipv6;
+extern struct t_config_option *config_proxy_address;
+extern struct t_config_option *config_proxy_port;
+extern struct t_config_option *config_proxy_username;
+extern struct t_config_option *config_proxy_password;
+
+extern struct t_config_option *config_plugins_path;
+extern struct t_config_option *config_plugins_autoload;
+extern struct t_config_option *config_plugins_extension;
+
+extern void config_change_noop ();
+extern void config_change_save_on_exit ();
+extern void config_change_title ();
+extern void config_change_buffers ();
+extern void config_change_buffer_content ();
+extern void config_change_buffer_time_format ();
+extern void config_change_hotlist ();
+extern void config_change_read_marker ();
+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_read ();
+extern int config_weechat_write ();
+extern void config_weechat_print_stdout ();
#endif /* wee-config.h */
diff --git a/src/core/wee-input.c b/src/core/wee-input.c
index a395b4725..74beb81a1 100644
--- a/src/core/wee-input.c
+++ b/src/core/wee-input.c
@@ -33,6 +33,7 @@
#include "wee-config.h"
#include "wee-hook.h"
#include "wee-string.h"
+#include "../gui/gui-chat.h"
#include "../plugins/plugin.h"
diff --git a/src/core/wee-util.c b/src/core/wee-util.c
index 70f90094e..408998164 100644
--- a/src/core/wee-util.c
+++ b/src/core/wee-util.c
@@ -157,15 +157,17 @@ util_search_full_lib_name (char *filename, char *sys_directory)
return strdup (filename);
length = strlen (filename) + 16;
- if (cfg_plugins_extension && cfg_plugins_extension[0])
- length += strlen (cfg_plugins_extension);
+ if (CONFIG_STRING(config_plugins_extension)
+ && CONFIG_STRING(config_plugins_extension)[0])
+ length += strlen (CONFIG_STRING(config_plugins_extension));
name_with_ext = (char *)malloc (length);
if (!name_with_ext)
return strdup (filename);
strcpy (name_with_ext, filename);
if (!strchr (filename, '.')
- && cfg_plugins_extension && cfg_plugins_extension[0])
- strcat (name_with_ext, cfg_plugins_extension);
+ && CONFIG_STRING(config_plugins_extension)
+ && CONFIG_STRING(config_plugins_extension)[0])
+ strcat (name_with_ext, CONFIG_STRING(config_plugins_extension));
/* try WeeChat user's dir */
length = strlen (weechat_home) + strlen (name_with_ext) +
diff --git a/src/core/weechat.c b/src/core/weechat.c
index e516e53b5..323b740ce 100644
--- a/src/core/weechat.c
+++ b/src/core/weechat.c
@@ -63,6 +63,7 @@
#include "wee-util.h"
#include "../gui/gui-buffer.h"
#include "../gui/gui-chat.h"
+#include "../gui/gui-color.h"
#include "../gui/gui-hotlist.h"
#include "../gui/gui-main.h"
#include "../gui/gui-keyboard.h"
@@ -129,7 +130,7 @@ weechat_display_config_options ()
/* TRANSLATORS: %s is "WeeChat" */
_("%s configuration options:\n"),
PACKAGE_NAME);
- weechat_config_print_stdout ();
+ config_file_print_stdout (weechat_config);
}
/*
@@ -425,7 +426,7 @@ weechat_init_vars ()
void
weechat_welcome_message ()
{
- if (cfg_look_startup_logo)
+ if (CONFIG_BOOLEAN(config_look_startup_logo))
{
gui_chat_printf (NULL,
"%s ___ __ ______________ _____ \n"
@@ -439,27 +440,31 @@ weechat_welcome_message ()
GUI_COLOR(GUI_COLOR_CHAT_NICK),
GUI_COLOR(GUI_COLOR_CHAT_NICK));
}
- if (cfg_look_weechat_slogan && cfg_look_weechat_slogan[0])
+ if (CONFIG_STRING(config_look_weechat_slogan)
+ && CONFIG_STRING(config_look_weechat_slogan)[0])
{
gui_chat_printf (NULL, _("%sWelcome to %s%s%s, %s"),
- (cfg_look_startup_logo) ? " " : "",
+ (CONFIG_BOOLEAN(config_look_startup_logo)) ?
+ " " : "",
GUI_COLOR(GUI_COLOR_CHAT_BUFFER),
PACKAGE_NAME,
GUI_NO_COLOR,
- cfg_look_weechat_slogan);
+ CONFIG_STRING(config_look_weechat_slogan));
}
- if (cfg_look_startup_version)
+ if (CONFIG_BOOLEAN(config_look_startup_version))
{
gui_chat_printf (NULL, "%s%s%s%s, %s %s %s",
- (cfg_look_startup_logo) ? " " : "",
+ (CONFIG_BOOLEAN(config_look_startup_logo)) ?
+ " " : "",
GUI_COLOR(GUI_COLOR_CHAT_BUFFER),
PACKAGE_STRING,
GUI_NO_COLOR,
_("compiled on"), __DATE__, __TIME__);
}
- if (cfg_look_startup_logo ||
- (cfg_look_weechat_slogan && cfg_look_weechat_slogan[0]) ||
- cfg_look_startup_version)
+ if (CONFIG_BOOLEAN(config_look_startup_logo) ||
+ (CONFIG_STRING(config_look_weechat_slogan)
+ && CONFIG_STRING(config_look_weechat_slogan)[0]) ||
+ CONFIG_BOOLEAN(config_look_startup_version))
gui_chat_printf (NULL,
"%s-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-",
GUI_COLOR(GUI_COLOR_CHAT_NICK));
@@ -592,10 +597,11 @@ main (int argc, char *argv[])
gui_main_pre_init (&argc, &argv); /* pre-initiliaze interface */
weechat_init_vars (); /* initialize some variables */
gui_keyboard_init (); /* init keyb. (default key bindings)*/
+ config_weechat_init (); /* init options with default values */
weechat_parse_args (argc, argv); /* parse command line args */
weechat_create_home_dirs (); /* create WeeChat directories */
log_init (); /* init log file */
- if (weechat_config_read () < 0) /* read WeeChat configuration */
+ if (config_weechat_read () < 0) /* read WeeChat configuration */
exit (EXIT_FAILURE);
command_index_build (); /* build cmd index for completion */
gui_main_init (); /* init WeeChat interface */
@@ -605,8 +611,8 @@ main (int argc, char *argv[])
plugin_init (auto_load_plugins); /* init plugin interface(s) */
gui_main_loop (); /* WeeChat main loop */
plugin_end (); /* end plugin interface(s) */
- if (cfg_look_save_on_exit)
- (void) weechat_config_write (NULL); /* save WeeChat config file */
+ if (CONFIG_BOOLEAN(config_look_save_on_exit))
+ (void) config_weechat_write (NULL); /* save WeeChat config file */
command_index_free (); /* free commands index */
gui_main_end (); /* shut down WeeChat GUI */
weechat_shutdown (EXIT_SUCCESS, 0); /* quit WeeChat (oh no, why?) */