mirror of
https://github.com/weechat/weechat.git
synced 2026-07-08 18:53:12 +02:00
Added charset plugin (WeeChat is now full UTF-8 for internal data storage), fixed compilation problems with FreeBSD, fixed status bar display bug
This commit is contained in:
@@ -42,10 +42,11 @@
|
||||
#include "weechat.h"
|
||||
#include "backtrace.h"
|
||||
#include "log.h"
|
||||
#include "util.h"
|
||||
|
||||
|
||||
/*
|
||||
* weechat_backtrace_printf: display a backtrage line (on stderr and in WeeChat log)
|
||||
* weechat_backtrace_printf: display a backtrace line (on stderr and in WeeChat log)
|
||||
*/
|
||||
|
||||
void
|
||||
@@ -58,7 +59,7 @@ weechat_backtrace_printf (char *message, ...)
|
||||
vsnprintf (buffer, sizeof (buffer) - 1, message, argptr);
|
||||
va_end (argptr);
|
||||
|
||||
fprintf (stderr, "%s", buffer);
|
||||
weechat_iconv_fprintf (stderr, "%s", buffer);
|
||||
weechat_log_printf ("%s", buffer);
|
||||
}
|
||||
|
||||
|
||||
+21
-273
@@ -74,13 +74,6 @@ t_weechat_command weechat_commands[] =
|
||||
N_("command"),
|
||||
N_("command: command to execute (a '/' is automatically added if not found at beginning of command)\n"),
|
||||
"%w|%i", 0, MAX_ARGS, 1, NULL, weechat_cmd_builtin },
|
||||
{ "charset", N_("change charset for server or channel"),
|
||||
N_("[(decode_iso | decode_utf | encode) charset]"),
|
||||
N_("decode_iso: charset used for decoding ISO\n"
|
||||
"decode_utf: charset used for decoding UTF\n"
|
||||
" encode: charset used for encoding messages\n"
|
||||
" charset: charset to use (for example: ISO-8859-15, UTF-8,..)"),
|
||||
"decode_iso|decode_utf|encode", 0, 2, 0, weechat_cmd_charset, NULL },
|
||||
{ "clear", N_("clear window(s)"),
|
||||
N_("[-all]"),
|
||||
N_("-all: clear all windows"),
|
||||
@@ -293,7 +286,7 @@ exec_weechat_command (t_irc_server *server, t_irc_channel *channel, char *string
|
||||
int only_builtin)
|
||||
{
|
||||
int i, rc, argc, argc2, return_code, length1, length2;
|
||||
char *command, *pos, *ptr_args, *ptr_args2, *ptr_args3;
|
||||
char *command, *pos, *ptr_args, *ptr_args2;
|
||||
char **argv, **argv2, *alias_command;
|
||||
char **commands, **ptr_cmd, **ptr_next_cmd;
|
||||
char *args_replaced, *vars_replaced, *new_ptr_cmd;
|
||||
@@ -497,16 +490,13 @@ exec_weechat_command (t_irc_server *server, t_irc_channel *channel, char *string
|
||||
}
|
||||
else
|
||||
{
|
||||
ptr_args2 = (weechat_commands[i].conversion && ptr_args) ?
|
||||
channel_iconv_encode (server, channel, ptr_args) : NULL;
|
||||
ptr_args3 = (weechat_commands[i].conversion
|
||||
&& cfg_irc_colors_send && ptr_args) ?
|
||||
(char *)gui_color_encode ((ptr_args2) ? (unsigned char *)ptr_args2 :
|
||||
(unsigned char *)ptr_args) : NULL;
|
||||
ptr_args2 = (weechat_commands[i].conversion
|
||||
&& cfg_irc_colors_send
|
||||
&& ptr_args) ?
|
||||
(char *)gui_color_encode ((unsigned char *)ptr_args) : NULL;
|
||||
if (weechat_commands[i].cmd_function_args)
|
||||
{
|
||||
argv2 = explode_string ((ptr_args3) ? ptr_args3 :
|
||||
((ptr_args2) ? ptr_args2 : ptr_args),
|
||||
argv2 = explode_string ((ptr_args2) ? ptr_args2 : ptr_args,
|
||||
" ", 0, &argc2);
|
||||
return_code = (int) (weechat_commands[i].cmd_function_args)
|
||||
(server, channel, argc2, argv2);
|
||||
@@ -514,8 +504,7 @@ exec_weechat_command (t_irc_server *server, t_irc_channel *channel, char *string
|
||||
}
|
||||
else
|
||||
return_code = (int) (weechat_commands[i].cmd_function_1arg)
|
||||
(server, channel, (ptr_args3) ? ptr_args3 :
|
||||
((ptr_args2) ? ptr_args2 : ptr_args));
|
||||
(server, channel, (ptr_args2) ? ptr_args2 : ptr_args);
|
||||
if (return_code < 0)
|
||||
{
|
||||
irc_display_prefix (NULL, NULL, PREFIX_ERROR);
|
||||
@@ -525,8 +514,6 @@ exec_weechat_command (t_irc_server *server, t_irc_channel *channel, char *string
|
||||
}
|
||||
if (ptr_args2)
|
||||
free (ptr_args2);
|
||||
if (ptr_args3)
|
||||
free (ptr_args3);
|
||||
}
|
||||
free_exploded_string (argv);
|
||||
free (command);
|
||||
@@ -592,16 +579,13 @@ exec_weechat_command (t_irc_server *server, t_irc_channel *channel, char *string
|
||||
free (command);
|
||||
return 0;
|
||||
}
|
||||
ptr_args2 = (irc_commands[i].conversion && ptr_args) ?
|
||||
channel_iconv_encode (server, channel, ptr_args) : NULL;
|
||||
ptr_args3 = (irc_commands[i].conversion
|
||||
&& cfg_irc_colors_send && ptr_args) ?
|
||||
(char *)gui_color_encode ((ptr_args2) ? (unsigned char *)ptr_args2 :
|
||||
(unsigned char *)ptr_args) : NULL;
|
||||
ptr_args2 = (irc_commands[i].conversion
|
||||
&& cfg_irc_colors_send
|
||||
&& ptr_args) ?
|
||||
(char *)gui_color_encode ((unsigned char *)ptr_args) : NULL;
|
||||
if (irc_commands[i].cmd_function_args)
|
||||
{
|
||||
argv2 = explode_string ((ptr_args3) ? ptr_args3 :
|
||||
((ptr_args2) ? ptr_args2 : ptr_args),
|
||||
argv2 = explode_string ((ptr_args2) ? ptr_args2 : ptr_args,
|
||||
" ", 0, &argc2);
|
||||
return_code = (int) (irc_commands[i].cmd_function_args)
|
||||
(server, channel, argc2, argv2);
|
||||
@@ -609,8 +593,7 @@ exec_weechat_command (t_irc_server *server, t_irc_channel *channel, char *string
|
||||
}
|
||||
else
|
||||
return_code = (int) (irc_commands[i].cmd_function_1arg)
|
||||
(server, channel, (ptr_args3) ? ptr_args3 :
|
||||
((ptr_args2) ? ptr_args2 : ptr_args));
|
||||
(server, channel, (ptr_args2) ? ptr_args2 : ptr_args);
|
||||
if (return_code < 0)
|
||||
{
|
||||
irc_display_prefix (NULL, NULL, PREFIX_ERROR);
|
||||
@@ -620,8 +603,6 @@ exec_weechat_command (t_irc_server *server, t_irc_channel *channel, char *string
|
||||
}
|
||||
if (ptr_args2)
|
||||
free (ptr_args2);
|
||||
if (ptr_args3)
|
||||
free (ptr_args3);
|
||||
}
|
||||
free_exploded_string (argv);
|
||||
free (command);
|
||||
@@ -742,7 +723,7 @@ user_command (t_irc_server *server, t_irc_channel *channel, char *command, int o
|
||||
{
|
||||
t_gui_buffer *buffer;
|
||||
char *new_cmd, *ptr_cmd, *pos;
|
||||
char *command_with_colors, *command_encoded;
|
||||
char *command_with_colors;
|
||||
|
||||
if ((!command) || (!command[0]) || (command[0] == '\r') || (command[0] == '\n'))
|
||||
return;
|
||||
@@ -791,9 +772,6 @@ user_command (t_irc_server *server, t_irc_channel *channel, char *command, int o
|
||||
command_with_colors = (cfg_irc_colors_send) ?
|
||||
(char *)gui_color_encode ((unsigned char *)ptr_cmd) : NULL;
|
||||
|
||||
command_encoded = channel_iconv_encode (server, channel,
|
||||
(command_with_colors) ? command_with_colors : ptr_cmd);
|
||||
|
||||
if (CHANNEL(buffer)->dcc_chat)
|
||||
{
|
||||
if (((t_irc_dcc *)(CHANNEL(buffer)->dcc_chat))->sock < 0)
|
||||
@@ -806,8 +784,7 @@ user_command (t_irc_server *server, t_irc_channel *channel, char *command, int o
|
||||
{
|
||||
dcc_chat_sendf ((t_irc_dcc *)(CHANNEL(buffer)->dcc_chat),
|
||||
"%s\r\n",
|
||||
(command_encoded) ? command_encoded :
|
||||
((command_with_colors) ? command_with_colors : ptr_cmd));
|
||||
(command_with_colors) ? command_with_colors : ptr_cmd);
|
||||
user_message_display (server, buffer,
|
||||
(command_with_colors) ?
|
||||
command_with_colors : ptr_cmd);
|
||||
@@ -815,13 +792,10 @@ user_command (t_irc_server *server, t_irc_channel *channel, char *command, int o
|
||||
}
|
||||
else
|
||||
user_message (server, buffer,
|
||||
(command_encoded) ? command_encoded :
|
||||
((command_with_colors) ? command_with_colors : ptr_cmd));
|
||||
(command_with_colors) ? command_with_colors : ptr_cmd);
|
||||
|
||||
if (command_with_colors)
|
||||
free (command_with_colors);
|
||||
if (command_encoded)
|
||||
free (command_encoded);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1394,232 +1368,6 @@ weechat_cmd_builtin (t_irc_server *server, t_irc_channel *channel,
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_cmd_charset_display: display charsets for a server or channel
|
||||
*/
|
||||
|
||||
void
|
||||
weechat_cmd_charset_display (t_gui_buffer *buffer)
|
||||
{
|
||||
char *server_item = "server", *ptr_item;
|
||||
char *value, *string, *herited;
|
||||
int length;
|
||||
|
||||
if ((BUFFER_IS_SERVER(buffer) && (SERVER(buffer)))
|
||||
|| BUFFER_IS_CHANNEL(buffer)
|
||||
|| BUFFER_IS_PRIVATE(buffer))
|
||||
{
|
||||
if (BUFFER_IS_SERVER(buffer))
|
||||
{
|
||||
gui_printf_nolog (NULL, _("Charsets for server %s%s%s: "),
|
||||
GUI_COLOR(COLOR_WIN_CHAT_SERVER),
|
||||
SERVER(buffer)->name,
|
||||
GUI_COLOR(COLOR_WIN_CHAT));
|
||||
ptr_item = server_item;
|
||||
}
|
||||
else if (BUFFER_IS_CHANNEL(buffer))
|
||||
{
|
||||
gui_printf_nolog (NULL, _("Charsets for channel %s%s%s: "),
|
||||
GUI_COLOR(COLOR_WIN_CHAT_CHANNEL),
|
||||
CHANNEL(buffer)->name,
|
||||
GUI_COLOR(COLOR_WIN_CHAT));
|
||||
ptr_item = CHANNEL(buffer)->name;
|
||||
}
|
||||
else
|
||||
{
|
||||
gui_printf_nolog (NULL, _("Charsets for private %s%s%s: "),
|
||||
GUI_COLOR(COLOR_WIN_CHAT_CHANNEL),
|
||||
CHANNEL(buffer)->name,
|
||||
GUI_COLOR(COLOR_WIN_CHAT));
|
||||
ptr_item = CHANNEL(buffer)->name;
|
||||
}
|
||||
|
||||
/* decode ISO */
|
||||
herited = NULL;
|
||||
config_option_list_get_value (&(SERVER(buffer)->charset_decode_iso),
|
||||
ptr_item, &value, &length);
|
||||
if (value && (length > 0))
|
||||
{
|
||||
string = strdup (value);
|
||||
string[length] = '\0';
|
||||
}
|
||||
else
|
||||
{
|
||||
string = strdup ("");
|
||||
herited = channel_get_charset_decode_iso (SERVER(buffer),
|
||||
CHANNEL(buffer));
|
||||
}
|
||||
gui_printf (NULL, "decode_iso: \"%s%s%s\"",
|
||||
GUI_COLOR(COLOR_WIN_CHAT_HOST),
|
||||
string,
|
||||
GUI_COLOR(COLOR_WIN_CHAT));
|
||||
if (herited)
|
||||
{
|
||||
gui_printf (NULL, _(" (inherited: \"%s%s%s\")"),
|
||||
GUI_COLOR(COLOR_WIN_CHAT_HOST),
|
||||
herited,
|
||||
GUI_COLOR(COLOR_WIN_CHAT));
|
||||
free (herited);
|
||||
}
|
||||
gui_printf (NULL, ", ");
|
||||
free (string);
|
||||
|
||||
/* decode UTF */
|
||||
herited = NULL;
|
||||
config_option_list_get_value (&(SERVER(buffer)->charset_decode_utf),
|
||||
ptr_item, &value, &length);
|
||||
if (value && (length > 0))
|
||||
{
|
||||
string = strdup (value);
|
||||
string[length] = '\0';
|
||||
}
|
||||
else
|
||||
{
|
||||
string = strdup ("");
|
||||
herited = channel_get_charset_decode_utf (SERVER(buffer),
|
||||
CHANNEL(buffer));
|
||||
}
|
||||
gui_printf (NULL, "decode_utf: \"%s%s%s\"",
|
||||
GUI_COLOR(COLOR_WIN_CHAT_HOST),
|
||||
string,
|
||||
GUI_COLOR(COLOR_WIN_CHAT));
|
||||
if (herited)
|
||||
{
|
||||
gui_printf (NULL, _(" (inherited: \"%s%s%s\")"),
|
||||
GUI_COLOR(COLOR_WIN_CHAT_HOST),
|
||||
herited,
|
||||
GUI_COLOR(COLOR_WIN_CHAT));
|
||||
free (herited);
|
||||
}
|
||||
gui_printf (NULL, ", ");
|
||||
free (string);
|
||||
|
||||
/* encode */
|
||||
herited = NULL;
|
||||
config_option_list_get_value (&(SERVER(buffer)->charset_encode),
|
||||
ptr_item, &value, &length);
|
||||
if (value && (length > 0))
|
||||
{
|
||||
string = strdup (value);
|
||||
string[length] = '\0';
|
||||
}
|
||||
else
|
||||
{
|
||||
string = strdup ("");
|
||||
herited = channel_get_charset_encode (SERVER(buffer),
|
||||
CHANNEL(buffer));
|
||||
}
|
||||
gui_printf (NULL, "encode: \"%s%s%s\"",
|
||||
GUI_COLOR(COLOR_WIN_CHAT_HOST),
|
||||
string,
|
||||
GUI_COLOR(COLOR_WIN_CHAT));
|
||||
if (herited)
|
||||
{
|
||||
gui_printf (NULL, _(" (inherited: \"%s%s%s\")"),
|
||||
GUI_COLOR(COLOR_WIN_CHAT_HOST),
|
||||
herited,
|
||||
GUI_COLOR(COLOR_WIN_CHAT));
|
||||
free (herited);
|
||||
}
|
||||
gui_printf (NULL, "\n");
|
||||
free (string);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_cmd_charset_set: set a charset for server or channel
|
||||
* from_internal == 1 if charset is used to encode data,
|
||||
* 0 if charset is used to decode data
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_cmd_charset_set (t_gui_buffer *buffer, char **string, char *charset,
|
||||
int from_internal)
|
||||
{
|
||||
int iconv_ok;
|
||||
|
||||
if (charset)
|
||||
{
|
||||
if (from_internal)
|
||||
iconv_ok = weechat_iconv_check (NULL, charset);
|
||||
else
|
||||
iconv_ok = weechat_iconv_check (charset, NULL);
|
||||
|
||||
if (!iconv_ok)
|
||||
{
|
||||
irc_display_prefix (NULL, NULL, PREFIX_ERROR);
|
||||
gui_printf (NULL,
|
||||
_("%s charset \"%s\" is not available\n"),
|
||||
WEECHAT_ERROR, charset);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
if (BUFFER_IS_SERVER(buffer))
|
||||
{
|
||||
if (SERVER(buffer))
|
||||
{
|
||||
if (charset)
|
||||
config_option_list_set (string, "server", charset);
|
||||
else
|
||||
config_option_list_remove (string, "server");
|
||||
weechat_cmd_charset_display (buffer);
|
||||
}
|
||||
}
|
||||
else if (BUFFER_IS_CHANNEL(buffer) ||
|
||||
BUFFER_IS_PRIVATE(buffer))
|
||||
{
|
||||
if (charset)
|
||||
config_option_list_set (string, CHANNEL(buffer)->name, charset);
|
||||
else
|
||||
config_option_list_remove (string, CHANNEL(buffer)->name);
|
||||
weechat_cmd_charset_display (buffer);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_cmd_charset: change charset for server or channel
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_cmd_charset (t_irc_server *server, t_irc_channel *channel,
|
||||
int argc, char **argv)
|
||||
{
|
||||
t_gui_buffer *buffer;
|
||||
int rc;
|
||||
|
||||
irc_find_context (server, channel, NULL, &buffer);
|
||||
|
||||
if (argc == 0)
|
||||
weechat_cmd_charset_display (buffer);
|
||||
else
|
||||
{
|
||||
if (ascii_strcasecmp (argv[0], "decode_iso") == 0)
|
||||
rc = weechat_cmd_charset_set (buffer,
|
||||
&(SERVER(buffer)->charset_decode_iso),
|
||||
(argc > 1) ? argv[1] : NULL, 0);
|
||||
else if (ascii_strcasecmp (argv[0], "decode_utf") == 0)
|
||||
rc = weechat_cmd_charset_set (buffer,
|
||||
&(SERVER(buffer)->charset_decode_utf),
|
||||
(argc > 1) ? argv[1] : NULL, 0);
|
||||
else if (ascii_strcasecmp (argv[0], "encode") == 0)
|
||||
rc = weechat_cmd_charset_set (buffer,
|
||||
&(SERVER(buffer)->charset_encode),
|
||||
(argc > 1) ? argv[1] : NULL, 1);
|
||||
else
|
||||
{
|
||||
irc_display_prefix (NULL, NULL, PREFIX_ERROR);
|
||||
gui_printf (NULL,
|
||||
_("%s unknown option for \"%s\" command\n"),
|
||||
WEECHAT_ERROR, "charset");
|
||||
return -1;
|
||||
}
|
||||
if (rc < 0)
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_cmd_clear: display or create alias
|
||||
*/
|
||||
@@ -2996,8 +2744,7 @@ weechat_cmd_server (t_irc_server *server, t_irc_channel *channel,
|
||||
server_tmp.nick2, server_tmp.nick3,
|
||||
server_tmp.username, server_tmp.realname,
|
||||
server_tmp.hostname,
|
||||
server_tmp.command, 1, server_tmp.autojoin, 1, NULL,
|
||||
NULL, NULL, NULL);
|
||||
server_tmp.command, 1, server_tmp.autojoin, 1, NULL);
|
||||
if (new_server)
|
||||
{
|
||||
irc_display_prefix (NULL, NULL, PREFIX_INFO);
|
||||
@@ -3789,9 +3536,10 @@ weechat_cmd_upgrade (t_irc_server *server, t_irc_channel *channel,
|
||||
plugin_init (1);
|
||||
#endif
|
||||
|
||||
fprintf (stderr, _("%s exec failed (program: \"%s\"), exiting WeeChat\n"),
|
||||
WEECHAT_ERROR,
|
||||
exec_args[0]);
|
||||
weechat_iconv_fprintf (stderr,
|
||||
_("%s exec failed (program: \"%s\"), exiting WeeChat\n"),
|
||||
WEECHAT_ERROR,
|
||||
exec_args[0]);
|
||||
|
||||
free (exec_args[0]);
|
||||
free (exec_args[3]);
|
||||
|
||||
@@ -60,7 +60,6 @@ extern void user_command (t_irc_server *, t_irc_channel *, char *, int);
|
||||
extern int weechat_cmd_alias (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int weechat_cmd_buffer (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int weechat_cmd_builtin (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int weechat_cmd_charset (t_irc_server *, t_irc_channel *, int, char **);
|
||||
extern int weechat_cmd_clear (t_irc_server *, t_irc_channel *, int, char **);
|
||||
extern int weechat_cmd_connect (t_irc_server *, t_irc_channel *, int, char **);
|
||||
extern int weechat_cmd_dcc (t_irc_server *, t_irc_channel *, char *);
|
||||
|
||||
@@ -664,7 +664,7 @@ completion_list_add_servers (t_completion *completion)
|
||||
void
|
||||
completion_list_add_topic (t_completion *completion)
|
||||
{
|
||||
char *string, *string2;
|
||||
char *string;
|
||||
|
||||
if (!completion->server || !completion->channel
|
||||
|| !((t_irc_channel *)(completion->channel))->topic
|
||||
@@ -676,16 +676,11 @@ completion_list_add_topic (t_completion *completion)
|
||||
string = (char *)gui_color_decode_for_user_entry ((unsigned char *)((t_irc_channel *)(completion->channel))->topic);
|
||||
else
|
||||
string = (char *)gui_color_decode ((unsigned char *)((t_irc_channel *)(completion->channel))->topic, 0);
|
||||
string2 = channel_iconv_decode ((t_irc_server *)(completion->server),
|
||||
(t_irc_channel *)(completion->channel),
|
||||
(string) ? string : ((t_irc_channel *)(completion->channel))->topic);
|
||||
completion_list_add (completion,
|
||||
(string2) ? string2 : ((string) ?
|
||||
string : ((t_irc_channel *)(completion->channel))->topic));
|
||||
(string) ?
|
||||
string : ((t_irc_channel *)(completion->channel))->topic);
|
||||
if (string)
|
||||
free (string);
|
||||
if (string2)
|
||||
free (string2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+14
-12
@@ -38,6 +38,7 @@
|
||||
|
||||
#include "weechat.h"
|
||||
#include "log.h"
|
||||
#include "util.h"
|
||||
|
||||
|
||||
char *weechat_log_filename = NULL; /* log name (~/.weechat/weechat.log) */
|
||||
@@ -99,11 +100,11 @@ weechat_log_init ()
|
||||
{
|
||||
if (!weechat_log_open (NULL, "w"))
|
||||
{
|
||||
fprintf (stderr,
|
||||
_("%s unable to create/append to log file\n"
|
||||
"If another WeeChat process is using this file, try to run WeeChat\n"
|
||||
"with another home using \"--dir\" command line option.\n"),
|
||||
WEECHAT_ERROR);
|
||||
weechat_iconv_fprintf (stderr,
|
||||
_("%s unable to create/append to log file\n"
|
||||
"If another WeeChat process is using this file, try to run WeeChat\n"
|
||||
"with another home using \"--dir\" command line option.\n"),
|
||||
WEECHAT_ERROR);
|
||||
exit (1);
|
||||
}
|
||||
}
|
||||
@@ -142,12 +143,13 @@ weechat_log_printf (char *message, ...)
|
||||
seconds = time (NULL);
|
||||
date_tmp = localtime (&seconds);
|
||||
if (date_tmp)
|
||||
fprintf (weechat_log_file, "[%04d-%02d-%02d %02d:%02d:%02d] %s",
|
||||
date_tmp->tm_year + 1900, date_tmp->tm_mon + 1, date_tmp->tm_mday,
|
||||
date_tmp->tm_hour, date_tmp->tm_min, date_tmp->tm_sec,
|
||||
buffer);
|
||||
weechat_iconv_fprintf (weechat_log_file, "[%04d-%02d-%02d %02d:%02d:%02d] %s",
|
||||
date_tmp->tm_year + 1900, date_tmp->tm_mon + 1, date_tmp->tm_mday,
|
||||
date_tmp->tm_hour, date_tmp->tm_min, date_tmp->tm_sec,
|
||||
buffer);
|
||||
else
|
||||
fprintf (weechat_log_file, "%s", buffer);
|
||||
weechat_iconv_fprintf (weechat_log_file, "%s", buffer);
|
||||
|
||||
fflush (weechat_log_file);
|
||||
}
|
||||
|
||||
@@ -212,8 +214,8 @@ weechat_log_crash_rename ()
|
||||
getpid());
|
||||
if (rename (old_name, new_name) == 0)
|
||||
{
|
||||
fprintf (stderr, "*** Full crash dump was saved to %s file.\n",
|
||||
new_name);
|
||||
weechat_iconv_fprintf (stderr, "*** Full crash dump was saved to %s file.\n",
|
||||
new_name);
|
||||
weechat_log_open (new_name, "a");
|
||||
free (old_name);
|
||||
free (new_name);
|
||||
|
||||
+22
-24
@@ -38,6 +38,7 @@
|
||||
#include "session.h"
|
||||
#include "hotlist.h"
|
||||
#include "log.h"
|
||||
#include "util.h"
|
||||
#include "../irc/irc.h"
|
||||
#include "../gui/gui.h"
|
||||
|
||||
@@ -265,9 +266,6 @@ session_save_servers (FILE *file)
|
||||
rc = rc && (session_write_int (file, SESSION_SERV_LAG, ptr_server->lag));
|
||||
rc = rc && (session_write_buf (file, SESSION_SERV_LAG_CHECK_TIME, &(ptr_server->lag_check_time), sizeof (struct timeval)));
|
||||
rc = rc && (session_write_buf (file, SESSION_SERV_LAG_NEXT_CHECK, &(ptr_server->lag_next_check), sizeof (time_t)));
|
||||
rc = rc && (session_write_str (file, SESSION_SERV_CHARSET_DECODE_ISO, ptr_server->charset_decode_iso));
|
||||
rc = rc && (session_write_str (file, SESSION_SERV_CHARSET_DECODE_UTF, ptr_server->charset_decode_utf));
|
||||
rc = rc && (session_write_str (file, SESSION_SERV_CHARSET_ENCODE, ptr_server->charset_encode));
|
||||
rc = rc && (session_write_id (file, SESSION_SERV_END));
|
||||
|
||||
if (!rc)
|
||||
@@ -510,21 +508,21 @@ session_crash (FILE *file, char *message, ...)
|
||||
|
||||
fclose (file);
|
||||
gui_main_end ();
|
||||
fprintf (stderr, "%s %s\n",
|
||||
WEECHAT_ERROR, buffer);
|
||||
fprintf (stderr,
|
||||
_("Last operation with session file was at position %ld, "
|
||||
"read of %d bytes\n"),
|
||||
session_last_read_pos,
|
||||
session_last_read_length);
|
||||
fprintf (stderr,
|
||||
_("Please send %s/%s, %s/%s and "
|
||||
"above messages to WeeChat developers for support.\n"
|
||||
"Be careful, private info may be in these files.\n"),
|
||||
weechat_home,
|
||||
WEECHAT_LOG_NAME,
|
||||
weechat_home,
|
||||
WEECHAT_SESSION_NAME);
|
||||
weechat_iconv_fprintf (stderr, "%s %s\n",
|
||||
WEECHAT_ERROR, buffer);
|
||||
weechat_iconv_fprintf (stderr,
|
||||
_("Last operation with session file was at position %ld, "
|
||||
"read of %d bytes\n"),
|
||||
session_last_read_pos,
|
||||
session_last_read_length);
|
||||
weechat_iconv_fprintf (stderr,
|
||||
_("Please send %s/%s, %s/%s and "
|
||||
"above messages to WeeChat developers for support.\n"
|
||||
"Be careful, private info may be in these files.\n"),
|
||||
weechat_home,
|
||||
WEECHAT_LOG_NAME,
|
||||
weechat_home,
|
||||
WEECHAT_SESSION_NAME);
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
@@ -995,14 +993,14 @@ session_load_server (FILE *file)
|
||||
case SESSION_SERV_LAG_NEXT_CHECK:
|
||||
rc = rc && (session_read_buf (file, &(session_current_server->lag_next_check), sizeof (time_t)));
|
||||
break;
|
||||
case SESSION_SERV_CHARSET_DECODE_ISO:
|
||||
rc = rc && (session_read_str (file, &(session_current_server->charset_decode_iso)));
|
||||
case SESSION_SERV_CHARSET_DECODE_ISO__UNUSED:
|
||||
rc = rc && (session_read_ignore_value (file));
|
||||
break;
|
||||
case SESSION_SERV_CHARSET_DECODE_UTF:
|
||||
rc = rc && (session_read_str (file, &(session_current_server->charset_decode_utf)));
|
||||
case SESSION_SERV_CHARSET_DECODE_UTF__UNUSED:
|
||||
rc = rc && (session_read_ignore_value (file));
|
||||
break;
|
||||
case SESSION_SERV_CHARSET_ENCODE:
|
||||
rc = rc && (session_read_str (file, &(session_current_server->charset_encode)));
|
||||
case SESSION_SERV_CHARSET_ENCODE__UNUSED:
|
||||
rc = rc && (session_read_ignore_value (file));
|
||||
break;
|
||||
default:
|
||||
weechat_log_printf (_("session: warning: ignoring value from "
|
||||
|
||||
@@ -87,9 +87,9 @@ enum t_session_server
|
||||
SESSION_SERV_LAG,
|
||||
SESSION_SERV_LAG_CHECK_TIME,
|
||||
SESSION_SERV_LAG_NEXT_CHECK,
|
||||
SESSION_SERV_CHARSET_DECODE_ISO,
|
||||
SESSION_SERV_CHARSET_DECODE_UTF,
|
||||
SESSION_SERV_CHARSET_ENCODE,
|
||||
SESSION_SERV_CHARSET_DECODE_ISO__UNUSED,
|
||||
SESSION_SERV_CHARSET_DECODE_UTF__UNUSED,
|
||||
SESSION_SERV_CHARSET_ENCODE__UNUSED,
|
||||
SESSION_SERV_HOSTNAME,
|
||||
SESSION_SERV_NICK_MODES,
|
||||
SESSION_SERV_AWAY_MESSAGE
|
||||
|
||||
+44
-36
@@ -39,12 +39,12 @@
|
||||
|
||||
#include "weechat.h"
|
||||
#include "utf8.h"
|
||||
#include "util.h"
|
||||
#include "weeconfig.h"
|
||||
|
||||
|
||||
int local_utf8 = 0;
|
||||
|
||||
|
||||
/*
|
||||
* utf8_init: initializes UTF-8 in WeeChat
|
||||
*/
|
||||
@@ -52,26 +52,17 @@ int local_utf8 = 0;
|
||||
void
|
||||
utf8_init ()
|
||||
{
|
||||
local_utf8 = 0;
|
||||
|
||||
if (cfg_look_charset_internal && cfg_look_charset_internal[0])
|
||||
{
|
||||
if (strstr (cfg_look_charset_internal, "UTF-8")
|
||||
|| strstr (cfg_look_charset_internal, "utf-8"))
|
||||
local_utf8 = 1;
|
||||
}
|
||||
else if ((local_charset)
|
||||
&& ((strstr (local_charset, "UTF-8")
|
||||
|| strstr (local_charset, "utf-8"))))
|
||||
local_utf8 = 1;
|
||||
local_utf8 = (ascii_strcasecmp (local_charset, "UTF-8") == 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* utf8_is_valid: return 1 if UTF-8 string is valid, 0 otherwise
|
||||
* if error is not NULL, it's set with first non valid UTF-8
|
||||
* char in string, if any
|
||||
*/
|
||||
|
||||
int
|
||||
utf8_is_valid (char *string)
|
||||
utf8_is_valid (char *string, char **error)
|
||||
{
|
||||
while (string && string[0])
|
||||
{
|
||||
@@ -79,7 +70,11 @@ utf8_is_valid (char *string)
|
||||
if (((unsigned char)(string[0]) & 0xE0) == 0xC0)
|
||||
{
|
||||
if (!string[1] || (((unsigned char)(string[1]) & 0xC0) != 0x80))
|
||||
{
|
||||
if (error)
|
||||
*error = string;
|
||||
return 0;
|
||||
}
|
||||
string += 2;
|
||||
}
|
||||
/* UTF-8, 3 bytes, should be: 1110vvvv 10vvvvvv 10vvvvvv */
|
||||
@@ -88,7 +83,11 @@ utf8_is_valid (char *string)
|
||||
if (!string[1] || !string[2]
|
||||
|| (((unsigned char)(string[1]) & 0xC0) != 0x80)
|
||||
|| (((unsigned char)(string[2]) & 0xC0) != 0x80))
|
||||
{
|
||||
if (error)
|
||||
*error = string;
|
||||
return 0;
|
||||
}
|
||||
string += 3;
|
||||
}
|
||||
/* UTF-8, 4 bytes, should be: 11110vvv 10vvvvvv 10vvvvvv 10vvvvvv */
|
||||
@@ -98,18 +97,47 @@ utf8_is_valid (char *string)
|
||||
|| (((unsigned char)(string[1]) & 0xC0) != 0x80)
|
||||
|| (((unsigned char)(string[2]) & 0xC0) != 0x80)
|
||||
|| (((unsigned char)(string[3]) & 0xC0) != 0x80))
|
||||
{
|
||||
if (error)
|
||||
*error = string;
|
||||
return 0;
|
||||
}
|
||||
string += 4;
|
||||
}
|
||||
/* UTF-8, 1 byte, should be: 0vvvvvvv */
|
||||
else if ((unsigned char)(string[0]) >= 0x80)
|
||||
{
|
||||
if (error)
|
||||
*error = string;
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
string++;
|
||||
}
|
||||
if (error)
|
||||
*error = NULL;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* utf8_normalize: normalize UTF-8 string: remove non UTF-8 chars and
|
||||
* replace them by a char
|
||||
*/
|
||||
|
||||
void
|
||||
utf8_normalize (char *string, char replacement)
|
||||
{
|
||||
char *error;
|
||||
|
||||
while (string && string[0])
|
||||
{
|
||||
if (utf8_is_valid (string, &error))
|
||||
return;
|
||||
error[0] = replacement;
|
||||
string = error + 1;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* utf8_prev_char: return previous UTF-8 char in a string
|
||||
*/
|
||||
@@ -122,9 +150,6 @@ utf8_prev_char (char *string_start, char *string)
|
||||
|
||||
string--;
|
||||
|
||||
if (!local_utf8)
|
||||
return string;
|
||||
|
||||
if (((unsigned char)(string[0]) & 0xC0) == 0x80)
|
||||
{
|
||||
/* UTF-8, at least 2 bytes */
|
||||
@@ -164,9 +189,6 @@ utf8_next_char (char *string)
|
||||
if (!string)
|
||||
return NULL;
|
||||
|
||||
if (!local_utf8)
|
||||
return string + 1;
|
||||
|
||||
/* UTF-8, 2 bytes: 110vvvvv 10vvvvvv */
|
||||
if (((unsigned char)(string[0]) & 0xE0) == 0xC0)
|
||||
{
|
||||
@@ -223,9 +245,6 @@ utf8_strlen (char *string)
|
||||
if (!string)
|
||||
return 0;
|
||||
|
||||
if (!local_utf8)
|
||||
return strlen (string);
|
||||
|
||||
length = 0;
|
||||
while (string && string[0])
|
||||
{
|
||||
@@ -248,14 +267,6 @@ utf8_strnlen (char *string, int bytes)
|
||||
if (!string)
|
||||
return 0;
|
||||
|
||||
if (!local_utf8)
|
||||
{
|
||||
length = strlen (string);
|
||||
if (bytes > length)
|
||||
return length;
|
||||
return bytes;
|
||||
}
|
||||
|
||||
start = string;
|
||||
length = 0;
|
||||
while (string && string[0] && (string - start < bytes))
|
||||
@@ -280,7 +291,7 @@ utf8_width_screen (char *string)
|
||||
return 0;
|
||||
|
||||
if (!local_utf8)
|
||||
return strlen (string);
|
||||
return utf8_strlen (string);
|
||||
|
||||
num_char = mbstowcs (NULL, string, 0) + 1;
|
||||
wstring = (wchar_t *) malloc ((num_char + 1) * sizeof (wchar_t));
|
||||
@@ -310,9 +321,6 @@ utf8_add_offset (char *string, int offset)
|
||||
if (!string)
|
||||
return string;
|
||||
|
||||
if (!local_utf8)
|
||||
return string + offset;
|
||||
|
||||
count = 0;
|
||||
while (string && string[0] && (count < offset))
|
||||
{
|
||||
@@ -333,7 +341,7 @@ utf8_real_pos (char *string, int pos)
|
||||
int count, real_pos;
|
||||
char *next_char;
|
||||
|
||||
if (!string || !local_utf8)
|
||||
if (!string)
|
||||
return pos;
|
||||
|
||||
count = 0;
|
||||
|
||||
+2
-1
@@ -24,7 +24,8 @@
|
||||
extern int local_utf8;
|
||||
|
||||
extern void utf8_init ();
|
||||
extern int utf8_is_valid (char *);
|
||||
extern int utf8_is_valid (char *, char **);
|
||||
extern void utf8_normalize (char *, char);
|
||||
extern char *utf8_prev_char (char *, char *);
|
||||
extern char *utf8_next_char (char *);
|
||||
extern int utf8_char_size (char *);
|
||||
|
||||
+91
-22
@@ -25,6 +25,7 @@
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef HAVE_ICONV
|
||||
@@ -32,9 +33,34 @@
|
||||
#endif
|
||||
|
||||
#include "weechat.h"
|
||||
#include "utf8.h"
|
||||
#include "weeconfig.h"
|
||||
|
||||
|
||||
/*
|
||||
* strndup: define strndup function if not existing (FreeBSD and maybe other)
|
||||
*/
|
||||
|
||||
#ifndef HAVE_STRNDUP
|
||||
char *
|
||||
strndup (char *string, int length)
|
||||
{
|
||||
char *result;
|
||||
|
||||
if ((int)strlen (string) < length)
|
||||
return strdup (string);
|
||||
|
||||
result = (char *)malloc (length + 1);
|
||||
if (!result)
|
||||
return NULL;
|
||||
|
||||
memcpy (result, string, length);
|
||||
result[length] = '\0';
|
||||
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* ascii_tolower: locale independant string conversion to lower case
|
||||
*/
|
||||
@@ -217,32 +243,75 @@ weechat_iconv (char *from_code, char *to_code, char *string)
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_iconv_check: check a charset
|
||||
* if a charset is NULL, internal charset is used
|
||||
* weechat_iconv_to_internal: convert user string (input, script, ..) to
|
||||
* WeeChat internal storage charset
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_iconv_check (char *from_code, char *to_code)
|
||||
char *
|
||||
weechat_iconv_to_internal (char *charset, char *string)
|
||||
{
|
||||
#ifdef HAVE_ICONV
|
||||
iconv_t cd;
|
||||
char *input, *output;
|
||||
|
||||
input = strdup (string);
|
||||
if (input)
|
||||
{
|
||||
if (utf8_is_valid (input, NULL))
|
||||
return input;
|
||||
|
||||
output = weechat_iconv ((charset && charset[0]) ?
|
||||
charset : local_charset,
|
||||
WEECHAT_INTERNAL_CHARSET,
|
||||
input);
|
||||
utf8_normalize (output, '?');
|
||||
free (input);
|
||||
return output;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_iconv_from_internal: convert internal string to terminal charset,
|
||||
* for display
|
||||
*/
|
||||
|
||||
char *
|
||||
weechat_iconv_from_internal (char *charset, char *string)
|
||||
{
|
||||
char *input, *output;
|
||||
|
||||
input = strdup (string);
|
||||
if (input)
|
||||
{
|
||||
utf8_normalize (input, '?');
|
||||
output = weechat_iconv (WEECHAT_INTERNAL_CHARSET,
|
||||
(charset && charset[0]) ?
|
||||
charset : local_charset,
|
||||
input);
|
||||
free (input);
|
||||
return output;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_iconv_fprintf: encode to terminal charset, then call fprintf on a file
|
||||
*/
|
||||
|
||||
void
|
||||
weechat_iconv_fprintf (FILE *file, char *data, ...)
|
||||
{
|
||||
va_list argptr;
|
||||
static char buf[4096];
|
||||
char *buf2;
|
||||
|
||||
if (!from_code || !from_code[0])
|
||||
from_code = (cfg_look_charset_internal && cfg_look_charset_internal[0]) ?
|
||||
cfg_look_charset_internal : local_charset;
|
||||
|
||||
if (!to_code || !to_code[0])
|
||||
to_code = (cfg_look_charset_internal && cfg_look_charset_internal[0]) ?
|
||||
cfg_look_charset_internal : local_charset;
|
||||
|
||||
cd = iconv_open (to_code, from_code);
|
||||
if (cd == (iconv_t)(-1))
|
||||
return 0;
|
||||
iconv_close (cd);
|
||||
return 1;
|
||||
#else
|
||||
return 1;
|
||||
#endif
|
||||
va_start (argptr, data);
|
||||
vsnprintf (buf, sizeof (buf) - 1, data, argptr);
|
||||
va_end (argptr);
|
||||
|
||||
buf2 = weechat_iconv_from_internal (NULL, buf);
|
||||
fprintf (file, "%s", (buf2) ? buf2 : buf);
|
||||
if (buf2)
|
||||
free (buf2);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
+6
-1
@@ -21,13 +21,18 @@
|
||||
#ifndef __WEECHAT_UTIL_H
|
||||
#define __WEECHAT_UTIL_H 1
|
||||
|
||||
#ifndef HAVE_STRNDUP
|
||||
extern char *strndup (char *, int);
|
||||
#endif
|
||||
extern void ascii_tolower (char *);
|
||||
extern void ascii_toupper (char *);
|
||||
extern int ascii_strcasecmp (char *, char *);
|
||||
extern int ascii_strncasecmp (char *, char *, int);
|
||||
extern char *ascii_strcasestr (char *, char *);
|
||||
extern char *weechat_iconv (char *, char *, char *);
|
||||
extern int weechat_iconv_check (char *, char *);
|
||||
extern char *weechat_iconv_to_internal (char *, char *);
|
||||
extern char *weechat_iconv_from_internal (char *, char *);
|
||||
extern void weechat_iconv_fprintf (FILE *, char *, ...);
|
||||
extern char *weechat_strreplace (char *, char *, char *);
|
||||
extern long get_timeval_diff (struct timeval *, struct timeval *);
|
||||
extern char **explode_string (char *, char *, int, int *);
|
||||
|
||||
+140
-126
@@ -98,27 +98,30 @@ gnutls_certificate_credentials gnutls_xcred; /* gnutls client credentials */
|
||||
void
|
||||
weechat_display_usage (char *exec_name)
|
||||
{
|
||||
printf ("\n");
|
||||
printf (_("%s (c) Copyright 2003-2006, compiled on %s %s\n"
|
||||
"Developed by FlashCode <flashcode@flashtux.org> - %s"),
|
||||
PACKAGE_STRING, __DATE__, __TIME__, WEECHAT_WEBSITE);
|
||||
printf ("\n\n");
|
||||
printf (_("Usage: %s [options ...]\n" \
|
||||
" or: %s [irc[6][s]://[nickname[:password]@]irc.example.org[:port][/channel][,channel[...]]"),
|
||||
exec_name, exec_name);
|
||||
printf ("\n\n");
|
||||
printf (_(" -a, --no-connect disable auto-connect to servers at startup\n"
|
||||
" -c, --config display config file options\n"
|
||||
" -d, --dir <path> set WeeChat home directory (default: ~/.weechat)\n"
|
||||
" -f, --key-functions display WeeChat internal functions for keys\n"
|
||||
" -h, --help this help\n"
|
||||
" -i, --irc-commands display IRC commands\n"
|
||||
" -k, --keys display WeeChat default keys\n"
|
||||
" -l, --license display WeeChat license\n"
|
||||
" -p, --no-plugin don't load any plugin at startup\n"
|
||||
" -v, --version display WeeChat version\n"
|
||||
" -w, --weechat-commands display WeeChat commands\n"));
|
||||
printf("\n");
|
||||
weechat_iconv_fprintf (stdout, "\n");
|
||||
weechat_iconv_fprintf (stdout,
|
||||
_("%s (c) Copyright 2003-2006, compiled on %s %s\n"
|
||||
"Developed by FlashCode <flashcode@flashtux.org> - %s"),
|
||||
PACKAGE_STRING, __DATE__, __TIME__, WEECHAT_WEBSITE);
|
||||
weechat_iconv_fprintf (stdout, "\n\n");
|
||||
weechat_iconv_fprintf (stdout,
|
||||
_("Usage: %s [options ...]\n" \
|
||||
" or: %s [irc[6][s]://[nickname[:password]@]irc.example.org[:port][/channel][,channel[...]]"),
|
||||
exec_name, exec_name);
|
||||
weechat_iconv_fprintf (stdout, "\n\n");
|
||||
weechat_iconv_fprintf (stdout,
|
||||
_(" -a, --no-connect disable auto-connect to servers at startup\n"
|
||||
" -c, --config display config file options\n"
|
||||
" -d, --dir <path> set WeeChat home directory (default: ~/.weechat)\n"
|
||||
" -f, --key-functions display WeeChat internal functions for keys\n"
|
||||
" -h, --help this help\n"
|
||||
" -i, --irc-commands display IRC commands\n"
|
||||
" -k, --keys display WeeChat default keys\n"
|
||||
" -l, --license display WeeChat license\n"
|
||||
" -p, --no-plugin don't load any plugin at startup\n"
|
||||
" -v, --version display WeeChat version\n"
|
||||
" -w, --weechat-commands display WeeChat commands\n"));
|
||||
weechat_iconv_fprintf(stdout, "\n");
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -130,7 +133,8 @@ weechat_display_config_options ()
|
||||
{
|
||||
int i, j, k;
|
||||
|
||||
printf (_("WeeChat configuration options (<weechat_home>/weechat.rc):\n\n"));
|
||||
weechat_iconv_fprintf (stdout,
|
||||
_("WeeChat configuration options (<weechat_home>/weechat.rc):\n\n"));
|
||||
for (i = 0; i < CONFIG_NUMBER_SECTIONS; i++)
|
||||
{
|
||||
if (weechat_options[i])
|
||||
@@ -138,60 +142,61 @@ weechat_display_config_options ()
|
||||
j = 0;
|
||||
while (weechat_options[i][j].option_name)
|
||||
{
|
||||
printf ("* %s:\n",
|
||||
weechat_options[i][j].option_name);
|
||||
weechat_iconv_fprintf (stdout,
|
||||
"* %s:\n",
|
||||
weechat_options[i][j].option_name);
|
||||
switch (weechat_options[i][j].option_type)
|
||||
{
|
||||
case OPTION_TYPE_BOOLEAN:
|
||||
printf (_(" . type: boolean\n"));
|
||||
printf (_(" . values: 'on' or 'off'\n"));
|
||||
printf (_(" . default value: '%s'\n"),
|
||||
(weechat_options[i][j].default_int == BOOL_TRUE) ?
|
||||
"on" : "off");
|
||||
weechat_iconv_fprintf (stdout, _(" . type: boolean\n"));
|
||||
weechat_iconv_fprintf (stdout, _(" . values: 'on' or 'off'\n"));
|
||||
weechat_iconv_fprintf (stdout, _(" . default value: '%s'\n"),
|
||||
(weechat_options[i][j].default_int == BOOL_TRUE) ?
|
||||
"on" : "off");
|
||||
break;
|
||||
case OPTION_TYPE_INT:
|
||||
printf (_(" . type: integer\n"));
|
||||
printf (_(" . values: between %d and %d\n"),
|
||||
weechat_options[i][j].min,
|
||||
weechat_options[i][j].max);
|
||||
printf (_(" . default value: %d\n"),
|
||||
weechat_options[i][j].default_int);
|
||||
weechat_iconv_fprintf (stdout, _(" . type: integer\n"));
|
||||
weechat_iconv_fprintf (stdout, _(" . values: between %d and %d\n"),
|
||||
weechat_options[i][j].min,
|
||||
weechat_options[i][j].max);
|
||||
weechat_iconv_fprintf (stdout, _(" . default value: %d\n"),
|
||||
weechat_options[i][j].default_int);
|
||||
break;
|
||||
case OPTION_TYPE_INT_WITH_STRING:
|
||||
printf (_(" . type: string\n"));
|
||||
printf (_(" . values: "));
|
||||
weechat_iconv_fprintf (stdout, _(" . type: string\n"));
|
||||
weechat_iconv_fprintf (stdout, _(" . values: "));
|
||||
k = 0;
|
||||
while (weechat_options[i][j].array_values[k])
|
||||
{
|
||||
printf ("'%s'",
|
||||
weechat_options[i][j].array_values[k]);
|
||||
weechat_iconv_fprintf (stdout, "'%s'",
|
||||
weechat_options[i][j].array_values[k]);
|
||||
if (weechat_options[i][j].array_values[k + 1])
|
||||
printf (", ");
|
||||
weechat_iconv_fprintf (stdout, ", ");
|
||||
k++;
|
||||
}
|
||||
printf ("\n");
|
||||
printf (_(" . default value: '%s'\n"),
|
||||
(weechat_options[i][j].default_string) ?
|
||||
weechat_options[i][j].default_string : _("empty"));
|
||||
weechat_iconv_fprintf (stdout, "\n");
|
||||
weechat_iconv_fprintf (stdout, _(" . default value: '%s'\n"),
|
||||
(weechat_options[i][j].default_string) ?
|
||||
weechat_options[i][j].default_string : _("empty"));
|
||||
break;
|
||||
case OPTION_TYPE_COLOR:
|
||||
printf (_(" . type: color\n"));
|
||||
printf (_(" . values: Curses or Gtk color\n"));
|
||||
printf (_(" . default value: '%s'\n"),
|
||||
(weechat_options[i][j].default_string) ?
|
||||
weechat_options[i][j].default_string : _("empty"));
|
||||
weechat_iconv_fprintf (stdout, _(" . type: color\n"));
|
||||
weechat_iconv_fprintf (stdout, _(" . values: Curses or Gtk color\n"));
|
||||
weechat_iconv_fprintf (stdout, _(" . default value: '%s'\n"),
|
||||
(weechat_options[i][j].default_string) ?
|
||||
weechat_options[i][j].default_string : _("empty"));
|
||||
break;
|
||||
case OPTION_TYPE_STRING:
|
||||
printf (_(" . type: string\n"));
|
||||
printf (_(" . values: any string\n"));
|
||||
printf (_(" . default value: '%s'\n"),
|
||||
(weechat_options[i][j].default_string) ?
|
||||
weechat_options[i][j].default_string : _("empty"));
|
||||
weechat_iconv_fprintf (stdout, _(" . type: string\n"));
|
||||
weechat_iconv_fprintf (stdout, _(" . values: any string\n"));
|
||||
weechat_iconv_fprintf (stdout, _(" . default value: '%s'\n"),
|
||||
(weechat_options[i][j].default_string) ?
|
||||
weechat_options[i][j].default_string : _("empty"));
|
||||
break;
|
||||
}
|
||||
printf (_(" . description: %s\n"),
|
||||
_(weechat_options[i][j].long_description));
|
||||
printf ("\n");
|
||||
weechat_iconv_fprintf (stdout, _(" . description: %s\n"),
|
||||
_(weechat_options[i][j].long_description));
|
||||
weechat_iconv_fprintf (stdout, "\n");
|
||||
j++;
|
||||
}
|
||||
}
|
||||
@@ -209,43 +214,44 @@ weechat_display_commands (int weechat_cmd, int irc_cmd)
|
||||
|
||||
if (weechat_cmd)
|
||||
{
|
||||
printf (_("%s internal commands:\n"), PACKAGE_NAME);
|
||||
printf ("\n");
|
||||
weechat_iconv_fprintf (stdout,
|
||||
_("%s internal commands:\n"), PACKAGE_NAME);
|
||||
weechat_iconv_fprintf (stdout, "\n");
|
||||
for (i = 0; weechat_commands[i].command_name; i++)
|
||||
{
|
||||
printf ("* %s", weechat_commands[i].command_name);
|
||||
weechat_iconv_fprintf (stdout, "* %s", weechat_commands[i].command_name);
|
||||
if (weechat_commands[i].arguments &&
|
||||
weechat_commands[i].arguments[0])
|
||||
printf (" %s\n\n", _(weechat_commands[i].arguments));
|
||||
weechat_iconv_fprintf (stdout, " %s\n\n", _(weechat_commands[i].arguments));
|
||||
else
|
||||
printf ("\n\n");
|
||||
printf ("%s\n\n", _(weechat_commands[i].command_description));
|
||||
weechat_iconv_fprintf (stdout, "\n\n");
|
||||
weechat_iconv_fprintf (stdout, "%s\n\n", _(weechat_commands[i].command_description));
|
||||
if (weechat_commands[i].arguments_description &&
|
||||
weechat_commands[i].arguments_description[0])
|
||||
printf ("%s\n\n",
|
||||
_(weechat_commands[i].arguments_description));
|
||||
weechat_iconv_fprintf (stdout, "%s\n\n",
|
||||
_(weechat_commands[i].arguments_description));
|
||||
}
|
||||
}
|
||||
|
||||
if (irc_cmd)
|
||||
{
|
||||
printf (_("IRC commands:\n"));
|
||||
printf ("\n");
|
||||
weechat_iconv_fprintf (stdout, _("IRC commands:\n"));
|
||||
weechat_iconv_fprintf (stdout, "\n");
|
||||
for (i = 0; irc_commands[i].command_name; i++)
|
||||
{
|
||||
if (irc_commands[i].cmd_function_args ||
|
||||
irc_commands[i].cmd_function_1arg)
|
||||
{
|
||||
printf ("* %s", irc_commands[i].command_name);
|
||||
weechat_iconv_fprintf (stdout, "* %s", irc_commands[i].command_name);
|
||||
if (irc_commands[i].arguments &&
|
||||
irc_commands[i].arguments[0])
|
||||
printf (" %s\n\n", _(irc_commands[i].arguments));
|
||||
weechat_iconv_fprintf (stdout, " %s\n\n", _(irc_commands[i].arguments));
|
||||
else
|
||||
printf ("\n\n");
|
||||
printf ("%s\n\n", _(irc_commands[i].command_description));
|
||||
weechat_iconv_fprintf (stdout, "\n\n");
|
||||
weechat_iconv_fprintf (stdout, "%s\n\n", _(irc_commands[i].command_description));
|
||||
if (irc_commands[i].arguments_description &&
|
||||
irc_commands[i].arguments_description[0])
|
||||
printf ("%s\n\n",
|
||||
weechat_iconv_fprintf (stdout, "%s\n\n",
|
||||
_(irc_commands[i].arguments_description));
|
||||
}
|
||||
}
|
||||
@@ -261,14 +267,15 @@ weechat_display_key_functions ()
|
||||
{
|
||||
int i;
|
||||
|
||||
printf (_("Internal key functions:\n"));
|
||||
printf ("\n");
|
||||
weechat_iconv_fprintf (stdout, _("Internal key functions:\n"));
|
||||
weechat_iconv_fprintf (stdout, "\n");
|
||||
i = 0;
|
||||
while (gui_key_functions[i].function_name)
|
||||
{
|
||||
printf ("* %s: %s\n",
|
||||
gui_key_functions[i].function_name,
|
||||
_(gui_key_functions[i].description));
|
||||
weechat_iconv_fprintf (stdout,
|
||||
"* %s: %s\n",
|
||||
gui_key_functions[i].function_name,
|
||||
_(gui_key_functions[i].description));
|
||||
i++;
|
||||
}
|
||||
}
|
||||
@@ -283,14 +290,16 @@ weechat_display_keys ()
|
||||
t_gui_key *ptr_key;
|
||||
char *expanded_name;
|
||||
|
||||
printf (_("%s default keys:\n"), PACKAGE_NAME);
|
||||
printf ("\n");
|
||||
weechat_iconv_fprintf (stdout,
|
||||
_("%s default keys:\n"), PACKAGE_NAME);
|
||||
weechat_iconv_fprintf (stdout, "\n");
|
||||
for (ptr_key = gui_keys; ptr_key; ptr_key = ptr_key->next_key)
|
||||
{
|
||||
expanded_name = gui_keyboard_get_expanded_name (ptr_key->key);
|
||||
printf ("* %s => %s\n",
|
||||
(expanded_name) ? expanded_name : ptr_key->key,
|
||||
(ptr_key->function) ? gui_keyboard_function_search_by_ptr (ptr_key->function) : ptr_key->command);
|
||||
weechat_iconv_fprintf (stdout,
|
||||
"* %s => %s\n",
|
||||
(expanded_name) ? expanded_name : ptr_key->key,
|
||||
(ptr_key->function) ? gui_keyboard_function_search_by_ptr (ptr_key->function) : ptr_key->command);
|
||||
if (expanded_name)
|
||||
free (expanded_name);
|
||||
}
|
||||
@@ -331,9 +340,9 @@ weechat_parse_args (int argc, char *argv[])
|
||||
weechat_home = strdup (argv[++i]);
|
||||
else
|
||||
{
|
||||
fprintf (stderr,
|
||||
_("%s missing argument for --dir option\n"),
|
||||
WEECHAT_ERROR);
|
||||
weechat_iconv_fprintf (stderr,
|
||||
_("%s missing argument for --dir option\n"),
|
||||
WEECHAT_ERROR);
|
||||
weechat_shutdown (EXIT_FAILURE, 0);
|
||||
}
|
||||
}
|
||||
@@ -364,7 +373,7 @@ weechat_parse_args (int argc, char *argv[])
|
||||
else if ((strcmp (argv[i], "-l") == 0)
|
||||
|| (strcmp (argv[i], "--license") == 0))
|
||||
{
|
||||
printf ("\n%s%s", WEE_LICENSE);
|
||||
weechat_iconv_fprintf (stdout, "\n%s%s", WEE_LICENSE);
|
||||
weechat_shutdown (EXIT_SUCCESS, 0);
|
||||
}
|
||||
else if ((strcmp (argv[i], "-p") == 0)
|
||||
@@ -376,16 +385,16 @@ weechat_parse_args (int argc, char *argv[])
|
||||
weechat_session = strdup (argv[++i]);
|
||||
else
|
||||
{
|
||||
fprintf (stderr,
|
||||
_("%s missing argument for --session option\n"),
|
||||
WEECHAT_ERROR);
|
||||
weechat_iconv_fprintf (stderr,
|
||||
_("%s missing argument for --session option\n"),
|
||||
WEECHAT_ERROR);
|
||||
weechat_shutdown (EXIT_FAILURE, 0);
|
||||
}
|
||||
}
|
||||
else if ((strcmp (argv[i], "-v") == 0)
|
||||
|| (strcmp (argv[i], "--version") == 0))
|
||||
{
|
||||
printf (PACKAGE_VERSION "\n");
|
||||
weechat_iconv_fprintf (stdout, PACKAGE_VERSION "\n");
|
||||
weechat_shutdown (EXIT_SUCCESS, 0);
|
||||
}
|
||||
else if ((strcmp (argv[i], "-w") == 0)
|
||||
@@ -398,8 +407,9 @@ weechat_parse_args (int argc, char *argv[])
|
||||
{
|
||||
if (server_init_with_url (argv[i], &server_tmp) < 0)
|
||||
{
|
||||
fprintf (stderr, _("%s invalid syntax for IRC server ('%s'), ignored\n"),
|
||||
WEECHAT_WARNING, argv[i]);
|
||||
weechat_iconv_fprintf (stderr,
|
||||
_("%s invalid syntax for IRC server ('%s'), ignored\n"),
|
||||
WEECHAT_WARNING, argv[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -411,19 +421,19 @@ weechat_parse_args (int argc, char *argv[])
|
||||
server_tmp.password, server_tmp.nick1,
|
||||
server_tmp.nick2, server_tmp.nick3,
|
||||
NULL, NULL, NULL, NULL, 0,
|
||||
server_tmp.autojoin, 1, NULL, NULL,
|
||||
NULL, NULL))
|
||||
fprintf (stderr, _("%s unable to create server ('%s'), ignored\n"),
|
||||
WEECHAT_WARNING, argv[i]);
|
||||
server_tmp.autojoin, 1, NULL))
|
||||
weechat_iconv_fprintf (stderr,
|
||||
_("%s unable to create server ('%s'), ignored\n"),
|
||||
WEECHAT_WARNING, argv[i]);
|
||||
server_destroy (&server_tmp);
|
||||
server_cmd_line = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf (stderr,
|
||||
_("%s unknown parameter '%s', ignored\n"),
|
||||
WEECHAT_WARNING, argv[i]);
|
||||
weechat_iconv_fprintf (stderr,
|
||||
_("%s unknown parameter '%s', ignored\n"),
|
||||
WEECHAT_WARNING, argv[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -442,8 +452,8 @@ weechat_create_dir (char *directory)
|
||||
/* exit if error (except if directory already exists) */
|
||||
if (errno != EEXIST)
|
||||
{
|
||||
fprintf (stderr, _("%s cannot create directory \"%s\"\n"),
|
||||
WEECHAT_ERROR, directory);
|
||||
weechat_iconv_fprintf (stderr, _("%s cannot create directory \"%s\"\n"),
|
||||
WEECHAT_ERROR, directory);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -466,8 +476,8 @@ weechat_create_home_dirs ()
|
||||
ptr_home = getenv ("HOME");
|
||||
if (!ptr_home)
|
||||
{
|
||||
fprintf (stderr, _("%s unable to get HOME directory\n"),
|
||||
WEECHAT_ERROR);
|
||||
weechat_iconv_fprintf (stderr, _("%s unable to get HOME directory\n"),
|
||||
WEECHAT_ERROR);
|
||||
weechat_shutdown (EXIT_FAILURE, 0);
|
||||
}
|
||||
dir_length = strlen (ptr_home) + 10;
|
||||
@@ -475,8 +485,8 @@ weechat_create_home_dirs ()
|
||||
(char *) malloc (dir_length * sizeof (char));
|
||||
if (!weechat_home)
|
||||
{
|
||||
fprintf (stderr, _("%s not enough memory for home directory\n"),
|
||||
WEECHAT_ERROR);
|
||||
weechat_iconv_fprintf (stderr, _("%s not enough memory for home directory\n"),
|
||||
WEECHAT_ERROR);
|
||||
weechat_shutdown (EXIT_FAILURE, 0);
|
||||
}
|
||||
snprintf (weechat_home, dir_length, "%s%s.weechat", ptr_home,
|
||||
@@ -488,8 +498,8 @@ weechat_create_home_dirs ()
|
||||
{
|
||||
if (!S_ISDIR (statinfo.st_mode))
|
||||
{
|
||||
fprintf (stderr, _("%s home (%s) is not a directory\n"),
|
||||
WEECHAT_ERROR, weechat_home);
|
||||
weechat_iconv_fprintf (stderr, _("%s home (%s) is not a directory\n"),
|
||||
WEECHAT_ERROR, weechat_home);
|
||||
weechat_shutdown (EXIT_FAILURE, 0);
|
||||
}
|
||||
}
|
||||
@@ -497,8 +507,8 @@ weechat_create_home_dirs ()
|
||||
/* create home directory; error is fatal */
|
||||
if (!weechat_create_dir (weechat_home))
|
||||
{
|
||||
fprintf (stderr, _("%s unable to create \"%s\" directory\n"),
|
||||
WEECHAT_ERROR, weechat_home);
|
||||
weechat_iconv_fprintf (stderr, _("%s unable to create \"%s\" directory\n"),
|
||||
WEECHAT_ERROR, weechat_home);
|
||||
weechat_shutdown (EXIT_FAILURE, 0);
|
||||
}
|
||||
}
|
||||
@@ -521,8 +531,8 @@ weechat_create_config_dirs ()
|
||||
chmod (dir2, 0700);
|
||||
}
|
||||
else
|
||||
fprintf (stderr, _("%s unable to create \"%s\" directory\n"),
|
||||
WEECHAT_WARNING, dir2);
|
||||
weechat_iconv_fprintf (stderr, _("%s unable to create \"%s\" directory\n"),
|
||||
WEECHAT_WARNING, dir2);
|
||||
if (dir1)
|
||||
free (dir1);
|
||||
if (dir2)
|
||||
@@ -537,8 +547,8 @@ weechat_create_config_dirs ()
|
||||
chmod (dir2, 0700);
|
||||
}
|
||||
else
|
||||
fprintf (stderr, _("%s unable to create \"%s\" directory\n"),
|
||||
WEECHAT_WARNING, dir2);
|
||||
weechat_iconv_fprintf (stderr, _("%s unable to create \"%s\" directory\n"),
|
||||
WEECHAT_WARNING, dir2);
|
||||
if (dir1)
|
||||
free (dir1);
|
||||
if (dir2)
|
||||
@@ -774,19 +784,20 @@ weechat_sigsegv ()
|
||||
server_free_all ();
|
||||
gui_main_end ();
|
||||
|
||||
fprintf (stderr, "\n");
|
||||
fprintf (stderr, "*** Very bad! WeeChat is crashing (SIGSEGV received)\n");
|
||||
weechat_iconv_fprintf (stderr, "\n");
|
||||
weechat_iconv_fprintf (stderr, "*** Very bad! WeeChat is crashing (SIGSEGV received)\n");
|
||||
if (!weechat_log_crash_rename ())
|
||||
fprintf (stderr, "*** Full crash dump was saved to %s/weechat.log file.\n",
|
||||
weechat_home);
|
||||
fprintf (stderr, "***\n");
|
||||
fprintf (stderr, "*** Please help WeeChat developers to fix this bug:\n");
|
||||
fprintf (stderr, "*** 1. If you have a core file, please run: gdb weechat-curses core\n");
|
||||
fprintf (stderr, "*** then issue \"bt\" command and send result to developers\n");
|
||||
fprintf (stderr, "*** To enable core files with bash shell: ulimit -c 10000\n");
|
||||
fprintf (stderr, "*** 2. Otherwise send backtrace (below) and weechat.log\n");
|
||||
fprintf (stderr, "*** (be careful, private info may be in this file since\n");
|
||||
fprintf (stderr, "*** part of chats are displayed, so remove lines if needed)\n\n");
|
||||
weechat_iconv_fprintf (stderr,
|
||||
"*** Full crash dump was saved to %s/weechat.log file.\n",
|
||||
weechat_home);
|
||||
weechat_iconv_fprintf (stderr, "***\n");
|
||||
weechat_iconv_fprintf (stderr, "*** Please help WeeChat developers to fix this bug:\n");
|
||||
weechat_iconv_fprintf (stderr, "*** 1. If you have a core file, please run: gdb weechat-curses core\n");
|
||||
weechat_iconv_fprintf (stderr, "*** then issue \"bt\" command and send result to developers\n");
|
||||
weechat_iconv_fprintf (stderr, "*** To enable core files with bash shell: ulimit -c 10000\n");
|
||||
weechat_iconv_fprintf (stderr, "*** 2. Otherwise send backtrace (below) and weechat.log\n");
|
||||
weechat_iconv_fprintf (stderr, "*** (be careful, private info may be in this file since\n");
|
||||
weechat_iconv_fprintf (stderr, "*** part of chats are displayed, so remove lines if needed)\n\n");
|
||||
|
||||
weechat_backtrace ();
|
||||
|
||||
@@ -804,12 +815,16 @@ main (int argc, char *argv[])
|
||||
#ifdef ENABLE_NLS
|
||||
setlocale (LC_ALL, ""); /* initialize gettext */
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
bind_textdomain_codeset (PACKAGE, "UTF-8");
|
||||
textdomain (PACKAGE);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LANGINFO_CODESET
|
||||
local_charset = strdup (nl_langinfo (CODESET));
|
||||
#else
|
||||
local_charset = strdup ("");
|
||||
#endif
|
||||
utf8_init ();
|
||||
|
||||
signal (SIGINT, SIG_IGN); /* ignore SIGINT signal */
|
||||
signal (SIGQUIT, SIG_IGN); /* ignore SIGQUIT signal */
|
||||
@@ -824,7 +839,6 @@ main (int argc, char *argv[])
|
||||
command_index_build (); /* build cmd index for completion */
|
||||
weechat_config_read (); /* read configuration */
|
||||
weechat_create_config_dirs (); /* create config directories */
|
||||
utf8_init (); /* init UTF-8 in WeeChat */
|
||||
gui_main_init (); /* init WeeChat interface */
|
||||
fifo_create (); /* FIFO pipe for remote control */
|
||||
if (weechat_session)
|
||||
|
||||
@@ -93,10 +93,15 @@
|
||||
#endif
|
||||
|
||||
/* some systems (like GNU/Hurd) doesn't define PATH_MAX */
|
||||
|
||||
#ifndef PATH_MAX
|
||||
#define PATH_MAX 4096
|
||||
#endif
|
||||
|
||||
/* internal charset */
|
||||
|
||||
#define WEECHAT_INTERNAL_CHARSET "UTF-8"
|
||||
|
||||
/* global variables and functions */
|
||||
|
||||
extern char *weechat_argv0;
|
||||
|
||||
+192
-235
@@ -71,10 +71,6 @@ int cfg_look_set_title;
|
||||
int cfg_look_startup_logo;
|
||||
int cfg_look_startup_version;
|
||||
char *cfg_look_weechat_slogan;
|
||||
char *cfg_look_charset_decode_iso;
|
||||
char *cfg_look_charset_decode_utf;
|
||||
char *cfg_look_charset_encode;
|
||||
char *cfg_look_charset_internal;
|
||||
int cfg_look_one_server_buffer;
|
||||
int cfg_look_scroll_amount;
|
||||
int cfg_look_open_near_server;
|
||||
@@ -134,24 +130,6 @@ t_config_option weechat_options_look[] =
|
||||
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, config_change_noop },
|
||||
{ "look_charset_decode_iso", N_("ISO charset for decoding messages from server (used only if locale is UTF-8)"),
|
||||
N_("ISO charset for decoding messages from server (used only if locale is UTF-8) "
|
||||
"(if empty, messages are not converted if locale is UTF-8)"),
|
||||
OPTION_TYPE_STRING, 0, 0, 0,
|
||||
"ISO-8859-1", NULL, NULL, &cfg_look_charset_decode_iso, config_change_charset },
|
||||
{ "look_charset_decode_utf", N_("UTF charset for decoding messages from server (used only if locale is not UTF-8)"),
|
||||
N_("UTF charset for decoding messages from server (used only if locale is not UTF-8) "
|
||||
"(if empty, messages are not converted if locale is not UTF-8)"),
|
||||
OPTION_TYPE_STRING, 0, 0, 0,
|
||||
"UTF-8", NULL, NULL, &cfg_look_charset_decode_utf, config_change_charset },
|
||||
{ "look_charset_encode", N_("charset for encoding messages sent to server"),
|
||||
N_("charset for encoding messages sent to server, examples: UTF-8, ISO-8859-1 (if empty, messages are not converted)"),
|
||||
OPTION_TYPE_STRING, 0, 0, 0,
|
||||
"", NULL, NULL, &cfg_look_charset_encode, config_change_charset },
|
||||
{ "look_charset_internal", N_("forces internal WeeChat charset (should be empty in most cases)"),
|
||||
N_("forces internal WeeChat charset (should be empty in most cases, that means detected charset is used)"),
|
||||
OPTION_TYPE_STRING, 0, 0, 0,
|
||||
"", NULL, NULL, &cfg_look_charset_internal, config_change_charset },
|
||||
{ "look_one_server_buffer", N_("use same buffer for all servers"),
|
||||
N_("use same buffer for all servers"),
|
||||
OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_FALSE,
|
||||
@@ -1031,21 +1009,6 @@ t_config_option weechat_options_server[] =
|
||||
"default notify level"),
|
||||
OPTION_TYPE_STRING, 0, 0, 0,
|
||||
"", NULL, NULL, &(cfg_server.notify_levels), config_change_notify_levels },
|
||||
{ "server_charset_decode_iso", N_("charset for decoding ISO on server and channels"),
|
||||
N_("comma separated list of charsets for server and channels, "
|
||||
"to decode ISO (format: server:charset,#channel:charset,..)"),
|
||||
OPTION_TYPE_STRING, 0, 0, 0,
|
||||
"", NULL, NULL, &(cfg_server.charset_decode_iso), config_change_noop },
|
||||
{ "server_charset_decode_utf", N_("charset for decoding UTF on server and channels"),
|
||||
N_("comma separated list of charsets for server and channels, "
|
||||
"to decode UTF (format: server:charset,#channel:charset,..)"),
|
||||
OPTION_TYPE_STRING, 0, 0, 0,
|
||||
"", NULL, NULL, &(cfg_server.charset_decode_utf), config_change_noop },
|
||||
{ "server_charset_encode", N_("charset for encoding messages on server and channels"),
|
||||
N_("comma separated list of charsets for server and channels, "
|
||||
"to encode messages (format: server:charset,#channel:charset,..)"),
|
||||
OPTION_TYPE_STRING, 0, 0, 0,
|
||||
"", NULL, NULL, &(cfg_server.charset_encode), config_change_noop },
|
||||
{ NULL, NULL, NULL, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL }
|
||||
};
|
||||
|
||||
@@ -1572,12 +1535,6 @@ config_get_server_option_ptr (t_irc_server *server, char *option_name)
|
||||
return (void *)(&server->autorejoin);
|
||||
if (ascii_strcasecmp (option_name, "server_notify_levels") == 0)
|
||||
return (void *)(&server->notify_levels);
|
||||
if (ascii_strcasecmp (option_name, "server_charset_decode_iso") == 0)
|
||||
return (void *)(&server->charset_decode_iso);
|
||||
if (ascii_strcasecmp (option_name, "server_charset_decode_utf") == 0)
|
||||
return (void *)(&server->charset_decode_utf);
|
||||
if (ascii_strcasecmp (option_name, "server_charset_encode") == 0)
|
||||
return (void *)(&server->charset_encode);
|
||||
/* option not found */
|
||||
return NULL;
|
||||
}
|
||||
@@ -1810,9 +1767,7 @@ config_allocate_server (char *filename, int line_number)
|
||||
cfg_server.nick3, cfg_server.username, cfg_server.realname,
|
||||
cfg_server.hostname, cfg_server.command,
|
||||
cfg_server.command_delay, cfg_server.autojoin,
|
||||
cfg_server.autorejoin, cfg_server.notify_levels,
|
||||
cfg_server.charset_decode_iso, cfg_server.charset_decode_utf,
|
||||
cfg_server.charset_encode))
|
||||
cfg_server.autorejoin, cfg_server.notify_levels))
|
||||
{
|
||||
server_free_all ();
|
||||
gui_printf (NULL,
|
||||
@@ -1895,7 +1850,7 @@ config_read ()
|
||||
FILE *file;
|
||||
int section, line_number, i, option_number;
|
||||
int server_found;
|
||||
char line[1024], *ptr_line, *pos, *pos2;
|
||||
char line[1024], *ptr_line, *ptr_line2, *pos, *pos2;
|
||||
|
||||
filename_length = strlen (weechat_home) + strlen (WEECHAT_CONFIG_NAME) + 2;
|
||||
filename = (char *) malloc (filename_length * sizeof (char));
|
||||
@@ -1924,6 +1879,14 @@ config_read ()
|
||||
line_number++;
|
||||
if (ptr_line)
|
||||
{
|
||||
/* encode line to internal charset */
|
||||
ptr_line2 = weechat_iconv_to_internal (NULL, ptr_line);
|
||||
if (ptr_line2)
|
||||
{
|
||||
snprintf (line, sizeof (line) - 1, "%s", ptr_line2);
|
||||
free (ptr_line2);
|
||||
}
|
||||
|
||||
/* skip spaces */
|
||||
while (ptr_line[0] == ' ')
|
||||
ptr_line++;
|
||||
@@ -2091,19 +2054,19 @@ config_read ()
|
||||
{
|
||||
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);
|
||||
_("%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"),
|
||||
"option '%s'\n"
|
||||
"Expected: integer between %d "
|
||||
"and %d\n"),
|
||||
WEECHAT_WARNING, filename,
|
||||
line_number, ptr_line,
|
||||
weechat_options[section][option_number].min,
|
||||
@@ -2112,15 +2075,15 @@ config_read ()
|
||||
case OPTION_TYPE_INT_WITH_STRING:
|
||||
gui_printf (NULL,
|
||||
_("%s %s, line %d: invalid value for "
|
||||
"option '%s'\n"
|
||||
"Expected: one of these strings: "),
|
||||
"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]);
|
||||
weechat_options[section][option_number].array_values[i]);
|
||||
i++;
|
||||
}
|
||||
gui_printf (NULL, "\n");
|
||||
@@ -2128,7 +2091,7 @@ config_read ()
|
||||
case OPTION_TYPE_COLOR:
|
||||
gui_printf (NULL,
|
||||
_("%s %s, line %d: invalid color "
|
||||
"name for option '%s'\n"),
|
||||
"name for option '%s'\n"),
|
||||
WEECHAT_WARNING, filename,
|
||||
line_number,
|
||||
ptr_line);
|
||||
@@ -2196,48 +2159,48 @@ config_create_default ()
|
||||
return -1;
|
||||
}
|
||||
|
||||
printf (_("%s: creating default config file...\n"), PACKAGE_NAME);
|
||||
weechat_iconv_fprintf (stdout, _("%s: creating default config file...\n"), PACKAGE_NAME);
|
||||
weechat_log_printf (_("Creating default config file\n"));
|
||||
|
||||
current_time = time (NULL);
|
||||
fprintf (file, _("#\n# %s configuration file, created by "
|
||||
"%s v%s on %s"),
|
||||
PACKAGE_NAME, PACKAGE_NAME, PACKAGE_VERSION,
|
||||
ctime (¤t_time));
|
||||
fprintf (file, _("# WARNING! Be careful when editing this file, "
|
||||
"WeeChat writes this file when exiting.\n#\n"));
|
||||
|
||||
weechat_iconv_fprintf (file, _("#\n# %s configuration file, created by "
|
||||
"%s v%s on %s"),
|
||||
PACKAGE_NAME, PACKAGE_NAME, PACKAGE_VERSION,
|
||||
ctime (¤t_time));
|
||||
weechat_iconv_fprintf (file, _("# WARNING! Be careful when editing this file, "
|
||||
"WeeChat writes this file when exiting.\n#\n"));
|
||||
|
||||
for (i = 0; i < CONFIG_NUMBER_SECTIONS; i++)
|
||||
{
|
||||
if ((i != CONFIG_SECTION_KEYS) && (i != CONFIG_SECTION_ALIAS)
|
||||
&& (i != CONFIG_SECTION_IGNORE) && (i != CONFIG_SECTION_SERVER))
|
||||
{
|
||||
fprintf (file, "\n[%s]\n", config_sections[i].section_name);
|
||||
weechat_iconv_fprintf (file, "\n[%s]\n", config_sections[i].section_name);
|
||||
for (j = 0; weechat_options[i][j].option_name; j++)
|
||||
{
|
||||
switch (weechat_options[i][j].option_type)
|
||||
{
|
||||
case OPTION_TYPE_BOOLEAN:
|
||||
fprintf (file, "%s = %s\n",
|
||||
weechat_options[i][j].option_name,
|
||||
(weechat_options[i][j].default_int) ?
|
||||
"on" : "off");
|
||||
weechat_iconv_fprintf (file, "%s = %s\n",
|
||||
weechat_options[i][j].option_name,
|
||||
(weechat_options[i][j].default_int) ?
|
||||
"on" : "off");
|
||||
break;
|
||||
case OPTION_TYPE_INT:
|
||||
fprintf (file, "%s = %d\n",
|
||||
weechat_options[i][j].option_name,
|
||||
weechat_options[i][j].default_int);
|
||||
weechat_iconv_fprintf (file, "%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:
|
||||
fprintf (file, "%s = %s\n",
|
||||
weechat_options[i][j].option_name,
|
||||
weechat_options[i][j].default_string);
|
||||
weechat_iconv_fprintf (file, "%s = %s\n",
|
||||
weechat_options[i][j].option_name,
|
||||
weechat_options[i][j].default_string);
|
||||
break;
|
||||
case OPTION_TYPE_STRING:
|
||||
fprintf (file, "%s = \"%s\"\n",
|
||||
weechat_options[i][j].option_name,
|
||||
weechat_options[i][j].default_string);
|
||||
weechat_iconv_fprintf (file, "%s = \"%s\"\n",
|
||||
weechat_options[i][j].option_name,
|
||||
weechat_options[i][j].default_string);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -2245,7 +2208,7 @@ config_create_default ()
|
||||
}
|
||||
|
||||
/* default key bindings */
|
||||
fprintf (file, "\n[keys]\n");
|
||||
weechat_iconv_fprintf (file, "\n[keys]\n");
|
||||
for (ptr_key = gui_keys; ptr_key; ptr_key = ptr_key->next_key)
|
||||
{
|
||||
expanded_name = gui_keyboard_get_expanded_name (ptr_key->key);
|
||||
@@ -2253,79 +2216,79 @@ config_create_default ()
|
||||
{
|
||||
function_name = gui_keyboard_function_search_by_ptr (ptr_key->function);
|
||||
if (function_name)
|
||||
fprintf (file, "%s = \"%s\"\n",
|
||||
(expanded_name) ? expanded_name : ptr_key->key,
|
||||
function_name);
|
||||
weechat_iconv_fprintf (file, "%s = \"%s\"\n",
|
||||
(expanded_name) ? expanded_name : ptr_key->key,
|
||||
function_name);
|
||||
}
|
||||
else
|
||||
fprintf (file, "%s = \"%s\"\n",
|
||||
(expanded_name) ? expanded_name : ptr_key->key,
|
||||
ptr_key->command);
|
||||
weechat_iconv_fprintf (file, "%s = \"%s\"\n",
|
||||
(expanded_name) ? expanded_name : ptr_key->key,
|
||||
ptr_key->command);
|
||||
if (expanded_name)
|
||||
free (expanded_name);
|
||||
}
|
||||
|
||||
/* default aliases */
|
||||
fprintf (file, "\n[alias]\n");
|
||||
fprintf (file, "SAY = \"msg *\"\n");
|
||||
fprintf (file, "BYE = \"quit\"\n");
|
||||
fprintf (file, "EXIT = \"quit\"\n");
|
||||
fprintf (file, "SIGNOFF = \"quit\"\n");
|
||||
fprintf (file, "C = \"clear\"\n");
|
||||
fprintf (file, "CL = \"clear\"\n");
|
||||
fprintf (file, "CLOSE = \"buffer close\"\n");
|
||||
fprintf (file, "CHAT = \"dcc chat\"\n");
|
||||
fprintf (file, "IG = \"ignore\"\n");
|
||||
fprintf (file, "J = \"join\"\n");
|
||||
fprintf (file, "K = \"kick\"\n");
|
||||
fprintf (file, "KB = \"kickban\"\n");
|
||||
fprintf (file, "LEAVE = \"part\"\n");
|
||||
fprintf (file, "M = \"msg\"\n");
|
||||
fprintf (file, "MUB = \"unban *\"\n");
|
||||
fprintf (file, "N = \"names\"\n");
|
||||
fprintf (file, "Q = \"query\"\n");
|
||||
fprintf (file, "T = \"topic\"\n");
|
||||
fprintf (file, "UB = \"unban\"\n");
|
||||
fprintf (file, "UNIG = \"unignore\"\n");
|
||||
fprintf (file, "W = \"who\"\n");
|
||||
fprintf (file, "WC = \"window merge\"\n");
|
||||
fprintf (file, "WI = \"whois\"\n");
|
||||
fprintf (file, "WW = \"whowas\"\n");
|
||||
weechat_iconv_fprintf (file, "\n[alias]\n");
|
||||
weechat_iconv_fprintf (file, "SAY = \"msg *\"\n");
|
||||
weechat_iconv_fprintf (file, "BYE = \"quit\"\n");
|
||||
weechat_iconv_fprintf (file, "EXIT = \"quit\"\n");
|
||||
weechat_iconv_fprintf (file, "SIGNOFF = \"quit\"\n");
|
||||
weechat_iconv_fprintf (file, "C = \"clear\"\n");
|
||||
weechat_iconv_fprintf (file, "CL = \"clear\"\n");
|
||||
weechat_iconv_fprintf (file, "CLOSE = \"buffer close\"\n");
|
||||
weechat_iconv_fprintf (file, "CHAT = \"dcc chat\"\n");
|
||||
weechat_iconv_fprintf (file, "IG = \"ignore\"\n");
|
||||
weechat_iconv_fprintf (file, "J = \"join\"\n");
|
||||
weechat_iconv_fprintf (file, "K = \"kick\"\n");
|
||||
weechat_iconv_fprintf (file, "KB = \"kickban\"\n");
|
||||
weechat_iconv_fprintf (file, "LEAVE = \"part\"\n");
|
||||
weechat_iconv_fprintf (file, "M = \"msg\"\n");
|
||||
weechat_iconv_fprintf (file, "MUB = \"unban *\"\n");
|
||||
weechat_iconv_fprintf (file, "N = \"names\"\n");
|
||||
weechat_iconv_fprintf (file, "Q = \"query\"\n");
|
||||
weechat_iconv_fprintf (file, "T = \"topic\"\n");
|
||||
weechat_iconv_fprintf (file, "UB = \"unban\"\n");
|
||||
weechat_iconv_fprintf (file, "UNIG = \"unignore\"\n");
|
||||
weechat_iconv_fprintf (file, "W = \"who\"\n");
|
||||
weechat_iconv_fprintf (file, "WC = \"window merge\"\n");
|
||||
weechat_iconv_fprintf (file, "WI = \"whois\"\n");
|
||||
weechat_iconv_fprintf (file, "WW = \"whowas\"\n");
|
||||
|
||||
/* no ignore by default */
|
||||
|
||||
/* default server is freenode */
|
||||
fprintf (file, "\n[server]\n");
|
||||
fprintf (file, "server_name = \"freenode\"\n");
|
||||
fprintf (file, "server_autoconnect = on\n");
|
||||
fprintf (file, "server_autoreconnect = on\n");
|
||||
fprintf (file, "server_autoreconnect_delay = 30\n");
|
||||
fprintf (file, "server_address = \"irc.freenode.net\"\n");
|
||||
fprintf (file, "server_port = 6667\n");
|
||||
fprintf (file, "server_ipv6 = off\n");
|
||||
fprintf (file, "server_ssl = off\n");
|
||||
fprintf (file, "server_password = \"\"\n");
|
||||
weechat_iconv_fprintf (file, "\n[server]\n");
|
||||
weechat_iconv_fprintf (file, "server_name = \"freenode\"\n");
|
||||
weechat_iconv_fprintf (file, "server_autoconnect = on\n");
|
||||
weechat_iconv_fprintf (file, "server_autoreconnect = on\n");
|
||||
weechat_iconv_fprintf (file, "server_autoreconnect_delay = 30\n");
|
||||
weechat_iconv_fprintf (file, "server_address = \"irc.freenode.net\"\n");
|
||||
weechat_iconv_fprintf (file, "server_port = 6667\n");
|
||||
weechat_iconv_fprintf (file, "server_ipv6 = off\n");
|
||||
weechat_iconv_fprintf (file, "server_ssl = off\n");
|
||||
weechat_iconv_fprintf (file, "server_password = \"\"\n");
|
||||
|
||||
/* Get the user's name from /etc/passwd */
|
||||
if ((my_passwd = getpwuid (geteuid ())) != NULL)
|
||||
{
|
||||
fprintf (file, "server_nick1 = \"%s\"\n", my_passwd->pw_name);
|
||||
fprintf (file, "server_nick2 = \"%s1\"\n", my_passwd->pw_name);
|
||||
fprintf (file, "server_nick3 = \"%s2\"\n", my_passwd->pw_name);
|
||||
fprintf (file, "server_username = \"%s\"\n", my_passwd->pw_name);
|
||||
weechat_iconv_fprintf (file, "server_nick1 = \"%s\"\n", my_passwd->pw_name);
|
||||
weechat_iconv_fprintf (file, "server_nick2 = \"%s1\"\n", my_passwd->pw_name);
|
||||
weechat_iconv_fprintf (file, "server_nick3 = \"%s2\"\n", my_passwd->pw_name);
|
||||
weechat_iconv_fprintf (file, "server_username = \"%s\"\n", my_passwd->pw_name);
|
||||
if ((!my_passwd->pw_gecos)
|
||||
|| (my_passwd->pw_gecos[0] == '\0')
|
||||
|| (my_passwd->pw_gecos[0] == ',')
|
||||
|| (my_passwd->pw_gecos[0] == ' '))
|
||||
fprintf (file, "server_realname = \"%s\"\n", my_passwd->pw_name);
|
||||
weechat_iconv_fprintf (file, "server_realname = \"%s\"\n", my_passwd->pw_name);
|
||||
else
|
||||
{
|
||||
realname = strdup (my_passwd->pw_gecos);
|
||||
pos = strchr (realname, ',');
|
||||
if (pos)
|
||||
pos[0] = '\0';
|
||||
fprintf (file, "server_realname = \"%s\"\n",
|
||||
realname);
|
||||
weechat_iconv_fprintf (file, "server_realname = \"%s\"\n",
|
||||
realname);
|
||||
if (pos)
|
||||
pos[0] = ',';
|
||||
free (realname);
|
||||
@@ -2334,26 +2297,26 @@ config_create_default ()
|
||||
else
|
||||
{
|
||||
/* default values if /etc/passwd can't be read */
|
||||
fprintf (stderr, "%s: %s (%s).",
|
||||
WEECHAT_WARNING,
|
||||
_("Unable to get user's name"),
|
||||
strerror (errno));
|
||||
fprintf (file, "server_nick1 = \"weechat1\"\n");
|
||||
fprintf (file, "server_nick2 = \"weechat2\"\n");
|
||||
fprintf (file, "server_nick3 = \"weechat3\"\n");
|
||||
fprintf (file, "server_username = \"weechat\"\n");
|
||||
fprintf (file, "server_realname = \"WeeChat default realname\"\n");
|
||||
weechat_iconv_fprintf (stderr, "%s: %s (%s).",
|
||||
WEECHAT_WARNING,
|
||||
_("Unable to get user's name"),
|
||||
strerror (errno));
|
||||
weechat_iconv_fprintf (file, "server_nick1 = \"weechat1\"\n");
|
||||
weechat_iconv_fprintf (file, "server_nick2 = \"weechat2\"\n");
|
||||
weechat_iconv_fprintf (file, "server_nick3 = \"weechat3\"\n");
|
||||
weechat_iconv_fprintf (file, "server_username = \"weechat\"\n");
|
||||
weechat_iconv_fprintf (file, "server_realname = \"WeeChat default realname\"\n");
|
||||
}
|
||||
|
||||
fprintf (file, "server_hostname = \"\"\n");
|
||||
fprintf (file, "server_command = \"\"\n");
|
||||
fprintf (file, "server_command_delay = 0\n");
|
||||
fprintf (file, "server_autojoin = \"\"\n");
|
||||
fprintf (file, "server_autorejoin = on\n");
|
||||
fprintf (file, "server_notify_levels = \"\"\n");
|
||||
fprintf (file, "server_charset_decode_iso = \"\"\n");
|
||||
fprintf (file, "server_charset_decode_utf = \"\"\n");
|
||||
fprintf (file, "server_charset_encode = \"\"\n");
|
||||
weechat_iconv_fprintf (file, "server_hostname = \"\"\n");
|
||||
weechat_iconv_fprintf (file, "server_command = \"\"\n");
|
||||
weechat_iconv_fprintf (file, "server_command_delay = 0\n");
|
||||
weechat_iconv_fprintf (file, "server_autojoin = \"\"\n");
|
||||
weechat_iconv_fprintf (file, "server_autorejoin = on\n");
|
||||
weechat_iconv_fprintf (file, "server_notify_levels = \"\"\n");
|
||||
weechat_iconv_fprintf (file, "server_charset_decode_iso = \"\"\n");
|
||||
weechat_iconv_fprintf (file, "server_charset_decode_utf = \"\"\n");
|
||||
weechat_iconv_fprintf (file, "server_charset_encode = \"\"\n");
|
||||
|
||||
fclose (file);
|
||||
chmod (filename, 0600);
|
||||
@@ -2406,57 +2369,57 @@ config_write (char *config_name)
|
||||
weechat_log_printf (_("Saving config to disk\n"));
|
||||
|
||||
current_time = time (NULL);
|
||||
fprintf (file, _("#\n# %s configuration file, created by "
|
||||
"%s v%s on %s"),
|
||||
PACKAGE_NAME, PACKAGE_NAME, PACKAGE_VERSION,
|
||||
ctime (¤t_time));
|
||||
fprintf (file, _("# WARNING! Be careful when editing this file, "
|
||||
"WeeChat writes this file when exiting.\n#\n"));
|
||||
weechat_iconv_fprintf (file, _("#\n# %s configuration file, created by "
|
||||
"%s v%s on %s"),
|
||||
PACKAGE_NAME, PACKAGE_NAME, PACKAGE_VERSION,
|
||||
ctime (¤t_time));
|
||||
weechat_iconv_fprintf (file, _("# WARNING! Be careful when editing this file, "
|
||||
"WeeChat writes this file when exiting.\n#\n"));
|
||||
|
||||
for (i = 0; i < CONFIG_NUMBER_SECTIONS; i++)
|
||||
{
|
||||
if ((i != CONFIG_SECTION_KEYS) && (i != CONFIG_SECTION_ALIAS)
|
||||
&& (i != CONFIG_SECTION_IGNORE) && (i != CONFIG_SECTION_SERVER))
|
||||
{
|
||||
fprintf (file, "\n[%s]\n", config_sections[i].section_name);
|
||||
weechat_iconv_fprintf (file, "\n[%s]\n", config_sections[i].section_name);
|
||||
for (j = 0; weechat_options[i][j].option_name; j++)
|
||||
{
|
||||
switch (weechat_options[i][j].option_type)
|
||||
{
|
||||
case OPTION_TYPE_BOOLEAN:
|
||||
fprintf (file, "%s = %s\n",
|
||||
weechat_options[i][j].option_name,
|
||||
(weechat_options[i][j].ptr_int &&
|
||||
*weechat_options[i][j].ptr_int) ?
|
||||
"on" : "off");
|
||||
weechat_iconv_fprintf (file, "%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:
|
||||
fprintf (file, "%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);
|
||||
weechat_iconv_fprintf (file, "%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:
|
||||
fprintf (file, "%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]);
|
||||
weechat_iconv_fprintf (file, "%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:
|
||||
fprintf (file, "%s = %s\n",
|
||||
weechat_options[i][j].option_name,
|
||||
(weechat_options[i][j].ptr_int) ?
|
||||
gui_color_get_name (*weechat_options[i][j].ptr_int) :
|
||||
weechat_options[i][j].default_string);
|
||||
weechat_iconv_fprintf (file, "%s = %s\n",
|
||||
weechat_options[i][j].option_name,
|
||||
(weechat_options[i][j].ptr_int) ?
|
||||
gui_color_get_name (*weechat_options[i][j].ptr_int) :
|
||||
weechat_options[i][j].default_string);
|
||||
break;
|
||||
case OPTION_TYPE_STRING:
|
||||
fprintf (file, "%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);
|
||||
weechat_iconv_fprintf (file, "%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;
|
||||
}
|
||||
}
|
||||
@@ -2464,7 +2427,7 @@ config_write (char *config_name)
|
||||
}
|
||||
|
||||
/* keys section */
|
||||
fprintf (file, "\n[keys]\n");
|
||||
weechat_iconv_fprintf (file, "\n[keys]\n");
|
||||
for (ptr_key = gui_keys; ptr_key; ptr_key = ptr_key->next_key)
|
||||
{
|
||||
expanded_name = gui_keyboard_get_expanded_name (ptr_key->key);
|
||||
@@ -2472,37 +2435,37 @@ config_write (char *config_name)
|
||||
{
|
||||
function_name = gui_keyboard_function_search_by_ptr (ptr_key->function);
|
||||
if (function_name)
|
||||
fprintf (file, "%s = \"%s\"\n",
|
||||
(expanded_name) ? expanded_name : ptr_key->key,
|
||||
function_name);
|
||||
weechat_iconv_fprintf (file, "%s = \"%s\"\n",
|
||||
(expanded_name) ? expanded_name : ptr_key->key,
|
||||
function_name);
|
||||
}
|
||||
else
|
||||
fprintf (file, "%s = \"%s\"\n",
|
||||
(expanded_name) ? expanded_name : ptr_key->key,
|
||||
ptr_key->command);
|
||||
weechat_iconv_fprintf (file, "%s = \"%s\"\n",
|
||||
(expanded_name) ? expanded_name : ptr_key->key,
|
||||
ptr_key->command);
|
||||
if (expanded_name)
|
||||
free (expanded_name);
|
||||
}
|
||||
|
||||
/* alias section */
|
||||
fprintf (file, "\n[alias]\n");
|
||||
weechat_iconv_fprintf (file, "\n[alias]\n");
|
||||
for (ptr_alias = weechat_alias; ptr_alias;
|
||||
ptr_alias = ptr_alias->next_alias)
|
||||
{
|
||||
fprintf (file, "%s = \"%s\"\n",
|
||||
ptr_alias->alias_name, ptr_alias->alias_command);
|
||||
weechat_iconv_fprintf (file, "%s = \"%s\"\n",
|
||||
ptr_alias->alias_name, ptr_alias->alias_command);
|
||||
}
|
||||
|
||||
/* ignore section */
|
||||
fprintf (file, "\n[ignore]\n");
|
||||
weechat_iconv_fprintf (file, "\n[ignore]\n");
|
||||
for (ptr_ignore = irc_ignore; ptr_ignore;
|
||||
ptr_ignore = ptr_ignore->next_ignore)
|
||||
{
|
||||
fprintf (file, "ignore = \"%s,%s,%s,%s\"\n",
|
||||
ptr_ignore->mask,
|
||||
ptr_ignore->type,
|
||||
ptr_ignore->channel_name,
|
||||
ptr_ignore->server_name);
|
||||
weechat_iconv_fprintf (file, "ignore = \"%s,%s,%s,%s\"\n",
|
||||
ptr_ignore->mask,
|
||||
ptr_ignore->type,
|
||||
ptr_ignore->channel_name,
|
||||
ptr_ignore->server_name);
|
||||
}
|
||||
|
||||
/* server section */
|
||||
@@ -2511,44 +2474,38 @@ config_write (char *config_name)
|
||||
{
|
||||
if (!ptr_server->command_line)
|
||||
{
|
||||
fprintf (file, "\n[server]\n");
|
||||
fprintf (file, "server_name = \"%s\"\n", ptr_server->name);
|
||||
fprintf (file, "server_autoconnect = %s\n",
|
||||
(ptr_server->autoconnect) ? "on" : "off");
|
||||
fprintf (file, "server_autoreconnect = %s\n",
|
||||
(ptr_server->autoreconnect) ? "on" : "off");
|
||||
fprintf (file, "server_autoreconnect_delay = %d\n",
|
||||
ptr_server->autoreconnect_delay);
|
||||
fprintf (file, "server_address = \"%s\"\n", ptr_server->address);
|
||||
fprintf (file, "server_port = %d\n", ptr_server->port);
|
||||
fprintf (file, "server_ipv6 = %s\n",
|
||||
(ptr_server->ipv6) ? "on" : "off");
|
||||
fprintf (file, "server_ssl = %s\n",
|
||||
(ptr_server->ssl) ? "on" : "off");
|
||||
fprintf (file, "server_password = \"%s\"\n",
|
||||
(ptr_server->password) ? ptr_server->password : "");
|
||||
fprintf (file, "server_nick1 = \"%s\"\n", ptr_server->nick1);
|
||||
fprintf (file, "server_nick2 = \"%s\"\n", ptr_server->nick2);
|
||||
fprintf (file, "server_nick3 = \"%s\"\n", ptr_server->nick3);
|
||||
fprintf (file, "server_username = \"%s\"\n", ptr_server->username);
|
||||
fprintf (file, "server_realname = \"%s\"\n", ptr_server->realname);
|
||||
fprintf (file, "server_hostname = \"%s\"\n",
|
||||
(ptr_server->hostname) ? ptr_server->hostname : "");
|
||||
fprintf (file, "server_command = \"%s\"\n",
|
||||
(ptr_server->command) ? ptr_server->command : "");
|
||||
fprintf (file, "server_command_delay = %d\n", ptr_server->command_delay);
|
||||
fprintf (file, "server_autojoin = \"%s\"\n",
|
||||
(ptr_server->autojoin) ? ptr_server->autojoin : "");
|
||||
fprintf (file, "server_autorejoin = %s\n",
|
||||
(ptr_server->autorejoin) ? "on" : "off");
|
||||
fprintf (file, "server_notify_levels = \"%s\"\n",
|
||||
(ptr_server->notify_levels) ? ptr_server->notify_levels : "");
|
||||
fprintf (file, "server_charset_decode_iso = \"%s\"\n",
|
||||
(ptr_server->charset_decode_iso) ? ptr_server->charset_decode_iso : "");
|
||||
fprintf (file, "server_charset_decode_utf = \"%s\"\n",
|
||||
(ptr_server->charset_decode_utf) ? ptr_server->charset_decode_utf : "");
|
||||
fprintf (file, "server_charset_encode = \"%s\"\n",
|
||||
(ptr_server->charset_encode) ? ptr_server->charset_encode : "");
|
||||
weechat_iconv_fprintf (file, "\n[server]\n");
|
||||
weechat_iconv_fprintf (file, "server_name = \"%s\"\n", ptr_server->name);
|
||||
weechat_iconv_fprintf (file, "server_autoconnect = %s\n",
|
||||
(ptr_server->autoconnect) ? "on" : "off");
|
||||
weechat_iconv_fprintf (file, "server_autoreconnect = %s\n",
|
||||
(ptr_server->autoreconnect) ? "on" : "off");
|
||||
weechat_iconv_fprintf (file, "server_autoreconnect_delay = %d\n",
|
||||
ptr_server->autoreconnect_delay);
|
||||
weechat_iconv_fprintf (file, "server_address = \"%s\"\n", ptr_server->address);
|
||||
weechat_iconv_fprintf (file, "server_port = %d\n", ptr_server->port);
|
||||
weechat_iconv_fprintf (file, "server_ipv6 = %s\n",
|
||||
(ptr_server->ipv6) ? "on" : "off");
|
||||
weechat_iconv_fprintf (file, "server_ssl = %s\n",
|
||||
(ptr_server->ssl) ? "on" : "off");
|
||||
weechat_iconv_fprintf (file, "server_password = \"%s\"\n",
|
||||
(ptr_server->password) ? ptr_server->password : "");
|
||||
weechat_iconv_fprintf (file, "server_nick1 = \"%s\"\n", ptr_server->nick1);
|
||||
weechat_iconv_fprintf (file, "server_nick2 = \"%s\"\n", ptr_server->nick2);
|
||||
weechat_iconv_fprintf (file, "server_nick3 = \"%s\"\n", ptr_server->nick3);
|
||||
weechat_iconv_fprintf (file, "server_username = \"%s\"\n", ptr_server->username);
|
||||
weechat_iconv_fprintf (file, "server_realname = \"%s\"\n", ptr_server->realname);
|
||||
weechat_iconv_fprintf (file, "server_hostname = \"%s\"\n",
|
||||
(ptr_server->hostname) ? ptr_server->hostname : "");
|
||||
weechat_iconv_fprintf (file, "server_command = \"%s\"\n",
|
||||
(ptr_server->command) ? ptr_server->command : "");
|
||||
weechat_iconv_fprintf (file, "server_command_delay = %d\n", ptr_server->command_delay);
|
||||
weechat_iconv_fprintf (file, "server_autojoin = \"%s\"\n",
|
||||
(ptr_server->autojoin) ? ptr_server->autojoin : "");
|
||||
weechat_iconv_fprintf (file, "server_autorejoin = %s\n",
|
||||
(ptr_server->autorejoin) ? "on" : "off");
|
||||
weechat_iconv_fprintf (file, "server_notify_levels = \"%s\"\n",
|
||||
(ptr_server->notify_levels) ? ptr_server->notify_levels : "");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -92,10 +92,6 @@ 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 char *cfg_look_charset_decode_iso;
|
||||
extern char *cfg_look_charset_decode_utf;
|
||||
extern char *cfg_look_charset_encode;
|
||||
extern char *cfg_look_charset_internal;
|
||||
extern int cfg_look_one_server_buffer;
|
||||
extern int cfg_look_open_near_server;
|
||||
extern int cfg_look_scroll_amount;
|
||||
|
||||
Reference in New Issue
Block a user