From 65c9a7960342f67bdedac0c47ab20e8de2090d15 Mon Sep 17 00:00:00 2001 From: Sebastien Helleu Date: Sun, 26 Oct 2003 13:21:07 +0000 Subject: [PATCH] Added #include "config.h" with #ifdef HAVE_CONFIG_H --- configure.in | 4 +- src/common/Makefile.am | 9 +- src/common/command.c | 17 +- src/common/completion.c | 5 +- src/common/history.c | 5 +- src/common/weechat.c | 13 +- src/common/weechat.h | 14 +- src/common/weeconfig.c | 1201 ++++++++++++++++++++++++++ src/common/weeconfig.h | 157 ++++ src/gui/curses/Makefile.am | 3 +- src/gui/curses/gui-display.c | 11 +- src/gui/curses/gui-input.c | 7 +- src/gui/gtk/Makefile.am | 3 +- src/gui/gtk/gui-display.c | 9 +- src/gui/gtk/gui-input.c | 7 +- src/gui/gui-common.c | 5 +- src/irc/Makefile.am | 3 +- src/irc/irc-channel.c | 5 +- src/irc/irc-commands.c | 7 +- src/irc/irc-display.c | 7 +- src/irc/irc-nick.c | 5 +- src/irc/irc-recv.c | 15 +- src/irc/irc-send.c | 11 +- src/irc/irc-server.c | 9 +- weechat/configure.in | 4 +- weechat/src/common/Makefile.am | 9 +- weechat/src/common/command.c | 17 +- weechat/src/common/completion.c | 5 +- weechat/src/common/history.c | 5 +- weechat/src/common/weechat.c | 13 +- weechat/src/common/weechat.h | 14 +- weechat/src/common/weeconfig.c | 1201 ++++++++++++++++++++++++++ weechat/src/common/weeconfig.h | 157 ++++ weechat/src/gui/curses/Makefile.am | 3 +- weechat/src/gui/curses/gui-display.c | 11 +- weechat/src/gui/curses/gui-input.c | 7 +- weechat/src/gui/gtk/Makefile.am | 3 +- weechat/src/gui/gtk/gui-display.c | 9 +- weechat/src/gui/gtk/gui-input.c | 7 +- weechat/src/gui/gui-common.c | 5 +- weechat/src/irc/Makefile.am | 3 +- weechat/src/irc/irc-channel.c | 5 +- weechat/src/irc/irc-commands.c | 7 +- weechat/src/irc/irc-display.c | 7 +- weechat/src/irc/irc-nick.c | 5 +- weechat/src/irc/irc-recv.c | 15 +- weechat/src/irc/irc-send.c | 11 +- weechat/src/irc/irc-server.c | 9 +- 48 files changed, 2942 insertions(+), 122 deletions(-) create mode 100644 src/common/weeconfig.c create mode 100644 src/common/weeconfig.h create mode 100644 weechat/src/common/weeconfig.c create mode 100644 weechat/src/common/weeconfig.h diff --git a/configure.in b/configure.in index da64b3d4d..b40507624 100644 --- a/configure.in +++ b/configure.in @@ -19,10 +19,10 @@ # Process this file with autoconf to produce a configure script. AC_PREREQ(2.56) -AC_INIT(WeeChat, 0.0.3, flashcode@flashtux.org) +AC_INIT(WeeChat, 0.0.3-pre3, flashcode@flashtux.org) AC_CONFIG_SRCDIR([src/common/weechat.c]) AM_CONFIG_HEADER(config.h) -AM_INIT_AUTOMAKE([weechat], [0.0.3]) +AM_INIT_AUTOMAKE([weechat], [0.0.3-pre3]) # Checks for programs. AC_PROG_CC diff --git a/src/common/Makefile.am b/src/common/Makefile.am index 4d4764c31..743e8cb51 100644 --- a/src/common/Makefile.am +++ b/src/common/Makefile.am @@ -18,7 +18,12 @@ noinst_LIBRARIES = lib_weechat_main.a lib_weechat_main_a_SOURCES = weechat.c \ + weechat.h \ command.c \ + command.h \ completion.c \ - config.c \ - history.c + completion.h \ + weeconfig.c \ + weeconfig.h \ + history.c \ + history.h diff --git a/src/common/command.c b/src/common/command.c index a60152123..633aa1f8a 100644 --- a/src/common/command.c +++ b/src/common/command.c @@ -19,16 +19,19 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - /* command.c: WeeChat internal commands */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #include "weechat.h" #include "command.h" -#include "config.h" +#include "weeconfig.h" #include "../irc/irc.h" #include "../gui/gui.h" @@ -528,7 +531,7 @@ exec_weechat_command (t_irc_server *server, char *string) gui_printf (NULL, _("%s wrong argument count for %s command \"%s\" " "(expected: %d arg%s)\n"), - WEECHAT_ERROR, WEECHAT_NAME, + WEECHAT_ERROR, PACKAGE_NAME, command + 1, weechat_commands[i].max_arg, (weechat_commands[i].max_arg > @@ -537,7 +540,7 @@ exec_weechat_command (t_irc_server *server, char *string) gui_printf (NULL, _("%s wrong argument count for %s command \"%s\" " "(expected: between %d and %d arg%s)\n"), - WEECHAT_ERROR, WEECHAT_NAME, + WEECHAT_ERROR, PACKAGE_NAME, command + 1, weechat_commands[i].min_arg, weechat_commands[i].max_arg, @@ -555,7 +558,7 @@ exec_weechat_command (t_irc_server *server, char *string) if (return_code < 0) gui_printf (NULL, _("%s %s command \"%s\" failed\n"), - WEECHAT_ERROR, WEECHAT_NAME, command + 1); + WEECHAT_ERROR, PACKAGE_NAME, command + 1); } if (argv) { @@ -906,7 +909,7 @@ weechat_cmd_help (int argc, char **argv) if (argc == 0) { gui_printf (NULL, - _("> List of %s internal commands:\n"), WEECHAT_NAME); + _("> List of %s internal commands:\n"), PACKAGE_NAME); for (i = 0; weechat_commands[i].command_name; i++) gui_printf (NULL, " %s - %s\n", weechat_commands[i].command_name, @@ -927,7 +930,7 @@ weechat_cmd_help (int argc, char **argv) gui_printf (NULL, _("> Help on %s internal command \"%s\":\n"), - WEECHAT_NAME, weechat_commands[i].command_name); + PACKAGE_NAME, weechat_commands[i].command_name); gui_printf (NULL, _("Syntax: /%s %s\n"), weechat_commands[i].command_name, diff --git a/src/common/completion.c b/src/common/completion.c index a050e2f0b..4a52cb2cf 100644 --- a/src/common/completion.c +++ b/src/common/completion.c @@ -19,10 +19,13 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - /* completion.c: completes words according to context (cmd/nick) */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include diff --git a/src/common/history.c b/src/common/history.c index fed419219..58ae318be 100644 --- a/src/common/history.c +++ b/src/common/history.c @@ -19,10 +19,13 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - /* history.c: memorize and call again commands or text */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include diff --git a/src/common/weechat.c b/src/common/weechat.c index 1e4866c02..632ef1c43 100644 --- a/src/common/weechat.c +++ b/src/common/weechat.c @@ -36,10 +36,13 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - /* weechat.c: core functions for WeeChat */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #include @@ -49,7 +52,7 @@ #include #include "weechat.h" -#include "config.h" +#include "weeconfig.h" #include "command.h" #include "../irc/irc.h" #include "../gui/gui.h" @@ -128,7 +131,7 @@ wee_parse_args (int argc, char *argv[]) else if ((strcmp (argv[i], "-v") == 0) || (strcmp (argv[i], "--version") == 0)) { - printf (WEECHAT_VERSION "\n"); + printf (PACKAGE_VERSION "\n"); exit (0); } else @@ -280,14 +283,14 @@ main (int argc, char *argv[]) { gui_printf_color (NULL, COLOR_WIN_CHAT, _("%sWelcome to "), (cfg_look_startup_logo) ? " " : ""); - gui_printf_color (NULL, COLOR_WIN_CHAT_PREFIX2, WEECHAT_NAME); + gui_printf_color (NULL, COLOR_WIN_CHAT_PREFIX2, PACKAGE_NAME); gui_printf_color (NULL, COLOR_WIN_CHAT, ", %s\n", cfg_look_weechat_slogan); } if (cfg_look_startup_version) { gui_printf_color (NULL, COLOR_WIN_CHAT_PREFIX2, - "%s" WEECHAT_NAME_AND_VERSION, + "%s" PACKAGE_STRING, (cfg_look_startup_logo) ? " " : ""); gui_printf_color (NULL, COLOR_WIN_CHAT, ", %s %s %s\n", diff --git a/src/common/weechat.h b/src/common/weechat.h index adc0bf04e..2e676ca86 100644 --- a/src/common/weechat.h +++ b/src/common/weechat.h @@ -31,15 +31,11 @@ #define _(string) gettext(string) #define N_(string) (string) -#define WEECHAT_NAME "WeeChat" -#define WEECHAT_VERSION "0.0.3-pre2" - -#define WEECHAT_NAME_AND_VERSION WEECHAT_NAME " " WEECHAT_VERSION -#define WEECHAT_COPYRIGHT WEECHAT_NAME " (c) 2003 by Wee Team" +#define WEECHAT_COPYRIGHT PACKAGE_NAME " (c) 2003 by Wee Team" #define WEECHAT_WEBSITE "http://weechat.flashtux.org" -#define WEECHAT_ERROR _(WEECHAT_NAME " Error:") -#define WEECHAT_WARNING _(WEECHAT_NAME " Warning:") +#define WEECHAT_ERROR _(PACKAGE_NAME " Error:") +#define WEECHAT_WARNING _(PACKAGE_NAME " Warning:") /* debug mode, 0=normal use, 1=some debug msg, 2=full debug (developers only) */ #define DEBUG 0 @@ -51,7 +47,7 @@ /* license */ #define WEE_LICENSE \ - WEECHAT_NAME_AND_VERSION " (c) Copyright 2003, compiled on " __DATE__ __TIME__ \ + PACKAGE_STRING " (c) Copyright 2003, compiled on " __DATE__ __TIME__ \ "Developed by FlashCode \n" \ " Bounga \n" \ " Xahlexx \n\n" \ @@ -71,7 +67,7 @@ "Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n\n" #define WEE_USAGE \ - WEECHAT_NAME_AND_VERSION " (c) Copyright 2003, compiled on " __DATE__ __TIME__ \ + PACKAGE_STRING " (c) Copyright 2003, compiled on " __DATE__ __TIME__ \ "Developed by FlashCode \n" \ " Bounga \n" \ " Xahlexx \n\n" \ diff --git a/src/common/weeconfig.c b/src/common/weeconfig.c new file mode 100644 index 000000000..3a58da127 --- /dev/null +++ b/src/common/weeconfig.c @@ -0,0 +1,1201 @@ +/* + * Copyright (c) 2003 by FlashCode + * Bounga + * Xahlexx + * See README for License detail. + * + * 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 2 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, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* config.c: WeeChat configuration */ + + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include +#include +#include + +#include "weechat.h" +#include "weeconfig.h" +#include "command.h" +#include "../irc/irc.h" +#include "../gui/gui.h" + + +/* config sections */ + +t_config_section config_sections[CONFIG_NUMBER_SECTIONS] = +{ { CONFIG_SECTION_LOOK, "look" }, + { CONFIG_SECTION_COLORS, "colors" }, + { CONFIG_SECTION_HISTORY, "history" }, + { CONFIG_SECTION_LOG, "log" }, + { CONFIG_SECTION_DCC, "dcc" }, + { CONFIG_SECTION_PROXY, "proxy" }, + { CONFIG_SECTION_ALIAS, "alias" }, + { CONFIG_SECTION_SERVER, "server" } +}; + +/* config, look & feel section */ + +int cfg_look_set_title; +int cfg_look_startup_logo; +int cfg_look_startup_version; +char *cfg_look_weechat_slogan; +int cfg_look_color_nicks; +int cfg_look_color_actions; +int cfg_look_remove_colors_from_msgs; +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_nickmode; +int cfg_look_nickmode_empty; +char *cfg_look_no_nickname; +char *cfg_look_completor; + +t_config_option weechat_options_look[] = +{ { "look_set_title", N_("set title for terminal window (curses GUI) with name & version"), + N_("set title for terminal window (curses GUI) with name & version"), + OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, + NULL, NULL, &cfg_look_set_title, NULL, NULL }, + { "look_startup_logo", N_("display WeeChat logo at startup"), + N_("display WeeChat logo at startup"), + OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, + NULL, NULL, &cfg_look_startup_logo, NULL, NULL }, + { "look_startup_version", N_("display WeeChat version at startup"), + N_("display WeeChat version at startup"), + OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, + NULL, NULL, &cfg_look_startup_version, NULL, NULL }, + { "look_weechat_slogan", N_("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, NULL }, + { "look_color_nicks", N_("display nick names with different colors"), + N_("display nick names with different colors"), + OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, + NULL, NULL, &cfg_look_color_nicks, NULL, NULL }, + { "look_color_actions", N_("display actions with different colors"), + N_("display actions with different colors"), + OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, + NULL, NULL, &cfg_look_color_actions, NULL, NULL }, + { "look_remove_colors_from_msgs", N_("remove colors from incoming messages"), + N_("remove colors from incoming messages"), + OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, + NULL, NULL, &cfg_look_remove_colors_from_msgs, NULL, NULL }, + { "look_nicklist", N_("display nicklist window"), + N_("display nicklist window (for channel windows)"), + OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, + NULL, NULL, &cfg_look_nicklist, NULL, NULL }, + { "look_nicklist_position", N_("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, NULL }, + { "look_nicklist_min_size", N_("min size for nicklist"), + 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, NULL }, + { "look_nicklist_max_size", N_("max size for nicklist"), + 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, NULL }, + { "look_no_nickname", N_("text to display instead of nick when not connected"), + N_("text to display instead of nick when not connected"), + OPTION_TYPE_STRING, 0, 0, 0, + "-cmd-", NULL, NULL, &cfg_look_no_nickname, NULL }, + { "look_nickmode", N_("display nick mode ((half)op/voice) before each nick"), + 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, NULL }, + { "look_nickmode_empty", N_("display space if nick mode is not (half)op/voice"), + 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, NULL }, + { "look_nick_completor", N_("the string inserted after nick completion"), + N_("the string inserted after nick completion"), + OPTION_TYPE_STRING, 0, 0, 0, + ":", NULL, NULL, &cfg_look_completor, NULL }, + { NULL, NULL, NULL, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL } +}; + +/* config, colors section */ + +int cfg_col_title; +int cfg_col_title_bg; +int cfg_col_chat; +int cfg_col_chat_time; +int cfg_col_chat_time_sep; +int cfg_col_chat_prefix1; +int cfg_col_chat_prefix2; +int cfg_col_chat_nick; +int cfg_col_chat_host; +int cfg_col_chat_channel; +int cfg_col_chat_dark; +int cfg_col_chat_bg; +int cfg_col_status; +int cfg_col_status_active; +int cfg_col_status_data_msg; +int cfg_col_status_data_other; +int cfg_col_status_more; +int cfg_col_status_bg; +int cfg_col_input; +int cfg_col_input_channel; +int cfg_col_input_nick; +int cfg_col_input_bg; +int cfg_col_nick; +int cfg_col_nick_op; +int cfg_col_nick_halfop; +int cfg_col_nick_voice; +int cfg_col_nick_sep; +int cfg_col_nick_self; +int cfg_col_nick_private; +int cfg_col_nick_bg; + +t_config_option weechat_options_colors[] = +{ /* title window */ + { "col_title", N_("color for title bar"), + N_("color for title bar"), + OPTION_TYPE_COLOR, 0, 0, 0, + "gray", NULL, &cfg_col_title, NULL, NULL }, + { "col_title_bg", N_("background for title bar"), + N_("background for title bar"), + OPTION_TYPE_COLOR, 0, 0, 0, + "blue", NULL, &cfg_col_title_bg, NULL, NULL }, + + /* chat window */ + { "col_chat", N_("color for chat text"), + N_("color for chat text"), + OPTION_TYPE_COLOR, 0, 0, 0, + "gray", NULL, &cfg_col_chat, NULL, NULL }, + { "col_chat_time", N_("color for time"), + N_("color for time in chat window"), + OPTION_TYPE_COLOR, 0, 0, 0, + "gray", NULL, &cfg_col_chat_time, NULL, NULL }, + { "col_chat_time_sep", N_("color for time separator"), + N_("color for time separator (chat window)"), + OPTION_TYPE_COLOR, 0, 0, 0, + "brown", NULL, &cfg_col_chat_time_sep, NULL, NULL }, + { "col_chat_prefix1", N_("color for 1st and 3rd char of prefix"), + N_("color for 1st and 3rd char of prefix"), + OPTION_TYPE_COLOR, 0, 0, 0, + "lightcyan", NULL, &cfg_col_chat_prefix1, NULL, NULL }, + { "col_chat_prefix2", N_("color for middle char of prefix"), + N_("color for middle char of prefix"), + OPTION_TYPE_COLOR, 0, 0, 0, + "white", NULL, &cfg_col_chat_prefix2, NULL, NULL }, + { "col_chat_nick", N_("color for nicks in actions"), + N_("color for nicks in actions (chat window)"), + OPTION_TYPE_COLOR, 0, 0, 0, + "lightcyan", NULL, &cfg_col_chat_nick, NULL, NULL }, + { "col_chat_host", N_("color for hostnames"), + N_("color for hostnames (chat window)"), + OPTION_TYPE_COLOR, 0, 0, 0, + "cyan", NULL, &cfg_col_chat_host, NULL, NULL }, + { "col_chat_channel", N_("color for channel names in actions"), + N_("color for channel names in actions (chat window)"), + OPTION_TYPE_COLOR, 0, 0, 0, + "white", NULL, &cfg_col_chat_channel, NULL, NULL }, + { "col_chat_dark", N_("color for dark separators"), + N_("color for dark separators (chat window)"), + OPTION_TYPE_COLOR, 0, 0, 0, + "green", NULL, &cfg_col_chat_dark, NULL, NULL }, + { "col_chat_bg", N_("background for chat"), + N_("background for chat window"), + OPTION_TYPE_COLOR, 0, 0, 0, + "default", NULL, &cfg_col_chat_bg, NULL, NULL }, + + /* status window */ + { "col_status", N_("color for status bar"), + N_("color for status bar"), + OPTION_TYPE_COLOR, 0, 0, 0, + "gray", NULL, &cfg_col_status, NULL, NULL }, + { "col_status_active", N_("color for active window"), + N_("color for active window (status bar)"), + OPTION_TYPE_COLOR, 0, 0, 0, + "yellow", NULL, &cfg_col_status_active, NULL, NULL }, + { "col_status_data_msg", N_("color for window with new messages"), + N_("color for window with new messages (status bar)"), + OPTION_TYPE_COLOR, 0, 0, 0, + "lightred", NULL, &cfg_col_status_data_msg, NULL, NULL }, + { "col_status_data_other", N_("color for window with new data (not messages)"), + N_("color for window with new data (not messages) (status bar)"), + OPTION_TYPE_COLOR, 0, 0, 0, + "lightmagenta", NULL, &cfg_col_status_data_other, NULL, NULL }, + { "col_status_more", N_("color for \"*MORE*\" text"), + N_("color for window with new data (status bar)"), + OPTION_TYPE_COLOR, 0, 0, 0, + "white", NULL, &cfg_col_status_more, NULL, NULL }, + { "col_status_bg", N_("background for status window"), + N_("background for status window"), + OPTION_TYPE_COLOR, 0, 0, 0, + "blue", NULL, &cfg_col_status_bg, NULL, NULL }, + + /* input window */ + { "col_input", N_("color for input text"), + N_("color for input text"), + OPTION_TYPE_COLOR, 0, 0, 0, + "gray", NULL, &cfg_col_input, NULL, NULL }, + { "col_input_channel", N_("color for input text (channel name)"), + N_("color for input text (channel name)"), + OPTION_TYPE_COLOR, 0, 0, 0, + "white", NULL, &cfg_col_input_channel, NULL, NULL }, + { "col_input_nick", N_("color for input text (nick name)"), + N_("color for input text (nick name)"), + OPTION_TYPE_COLOR, 0, 0, 0, + "lightgreen", NULL, &cfg_col_input_nick, NULL, NULL }, + { "col_input_bg", N_("background for input window"), + N_("background for input window"), + OPTION_TYPE_COLOR, 0, 0, 0, + "default", NULL, &cfg_col_input_bg, NULL, NULL }, + + /* nick window */ + { "col_nick", N_("color for nicknames"), + N_("color for nicknames"), + OPTION_TYPE_COLOR, 0, 0, 0, + "gray", NULL, &cfg_col_nick, NULL, NULL }, + { "col_nick_op", N_("color for operator symbol"), + N_("color for operator symbol"), + OPTION_TYPE_COLOR, 0, 0, 0, + "lightgreen", NULL, &cfg_col_nick_op, NULL, NULL }, + { "col_nick_halfop", N_("color for half-operator symbol"), + N_("color for half-operator symbol"), + OPTION_TYPE_COLOR, 0, 0, 0, + "lightmagenta", NULL, &cfg_col_nick_halfop, NULL, NULL }, + { "col_nick_voice", N_("color for voice symbol"), + N_("color for voice symbol"), + OPTION_TYPE_COLOR, 0, 0, 0, + "yellow", NULL, &cfg_col_nick_voice, NULL, NULL }, + { "col_nick_sep", N_("color for nick separator"), + N_("color for nick separator"), + OPTION_TYPE_COLOR, 0, 0, 0, + "blue", NULL, &cfg_col_nick_sep, NULL, NULL }, + { "col_nick_self", N_("color for local nick"), + N_("color for local nick"), + OPTION_TYPE_COLOR, 0, 0, 0, + "white", NULL, &cfg_col_nick_self, NULL, NULL }, + { "col_nick_private", N_("color for other nick in private window"), + N_("color for other nick in private window"), + OPTION_TYPE_COLOR, 0, 0, 0, + "brown", NULL, &cfg_col_nick_private, NULL, NULL }, + { "col_nick_bg", N_("background for nicknames"), + N_("background for nicknames"), + OPTION_TYPE_COLOR, 0, 0, 0, + "default", NULL, &cfg_col_nick_bg, NULL, NULL }, + + { NULL, NULL, NULL, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL } +}; + +/* config, history section */ + +int cfg_history_max_lines; +int cfg_history_max_commands; + +t_config_option weechat_options_history[] = +{ { "history_max_lines", N_("max lines in history (per window)"), + 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, NULL }, + { "history_max_commands", N_("max user commands in history"), + N_("maximum number of user commands in history (0 = unlimited)"), + OPTION_TYPE_INT, 0, INT_MAX, 100, + NULL, NULL, &cfg_history_max_commands, NULL, NULL }, + { NULL, NULL, NULL, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL } +}; + +/* config, log section */ + +int cfg_log_auto_channels; +int cfg_log_auto_private; +char *cfg_log_path; +char *cfg_log_name; +char *cfg_log_timestamp; +char *cfg_log_start_string; +char *cfg_log_end_string; + +t_config_option weechat_options_log[] = +{ { "log_auto_channels", N_("automatically log channel chats"), + N_("automatically log channel chats"), + OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, + NULL, NULL, &cfg_log_auto_channels, NULL, NULL }, + { "log_auto_private", N_("automatically log private chats"), + N_("automatically log private chats"), + OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, + NULL, NULL, &cfg_log_auto_private, NULL, NULL }, + { "log_path", N_("path for log files"), + N_("path for WeeChat log files"), + OPTION_TYPE_STRING, 0, 0, 0, + "~/.weechat/logs/", NULL, NULL, &cfg_log_path, NULL }, + { "log_name", N_("name for log files"), + N_("name for log files (%S == irc server name, " + "%N == channel name (or nickname if private chat)"), + OPTION_TYPE_STRING, 0, 0, 0, + "%S,%N.weechatlog", NULL, NULL, &cfg_log_name, NULL }, + { "log_timestamp", N_("timestamp for log"), + N_("timestamp for log (see man strftime for date/time specifiers)"), + OPTION_TYPE_STRING, 0, 0, 0, + "~", NULL, NULL, &cfg_log_timestamp, NULL }, + { "log_start_string", N_("start string for log files"), + N_("text written when starting new log file " + "(see man strftime for date/time specifiers)"), + OPTION_TYPE_STRING, 0, 0, 0, + "--- Log started %a %b %d %Y %H:%M:%s", NULL, NULL, &cfg_log_start_string, NULL }, + { "log_end_string", N_("end string for log files"), + N_("text written when ending log file " + "(see man strftime for date/time specifiers)"), + OPTION_TYPE_STRING, 0, 0, 0, + "--- Log ended %a %b %d %Y %H:%M:%s", NULL, NULL, &cfg_log_end_string, NULL }, + { NULL, NULL, NULL, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL } +}; + +/* config, dcc section */ + +int cfg_dcc_auto_accept_files; +int cfg_dcc_auto_accept_max_size; +int cfg_dcc_auto_accept_chats; +int cfg_dcc_timeout; +char *cfg_dcc_download_path; +char *cfg_dcc_upload_path; +int cfg_dcc_auto_rename; +int cfg_dcc_auto_resume; + +t_config_option weechat_options_dcc[] = +{ { "dcc_auto_accept_files", N_("automatically accept dcc files"), + N_("automatically accept incoming dcc files"), + OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, + NULL, NULL, &cfg_dcc_auto_accept_files, NULL, NULL }, + { "dcc_auto_accept_max_size", N_("max size when auto accepting file"), + N_("maximum size for incoming file when automatically accepted"), + OPTION_TYPE_INT, 0, INT_MAX, 0, + NULL, NULL, &cfg_dcc_auto_accept_max_size, NULL, NULL }, + { "dcc_auto_accept_chats", N_("automatically accept dcc chats"), + N_("automatically accept dcc chats (use carefully!)"), + OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, + NULL, NULL, &cfg_dcc_auto_accept_chats, NULL, NULL }, + { "dcc_timeout", N_("timeout for dcc request"), + N_("timeout for dcc request (in seconds)"), + OPTION_TYPE_INT, 1, INT_MAX, 300, + NULL, NULL, &cfg_dcc_timeout, NULL, NULL }, + { "dcc_download_path", N_("path for incoming files with dcc"), + N_("path for writing incoming files with dcc (default: user home)"), + OPTION_TYPE_STRING, 0, 0, 0, "~", + NULL, NULL, &cfg_dcc_download_path, NULL }, + { "dcc_upload_path", N_("default path for sending files with dcc"), + N_("path for reading files when sending thru dcc (when no path is specified)"), + OPTION_TYPE_STRING, 0, 0, 0, "~", + NULL, NULL, &cfg_dcc_upload_path, NULL }, + { "dcc_auto_rename", N_("automatically rename dcc files if already exists"), + N_("rename incoming files if already exists (add '.1', '.2', ...)"), + OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, + NULL, NULL, &cfg_dcc_auto_rename, NULL, NULL }, + { "dcc_auto_resume", N_("automatically resume aborted transfers"), + N_("automatically resume dcc transfer if connection with remote host is loosed"), + OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, + NULL, NULL, &cfg_dcc_auto_resume, NULL, NULL }, + { NULL, NULL, NULL, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL } +}; + +/* config, proxy section */ + +int cfg_proxy_use; +char *cfg_proxy_address; +int cfg_proxy_port; +char *cfg_proxy_password; + +t_config_option weechat_options_proxy[] = +{ { "proxy_use", N_("use proxy"), + 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, NULL }, + { "proxy_address", N_("proxy address"), + N_("proxy server address (IP or hostname)"), + OPTION_TYPE_STRING, 0, 0, 0, + "", NULL, NULL, &cfg_proxy_address, NULL }, + { "proxy_port", N_("port for proxy"), + N_("port for connecting to proxy server"), + OPTION_TYPE_INT, 0, 65535, 1080, + NULL, NULL, &cfg_proxy_port, NULL, NULL }, + { "proxy_password", N_("proxy password"), + N_("password for proxy server"), + OPTION_TYPE_STRING, 0, 0, 0, + "", NULL, NULL, &cfg_proxy_password, NULL }, + { NULL, NULL, NULL, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL } +}; + +/* config, server section */ + +static t_irc_server cfg_server; + +t_config_option weechat_options_server[] = +{ { "server_name", N_("server name"), + N_("name associated to IRC server (for display only)"), + OPTION_TYPE_STRING, 0, 0, 0, + "", NULL, NULL, &(cfg_server.name), NULL }, + { "server_autoconnect", N_("automatically connect to server"), + N_("automatically connect to server when WeeChat is starting"), + OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, + NULL, NULL, &(cfg_server.autoconnect), NULL, NULL }, + { "server_address", N_("server address or hostname"), + N_("IP address or hostname of IRC server"), + OPTION_TYPE_STRING, 0, 0, 0, + "", NULL, NULL, &(cfg_server.address), NULL }, + { "server_port", N_("port for IRC server"), + N_("port for connecting to server"), + OPTION_TYPE_INT, 0, 65535, 6667, + NULL, NULL, &(cfg_server.port), NULL, NULL }, + { "server_password", N_("server password"), + N_("password for IRC server"), + OPTION_TYPE_STRING, 0, 0, 0, + "", NULL, NULL, &(cfg_server.password), NULL }, + { "server_nick1", N_("nickname for server"), + N_("nickname to use on IRC server"), + OPTION_TYPE_STRING, 0, 0, 0, + "", NULL, NULL, &(cfg_server.nick1), NULL }, + { "server_nick2", N_("alternate nickname for server"), + N_("alternate nickname to use on IRC server (if nickname is already used)"), + OPTION_TYPE_STRING, 0, 0, 0, + "", NULL, NULL, &(cfg_server.nick2), NULL }, + { "server_nick3", N_("2nd alternate nickname for server"), + N_("2nd alternate nickname to use on IRC server (if alternate nickname is already used)"), + OPTION_TYPE_STRING, 0, 0, 0, + "", NULL, NULL, &(cfg_server.nick3), NULL }, + { "server_username", N_("user name for server"), + N_("user name to use on IRC server"), + OPTION_TYPE_STRING, 0, 0, 0, + "", NULL, NULL, &(cfg_server.username), NULL }, + { "server_realname", N_("real name for server"), + N_("real name to use on IRC server"), + OPTION_TYPE_STRING, 0, 0, 0, + "", NULL, NULL, &(cfg_server.realname), NULL }, + { "server_command", N_("first command to run when connected to server"), + N_("first command to run when connected to server"), + OPTION_TYPE_STRING, 0, 0, 0, + "", NULL, NULL, &(cfg_server.command), NULL }, + { "server_autojoin", N_("list of channels to join when connected to server"), + N_("comma separated list of channels to join when connected to server"), + OPTION_TYPE_STRING, 0, 0, 0, + "", NULL, NULL, &(cfg_server.autojoin), NULL }, + { NULL, NULL, NULL, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL } +}; + +/* all weechat options */ + +t_config_option *weechat_options[CONFIG_NUMBER_SECTIONS] = +{ weechat_options_look, weechat_options_colors, weechat_options_history, + weechat_options_log, weechat_options_dcc, weechat_options_proxy, + NULL, weechat_options_server +}; + + +/* + * get_pos_array_values: returns position of a string in an array of values + * returns -1 if not found, otherwise position + */ + +int +get_pos_array_values (char **array, char *string) +{ + int i; + + i = 0; + while (array[i]) + { + if (strcasecmp (array[i], string) == 0) + return i; + i++; + } + /* string not found in array */ + return -1; +} + +/* + * config_option_set_value: set new value for an option + * return: 0 if success + * -1 if error (bad value) + */ + +int +config_option_set_value (t_config_option *option, char *value) +{ + int int_value; + + switch (option->option_type) + { + case OPTION_TYPE_BOOLEAN: + if (strcasecmp (value, "on") == 0) + *(option->ptr_int) = BOOL_TRUE; + else if (strcasecmp (value, "off") == 0) + *(option->ptr_int) = BOOL_FALSE; + else + 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 = get_pos_array_values (option->array_values, value); + if (int_value < 0) + return -1; + *(option->ptr_int) = int_value; + break; + case OPTION_TYPE_COLOR: + if (!gui_assign_color (option->ptr_int, value)) + return -1; + break; + case OPTION_TYPE_STRING: + if (*(option->ptr_string)) + free (*(option->ptr_string)); + *(option->ptr_string) = strdup (value); + break; + } + return 0; +} + +/* + * config_set_value: 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_set_value (char *option_name, char *value) +{ + int i, j; + + for (i = 0; i < CONFIG_NUMBER_SECTIONS; i++) + { + if ((i != CONFIG_SECTION_ALIAS) && (i != CONFIG_SECTION_SERVER)) + { + for (j = 0; weechat_options[i][j].option_name; j++) + { + /* if option found, assign value and exit */ + if (strcasecmp (weechat_options[i][j].option_name, option_name) == 0) + return config_option_set_value (&weechat_options[i][j], value); + } + } + } + /* option not found */ + return -2; +} + +/* + * config_allocate_server: allocate a new server + */ + +int +config_allocate_server (char *filename, int line_number) +{ + if (!cfg_server.name + || !cfg_server.address + || cfg_server.port < 0 + || !cfg_server.nick1 + || !cfg_server.nick2 + || !cfg_server.nick3 + || !cfg_server.username + || !cfg_server.realname) + { + server_free_all (); + gui_printf (NULL, + _("%s %s, line %d: new server, but previous was incomplete\n"), + WEECHAT_WARNING, filename, line_number); + return 0; + + } + if (server_name_already_exists (cfg_server.name)) + { + server_free_all (); + gui_printf (NULL, + _("%s %s, line %d: server '%s' already exists\n"), + WEECHAT_WARNING, filename, line_number, cfg_server.name); + return 0; + } + if (!server_new (cfg_server.name, + cfg_server.autoconnect, cfg_server.address, cfg_server.port, + cfg_server.password, cfg_server.nick1, cfg_server.nick2, + cfg_server.nick3, cfg_server.username, cfg_server.realname, + cfg_server.command, cfg_server.autojoin)) + { + server_free_all (); + gui_printf (NULL, + _("%s %s, line %d: unable to create server\n"), + WEECHAT_WARNING, filename, line_number); + return 0; + } + + server_destroy (&cfg_server); + server_init (&cfg_server); + + return 1; +} + +/* + * config_default_values: initialize config variables with default values + */ + +void +config_default_values () +{ + int i, j, int_value; + + for (i = 0; i < CONFIG_NUMBER_SECTIONS; i++) + { + if ((i != CONFIG_SECTION_ALIAS) && (i != CONFIG_SECTION_SERVER)) + { + for (j = 0; weechat_options[i][j].option_name; j++) + { + switch (weechat_options[i][j].option_type) + { + case OPTION_TYPE_BOOLEAN: + case OPTION_TYPE_INT: + *weechat_options[i][j].ptr_int = + weechat_options[i][j].default_int; + break; + case OPTION_TYPE_INT_WITH_STRING: + int_value = get_pos_array_values ( + weechat_options[i][j].array_values, + weechat_options[i][j].default_string); + if (int_value < 0) + gui_printf (NULL, + _("%s unable to assign default int with string (\"%s\")\n"), + weechat_options[i][j].default_string); + else + *weechat_options[i][j].ptr_int = + int_value; + break; + case OPTION_TYPE_COLOR: + if (!gui_assign_color ( + weechat_options[i][j].ptr_int, + weechat_options[i][j].default_string)) + gui_printf (NULL, + _("%s unable to assign default color (\"%s\")\n"), + weechat_options[i][j].default_string); + break; + case OPTION_TYPE_STRING: + *weechat_options[i][j].ptr_string = + strdup (weechat_options[i][j].default_string); + break; + } + } + } + } +} + +/* + * config_read: read WeeChat configuration + * returns: 0 = successful + * -1 = config file file not found + * < -1 = other error (fatal) + */ + +int +config_read () +{ + char *filename; + FILE *file; + int section, line_number, i, option_number; + int server_found; + char line[1024], *ptr_line, *pos, *pos2; + + filename = + (char *) malloc ((strlen (getenv ("HOME")) + 64) * sizeof (char)); + sprintf (filename, "%s/.weechat/" WEECHAT_CONFIG_NAME, getenv ("HOME")); + if ((file = fopen (filename, "rt")) == NULL) + { + gui_printf (NULL, _("%s config file \"%s\" not found.\n"), + WEECHAT_WARNING, filename); + free (filename); + return -1; + } + + config_default_values (); + server_init (&cfg_server); + + /* read config file */ + section = CONFIG_SECTION_NONE; + server_found = 0; + line_number = 0; + while (!feof (file)) + { + ptr_line = fgets (line, sizeof (line) - 1, file); + line_number++; + if (ptr_line) + { + /* skip spaces */ + while (ptr_line[0] == ' ') + ptr_line++; + /* not a comment and not an empty line */ + if ((ptr_line[0] != '#') && (ptr_line[0] != '\r') + && (ptr_line[0] != '\n')) + { + /* beginning of section */ + if (ptr_line[0] == '[') + { + pos = strchr (line, ']'); + if (pos == NULL) + gui_printf (NULL, + _("%s %s, line %d: invalid syntax, missing \"]\"\n"), + WEECHAT_WARNING, filename, line_number); + else + { + pos[0] = '\0'; + pos = ptr_line + 1; + section = CONFIG_SECTION_NONE; + for (i = 0; config_sections[i].section_name; i++) + { + if (strcmp (config_sections[i].section_name, pos) == 0) + { + section = i; + break; + } + } + if (section == CONFIG_SECTION_NONE) + gui_printf (NULL, + _("%s %s, line %d: unknown section identifier (\"%s\")\n"), + WEECHAT_WARNING, filename, line_number, pos); + else + { + if (server_found) + { + /* if server already started => create it */ + config_allocate_server (filename, line_number); + } + server_found = (section == CONFIG_SECTION_SERVER) ? 1 : 0; + } + } + } + else + { + pos = strchr (line, '='); + if (pos == NULL) + gui_printf (NULL, + _("%s %s, line %d: invalid syntax, missing \"=\"\n"), + WEECHAT_WARNING, filename, line_number); + else + { + pos[0] = '\0'; + pos++; + pos2 = strchr (pos, '\r'); + if (pos2 != NULL) + pos2[0] = '\0'; + pos2 = strchr (pos, '\n'); + if (pos2 != NULL) + pos2[0] = '\0'; + + if (section == CONFIG_SECTION_ALIAS) + { + if (alias_new (line, pos)) + index_command_new (pos); + } + else + { + option_number = -1; + for (i = 0; + weechat_options[section][i].option_name; i++) + { + if (strcmp + (weechat_options[section][i].option_name, + ptr_line) == 0) + { + option_number = i; + break; + } + } + if (option_number < 0) + gui_printf (NULL, + _("%s %s, line %d: invalid option \"%s\"\n"), + WEECHAT_WARNING, filename, line_number, ptr_line); + else + { + if (config_option_set_value (&weechat_options[section][option_number], pos) < 0) + { + switch (weechat_options[section] + [option_number].option_type) + { + case OPTION_TYPE_BOOLEAN: + gui_printf (NULL, + _("%s %s, line %d: invalid value for" + "option '%s'\n" + "Expected: boolean value: " + "'off' or 'on'\n"), + WEECHAT_WARNING, filename, + line_number, ptr_line); + break; + case OPTION_TYPE_INT: + gui_printf (NULL, + _("%s %s, line %d: invalid value for " + "option '%s'\n" + "Expected: integer between %d " + "and %d\n"), + WEECHAT_WARNING, filename, + line_number, ptr_line, + weechat_options[section][option_number].min, + weechat_options[section][option_number].max); + break; + case OPTION_TYPE_INT_WITH_STRING: + gui_printf (NULL, + _("%s %s, line %d: invalid value for " + "option '%s'\n" + "Expected: one of these strings: "), + WEECHAT_WARNING, filename, + line_number, ptr_line); + i = 0; + while (weechat_options[section][option_number].array_values[i]) + { + gui_printf (NULL, "\"%s\" ", + weechat_options[section][option_number].array_values[i]); + i++; + } + gui_printf (NULL, "\n"); + break; + case OPTION_TYPE_COLOR: + gui_printf (NULL, + _("%s %s, line %d: invalid color " + "name for option '%s'\n"), + WEECHAT_WARNING, filename, + line_number, + ptr_line); + break; + } + } + } + } + } + } + } + } + } + + if (server_found) + { + if (!config_allocate_server (filename, line_number)) + { + fclose (file); + free (filename); + return -2; + } + } + + /* set default colors for colors not set */ + /*for (i = 0; i < CONFIG_NUMBER_SECTIONS; i++) + { + if (i != CONFIG_SECTION_SERVER) + { + for (j = 0; weechat_options[i][j].option_name; j++) + { + if ((weechat_options[i][j].option_type == OPTION_TYPE_COLOR) && + (*weechat_options[i][j].ptr_int == COLOR_NOT_SET)) + *weechat_options[i][j].ptr_int = + gui_get_color_by_name (weechat_options[i][j].default_string); + } + } + }*/ + + fclose (file); + free (filename); + + return 0; +} + + +/* + * config_create_default: create default WeeChat config + * return: 0 if ok + * < 0 if error + */ + +int +config_create_default () +{ + char *filename; + char line[1024]; + FILE *file; + int i, j; + time_t current_time; + + filename = + (char *) malloc ((strlen (getenv ("HOME")) + 64) * sizeof (char)); + sprintf (filename, "%s/.weechat/" WEECHAT_CONFIG_NAME, getenv ("HOME")); + if ((file = fopen (filename, "wt")) == NULL) + { + gui_printf (NULL, _("%s cannot create file \"%s\"\n"), + WEECHAT_ERROR, filename); + free (filename); + return -1; + } + + printf (_("%s: creating default config file...\n"), PACKAGE_NAME); + log_printf (_("creating default config file\n")); + + current_time = time (NULL); + sprintf (line, _("#\n# %s configuration file, created by " + "%s v%s on %s#\n"), + PACKAGE_NAME, PACKAGE_NAME, PACKAGE_VERSION, + ctime (¤t_time)); + fputs (line, file); + + for (i = 0; i < CONFIG_NUMBER_SECTIONS; i++) + { + if ((i != CONFIG_SECTION_ALIAS) && (i != CONFIG_SECTION_SERVER)) + { + sprintf (line, "\n[%s]\n", config_sections[i].section_name); + fputs (line, file); + if ((i == CONFIG_SECTION_HISTORY) || (i == CONFIG_SECTION_LOG) || + (i == CONFIG_SECTION_DCC) || (i == CONFIG_SECTION_PROXY)) + { + sprintf (line, + "# WARNING!!! Options for section \"%s\" are not developed!\n", + config_sections[i].section_name); + fputs (line, file); + } + for (j = 0; weechat_options[i][j].option_name; j++) + { + switch (weechat_options[i][j].option_type) + { + case OPTION_TYPE_BOOLEAN: + sprintf (line, "%s=%s\n", + weechat_options[i][j].option_name, + (weechat_options[i][j].default_int) ? + "on" : "off"); + break; + case OPTION_TYPE_INT: + sprintf (line, "%s=%d\n", + weechat_options[i][j].option_name, + weechat_options[i][j].default_int); + break; + case OPTION_TYPE_INT_WITH_STRING: + case OPTION_TYPE_COLOR: + case OPTION_TYPE_STRING: + sprintf (line, "%s=%s\n", + weechat_options[i][j].option_name, + weechat_options[i][j].default_string); + break; + } + fputs (line, file); + } + } + } + + /* default aliases */ + /* TODO: remove comments when missing commands will be ok */ + fputs ("\n[alias]\n", file); + fputs ("SAY=msg *\n", file); + fputs ("BYE=quit\n", file); + fputs ("EXIT=quit\n", file); + fputs ("SIGNOFF=quit\n", file); + fputs ("C=clear\n", file); + fputs ("CL=clear\n", file); + fputs ("# CHAT=dcc chat\n", file); + fputs ("# GET=dcc get\n", file); + fputs ("# IG=ignore\n", file); + fputs ("J=join\n", file); + fputs ("K=kick\n", file); + fputs ("# KB=kickban\n", file); + fputs ("# KN=knockout\n", file); + fputs ("LEAVE=part\n", file); + fputs ("M=msg\n", file); + fputs ("# MUB=unban *\n", file); + fputs ("N=names\n", file); + fputs ("T=topic\n", file); + fputs ("# UB=unban\n", file); + fputs ("# UNIG=unignore\n", file); + fputs ("# W=who\n", file); + fputs ("WC=part\n", file); + fputs ("WI=whois\n", file); + fputs ("# WW=whowas\n", file); + + /* default server is freenode */ + fputs ("\n[server]\n", file); + fputs ("server_name=freenode\n", file); + fputs ("server_autoconnect=on\n", file); + fputs ("server_address=irc.freenode.net\n", file); + fputs ("server_port=6667\n", file); + fputs ("server_password=\n", file); + fputs ("server_nick1=weechat_user\n", file); + fputs ("server_nick2=weechat2\n", file); + fputs ("server_nick3=weechat3\n", file); + fputs ("server_username=weechat\n", file); + fputs ("server_realname=WeeChat default realname\n", file); + fputs ("server_command=\n", file); + fputs ("server_autojoin=\n", file); + + fclose (file); + free (filename); + return 0; +} + +/* + * config_write: write WeeChat configurtion + * return: 0 if ok + * < 0 if error + */ + +int +config_write (char *config_name) +{ + char *filename; + char line[1024]; + FILE *file; + int i, j; + time_t current_time; + t_irc_server *ptr_server; + t_weechat_alias *ptr_alias; + + if (config_name) + filename = strdup (config_name); + else + { + filename = + (char *) malloc ((strlen (getenv ("HOME")) + 64) * sizeof (char)); + sprintf (filename, "%s/.weechat/" WEECHAT_CONFIG_NAME, getenv ("HOME")); + } + + if ((file = fopen (filename, "wt")) == NULL) + { + gui_printf (NULL, _("%s cannot create file \"%s\"\n"), + WEECHAT_ERROR, filename); + free (filename); + return -1; + } + + log_printf (_("saving config to disk\n")); + + current_time = time (NULL); + sprintf (line, _("#\n# %s configuration file, created by " + "%s v%s on %s#\n"), + PACKAGE_NAME, PACKAGE_NAME, PACKAGE_VERSION, + ctime (¤t_time)); + fputs (line, file); + + for (i = 0; i < CONFIG_NUMBER_SECTIONS; i++) + { + if ((i != CONFIG_SECTION_ALIAS) && (i != CONFIG_SECTION_SERVER)) + { + sprintf (line, "\n[%s]\n", config_sections[i].section_name); + fputs (line, file); + if ((i == CONFIG_SECTION_HISTORY) || (i == CONFIG_SECTION_LOG) || + (i == CONFIG_SECTION_DCC) || (i == CONFIG_SECTION_PROXY)) + { + sprintf (line, + "# WARNING!!! Options for section \"%s\" are not developed!\n", + config_sections[i].section_name); + fputs (line, file); + } + for (j = 0; weechat_options[i][j].option_name; j++) + { + switch (weechat_options[i][j].option_type) + { + case OPTION_TYPE_BOOLEAN: + sprintf (line, "%s=%s\n", + weechat_options[i][j].option_name, + (weechat_options[i][j].ptr_int && + *weechat_options[i][j].ptr_int) ? + "on" : "off"); + break; + case OPTION_TYPE_INT: + sprintf (line, "%s=%d\n", + weechat_options[i][j].option_name, + (weechat_options[i][j].ptr_int) ? + *weechat_options[i][j].ptr_int : + weechat_options[i][j].default_int); + break; + case OPTION_TYPE_INT_WITH_STRING: + sprintf (line, "%s=%s\n", + weechat_options[i][j].option_name, + (weechat_options[i][j].ptr_int) ? + weechat_options[i][j].array_values[*weechat_options[i][j].ptr_int] : + weechat_options[i][j].array_values[weechat_options[i][j].default_int]); + break; + case OPTION_TYPE_COLOR: + sprintf (line, "%s=%s\n", + weechat_options[i][j].option_name, + (weechat_options[i][j].ptr_int) ? + gui_get_color_by_value (*weechat_options[i][j].ptr_int) : + weechat_options[i][j].default_string); + break; + case OPTION_TYPE_STRING: + sprintf (line, "%s=%s\n", + weechat_options[i][j].option_name, + (weechat_options[i][j].ptr_string) ? + *weechat_options[i][j].ptr_string : + weechat_options[i][j].default_string); + break; + } + fputs (line, file); + } + } + } + + /* alias section */ + fputs ("\n[alias]\n", file); + for (ptr_alias = weechat_alias; ptr_alias; + ptr_alias = ptr_alias->next_alias) + { + sprintf (line, "%s=%s\n", + ptr_alias->alias_name, ptr_alias->alias_command + 1); + fputs (line, file); + } + + /* server section */ + for (ptr_server = irc_servers; ptr_server; + ptr_server = ptr_server->next_server) + { + /* default server is freenode */ + fputs ("\n[server]\n", file); + sprintf (line, "server_name=%s\n", ptr_server->name); + fputs (line, file); + sprintf (line, "server_autoconnect=%s\n", + (ptr_server->autoconnect) ? "on" : "off"); + fputs (line, file); + sprintf (line, "server_address=%s\n", ptr_server->address); + fputs (line, file); + sprintf (line, "server_port=%d\n", ptr_server->port); + fputs (line, file); + sprintf (line, "server_password=%s\n", + (ptr_server->password) ? ptr_server->password : ""); + fputs (line, file); + sprintf (line, "server_nick1=%s\n", ptr_server->nick1); + fputs (line, file); + sprintf (line, "server_nick2=%s\n", ptr_server->nick2); + fputs (line, file); + sprintf (line, "server_nick3=%s\n", ptr_server->nick3); + fputs (line, file); + sprintf (line, "server_username=%s\n", ptr_server->username); + fputs (line, file); + sprintf (line, "server_realname=%s\n", ptr_server->realname); + fputs (line, file); + sprintf (line, "server_command=%s\n", + (ptr_server->command) ? ptr_server->command : ""); + fputs (line, file); + sprintf (line, "server_autojoin=%s\n", + (ptr_server->autojoin) ? ptr_server->autojoin : ""); + fputs (line, file); + } + + fclose (file); + free (filename); + return 0; +} diff --git a/src/common/weeconfig.h b/src/common/weeconfig.h new file mode 100644 index 000000000..692698797 --- /dev/null +++ b/src/common/weeconfig.h @@ -0,0 +1,157 @@ +/* + * Copyright (c) 2003 by FlashCode + * Bounga + * Xahlexx + * See README for License detail. + * + * 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 2 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, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + + +#ifndef __WEECHAT_CONFIG_H +#define __WEECHAT_CONFIG_H 1 + +#define WEECHAT_CONFIG_NAME "weechat.rc" + +#define CONFIG_SECTION_NONE -1 +#define CONFIG_SECTION_LOOK 0 +#define CONFIG_SECTION_COLORS 1 +#define CONFIG_SECTION_HISTORY 2 +#define CONFIG_SECTION_LOG 3 +#define CONFIG_SECTION_DCC 4 +#define CONFIG_SECTION_PROXY 5 +#define CONFIG_SECTION_ALIAS 6 +#define CONFIG_SECTION_SERVER 7 +#define CONFIG_NUMBER_SECTIONS 8 + +#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_COLOR 4 /* values: a color name */ +#define OPTION_TYPE_STRING 5 /* values: any string, may be empty */ + +#define BOOL_FALSE 0 +#define BOOL_TRUE 1 + +#define CFG_LOOK_NICKLIST_LEFT 0 +#define CFG_LOOK_NICKLIST_RIGHT 1 +#define CFG_LOOK_NICKLIST_TOP 2 +#define CFG_LOOK_NICKLIST_BOTTOM 3 + +typedef struct t_config_section t_config_section; + +struct t_config_section +{ + int section_number; + char *section_name; +}; + +typedef struct t_config_option t_config_option; + +struct t_config_option +{ + char *option_name; + char *short_description; + char *long_description; + int option_type; + int min, max; + int default_int; + char *default_string; + char **array_values; + int *ptr_int; + char **ptr_string; + int (*handler_change)(int *, char **); +}; + +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_color_nicks; +extern int cfg_look_color_actions; +extern int cfg_look_remove_colors_from_msgs; +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_nickmode; +extern int cfg_look_nickmode_empty; +extern char *cfg_look_no_nickname; +extern char *cfg_look_completor; + +extern int cfg_col_title; +extern int cfg_col_title_bg; +extern int cfg_col_chat; +extern int cfg_col_chat_time; +extern int cfg_col_chat_time_sep; +extern int cfg_col_chat_prefix1; +extern int cfg_col_chat_prefix2; +extern int cfg_col_chat_nick; +extern int cfg_col_chat_host; +extern int cfg_col_chat_channel; +extern int cfg_col_chat_dark; +extern int cfg_col_chat_bg; +extern int cfg_col_status; +extern int cfg_col_status_active; +extern int cfg_col_status_data_msg; +extern int cfg_col_status_data_other; +extern int cfg_col_status_more; +extern int cfg_col_status_bg; +extern int cfg_col_input; +extern int cfg_col_input_channel; +extern int cfg_col_input_nick; +extern int cfg_col_input_bg; +extern int cfg_col_nick; +extern int cfg_col_nick_op; +extern int cfg_col_nick_halfop; +extern int cfg_col_nick_voice; +extern int cfg_col_nick_sep; +extern int cfg_col_nick_self; +extern int cfg_col_nick_private; +extern int cfg_col_nick_bg; + +extern int cfg_history_max_lines; +extern int cfg_history_max_commands; + +extern int cfg_log_auto_channels; +extern int cfg_log_auto_private; +extern char *cfg_log_path; +extern char *cfg_log_name; +extern char *cfg_log_timestamp; +extern char *cfg_log_start_string; +extern char *cfg_log_end_string; + +extern int cfg_dcc_auto_accept_files; +extern int cfg_dcc_auto_accept_max_size; +extern int cfg_dcc_auto_accept_chats; +extern int cfg_dcc_timeout; +extern char *cfg_dcc_download_path; +extern char *cfg_dcc_upload_path; +extern int cfg_dcc_auto_rename; +extern int cfg_dcc_auto_resume; + +extern int cfg_proxy_use; +extern char *cfg_proxy_address; +extern int cfg_proxy_port; +extern char *cfg_proxy_password; + +extern t_config_section config_sections [CONFIG_NUMBER_SECTIONS]; +extern t_config_option * weechat_options [CONFIG_NUMBER_SECTIONS]; + +extern int config_read (); +extern int config_create_default (); +extern int config_write (); + +#endif /* config.h */ diff --git a/src/gui/curses/Makefile.am b/src/gui/curses/Makefile.am index 7a8aaacc3..d54881329 100644 --- a/src/gui/curses/Makefile.am +++ b/src/gui/curses/Makefile.am @@ -21,6 +21,7 @@ weechat_curses_LDADD = ../../common/lib_weechat_main.a \ ../../irc/lib_weechat_irc.a \ $(CURSES_LIBS) -weechat_curses_SOURCES = ../gui-common.c \ +weechat_curses_SOURCES = ../gui.h \ + ../gui-common.c \ gui-display.c \ gui-input.c diff --git a/src/gui/curses/gui-display.c b/src/gui/curses/gui-display.c index 99ab1994c..59b9e75dd 100644 --- a/src/gui/curses/gui-display.c +++ b/src/gui/curses/gui-display.c @@ -19,10 +19,13 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - /* gui-display.c: display functions for Curses GUI */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #include @@ -33,7 +36,7 @@ #include "../../common/weechat.h" #include "../gui.h" -#include "../../common/config.h" +#include "../../common/weeconfig.h" #include "../../irc/irc.h" @@ -302,7 +305,7 @@ gui_draw_window_title (t_gui_window *window) { /* TODO: change this copyright as title? */ mvwprintw (window->win_title, 0, 0, - "%s", WEECHAT_NAME_AND_VERSION " - " WEECHAT_WEBSITE); + "%s", PACKAGE_STRING " - " WEECHAT_WEBSITE); mvwprintw (window->win_title, 0, COLS - strlen (WEECHAT_COPYRIGHT), "%s", WEECHAT_COPYRIGHT); } @@ -1396,7 +1399,7 @@ gui_init () #ifdef __linux__ /* set title for term window, not for console */ if (cfg_look_set_title && (strcmp (getenv ("TERM"), "linux") != 0)) - printf ("\e]2;" WEECHAT_NAME " " WEECHAT_VERSION "\a\e]1;" WEECHAT_NAME " " WEECHAT_VERSION "\a"); + printf ("\e]2;" PACKAGE_NAME " " PACKAGE_VERSION "\a\e]1;" PACKAGE_NAME " " PACKAGE_VERSION "\a"); #endif gui_ready = 1; diff --git a/src/gui/curses/gui-input.c b/src/gui/curses/gui-input.c index 61a5243d5..fb608508e 100644 --- a/src/gui/curses/gui-input.c +++ b/src/gui/curses/gui-input.c @@ -19,10 +19,13 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - /* gui-input: user input functions for Curses GUI */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #include @@ -34,7 +37,7 @@ #include "../../common/weechat.h" #include "../gui.h" -#include "../../common/config.h" +#include "../../common/weeconfig.h" #include "../../common/command.h" #include "../../irc/irc.h" diff --git a/src/gui/gtk/Makefile.am b/src/gui/gtk/Makefile.am index 8f2e52569..126eae3a8 100644 --- a/src/gui/gtk/Makefile.am +++ b/src/gui/gtk/Makefile.am @@ -23,6 +23,7 @@ weechat_gtk_LDADD = ../../common/lib_weechat_main.a \ ../../irc/lib_weechat_irc.a \ $(GTK_LIBS) -weechat_gtk_SOURCES = ../gui-common.c \ +weechat_gtk_SOURCES = ../gui.h \ + ../gui-common.c \ gui-display.c \ gui-input.c diff --git a/src/gui/gtk/gui-display.c b/src/gui/gtk/gui-display.c index d2d12fc39..77e983482 100644 --- a/src/gui/gtk/gui-display.c +++ b/src/gui/gtk/gui-display.c @@ -19,10 +19,13 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - /* gui-display.c: display functions for Gtk GUI */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #include @@ -33,7 +36,7 @@ #include "../../common/weechat.h" #include "../gui.h" -#include "../../common/config.h" +#include "../../common/weeconfig.h" #include "../../irc/irc.h" @@ -577,7 +580,7 @@ void gui_init () { gtk_main_window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_window_set_title (GTK_WINDOW (gtk_main_window), WEECHAT_NAME_AND_VERSION); + gtk_window_set_title (GTK_WINDOW (gtk_main_window), PACKAGE_STRING); vbox1 = gtk_vbox_new (FALSE, 0); gtk_widget_show (vbox1); diff --git a/src/gui/gtk/gui-input.c b/src/gui/gtk/gui-input.c index db30e6523..66a27684c 100644 --- a/src/gui/gtk/gui-input.c +++ b/src/gui/gtk/gui-input.c @@ -19,10 +19,13 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - /* gui-input: user input functions for Gtk GUI */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #include @@ -34,7 +37,7 @@ #include "../../common/weechat.h" #include "../gui.h" -#include "../../common/config.h" +#include "../../common/weeconfig.h" #include "../../common/command.h" #include "../../irc/irc.h" diff --git a/src/gui/gui-common.c b/src/gui/gui-common.c index 7d626024d..453e75835 100644 --- a/src/gui/gui-common.c +++ b/src/gui/gui-common.c @@ -19,10 +19,13 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - /* gui-common.c: display functions, used by any GUI */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #include diff --git a/src/irc/Makefile.am b/src/irc/Makefile.am index d7e85d1ee..c316c6a89 100644 --- a/src/irc/Makefile.am +++ b/src/irc/Makefile.am @@ -17,7 +17,8 @@ noinst_LIBRARIES = lib_weechat_irc.a -lib_weechat_irc_a_SOURCES = irc-commands.c \ +lib_weechat_irc_a_SOURCES = irc.h \ + irc-commands.c \ irc-send.c \ irc-recv.c \ irc-server.c \ diff --git a/src/irc/irc-channel.c b/src/irc/irc-channel.c index 7d426210c..a21d8465a 100644 --- a/src/irc/irc-channel.c +++ b/src/irc/irc-channel.c @@ -19,10 +19,13 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - /* irc-channel.c: manages a chat (channel or private chat) */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include diff --git a/src/irc/irc-commands.c b/src/irc/irc-commands.c index ae0854181..2a234871c 100644 --- a/src/irc/irc-commands.c +++ b/src/irc/irc-commands.c @@ -19,11 +19,14 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - /* irc-commands.c: implementation of IRC commands, according to RFC 1459,2810,2811,2812 */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include "../common/weechat.h" #include "irc.h" #include "../common/command.h" @@ -157,7 +160,7 @@ t_irc_command irc_commands[] = { "privmsg", N_("message received"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_privmsg }, - { "quit", N_("close all connections & quit " WEECHAT_NAME), + { "quit", N_("close all connections & quit " PACKAGE_NAME), N_("[quit_message]"), N_("quit_message: quit message (displayed to other users)"), 0, MAX_ARGS, 0, NULL, irc_cmd_send_quit, irc_cmd_recv_quit }, diff --git a/src/irc/irc-display.c b/src/irc/irc-display.c index 69ca1dea7..9b7a80275 100644 --- a/src/irc/irc-display.c +++ b/src/irc/irc-display.c @@ -19,10 +19,13 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - /* irc-display.c: display functions for IRC */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #include @@ -30,7 +33,7 @@ #include "../common/weechat.h" #include "irc.h" -#include "../common/config.h" +#include "../common/weeconfig.h" #include "../gui/gui.h" diff --git a/src/irc/irc-nick.c b/src/irc/irc-nick.c index 4365ce23f..c0104a0d7 100644 --- a/src/irc/irc-nick.c +++ b/src/irc/irc-nick.c @@ -19,10 +19,13 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - /* irc-nick.c: manages nick list for channels */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #include diff --git a/src/irc/irc-recv.c b/src/irc/irc-recv.c index ccd6832c8..d5b2213e3 100644 --- a/src/irc/irc-recv.c +++ b/src/irc/irc-recv.c @@ -19,11 +19,14 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - /* irc-recv.c: implementation of IRC commands (server to client), according to RFC 1459,2810,2811,2812 */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #include @@ -35,7 +38,7 @@ #include "../common/weechat.h" #include "irc.h" #include "../common/command.h" -#include "../common/config.h" +#include "../common/weeconfig.h" #include "../gui/gui.h" @@ -838,7 +841,7 @@ irc_cmd_recv_privmsg (t_irc_server *server, char *host, char *arguments) _("NOTICE %s :%sVERSION %s v%s" " compiled on %s, host \"%s\" is running " "%s %s / %s%s"), - host, "\01", WEECHAT_NAME, WEECHAT_VERSION, __DATE__, + host, "\01", PACKAGE_NAME, PACKAGE_VERSION, __DATE__, &buf->nodename, &buf->sysname, &buf->release, &buf->machine, "\01\r\n"); free (buf); @@ -2418,7 +2421,7 @@ irc_cmd_recv_433 (t_irc_server *server, char *host, char *arguments) gui_printf (server->window, _("%s: nickname \"%s\" is already in use, " "trying 2nd nickname \"%s\"\n"), - WEECHAT_NAME, server->nick, server->nick2); + PACKAGE_NAME, server->nick, server->nick2); free (server->nick); server->nick = strdup (server->nick2); } @@ -2429,7 +2432,7 @@ irc_cmd_recv_433 (t_irc_server *server, char *host, char *arguments) gui_printf (server->window, _("%s: nickname \"%s\" is already in use, " "trying 3rd nickname \"%s\"\n"), - WEECHAT_NAME, server->nick, server->nick3); + PACKAGE_NAME, server->nick, server->nick3); free (server->nick); server->nick = strdup (server->nick3); } @@ -2438,7 +2441,7 @@ irc_cmd_recv_433 (t_irc_server *server, char *host, char *arguments) gui_printf (server->window, _("%s: all declared nicknames are already in use, " "closing connection with server!\n"), - WEECHAT_NAME); + PACKAGE_NAME); server_disconnect (server); return 0; } diff --git a/src/irc/irc-send.c b/src/irc/irc-send.c index 147cfa19b..4c9c025a0 100644 --- a/src/irc/irc-send.c +++ b/src/irc/irc-send.c @@ -19,11 +19,14 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - /* irc-send.c: implementation of IRC commands (client to server), according to RFC 1459,2810,2811,2812 */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #include @@ -35,7 +38,7 @@ #include "../common/weechat.h" #include "irc.h" #include "../common/command.h" -#include "../common/config.h" +#include "../common/weeconfig.h" #include "../gui/gui.h" @@ -57,7 +60,7 @@ irc_login (t_irc_server *server) strcpy (hostname, _("unknown")); gui_printf (server->window, _("%s: using local hostname \"%s\"\n"), - WEECHAT_NAME, hostname); + PACKAGE_NAME, hostname); server_sendf (server, "NICK %s\r\n" "USER %s %s %s :%s\r\n", @@ -973,7 +976,7 @@ irc_cmd_send_version (t_irc_server *server, char *arguments) { irc_display_prefix (server->window, PREFIX_INFO); gui_printf (server->window, _("%s, compiled on %s %s\n"), - WEECHAT_NAME_AND_VERSION, + PACKAGE_STRING, __DATE__, __TIME__); server_sendf (server, "VERSION\r\n"); } diff --git a/src/irc/irc-server.c b/src/irc/irc-server.c index ee1ead0e3..e7fe42880 100644 --- a/src/irc/irc-server.c +++ b/src/irc/irc-server.c @@ -19,10 +19,13 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - /* irc-server.c: (dis)connection and communication with irc server */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #include @@ -480,7 +483,7 @@ server_connect (t_irc_server *server) gui_printf (server->window, _("%s: connecting to %s:%d...\n"), - WEECHAT_NAME, server->address, server->port); + PACKAGE_NAME, server->address, server->port); log_printf (_("connecting to server %s:%d...\n"), server->address, server->port); server->is_connected = 0; @@ -551,7 +554,7 @@ server_connect (t_irc_server *server) /* connection to server */ gui_printf (server->window, - _("%s: server IP is: %s\n"), WEECHAT_NAME, ip_address); + _("%s: server IP is: %s\n"), PACKAGE_NAME, ip_address); error = connect (server->sock4, (struct sockaddr *) &addr, sizeof (addr)); if (error != 0) diff --git a/weechat/configure.in b/weechat/configure.in index da64b3d4d..b40507624 100644 --- a/weechat/configure.in +++ b/weechat/configure.in @@ -19,10 +19,10 @@ # Process this file with autoconf to produce a configure script. AC_PREREQ(2.56) -AC_INIT(WeeChat, 0.0.3, flashcode@flashtux.org) +AC_INIT(WeeChat, 0.0.3-pre3, flashcode@flashtux.org) AC_CONFIG_SRCDIR([src/common/weechat.c]) AM_CONFIG_HEADER(config.h) -AM_INIT_AUTOMAKE([weechat], [0.0.3]) +AM_INIT_AUTOMAKE([weechat], [0.0.3-pre3]) # Checks for programs. AC_PROG_CC diff --git a/weechat/src/common/Makefile.am b/weechat/src/common/Makefile.am index 4d4764c31..743e8cb51 100644 --- a/weechat/src/common/Makefile.am +++ b/weechat/src/common/Makefile.am @@ -18,7 +18,12 @@ noinst_LIBRARIES = lib_weechat_main.a lib_weechat_main_a_SOURCES = weechat.c \ + weechat.h \ command.c \ + command.h \ completion.c \ - config.c \ - history.c + completion.h \ + weeconfig.c \ + weeconfig.h \ + history.c \ + history.h diff --git a/weechat/src/common/command.c b/weechat/src/common/command.c index a60152123..633aa1f8a 100644 --- a/weechat/src/common/command.c +++ b/weechat/src/common/command.c @@ -19,16 +19,19 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - /* command.c: WeeChat internal commands */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #include "weechat.h" #include "command.h" -#include "config.h" +#include "weeconfig.h" #include "../irc/irc.h" #include "../gui/gui.h" @@ -528,7 +531,7 @@ exec_weechat_command (t_irc_server *server, char *string) gui_printf (NULL, _("%s wrong argument count for %s command \"%s\" " "(expected: %d arg%s)\n"), - WEECHAT_ERROR, WEECHAT_NAME, + WEECHAT_ERROR, PACKAGE_NAME, command + 1, weechat_commands[i].max_arg, (weechat_commands[i].max_arg > @@ -537,7 +540,7 @@ exec_weechat_command (t_irc_server *server, char *string) gui_printf (NULL, _("%s wrong argument count for %s command \"%s\" " "(expected: between %d and %d arg%s)\n"), - WEECHAT_ERROR, WEECHAT_NAME, + WEECHAT_ERROR, PACKAGE_NAME, command + 1, weechat_commands[i].min_arg, weechat_commands[i].max_arg, @@ -555,7 +558,7 @@ exec_weechat_command (t_irc_server *server, char *string) if (return_code < 0) gui_printf (NULL, _("%s %s command \"%s\" failed\n"), - WEECHAT_ERROR, WEECHAT_NAME, command + 1); + WEECHAT_ERROR, PACKAGE_NAME, command + 1); } if (argv) { @@ -906,7 +909,7 @@ weechat_cmd_help (int argc, char **argv) if (argc == 0) { gui_printf (NULL, - _("> List of %s internal commands:\n"), WEECHAT_NAME); + _("> List of %s internal commands:\n"), PACKAGE_NAME); for (i = 0; weechat_commands[i].command_name; i++) gui_printf (NULL, " %s - %s\n", weechat_commands[i].command_name, @@ -927,7 +930,7 @@ weechat_cmd_help (int argc, char **argv) gui_printf (NULL, _("> Help on %s internal command \"%s\":\n"), - WEECHAT_NAME, weechat_commands[i].command_name); + PACKAGE_NAME, weechat_commands[i].command_name); gui_printf (NULL, _("Syntax: /%s %s\n"), weechat_commands[i].command_name, diff --git a/weechat/src/common/completion.c b/weechat/src/common/completion.c index a050e2f0b..4a52cb2cf 100644 --- a/weechat/src/common/completion.c +++ b/weechat/src/common/completion.c @@ -19,10 +19,13 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - /* completion.c: completes words according to context (cmd/nick) */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include diff --git a/weechat/src/common/history.c b/weechat/src/common/history.c index fed419219..58ae318be 100644 --- a/weechat/src/common/history.c +++ b/weechat/src/common/history.c @@ -19,10 +19,13 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - /* history.c: memorize and call again commands or text */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include diff --git a/weechat/src/common/weechat.c b/weechat/src/common/weechat.c index 1e4866c02..632ef1c43 100644 --- a/weechat/src/common/weechat.c +++ b/weechat/src/common/weechat.c @@ -36,10 +36,13 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - /* weechat.c: core functions for WeeChat */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #include @@ -49,7 +52,7 @@ #include #include "weechat.h" -#include "config.h" +#include "weeconfig.h" #include "command.h" #include "../irc/irc.h" #include "../gui/gui.h" @@ -128,7 +131,7 @@ wee_parse_args (int argc, char *argv[]) else if ((strcmp (argv[i], "-v") == 0) || (strcmp (argv[i], "--version") == 0)) { - printf (WEECHAT_VERSION "\n"); + printf (PACKAGE_VERSION "\n"); exit (0); } else @@ -280,14 +283,14 @@ main (int argc, char *argv[]) { gui_printf_color (NULL, COLOR_WIN_CHAT, _("%sWelcome to "), (cfg_look_startup_logo) ? " " : ""); - gui_printf_color (NULL, COLOR_WIN_CHAT_PREFIX2, WEECHAT_NAME); + gui_printf_color (NULL, COLOR_WIN_CHAT_PREFIX2, PACKAGE_NAME); gui_printf_color (NULL, COLOR_WIN_CHAT, ", %s\n", cfg_look_weechat_slogan); } if (cfg_look_startup_version) { gui_printf_color (NULL, COLOR_WIN_CHAT_PREFIX2, - "%s" WEECHAT_NAME_AND_VERSION, + "%s" PACKAGE_STRING, (cfg_look_startup_logo) ? " " : ""); gui_printf_color (NULL, COLOR_WIN_CHAT, ", %s %s %s\n", diff --git a/weechat/src/common/weechat.h b/weechat/src/common/weechat.h index adc0bf04e..2e676ca86 100644 --- a/weechat/src/common/weechat.h +++ b/weechat/src/common/weechat.h @@ -31,15 +31,11 @@ #define _(string) gettext(string) #define N_(string) (string) -#define WEECHAT_NAME "WeeChat" -#define WEECHAT_VERSION "0.0.3-pre2" - -#define WEECHAT_NAME_AND_VERSION WEECHAT_NAME " " WEECHAT_VERSION -#define WEECHAT_COPYRIGHT WEECHAT_NAME " (c) 2003 by Wee Team" +#define WEECHAT_COPYRIGHT PACKAGE_NAME " (c) 2003 by Wee Team" #define WEECHAT_WEBSITE "http://weechat.flashtux.org" -#define WEECHAT_ERROR _(WEECHAT_NAME " Error:") -#define WEECHAT_WARNING _(WEECHAT_NAME " Warning:") +#define WEECHAT_ERROR _(PACKAGE_NAME " Error:") +#define WEECHAT_WARNING _(PACKAGE_NAME " Warning:") /* debug mode, 0=normal use, 1=some debug msg, 2=full debug (developers only) */ #define DEBUG 0 @@ -51,7 +47,7 @@ /* license */ #define WEE_LICENSE \ - WEECHAT_NAME_AND_VERSION " (c) Copyright 2003, compiled on " __DATE__ __TIME__ \ + PACKAGE_STRING " (c) Copyright 2003, compiled on " __DATE__ __TIME__ \ "Developed by FlashCode \n" \ " Bounga \n" \ " Xahlexx \n\n" \ @@ -71,7 +67,7 @@ "Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n\n" #define WEE_USAGE \ - WEECHAT_NAME_AND_VERSION " (c) Copyright 2003, compiled on " __DATE__ __TIME__ \ + PACKAGE_STRING " (c) Copyright 2003, compiled on " __DATE__ __TIME__ \ "Developed by FlashCode \n" \ " Bounga \n" \ " Xahlexx \n\n" \ diff --git a/weechat/src/common/weeconfig.c b/weechat/src/common/weeconfig.c new file mode 100644 index 000000000..3a58da127 --- /dev/null +++ b/weechat/src/common/weeconfig.c @@ -0,0 +1,1201 @@ +/* + * Copyright (c) 2003 by FlashCode + * Bounga + * Xahlexx + * See README for License detail. + * + * 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 2 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, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* config.c: WeeChat configuration */ + + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include +#include +#include + +#include "weechat.h" +#include "weeconfig.h" +#include "command.h" +#include "../irc/irc.h" +#include "../gui/gui.h" + + +/* config sections */ + +t_config_section config_sections[CONFIG_NUMBER_SECTIONS] = +{ { CONFIG_SECTION_LOOK, "look" }, + { CONFIG_SECTION_COLORS, "colors" }, + { CONFIG_SECTION_HISTORY, "history" }, + { CONFIG_SECTION_LOG, "log" }, + { CONFIG_SECTION_DCC, "dcc" }, + { CONFIG_SECTION_PROXY, "proxy" }, + { CONFIG_SECTION_ALIAS, "alias" }, + { CONFIG_SECTION_SERVER, "server" } +}; + +/* config, look & feel section */ + +int cfg_look_set_title; +int cfg_look_startup_logo; +int cfg_look_startup_version; +char *cfg_look_weechat_slogan; +int cfg_look_color_nicks; +int cfg_look_color_actions; +int cfg_look_remove_colors_from_msgs; +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_nickmode; +int cfg_look_nickmode_empty; +char *cfg_look_no_nickname; +char *cfg_look_completor; + +t_config_option weechat_options_look[] = +{ { "look_set_title", N_("set title for terminal window (curses GUI) with name & version"), + N_("set title for terminal window (curses GUI) with name & version"), + OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, + NULL, NULL, &cfg_look_set_title, NULL, NULL }, + { "look_startup_logo", N_("display WeeChat logo at startup"), + N_("display WeeChat logo at startup"), + OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, + NULL, NULL, &cfg_look_startup_logo, NULL, NULL }, + { "look_startup_version", N_("display WeeChat version at startup"), + N_("display WeeChat version at startup"), + OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, + NULL, NULL, &cfg_look_startup_version, NULL, NULL }, + { "look_weechat_slogan", N_("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, NULL }, + { "look_color_nicks", N_("display nick names with different colors"), + N_("display nick names with different colors"), + OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, + NULL, NULL, &cfg_look_color_nicks, NULL, NULL }, + { "look_color_actions", N_("display actions with different colors"), + N_("display actions with different colors"), + OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, + NULL, NULL, &cfg_look_color_actions, NULL, NULL }, + { "look_remove_colors_from_msgs", N_("remove colors from incoming messages"), + N_("remove colors from incoming messages"), + OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, + NULL, NULL, &cfg_look_remove_colors_from_msgs, NULL, NULL }, + { "look_nicklist", N_("display nicklist window"), + N_("display nicklist window (for channel windows)"), + OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, + NULL, NULL, &cfg_look_nicklist, NULL, NULL }, + { "look_nicklist_position", N_("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, NULL }, + { "look_nicklist_min_size", N_("min size for nicklist"), + 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, NULL }, + { "look_nicklist_max_size", N_("max size for nicklist"), + 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, NULL }, + { "look_no_nickname", N_("text to display instead of nick when not connected"), + N_("text to display instead of nick when not connected"), + OPTION_TYPE_STRING, 0, 0, 0, + "-cmd-", NULL, NULL, &cfg_look_no_nickname, NULL }, + { "look_nickmode", N_("display nick mode ((half)op/voice) before each nick"), + 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, NULL }, + { "look_nickmode_empty", N_("display space if nick mode is not (half)op/voice"), + 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, NULL }, + { "look_nick_completor", N_("the string inserted after nick completion"), + N_("the string inserted after nick completion"), + OPTION_TYPE_STRING, 0, 0, 0, + ":", NULL, NULL, &cfg_look_completor, NULL }, + { NULL, NULL, NULL, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL } +}; + +/* config, colors section */ + +int cfg_col_title; +int cfg_col_title_bg; +int cfg_col_chat; +int cfg_col_chat_time; +int cfg_col_chat_time_sep; +int cfg_col_chat_prefix1; +int cfg_col_chat_prefix2; +int cfg_col_chat_nick; +int cfg_col_chat_host; +int cfg_col_chat_channel; +int cfg_col_chat_dark; +int cfg_col_chat_bg; +int cfg_col_status; +int cfg_col_status_active; +int cfg_col_status_data_msg; +int cfg_col_status_data_other; +int cfg_col_status_more; +int cfg_col_status_bg; +int cfg_col_input; +int cfg_col_input_channel; +int cfg_col_input_nick; +int cfg_col_input_bg; +int cfg_col_nick; +int cfg_col_nick_op; +int cfg_col_nick_halfop; +int cfg_col_nick_voice; +int cfg_col_nick_sep; +int cfg_col_nick_self; +int cfg_col_nick_private; +int cfg_col_nick_bg; + +t_config_option weechat_options_colors[] = +{ /* title window */ + { "col_title", N_("color for title bar"), + N_("color for title bar"), + OPTION_TYPE_COLOR, 0, 0, 0, + "gray", NULL, &cfg_col_title, NULL, NULL }, + { "col_title_bg", N_("background for title bar"), + N_("background for title bar"), + OPTION_TYPE_COLOR, 0, 0, 0, + "blue", NULL, &cfg_col_title_bg, NULL, NULL }, + + /* chat window */ + { "col_chat", N_("color for chat text"), + N_("color for chat text"), + OPTION_TYPE_COLOR, 0, 0, 0, + "gray", NULL, &cfg_col_chat, NULL, NULL }, + { "col_chat_time", N_("color for time"), + N_("color for time in chat window"), + OPTION_TYPE_COLOR, 0, 0, 0, + "gray", NULL, &cfg_col_chat_time, NULL, NULL }, + { "col_chat_time_sep", N_("color for time separator"), + N_("color for time separator (chat window)"), + OPTION_TYPE_COLOR, 0, 0, 0, + "brown", NULL, &cfg_col_chat_time_sep, NULL, NULL }, + { "col_chat_prefix1", N_("color for 1st and 3rd char of prefix"), + N_("color for 1st and 3rd char of prefix"), + OPTION_TYPE_COLOR, 0, 0, 0, + "lightcyan", NULL, &cfg_col_chat_prefix1, NULL, NULL }, + { "col_chat_prefix2", N_("color for middle char of prefix"), + N_("color for middle char of prefix"), + OPTION_TYPE_COLOR, 0, 0, 0, + "white", NULL, &cfg_col_chat_prefix2, NULL, NULL }, + { "col_chat_nick", N_("color for nicks in actions"), + N_("color for nicks in actions (chat window)"), + OPTION_TYPE_COLOR, 0, 0, 0, + "lightcyan", NULL, &cfg_col_chat_nick, NULL, NULL }, + { "col_chat_host", N_("color for hostnames"), + N_("color for hostnames (chat window)"), + OPTION_TYPE_COLOR, 0, 0, 0, + "cyan", NULL, &cfg_col_chat_host, NULL, NULL }, + { "col_chat_channel", N_("color for channel names in actions"), + N_("color for channel names in actions (chat window)"), + OPTION_TYPE_COLOR, 0, 0, 0, + "white", NULL, &cfg_col_chat_channel, NULL, NULL }, + { "col_chat_dark", N_("color for dark separators"), + N_("color for dark separators (chat window)"), + OPTION_TYPE_COLOR, 0, 0, 0, + "green", NULL, &cfg_col_chat_dark, NULL, NULL }, + { "col_chat_bg", N_("background for chat"), + N_("background for chat window"), + OPTION_TYPE_COLOR, 0, 0, 0, + "default", NULL, &cfg_col_chat_bg, NULL, NULL }, + + /* status window */ + { "col_status", N_("color for status bar"), + N_("color for status bar"), + OPTION_TYPE_COLOR, 0, 0, 0, + "gray", NULL, &cfg_col_status, NULL, NULL }, + { "col_status_active", N_("color for active window"), + N_("color for active window (status bar)"), + OPTION_TYPE_COLOR, 0, 0, 0, + "yellow", NULL, &cfg_col_status_active, NULL, NULL }, + { "col_status_data_msg", N_("color for window with new messages"), + N_("color for window with new messages (status bar)"), + OPTION_TYPE_COLOR, 0, 0, 0, + "lightred", NULL, &cfg_col_status_data_msg, NULL, NULL }, + { "col_status_data_other", N_("color for window with new data (not messages)"), + N_("color for window with new data (not messages) (status bar)"), + OPTION_TYPE_COLOR, 0, 0, 0, + "lightmagenta", NULL, &cfg_col_status_data_other, NULL, NULL }, + { "col_status_more", N_("color for \"*MORE*\" text"), + N_("color for window with new data (status bar)"), + OPTION_TYPE_COLOR, 0, 0, 0, + "white", NULL, &cfg_col_status_more, NULL, NULL }, + { "col_status_bg", N_("background for status window"), + N_("background for status window"), + OPTION_TYPE_COLOR, 0, 0, 0, + "blue", NULL, &cfg_col_status_bg, NULL, NULL }, + + /* input window */ + { "col_input", N_("color for input text"), + N_("color for input text"), + OPTION_TYPE_COLOR, 0, 0, 0, + "gray", NULL, &cfg_col_input, NULL, NULL }, + { "col_input_channel", N_("color for input text (channel name)"), + N_("color for input text (channel name)"), + OPTION_TYPE_COLOR, 0, 0, 0, + "white", NULL, &cfg_col_input_channel, NULL, NULL }, + { "col_input_nick", N_("color for input text (nick name)"), + N_("color for input text (nick name)"), + OPTION_TYPE_COLOR, 0, 0, 0, + "lightgreen", NULL, &cfg_col_input_nick, NULL, NULL }, + { "col_input_bg", N_("background for input window"), + N_("background for input window"), + OPTION_TYPE_COLOR, 0, 0, 0, + "default", NULL, &cfg_col_input_bg, NULL, NULL }, + + /* nick window */ + { "col_nick", N_("color for nicknames"), + N_("color for nicknames"), + OPTION_TYPE_COLOR, 0, 0, 0, + "gray", NULL, &cfg_col_nick, NULL, NULL }, + { "col_nick_op", N_("color for operator symbol"), + N_("color for operator symbol"), + OPTION_TYPE_COLOR, 0, 0, 0, + "lightgreen", NULL, &cfg_col_nick_op, NULL, NULL }, + { "col_nick_halfop", N_("color for half-operator symbol"), + N_("color for half-operator symbol"), + OPTION_TYPE_COLOR, 0, 0, 0, + "lightmagenta", NULL, &cfg_col_nick_halfop, NULL, NULL }, + { "col_nick_voice", N_("color for voice symbol"), + N_("color for voice symbol"), + OPTION_TYPE_COLOR, 0, 0, 0, + "yellow", NULL, &cfg_col_nick_voice, NULL, NULL }, + { "col_nick_sep", N_("color for nick separator"), + N_("color for nick separator"), + OPTION_TYPE_COLOR, 0, 0, 0, + "blue", NULL, &cfg_col_nick_sep, NULL, NULL }, + { "col_nick_self", N_("color for local nick"), + N_("color for local nick"), + OPTION_TYPE_COLOR, 0, 0, 0, + "white", NULL, &cfg_col_nick_self, NULL, NULL }, + { "col_nick_private", N_("color for other nick in private window"), + N_("color for other nick in private window"), + OPTION_TYPE_COLOR, 0, 0, 0, + "brown", NULL, &cfg_col_nick_private, NULL, NULL }, + { "col_nick_bg", N_("background for nicknames"), + N_("background for nicknames"), + OPTION_TYPE_COLOR, 0, 0, 0, + "default", NULL, &cfg_col_nick_bg, NULL, NULL }, + + { NULL, NULL, NULL, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL } +}; + +/* config, history section */ + +int cfg_history_max_lines; +int cfg_history_max_commands; + +t_config_option weechat_options_history[] = +{ { "history_max_lines", N_("max lines in history (per window)"), + 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, NULL }, + { "history_max_commands", N_("max user commands in history"), + N_("maximum number of user commands in history (0 = unlimited)"), + OPTION_TYPE_INT, 0, INT_MAX, 100, + NULL, NULL, &cfg_history_max_commands, NULL, NULL }, + { NULL, NULL, NULL, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL } +}; + +/* config, log section */ + +int cfg_log_auto_channels; +int cfg_log_auto_private; +char *cfg_log_path; +char *cfg_log_name; +char *cfg_log_timestamp; +char *cfg_log_start_string; +char *cfg_log_end_string; + +t_config_option weechat_options_log[] = +{ { "log_auto_channels", N_("automatically log channel chats"), + N_("automatically log channel chats"), + OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, + NULL, NULL, &cfg_log_auto_channels, NULL, NULL }, + { "log_auto_private", N_("automatically log private chats"), + N_("automatically log private chats"), + OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, + NULL, NULL, &cfg_log_auto_private, NULL, NULL }, + { "log_path", N_("path for log files"), + N_("path for WeeChat log files"), + OPTION_TYPE_STRING, 0, 0, 0, + "~/.weechat/logs/", NULL, NULL, &cfg_log_path, NULL }, + { "log_name", N_("name for log files"), + N_("name for log files (%S == irc server name, " + "%N == channel name (or nickname if private chat)"), + OPTION_TYPE_STRING, 0, 0, 0, + "%S,%N.weechatlog", NULL, NULL, &cfg_log_name, NULL }, + { "log_timestamp", N_("timestamp for log"), + N_("timestamp for log (see man strftime for date/time specifiers)"), + OPTION_TYPE_STRING, 0, 0, 0, + "~", NULL, NULL, &cfg_log_timestamp, NULL }, + { "log_start_string", N_("start string for log files"), + N_("text written when starting new log file " + "(see man strftime for date/time specifiers)"), + OPTION_TYPE_STRING, 0, 0, 0, + "--- Log started %a %b %d %Y %H:%M:%s", NULL, NULL, &cfg_log_start_string, NULL }, + { "log_end_string", N_("end string for log files"), + N_("text written when ending log file " + "(see man strftime for date/time specifiers)"), + OPTION_TYPE_STRING, 0, 0, 0, + "--- Log ended %a %b %d %Y %H:%M:%s", NULL, NULL, &cfg_log_end_string, NULL }, + { NULL, NULL, NULL, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL } +}; + +/* config, dcc section */ + +int cfg_dcc_auto_accept_files; +int cfg_dcc_auto_accept_max_size; +int cfg_dcc_auto_accept_chats; +int cfg_dcc_timeout; +char *cfg_dcc_download_path; +char *cfg_dcc_upload_path; +int cfg_dcc_auto_rename; +int cfg_dcc_auto_resume; + +t_config_option weechat_options_dcc[] = +{ { "dcc_auto_accept_files", N_("automatically accept dcc files"), + N_("automatically accept incoming dcc files"), + OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, + NULL, NULL, &cfg_dcc_auto_accept_files, NULL, NULL }, + { "dcc_auto_accept_max_size", N_("max size when auto accepting file"), + N_("maximum size for incoming file when automatically accepted"), + OPTION_TYPE_INT, 0, INT_MAX, 0, + NULL, NULL, &cfg_dcc_auto_accept_max_size, NULL, NULL }, + { "dcc_auto_accept_chats", N_("automatically accept dcc chats"), + N_("automatically accept dcc chats (use carefully!)"), + OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, + NULL, NULL, &cfg_dcc_auto_accept_chats, NULL, NULL }, + { "dcc_timeout", N_("timeout for dcc request"), + N_("timeout for dcc request (in seconds)"), + OPTION_TYPE_INT, 1, INT_MAX, 300, + NULL, NULL, &cfg_dcc_timeout, NULL, NULL }, + { "dcc_download_path", N_("path for incoming files with dcc"), + N_("path for writing incoming files with dcc (default: user home)"), + OPTION_TYPE_STRING, 0, 0, 0, "~", + NULL, NULL, &cfg_dcc_download_path, NULL }, + { "dcc_upload_path", N_("default path for sending files with dcc"), + N_("path for reading files when sending thru dcc (when no path is specified)"), + OPTION_TYPE_STRING, 0, 0, 0, "~", + NULL, NULL, &cfg_dcc_upload_path, NULL }, + { "dcc_auto_rename", N_("automatically rename dcc files if already exists"), + N_("rename incoming files if already exists (add '.1', '.2', ...)"), + OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, + NULL, NULL, &cfg_dcc_auto_rename, NULL, NULL }, + { "dcc_auto_resume", N_("automatically resume aborted transfers"), + N_("automatically resume dcc transfer if connection with remote host is loosed"), + OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, + NULL, NULL, &cfg_dcc_auto_resume, NULL, NULL }, + { NULL, NULL, NULL, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL } +}; + +/* config, proxy section */ + +int cfg_proxy_use; +char *cfg_proxy_address; +int cfg_proxy_port; +char *cfg_proxy_password; + +t_config_option weechat_options_proxy[] = +{ { "proxy_use", N_("use proxy"), + 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, NULL }, + { "proxy_address", N_("proxy address"), + N_("proxy server address (IP or hostname)"), + OPTION_TYPE_STRING, 0, 0, 0, + "", NULL, NULL, &cfg_proxy_address, NULL }, + { "proxy_port", N_("port for proxy"), + N_("port for connecting to proxy server"), + OPTION_TYPE_INT, 0, 65535, 1080, + NULL, NULL, &cfg_proxy_port, NULL, NULL }, + { "proxy_password", N_("proxy password"), + N_("password for proxy server"), + OPTION_TYPE_STRING, 0, 0, 0, + "", NULL, NULL, &cfg_proxy_password, NULL }, + { NULL, NULL, NULL, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL } +}; + +/* config, server section */ + +static t_irc_server cfg_server; + +t_config_option weechat_options_server[] = +{ { "server_name", N_("server name"), + N_("name associated to IRC server (for display only)"), + OPTION_TYPE_STRING, 0, 0, 0, + "", NULL, NULL, &(cfg_server.name), NULL }, + { "server_autoconnect", N_("automatically connect to server"), + N_("automatically connect to server when WeeChat is starting"), + OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, + NULL, NULL, &(cfg_server.autoconnect), NULL, NULL }, + { "server_address", N_("server address or hostname"), + N_("IP address or hostname of IRC server"), + OPTION_TYPE_STRING, 0, 0, 0, + "", NULL, NULL, &(cfg_server.address), NULL }, + { "server_port", N_("port for IRC server"), + N_("port for connecting to server"), + OPTION_TYPE_INT, 0, 65535, 6667, + NULL, NULL, &(cfg_server.port), NULL, NULL }, + { "server_password", N_("server password"), + N_("password for IRC server"), + OPTION_TYPE_STRING, 0, 0, 0, + "", NULL, NULL, &(cfg_server.password), NULL }, + { "server_nick1", N_("nickname for server"), + N_("nickname to use on IRC server"), + OPTION_TYPE_STRING, 0, 0, 0, + "", NULL, NULL, &(cfg_server.nick1), NULL }, + { "server_nick2", N_("alternate nickname for server"), + N_("alternate nickname to use on IRC server (if nickname is already used)"), + OPTION_TYPE_STRING, 0, 0, 0, + "", NULL, NULL, &(cfg_server.nick2), NULL }, + { "server_nick3", N_("2nd alternate nickname for server"), + N_("2nd alternate nickname to use on IRC server (if alternate nickname is already used)"), + OPTION_TYPE_STRING, 0, 0, 0, + "", NULL, NULL, &(cfg_server.nick3), NULL }, + { "server_username", N_("user name for server"), + N_("user name to use on IRC server"), + OPTION_TYPE_STRING, 0, 0, 0, + "", NULL, NULL, &(cfg_server.username), NULL }, + { "server_realname", N_("real name for server"), + N_("real name to use on IRC server"), + OPTION_TYPE_STRING, 0, 0, 0, + "", NULL, NULL, &(cfg_server.realname), NULL }, + { "server_command", N_("first command to run when connected to server"), + N_("first command to run when connected to server"), + OPTION_TYPE_STRING, 0, 0, 0, + "", NULL, NULL, &(cfg_server.command), NULL }, + { "server_autojoin", N_("list of channels to join when connected to server"), + N_("comma separated list of channels to join when connected to server"), + OPTION_TYPE_STRING, 0, 0, 0, + "", NULL, NULL, &(cfg_server.autojoin), NULL }, + { NULL, NULL, NULL, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL } +}; + +/* all weechat options */ + +t_config_option *weechat_options[CONFIG_NUMBER_SECTIONS] = +{ weechat_options_look, weechat_options_colors, weechat_options_history, + weechat_options_log, weechat_options_dcc, weechat_options_proxy, + NULL, weechat_options_server +}; + + +/* + * get_pos_array_values: returns position of a string in an array of values + * returns -1 if not found, otherwise position + */ + +int +get_pos_array_values (char **array, char *string) +{ + int i; + + i = 0; + while (array[i]) + { + if (strcasecmp (array[i], string) == 0) + return i; + i++; + } + /* string not found in array */ + return -1; +} + +/* + * config_option_set_value: set new value for an option + * return: 0 if success + * -1 if error (bad value) + */ + +int +config_option_set_value (t_config_option *option, char *value) +{ + int int_value; + + switch (option->option_type) + { + case OPTION_TYPE_BOOLEAN: + if (strcasecmp (value, "on") == 0) + *(option->ptr_int) = BOOL_TRUE; + else if (strcasecmp (value, "off") == 0) + *(option->ptr_int) = BOOL_FALSE; + else + 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 = get_pos_array_values (option->array_values, value); + if (int_value < 0) + return -1; + *(option->ptr_int) = int_value; + break; + case OPTION_TYPE_COLOR: + if (!gui_assign_color (option->ptr_int, value)) + return -1; + break; + case OPTION_TYPE_STRING: + if (*(option->ptr_string)) + free (*(option->ptr_string)); + *(option->ptr_string) = strdup (value); + break; + } + return 0; +} + +/* + * config_set_value: 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_set_value (char *option_name, char *value) +{ + int i, j; + + for (i = 0; i < CONFIG_NUMBER_SECTIONS; i++) + { + if ((i != CONFIG_SECTION_ALIAS) && (i != CONFIG_SECTION_SERVER)) + { + for (j = 0; weechat_options[i][j].option_name; j++) + { + /* if option found, assign value and exit */ + if (strcasecmp (weechat_options[i][j].option_name, option_name) == 0) + return config_option_set_value (&weechat_options[i][j], value); + } + } + } + /* option not found */ + return -2; +} + +/* + * config_allocate_server: allocate a new server + */ + +int +config_allocate_server (char *filename, int line_number) +{ + if (!cfg_server.name + || !cfg_server.address + || cfg_server.port < 0 + || !cfg_server.nick1 + || !cfg_server.nick2 + || !cfg_server.nick3 + || !cfg_server.username + || !cfg_server.realname) + { + server_free_all (); + gui_printf (NULL, + _("%s %s, line %d: new server, but previous was incomplete\n"), + WEECHAT_WARNING, filename, line_number); + return 0; + + } + if (server_name_already_exists (cfg_server.name)) + { + server_free_all (); + gui_printf (NULL, + _("%s %s, line %d: server '%s' already exists\n"), + WEECHAT_WARNING, filename, line_number, cfg_server.name); + return 0; + } + if (!server_new (cfg_server.name, + cfg_server.autoconnect, cfg_server.address, cfg_server.port, + cfg_server.password, cfg_server.nick1, cfg_server.nick2, + cfg_server.nick3, cfg_server.username, cfg_server.realname, + cfg_server.command, cfg_server.autojoin)) + { + server_free_all (); + gui_printf (NULL, + _("%s %s, line %d: unable to create server\n"), + WEECHAT_WARNING, filename, line_number); + return 0; + } + + server_destroy (&cfg_server); + server_init (&cfg_server); + + return 1; +} + +/* + * config_default_values: initialize config variables with default values + */ + +void +config_default_values () +{ + int i, j, int_value; + + for (i = 0; i < CONFIG_NUMBER_SECTIONS; i++) + { + if ((i != CONFIG_SECTION_ALIAS) && (i != CONFIG_SECTION_SERVER)) + { + for (j = 0; weechat_options[i][j].option_name; j++) + { + switch (weechat_options[i][j].option_type) + { + case OPTION_TYPE_BOOLEAN: + case OPTION_TYPE_INT: + *weechat_options[i][j].ptr_int = + weechat_options[i][j].default_int; + break; + case OPTION_TYPE_INT_WITH_STRING: + int_value = get_pos_array_values ( + weechat_options[i][j].array_values, + weechat_options[i][j].default_string); + if (int_value < 0) + gui_printf (NULL, + _("%s unable to assign default int with string (\"%s\")\n"), + weechat_options[i][j].default_string); + else + *weechat_options[i][j].ptr_int = + int_value; + break; + case OPTION_TYPE_COLOR: + if (!gui_assign_color ( + weechat_options[i][j].ptr_int, + weechat_options[i][j].default_string)) + gui_printf (NULL, + _("%s unable to assign default color (\"%s\")\n"), + weechat_options[i][j].default_string); + break; + case OPTION_TYPE_STRING: + *weechat_options[i][j].ptr_string = + strdup (weechat_options[i][j].default_string); + break; + } + } + } + } +} + +/* + * config_read: read WeeChat configuration + * returns: 0 = successful + * -1 = config file file not found + * < -1 = other error (fatal) + */ + +int +config_read () +{ + char *filename; + FILE *file; + int section, line_number, i, option_number; + int server_found; + char line[1024], *ptr_line, *pos, *pos2; + + filename = + (char *) malloc ((strlen (getenv ("HOME")) + 64) * sizeof (char)); + sprintf (filename, "%s/.weechat/" WEECHAT_CONFIG_NAME, getenv ("HOME")); + if ((file = fopen (filename, "rt")) == NULL) + { + gui_printf (NULL, _("%s config file \"%s\" not found.\n"), + WEECHAT_WARNING, filename); + free (filename); + return -1; + } + + config_default_values (); + server_init (&cfg_server); + + /* read config file */ + section = CONFIG_SECTION_NONE; + server_found = 0; + line_number = 0; + while (!feof (file)) + { + ptr_line = fgets (line, sizeof (line) - 1, file); + line_number++; + if (ptr_line) + { + /* skip spaces */ + while (ptr_line[0] == ' ') + ptr_line++; + /* not a comment and not an empty line */ + if ((ptr_line[0] != '#') && (ptr_line[0] != '\r') + && (ptr_line[0] != '\n')) + { + /* beginning of section */ + if (ptr_line[0] == '[') + { + pos = strchr (line, ']'); + if (pos == NULL) + gui_printf (NULL, + _("%s %s, line %d: invalid syntax, missing \"]\"\n"), + WEECHAT_WARNING, filename, line_number); + else + { + pos[0] = '\0'; + pos = ptr_line + 1; + section = CONFIG_SECTION_NONE; + for (i = 0; config_sections[i].section_name; i++) + { + if (strcmp (config_sections[i].section_name, pos) == 0) + { + section = i; + break; + } + } + if (section == CONFIG_SECTION_NONE) + gui_printf (NULL, + _("%s %s, line %d: unknown section identifier (\"%s\")\n"), + WEECHAT_WARNING, filename, line_number, pos); + else + { + if (server_found) + { + /* if server already started => create it */ + config_allocate_server (filename, line_number); + } + server_found = (section == CONFIG_SECTION_SERVER) ? 1 : 0; + } + } + } + else + { + pos = strchr (line, '='); + if (pos == NULL) + gui_printf (NULL, + _("%s %s, line %d: invalid syntax, missing \"=\"\n"), + WEECHAT_WARNING, filename, line_number); + else + { + pos[0] = '\0'; + pos++; + pos2 = strchr (pos, '\r'); + if (pos2 != NULL) + pos2[0] = '\0'; + pos2 = strchr (pos, '\n'); + if (pos2 != NULL) + pos2[0] = '\0'; + + if (section == CONFIG_SECTION_ALIAS) + { + if (alias_new (line, pos)) + index_command_new (pos); + } + else + { + option_number = -1; + for (i = 0; + weechat_options[section][i].option_name; i++) + { + if (strcmp + (weechat_options[section][i].option_name, + ptr_line) == 0) + { + option_number = i; + break; + } + } + if (option_number < 0) + gui_printf (NULL, + _("%s %s, line %d: invalid option \"%s\"\n"), + WEECHAT_WARNING, filename, line_number, ptr_line); + else + { + if (config_option_set_value (&weechat_options[section][option_number], pos) < 0) + { + switch (weechat_options[section] + [option_number].option_type) + { + case OPTION_TYPE_BOOLEAN: + gui_printf (NULL, + _("%s %s, line %d: invalid value for" + "option '%s'\n" + "Expected: boolean value: " + "'off' or 'on'\n"), + WEECHAT_WARNING, filename, + line_number, ptr_line); + break; + case OPTION_TYPE_INT: + gui_printf (NULL, + _("%s %s, line %d: invalid value for " + "option '%s'\n" + "Expected: integer between %d " + "and %d\n"), + WEECHAT_WARNING, filename, + line_number, ptr_line, + weechat_options[section][option_number].min, + weechat_options[section][option_number].max); + break; + case OPTION_TYPE_INT_WITH_STRING: + gui_printf (NULL, + _("%s %s, line %d: invalid value for " + "option '%s'\n" + "Expected: one of these strings: "), + WEECHAT_WARNING, filename, + line_number, ptr_line); + i = 0; + while (weechat_options[section][option_number].array_values[i]) + { + gui_printf (NULL, "\"%s\" ", + weechat_options[section][option_number].array_values[i]); + i++; + } + gui_printf (NULL, "\n"); + break; + case OPTION_TYPE_COLOR: + gui_printf (NULL, + _("%s %s, line %d: invalid color " + "name for option '%s'\n"), + WEECHAT_WARNING, filename, + line_number, + ptr_line); + break; + } + } + } + } + } + } + } + } + } + + if (server_found) + { + if (!config_allocate_server (filename, line_number)) + { + fclose (file); + free (filename); + return -2; + } + } + + /* set default colors for colors not set */ + /*for (i = 0; i < CONFIG_NUMBER_SECTIONS; i++) + { + if (i != CONFIG_SECTION_SERVER) + { + for (j = 0; weechat_options[i][j].option_name; j++) + { + if ((weechat_options[i][j].option_type == OPTION_TYPE_COLOR) && + (*weechat_options[i][j].ptr_int == COLOR_NOT_SET)) + *weechat_options[i][j].ptr_int = + gui_get_color_by_name (weechat_options[i][j].default_string); + } + } + }*/ + + fclose (file); + free (filename); + + return 0; +} + + +/* + * config_create_default: create default WeeChat config + * return: 0 if ok + * < 0 if error + */ + +int +config_create_default () +{ + char *filename; + char line[1024]; + FILE *file; + int i, j; + time_t current_time; + + filename = + (char *) malloc ((strlen (getenv ("HOME")) + 64) * sizeof (char)); + sprintf (filename, "%s/.weechat/" WEECHAT_CONFIG_NAME, getenv ("HOME")); + if ((file = fopen (filename, "wt")) == NULL) + { + gui_printf (NULL, _("%s cannot create file \"%s\"\n"), + WEECHAT_ERROR, filename); + free (filename); + return -1; + } + + printf (_("%s: creating default config file...\n"), PACKAGE_NAME); + log_printf (_("creating default config file\n")); + + current_time = time (NULL); + sprintf (line, _("#\n# %s configuration file, created by " + "%s v%s on %s#\n"), + PACKAGE_NAME, PACKAGE_NAME, PACKAGE_VERSION, + ctime (¤t_time)); + fputs (line, file); + + for (i = 0; i < CONFIG_NUMBER_SECTIONS; i++) + { + if ((i != CONFIG_SECTION_ALIAS) && (i != CONFIG_SECTION_SERVER)) + { + sprintf (line, "\n[%s]\n", config_sections[i].section_name); + fputs (line, file); + if ((i == CONFIG_SECTION_HISTORY) || (i == CONFIG_SECTION_LOG) || + (i == CONFIG_SECTION_DCC) || (i == CONFIG_SECTION_PROXY)) + { + sprintf (line, + "# WARNING!!! Options for section \"%s\" are not developed!\n", + config_sections[i].section_name); + fputs (line, file); + } + for (j = 0; weechat_options[i][j].option_name; j++) + { + switch (weechat_options[i][j].option_type) + { + case OPTION_TYPE_BOOLEAN: + sprintf (line, "%s=%s\n", + weechat_options[i][j].option_name, + (weechat_options[i][j].default_int) ? + "on" : "off"); + break; + case OPTION_TYPE_INT: + sprintf (line, "%s=%d\n", + weechat_options[i][j].option_name, + weechat_options[i][j].default_int); + break; + case OPTION_TYPE_INT_WITH_STRING: + case OPTION_TYPE_COLOR: + case OPTION_TYPE_STRING: + sprintf (line, "%s=%s\n", + weechat_options[i][j].option_name, + weechat_options[i][j].default_string); + break; + } + fputs (line, file); + } + } + } + + /* default aliases */ + /* TODO: remove comments when missing commands will be ok */ + fputs ("\n[alias]\n", file); + fputs ("SAY=msg *\n", file); + fputs ("BYE=quit\n", file); + fputs ("EXIT=quit\n", file); + fputs ("SIGNOFF=quit\n", file); + fputs ("C=clear\n", file); + fputs ("CL=clear\n", file); + fputs ("# CHAT=dcc chat\n", file); + fputs ("# GET=dcc get\n", file); + fputs ("# IG=ignore\n", file); + fputs ("J=join\n", file); + fputs ("K=kick\n", file); + fputs ("# KB=kickban\n", file); + fputs ("# KN=knockout\n", file); + fputs ("LEAVE=part\n", file); + fputs ("M=msg\n", file); + fputs ("# MUB=unban *\n", file); + fputs ("N=names\n", file); + fputs ("T=topic\n", file); + fputs ("# UB=unban\n", file); + fputs ("# UNIG=unignore\n", file); + fputs ("# W=who\n", file); + fputs ("WC=part\n", file); + fputs ("WI=whois\n", file); + fputs ("# WW=whowas\n", file); + + /* default server is freenode */ + fputs ("\n[server]\n", file); + fputs ("server_name=freenode\n", file); + fputs ("server_autoconnect=on\n", file); + fputs ("server_address=irc.freenode.net\n", file); + fputs ("server_port=6667\n", file); + fputs ("server_password=\n", file); + fputs ("server_nick1=weechat_user\n", file); + fputs ("server_nick2=weechat2\n", file); + fputs ("server_nick3=weechat3\n", file); + fputs ("server_username=weechat\n", file); + fputs ("server_realname=WeeChat default realname\n", file); + fputs ("server_command=\n", file); + fputs ("server_autojoin=\n", file); + + fclose (file); + free (filename); + return 0; +} + +/* + * config_write: write WeeChat configurtion + * return: 0 if ok + * < 0 if error + */ + +int +config_write (char *config_name) +{ + char *filename; + char line[1024]; + FILE *file; + int i, j; + time_t current_time; + t_irc_server *ptr_server; + t_weechat_alias *ptr_alias; + + if (config_name) + filename = strdup (config_name); + else + { + filename = + (char *) malloc ((strlen (getenv ("HOME")) + 64) * sizeof (char)); + sprintf (filename, "%s/.weechat/" WEECHAT_CONFIG_NAME, getenv ("HOME")); + } + + if ((file = fopen (filename, "wt")) == NULL) + { + gui_printf (NULL, _("%s cannot create file \"%s\"\n"), + WEECHAT_ERROR, filename); + free (filename); + return -1; + } + + log_printf (_("saving config to disk\n")); + + current_time = time (NULL); + sprintf (line, _("#\n# %s configuration file, created by " + "%s v%s on %s#\n"), + PACKAGE_NAME, PACKAGE_NAME, PACKAGE_VERSION, + ctime (¤t_time)); + fputs (line, file); + + for (i = 0; i < CONFIG_NUMBER_SECTIONS; i++) + { + if ((i != CONFIG_SECTION_ALIAS) && (i != CONFIG_SECTION_SERVER)) + { + sprintf (line, "\n[%s]\n", config_sections[i].section_name); + fputs (line, file); + if ((i == CONFIG_SECTION_HISTORY) || (i == CONFIG_SECTION_LOG) || + (i == CONFIG_SECTION_DCC) || (i == CONFIG_SECTION_PROXY)) + { + sprintf (line, + "# WARNING!!! Options for section \"%s\" are not developed!\n", + config_sections[i].section_name); + fputs (line, file); + } + for (j = 0; weechat_options[i][j].option_name; j++) + { + switch (weechat_options[i][j].option_type) + { + case OPTION_TYPE_BOOLEAN: + sprintf (line, "%s=%s\n", + weechat_options[i][j].option_name, + (weechat_options[i][j].ptr_int && + *weechat_options[i][j].ptr_int) ? + "on" : "off"); + break; + case OPTION_TYPE_INT: + sprintf (line, "%s=%d\n", + weechat_options[i][j].option_name, + (weechat_options[i][j].ptr_int) ? + *weechat_options[i][j].ptr_int : + weechat_options[i][j].default_int); + break; + case OPTION_TYPE_INT_WITH_STRING: + sprintf (line, "%s=%s\n", + weechat_options[i][j].option_name, + (weechat_options[i][j].ptr_int) ? + weechat_options[i][j].array_values[*weechat_options[i][j].ptr_int] : + weechat_options[i][j].array_values[weechat_options[i][j].default_int]); + break; + case OPTION_TYPE_COLOR: + sprintf (line, "%s=%s\n", + weechat_options[i][j].option_name, + (weechat_options[i][j].ptr_int) ? + gui_get_color_by_value (*weechat_options[i][j].ptr_int) : + weechat_options[i][j].default_string); + break; + case OPTION_TYPE_STRING: + sprintf (line, "%s=%s\n", + weechat_options[i][j].option_name, + (weechat_options[i][j].ptr_string) ? + *weechat_options[i][j].ptr_string : + weechat_options[i][j].default_string); + break; + } + fputs (line, file); + } + } + } + + /* alias section */ + fputs ("\n[alias]\n", file); + for (ptr_alias = weechat_alias; ptr_alias; + ptr_alias = ptr_alias->next_alias) + { + sprintf (line, "%s=%s\n", + ptr_alias->alias_name, ptr_alias->alias_command + 1); + fputs (line, file); + } + + /* server section */ + for (ptr_server = irc_servers; ptr_server; + ptr_server = ptr_server->next_server) + { + /* default server is freenode */ + fputs ("\n[server]\n", file); + sprintf (line, "server_name=%s\n", ptr_server->name); + fputs (line, file); + sprintf (line, "server_autoconnect=%s\n", + (ptr_server->autoconnect) ? "on" : "off"); + fputs (line, file); + sprintf (line, "server_address=%s\n", ptr_server->address); + fputs (line, file); + sprintf (line, "server_port=%d\n", ptr_server->port); + fputs (line, file); + sprintf (line, "server_password=%s\n", + (ptr_server->password) ? ptr_server->password : ""); + fputs (line, file); + sprintf (line, "server_nick1=%s\n", ptr_server->nick1); + fputs (line, file); + sprintf (line, "server_nick2=%s\n", ptr_server->nick2); + fputs (line, file); + sprintf (line, "server_nick3=%s\n", ptr_server->nick3); + fputs (line, file); + sprintf (line, "server_username=%s\n", ptr_server->username); + fputs (line, file); + sprintf (line, "server_realname=%s\n", ptr_server->realname); + fputs (line, file); + sprintf (line, "server_command=%s\n", + (ptr_server->command) ? ptr_server->command : ""); + fputs (line, file); + sprintf (line, "server_autojoin=%s\n", + (ptr_server->autojoin) ? ptr_server->autojoin : ""); + fputs (line, file); + } + + fclose (file); + free (filename); + return 0; +} diff --git a/weechat/src/common/weeconfig.h b/weechat/src/common/weeconfig.h new file mode 100644 index 000000000..692698797 --- /dev/null +++ b/weechat/src/common/weeconfig.h @@ -0,0 +1,157 @@ +/* + * Copyright (c) 2003 by FlashCode + * Bounga + * Xahlexx + * See README for License detail. + * + * 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 2 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, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + + +#ifndef __WEECHAT_CONFIG_H +#define __WEECHAT_CONFIG_H 1 + +#define WEECHAT_CONFIG_NAME "weechat.rc" + +#define CONFIG_SECTION_NONE -1 +#define CONFIG_SECTION_LOOK 0 +#define CONFIG_SECTION_COLORS 1 +#define CONFIG_SECTION_HISTORY 2 +#define CONFIG_SECTION_LOG 3 +#define CONFIG_SECTION_DCC 4 +#define CONFIG_SECTION_PROXY 5 +#define CONFIG_SECTION_ALIAS 6 +#define CONFIG_SECTION_SERVER 7 +#define CONFIG_NUMBER_SECTIONS 8 + +#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_COLOR 4 /* values: a color name */ +#define OPTION_TYPE_STRING 5 /* values: any string, may be empty */ + +#define BOOL_FALSE 0 +#define BOOL_TRUE 1 + +#define CFG_LOOK_NICKLIST_LEFT 0 +#define CFG_LOOK_NICKLIST_RIGHT 1 +#define CFG_LOOK_NICKLIST_TOP 2 +#define CFG_LOOK_NICKLIST_BOTTOM 3 + +typedef struct t_config_section t_config_section; + +struct t_config_section +{ + int section_number; + char *section_name; +}; + +typedef struct t_config_option t_config_option; + +struct t_config_option +{ + char *option_name; + char *short_description; + char *long_description; + int option_type; + int min, max; + int default_int; + char *default_string; + char **array_values; + int *ptr_int; + char **ptr_string; + int (*handler_change)(int *, char **); +}; + +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_color_nicks; +extern int cfg_look_color_actions; +extern int cfg_look_remove_colors_from_msgs; +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_nickmode; +extern int cfg_look_nickmode_empty; +extern char *cfg_look_no_nickname; +extern char *cfg_look_completor; + +extern int cfg_col_title; +extern int cfg_col_title_bg; +extern int cfg_col_chat; +extern int cfg_col_chat_time; +extern int cfg_col_chat_time_sep; +extern int cfg_col_chat_prefix1; +extern int cfg_col_chat_prefix2; +extern int cfg_col_chat_nick; +extern int cfg_col_chat_host; +extern int cfg_col_chat_channel; +extern int cfg_col_chat_dark; +extern int cfg_col_chat_bg; +extern int cfg_col_status; +extern int cfg_col_status_active; +extern int cfg_col_status_data_msg; +extern int cfg_col_status_data_other; +extern int cfg_col_status_more; +extern int cfg_col_status_bg; +extern int cfg_col_input; +extern int cfg_col_input_channel; +extern int cfg_col_input_nick; +extern int cfg_col_input_bg; +extern int cfg_col_nick; +extern int cfg_col_nick_op; +extern int cfg_col_nick_halfop; +extern int cfg_col_nick_voice; +extern int cfg_col_nick_sep; +extern int cfg_col_nick_self; +extern int cfg_col_nick_private; +extern int cfg_col_nick_bg; + +extern int cfg_history_max_lines; +extern int cfg_history_max_commands; + +extern int cfg_log_auto_channels; +extern int cfg_log_auto_private; +extern char *cfg_log_path; +extern char *cfg_log_name; +extern char *cfg_log_timestamp; +extern char *cfg_log_start_string; +extern char *cfg_log_end_string; + +extern int cfg_dcc_auto_accept_files; +extern int cfg_dcc_auto_accept_max_size; +extern int cfg_dcc_auto_accept_chats; +extern int cfg_dcc_timeout; +extern char *cfg_dcc_download_path; +extern char *cfg_dcc_upload_path; +extern int cfg_dcc_auto_rename; +extern int cfg_dcc_auto_resume; + +extern int cfg_proxy_use; +extern char *cfg_proxy_address; +extern int cfg_proxy_port; +extern char *cfg_proxy_password; + +extern t_config_section config_sections [CONFIG_NUMBER_SECTIONS]; +extern t_config_option * weechat_options [CONFIG_NUMBER_SECTIONS]; + +extern int config_read (); +extern int config_create_default (); +extern int config_write (); + +#endif /* config.h */ diff --git a/weechat/src/gui/curses/Makefile.am b/weechat/src/gui/curses/Makefile.am index 7a8aaacc3..d54881329 100644 --- a/weechat/src/gui/curses/Makefile.am +++ b/weechat/src/gui/curses/Makefile.am @@ -21,6 +21,7 @@ weechat_curses_LDADD = ../../common/lib_weechat_main.a \ ../../irc/lib_weechat_irc.a \ $(CURSES_LIBS) -weechat_curses_SOURCES = ../gui-common.c \ +weechat_curses_SOURCES = ../gui.h \ + ../gui-common.c \ gui-display.c \ gui-input.c diff --git a/weechat/src/gui/curses/gui-display.c b/weechat/src/gui/curses/gui-display.c index 99ab1994c..59b9e75dd 100644 --- a/weechat/src/gui/curses/gui-display.c +++ b/weechat/src/gui/curses/gui-display.c @@ -19,10 +19,13 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - /* gui-display.c: display functions for Curses GUI */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #include @@ -33,7 +36,7 @@ #include "../../common/weechat.h" #include "../gui.h" -#include "../../common/config.h" +#include "../../common/weeconfig.h" #include "../../irc/irc.h" @@ -302,7 +305,7 @@ gui_draw_window_title (t_gui_window *window) { /* TODO: change this copyright as title? */ mvwprintw (window->win_title, 0, 0, - "%s", WEECHAT_NAME_AND_VERSION " - " WEECHAT_WEBSITE); + "%s", PACKAGE_STRING " - " WEECHAT_WEBSITE); mvwprintw (window->win_title, 0, COLS - strlen (WEECHAT_COPYRIGHT), "%s", WEECHAT_COPYRIGHT); } @@ -1396,7 +1399,7 @@ gui_init () #ifdef __linux__ /* set title for term window, not for console */ if (cfg_look_set_title && (strcmp (getenv ("TERM"), "linux") != 0)) - printf ("\e]2;" WEECHAT_NAME " " WEECHAT_VERSION "\a\e]1;" WEECHAT_NAME " " WEECHAT_VERSION "\a"); + printf ("\e]2;" PACKAGE_NAME " " PACKAGE_VERSION "\a\e]1;" PACKAGE_NAME " " PACKAGE_VERSION "\a"); #endif gui_ready = 1; diff --git a/weechat/src/gui/curses/gui-input.c b/weechat/src/gui/curses/gui-input.c index 61a5243d5..fb608508e 100644 --- a/weechat/src/gui/curses/gui-input.c +++ b/weechat/src/gui/curses/gui-input.c @@ -19,10 +19,13 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - /* gui-input: user input functions for Curses GUI */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #include @@ -34,7 +37,7 @@ #include "../../common/weechat.h" #include "../gui.h" -#include "../../common/config.h" +#include "../../common/weeconfig.h" #include "../../common/command.h" #include "../../irc/irc.h" diff --git a/weechat/src/gui/gtk/Makefile.am b/weechat/src/gui/gtk/Makefile.am index 8f2e52569..126eae3a8 100644 --- a/weechat/src/gui/gtk/Makefile.am +++ b/weechat/src/gui/gtk/Makefile.am @@ -23,6 +23,7 @@ weechat_gtk_LDADD = ../../common/lib_weechat_main.a \ ../../irc/lib_weechat_irc.a \ $(GTK_LIBS) -weechat_gtk_SOURCES = ../gui-common.c \ +weechat_gtk_SOURCES = ../gui.h \ + ../gui-common.c \ gui-display.c \ gui-input.c diff --git a/weechat/src/gui/gtk/gui-display.c b/weechat/src/gui/gtk/gui-display.c index d2d12fc39..77e983482 100644 --- a/weechat/src/gui/gtk/gui-display.c +++ b/weechat/src/gui/gtk/gui-display.c @@ -19,10 +19,13 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - /* gui-display.c: display functions for Gtk GUI */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #include @@ -33,7 +36,7 @@ #include "../../common/weechat.h" #include "../gui.h" -#include "../../common/config.h" +#include "../../common/weeconfig.h" #include "../../irc/irc.h" @@ -577,7 +580,7 @@ void gui_init () { gtk_main_window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_window_set_title (GTK_WINDOW (gtk_main_window), WEECHAT_NAME_AND_VERSION); + gtk_window_set_title (GTK_WINDOW (gtk_main_window), PACKAGE_STRING); vbox1 = gtk_vbox_new (FALSE, 0); gtk_widget_show (vbox1); diff --git a/weechat/src/gui/gtk/gui-input.c b/weechat/src/gui/gtk/gui-input.c index db30e6523..66a27684c 100644 --- a/weechat/src/gui/gtk/gui-input.c +++ b/weechat/src/gui/gtk/gui-input.c @@ -19,10 +19,13 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - /* gui-input: user input functions for Gtk GUI */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #include @@ -34,7 +37,7 @@ #include "../../common/weechat.h" #include "../gui.h" -#include "../../common/config.h" +#include "../../common/weeconfig.h" #include "../../common/command.h" #include "../../irc/irc.h" diff --git a/weechat/src/gui/gui-common.c b/weechat/src/gui/gui-common.c index 7d626024d..453e75835 100644 --- a/weechat/src/gui/gui-common.c +++ b/weechat/src/gui/gui-common.c @@ -19,10 +19,13 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - /* gui-common.c: display functions, used by any GUI */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #include diff --git a/weechat/src/irc/Makefile.am b/weechat/src/irc/Makefile.am index d7e85d1ee..c316c6a89 100644 --- a/weechat/src/irc/Makefile.am +++ b/weechat/src/irc/Makefile.am @@ -17,7 +17,8 @@ noinst_LIBRARIES = lib_weechat_irc.a -lib_weechat_irc_a_SOURCES = irc-commands.c \ +lib_weechat_irc_a_SOURCES = irc.h \ + irc-commands.c \ irc-send.c \ irc-recv.c \ irc-server.c \ diff --git a/weechat/src/irc/irc-channel.c b/weechat/src/irc/irc-channel.c index 7d426210c..a21d8465a 100644 --- a/weechat/src/irc/irc-channel.c +++ b/weechat/src/irc/irc-channel.c @@ -19,10 +19,13 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - /* irc-channel.c: manages a chat (channel or private chat) */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include diff --git a/weechat/src/irc/irc-commands.c b/weechat/src/irc/irc-commands.c index ae0854181..2a234871c 100644 --- a/weechat/src/irc/irc-commands.c +++ b/weechat/src/irc/irc-commands.c @@ -19,11 +19,14 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - /* irc-commands.c: implementation of IRC commands, according to RFC 1459,2810,2811,2812 */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include "../common/weechat.h" #include "irc.h" #include "../common/command.h" @@ -157,7 +160,7 @@ t_irc_command irc_commands[] = { "privmsg", N_("message received"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_privmsg }, - { "quit", N_("close all connections & quit " WEECHAT_NAME), + { "quit", N_("close all connections & quit " PACKAGE_NAME), N_("[quit_message]"), N_("quit_message: quit message (displayed to other users)"), 0, MAX_ARGS, 0, NULL, irc_cmd_send_quit, irc_cmd_recv_quit }, diff --git a/weechat/src/irc/irc-display.c b/weechat/src/irc/irc-display.c index 69ca1dea7..9b7a80275 100644 --- a/weechat/src/irc/irc-display.c +++ b/weechat/src/irc/irc-display.c @@ -19,10 +19,13 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - /* irc-display.c: display functions for IRC */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #include @@ -30,7 +33,7 @@ #include "../common/weechat.h" #include "irc.h" -#include "../common/config.h" +#include "../common/weeconfig.h" #include "../gui/gui.h" diff --git a/weechat/src/irc/irc-nick.c b/weechat/src/irc/irc-nick.c index 4365ce23f..c0104a0d7 100644 --- a/weechat/src/irc/irc-nick.c +++ b/weechat/src/irc/irc-nick.c @@ -19,10 +19,13 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - /* irc-nick.c: manages nick list for channels */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #include diff --git a/weechat/src/irc/irc-recv.c b/weechat/src/irc/irc-recv.c index ccd6832c8..d5b2213e3 100644 --- a/weechat/src/irc/irc-recv.c +++ b/weechat/src/irc/irc-recv.c @@ -19,11 +19,14 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - /* irc-recv.c: implementation of IRC commands (server to client), according to RFC 1459,2810,2811,2812 */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #include @@ -35,7 +38,7 @@ #include "../common/weechat.h" #include "irc.h" #include "../common/command.h" -#include "../common/config.h" +#include "../common/weeconfig.h" #include "../gui/gui.h" @@ -838,7 +841,7 @@ irc_cmd_recv_privmsg (t_irc_server *server, char *host, char *arguments) _("NOTICE %s :%sVERSION %s v%s" " compiled on %s, host \"%s\" is running " "%s %s / %s%s"), - host, "\01", WEECHAT_NAME, WEECHAT_VERSION, __DATE__, + host, "\01", PACKAGE_NAME, PACKAGE_VERSION, __DATE__, &buf->nodename, &buf->sysname, &buf->release, &buf->machine, "\01\r\n"); free (buf); @@ -2418,7 +2421,7 @@ irc_cmd_recv_433 (t_irc_server *server, char *host, char *arguments) gui_printf (server->window, _("%s: nickname \"%s\" is already in use, " "trying 2nd nickname \"%s\"\n"), - WEECHAT_NAME, server->nick, server->nick2); + PACKAGE_NAME, server->nick, server->nick2); free (server->nick); server->nick = strdup (server->nick2); } @@ -2429,7 +2432,7 @@ irc_cmd_recv_433 (t_irc_server *server, char *host, char *arguments) gui_printf (server->window, _("%s: nickname \"%s\" is already in use, " "trying 3rd nickname \"%s\"\n"), - WEECHAT_NAME, server->nick, server->nick3); + PACKAGE_NAME, server->nick, server->nick3); free (server->nick); server->nick = strdup (server->nick3); } @@ -2438,7 +2441,7 @@ irc_cmd_recv_433 (t_irc_server *server, char *host, char *arguments) gui_printf (server->window, _("%s: all declared nicknames are already in use, " "closing connection with server!\n"), - WEECHAT_NAME); + PACKAGE_NAME); server_disconnect (server); return 0; } diff --git a/weechat/src/irc/irc-send.c b/weechat/src/irc/irc-send.c index 147cfa19b..4c9c025a0 100644 --- a/weechat/src/irc/irc-send.c +++ b/weechat/src/irc/irc-send.c @@ -19,11 +19,14 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - /* irc-send.c: implementation of IRC commands (client to server), according to RFC 1459,2810,2811,2812 */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #include @@ -35,7 +38,7 @@ #include "../common/weechat.h" #include "irc.h" #include "../common/command.h" -#include "../common/config.h" +#include "../common/weeconfig.h" #include "../gui/gui.h" @@ -57,7 +60,7 @@ irc_login (t_irc_server *server) strcpy (hostname, _("unknown")); gui_printf (server->window, _("%s: using local hostname \"%s\"\n"), - WEECHAT_NAME, hostname); + PACKAGE_NAME, hostname); server_sendf (server, "NICK %s\r\n" "USER %s %s %s :%s\r\n", @@ -973,7 +976,7 @@ irc_cmd_send_version (t_irc_server *server, char *arguments) { irc_display_prefix (server->window, PREFIX_INFO); gui_printf (server->window, _("%s, compiled on %s %s\n"), - WEECHAT_NAME_AND_VERSION, + PACKAGE_STRING, __DATE__, __TIME__); server_sendf (server, "VERSION\r\n"); } diff --git a/weechat/src/irc/irc-server.c b/weechat/src/irc/irc-server.c index ee1ead0e3..e7fe42880 100644 --- a/weechat/src/irc/irc-server.c +++ b/weechat/src/irc/irc-server.c @@ -19,10 +19,13 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - /* irc-server.c: (dis)connection and communication with irc server */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #include @@ -480,7 +483,7 @@ server_connect (t_irc_server *server) gui_printf (server->window, _("%s: connecting to %s:%d...\n"), - WEECHAT_NAME, server->address, server->port); + PACKAGE_NAME, server->address, server->port); log_printf (_("connecting to server %s:%d...\n"), server->address, server->port); server->is_connected = 0; @@ -551,7 +554,7 @@ server_connect (t_irc_server *server) /* connection to server */ gui_printf (server->window, - _("%s: server IP is: %s\n"), WEECHAT_NAME, ip_address); + _("%s: server IP is: %s\n"), PACKAGE_NAME, ip_address); error = connect (server->sock4, (struct sockaddr *) &addr, sizeof (addr)); if (error != 0)