mirror of
https://github.com/weechat/weechat.git
synced 2026-07-07 10:13:12 +02:00
New config functions, almost entirely rewritten from scratch
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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 \
|
||||
|
||||
@@ -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;
|
||||
|
||||
+56
-70
@@ -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",
|
||||
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 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),
|
||||
*((int *)(option->ptr_int)));
|
||||
(option->value) ? CONFIG_STRING(option) : "",
|
||||
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS));
|
||||
break;
|
||||
case OPTION_TYPE_INT_WITH_STRING:
|
||||
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->array_values[*((int *)(option->ptr_int))]);
|
||||
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 ();
|
||||
|
||||
+811
-297
File diff suppressed because it is too large
Load Diff
+100
-16
@@ -20,24 +20,108 @@
|
||||
#ifndef __WEECHAT_CONFIG_FILE_H
|
||||
#define __WEECHAT_CONFIG_FILE_H 1
|
||||
|
||||
#include "wee-config-option.h"
|
||||
#define CONFIG_BOOLEAN(option) (*((char *)((option)->value)))
|
||||
#define CONFIG_BOOLEAN_DEFAULT(option) (*((char *)((option)->default_value)))
|
||||
|
||||
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 *);
|
||||
#define CONFIG_INTEGER(option) (*((int *)((option)->value)))
|
||||
#define CONFIG_INTEGER_DEFAULT(option) (*((int *)((option)->default_value)))
|
||||
|
||||
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 *);
|
||||
#define CONFIG_STRING(option) ((char *)((option)->value))
|
||||
#define CONFIG_STRING_DEFAULT(option) ((char *)((option)->default_value))
|
||||
|
||||
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_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 */
|
||||
|
||||
@@ -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++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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 */
|
||||
+926
-1031
File diff suppressed because it is too large
Load Diff
+147
-165
@@ -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 WEECHAT_CONFIG_FILENAME "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 CONFIG_LOOK_NICKLIST_LEFT 0
|
||||
#define CONFIG_LOOK_NICKLIST_RIGHT 1
|
||||
#define CONFIG_LOOK_NICKLIST_TOP 2
|
||||
#define CONFIG_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 CONFIG_LOOK_PREFIX_ALIGN_NONE 0
|
||||
#define CONFIG_LOOK_PREFIX_ALIGN_LEFT 1
|
||||
#define CONFIG_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
|
||||
#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_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_file *weechat_config;
|
||||
|
||||
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 *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 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 *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 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 *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 weechat_options_plugins[];
|
||||
extern char *cfg_plugins_path;
|
||||
extern char *cfg_plugins_autoload;
|
||||
extern char *cfg_plugins_extension;
|
||||
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 char *weechat_config_sections[];
|
||||
extern struct t_config_option *weechat_config_options[];
|
||||
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 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 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 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 ();
|
||||
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 */
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
|
||||
+6
-4
@@ -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) +
|
||||
|
||||
+19
-13
@@ -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?) */
|
||||
|
||||
Reference in New Issue
Block a user