1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-22 10:56:38 +02:00

Compare commits

..

1 Commits

Author SHA1 Message Date
Sebastien Helleu 0f3efd732c Fix compilation errors/warnings
Just for fun :)
2014-02-07 14:15:04 +01:00
40 changed files with 1138 additions and 3217 deletions
+7 -6
View File
@@ -1,16 +1,17 @@
WeeChat - Wee Enhanced Environment for Chat
===========================================
WeeChat known bugs, 2003-10-05
WeeChat known bugs, 2003-09-27
- too much nicks in the channel (> height of window) => display bug
- some IRC commands are marked as 'unknown' when received
(IRC protocol is under dev!)
(irc protocol is under dev!)
- bug in nicklist resize (sometimes resize doesn't work and there is display
problem)
- alias/unalias commands doesn't work
- config is not saved (to ~/.weechat/weechatrc)
- intercept Ctrl-C (do not quit immediately if Ctrl-C pressed!)
- program is stopped when bad option in config file (it should not, only display
warning)
- too much opened channels => display bug
- too much opened channel => display bug
- when kicked, channel is not prefixed by '(' and sufixed by ')'
- when function key (non used by WeeChat) is pressed, prompt is deleted
- when quitting WeeChat term title is not restored (if look_set_title is ON)
- command name for /server can not contain spaces
+82 -25
View File
@@ -1,31 +1,88 @@
WeeChat - Wee Enhanced Environment for Chat
===========================================
ChangeLog - 2003-10-05
ChangeLog - 2003-09-27
* 2003-09-27:
- WeeChat 0.0.1 released!
Version 0.0.2 (2003-10-05):
* added commands /rehash and /restart
* command & auto-join channels when connected to server
* new commands for alias: /alias, /unalias (new section in config file)
* config is now saved automatically when quitting WeeChat, /save command added
* new commands for servers: /server, /connect, /disconnect
* added autoconnect flag for each server in config file
* added "look_set_title" option in config file
* term window title is modified with WeeChat name and version
* fixed nicklist display bug
* fixed crash when sending command which can only be received
* CTCP version returns more info (about OS)
* 2003-09-26:
- added completor prefix (in config: look_nick_completor)
- fixef log_printf command (bug with year & month)
- added "/kill" command
- fixed /version and /ctcp commands (missing ":" before message)
Version 0.0.1 (2003-09-27):
* ncurses GUI with color output
* multi-servers
* channel windows, with nicklist (position: top, bottom, left or right)
* private windows
* IRC commands: away, ctcp, deop, devoice, invite, join, kick, kill, list,
me, mode, msg, names, nick, notice, op, oper, part, ping, pong, quit,
quote, topic, version, voice, whois
* WeeChat commands: clear, help, set (partial)
* many config options
* log file (~/.weechat/weechat.log)
* nicklist can be moved on top, bottom, left or right of window
* 2003-09-25:
- added "/kick" command
- added IRC errors 402 to 407
- added "/invite" command
* 2003-09-24:
- "ctcp version" received is now correctly displayed
- "/version" command is ok
* 2003-09-23:
- log file (~/.weechat/weechat.log)
- renamed config file (~/.weechat/weechatrc to ~/.weechat/weechat.rc)
* 2003-09-21:
- "demi-highlight": 2 types of windows highlight: lightred for windows with
unread messages (from other users), lightmagenta for windows with other
unread data (join, part, quit, away, ...)
- "320" IRC message management
- "/clear" command
* 2003-09-19:
- préparation des sources pour l'internationalisation avec gettext
- "301" IRC command (away message)
- functions renamed in rc-commands.c, irc-server.c,
command.c and config.c (all functions are beginning with a prefix:
irc_cmd_recv_xxx, irc_cmd_send_xxx, server_xxx, weechat_cmd_xxx and
config_xxx). Moreover, all commands (sent and received) return a value
(success or not)
- "/quote" command
- "/whois" command (and colored display of /whois result in server window)
* 2003-09-18:
- use of alternate nickname (and 2nd alternate) if nick is already used
on server (changed/added in config file: options "nick1", "nick2", "nick3"
for a server, all are mandatory)
- "433" IRC error management (nickname already in use)
- "mode" command received correctly for "channel flags" and
op/deop/voice/devoice actions for a nick
- "401" IRC error management (no such nick/channel)
- private windows management (when received and opened, with /privmsg),
"/privmsg" completed consequently
* 2003-09-17:
- nickmode display ((half)op/voice) before nicks (as option, look at config
options beginning with "look_nickmode")
- windows history is now ok (pgup/pgdn on any window type)
- "/me" command (and OK when received)
- display nicks count when joining channel or with "/names" command
(total, ops, halfops, voices et normaux)
* 2003-09-16:
- added and normalized chat window colors
(new colors in config file)
- "/topic" command
- nicklist can be moved on top, bottom, left or right of window
* 2003-09-15:
- auto-resize of nicklist, according to nick max length
- IRC multi-servers is OK
* 2003-09-14:
- no hangup if "/part" command is executed on server window
- continue if no server is declared in config file
(empty window will be opened for executing WeeChat commands)
- string array for strings in config file
example: cfg_look_nicklist_position can take values "left", "right",
"top", "bottom", which are converted to int (from 0 for "left" to 3 for
"bottom")
- messages are aligned under time (server window) or under time + nick
(channel window)
* 2003-09-13:
- sources exploded in many directories: ./irc, ./gui/curses, ./gui/gtk,
./gui/qt and ./gui/text
+2 -6
View File
@@ -1,10 +1,6 @@
WeeChat - Wee Enhanced Environment for Chat
===========================================
* FlashCode, 2003-10-05
FlashCode, 2003-09-27
WeeChat 0.0.2 released.
* FlashCode, 2003-09-27
WeeChat 0.0.1 released.
WeeChat 0.0.1 released.
+54 -23
View File
@@ -1,7 +1,7 @@
WeeChat - Wee Enhanced Environment for Chat
===========================================
TODO - 2003-10-05
TODO - 2003-09-27
Legend:
# done
@@ -10,40 +10,70 @@ Legend:
? is this really necessary?
v0.0.2:
------
v0.0.1:
* IRC protocol:
# "/rehash" command: tell the server to reload its config file
# "/restart" command: tell the server to restart itself
# "/quote" command: send a raw string to the server without parsing it
# "/me" command (for user actions description)
# "/away" command (to toggle the away status)
# "/op", "/deop", "/voice", "/devoice" commands
# "/invite" command
# "/kick", "/ban", "/unban" commands
# "/kill" command
# "/list" command: list of channels
# "/names" command: view who is on a given channel without being
on it (for example /names #weechat gives all the nicks present on
#weechat, except those who have the +i flag (server side))
# "/oper" command: become operator on the irc network
# "/topic" command: change the topic of a channel
# "/version" command: give the irc client version (CTCP VERSION)
of a given nick/channel (without parameter: gives WeeChat version)
# "/whois" command
* WeeChat commands:
# "/connect" and "/disconnect" commands (for multiservers use)
# "/server" command to add, remove or list servers
# "/save" command: save configuration to disk
# "/alias" and "/unalias" commands
# "/clear": to clear window content
* Interface:
# "demi-highlight" when joins/quits etc
# log messages/warning/errors to ~/.weechat/log file
# improve editing zone (left arrow <> backspace)
# sort nick list
# choose nick list position (top, left, right (default), bottom)
# auto-resize nicklist (when nick too long)
# do pretty cutting of long lines (align on the nick or after hour for server)
# keep history of commands and call them again with up/down arrow
# text GUI
# ncurses GUI:
# one window for each channel
# color display
# private windows
# redraw window when term size is modified
# chat history (pgup/pgdn for displaying history)
# switch to other channel window
* TCP/IP communication:
# IPv4 protocol implementation
* Configuration:
# write config file
# add alias definition
# add an option for each server in order to run commands on join
(example: /msg nickserv identify password)
# channel list for auto-join (for each server)
# write default config file
Future versions:
---------------
* IRC protocol:
- implement RFC 2812
+ "/mode" command: change the user/channels modes
- "/dcc" command (for chat and sending/receiving files)
- manage "halfop" status
- complete "/list" command: add regexp search, display only channels that
match regexp
- "/connect" and "/disconnect" commands (for multiservers use)
- "/ignore" and "/unignore" commands: hide all that is write by a given
nick/host
- when we're away, WeeChat should log all the lines begenning by our nick.
When we come back from our away it should print it to the current window
- "/rehash" command: tell the server to reload its config file
- "/restart" command: tell the server to restart itself
- "/notify" and "/unnotify" command to be warn by WeeChat when a given
nick/host connect to the given irc network
- "/wallops" command: write the same string to all the
@@ -57,15 +87,15 @@ Future versions:
like -o could send the output to the server, on the current
channel/private
- "/reload" command: reload the WeeChat's config file
- "/highlight" command: highlight a given word when it appears on
channels/privates
+ "/set" command: allow the user to set the WeeChat variables
- "/set" command: allow the user to set the WeeChat variables
under WeeChat without editing the config file (colours, time
format, etc)
- "/highlight" command: highlight a given word when it appears on
channels/privates
* Interface:
- display current channel modes (example : #weechat(+nt))
- interpret special chars in messages (color & bold for example)
- interpret ^B in messages (this means bold text)
- internationalization (traduce WeeChat in many languages)
- many channel windows in one window/term (window split)
- add lag indicator
@@ -79,14 +109,15 @@ Future versions:
? Qt GUI
* TCP/IP communication:
- connect to server with child process (background)
- SSL support
- IPv6 protocol implementation
* Configuration:
- add key bindings to config file
- add missing options for config file
- wrong alias is not created and not saved when quitting WeeChat
- write config file
- add an option for each server in order to run commands on join
(example: /msg nickserv identify password)
- channel list for auto-join (for each server)
- do not stop program if problem with options in config file
- load config file after GUI (so init values by default (colors, ...) before
loading config)
+1 -7
View File
@@ -1,11 +1,5 @@
weechat (0.0.2-1) unstable; urgency=low
* WeeChat version 0.0.2, see ChangeLog for detail.
-- FlashCode <flashcode@flashtux.org> Sun, 05 Oct 2003 12:00:00 +0200
weechat (0.0.1-1) unstable; urgency=low
* First version.
-- FlashCode <flashcode@flashtux.org> Sat, 27 Sep 2003 12:00:00 +0200
-- FlashCode <flashcode@flashtux.org> Sat, 27 Jun 2003 12:00:00 +0200
+1 -1
View File
@@ -1,5 +1,5 @@
This package was debianized by FlashCode <flashcode@flashtux.org> on
Sun, 05 Oct 2003 12:00:00 +0200.
Sat, 27 Sep 2003 10:00:00 +0200.
It was downloaded from http://weechat.flashtux.org/download
+1 -1
View File
@@ -1 +1 @@
weechat_0.0.2-1_i386.deb net optional
weechat_0.0.1-1_i386.deb net optional
+2 -2
View File
@@ -84,8 +84,8 @@ command.o: command.c weechat.h command.h irc/irc.h gui/gui.h completion.h \
history.h config.h
completion.o: completion.c weechat.h completion.h irc/irc.h gui/gui.h \
history.h command.h
config.o: config.c weechat.h config.h command.h irc/irc.h gui/gui.h \
completion.h history.h
config.o: config.c weechat.h config.h irc/irc.h gui/gui.h completion.h \
history.h
history.o: history.c weechat.h history.h gui/gui.h completion.h
weechat.o: weechat.c weechat.h config.h command.h irc/irc.h gui/gui.h \
completion.h history.h
+64 -774
View File
File diff suppressed because it is too large Load Diff
+3 -20
View File
@@ -40,16 +40,6 @@ struct t_weechat_command
int (*cmd_function_1arg)(char *);
};
typedef struct t_weechat_alias t_weechat_alias;
struct t_weechat_alias
{
char *alias_name;
char *alias_command;
t_weechat_alias *prev_alias;
t_weechat_alias *next_alias;
};
typedef struct t_index_command t_index_command;
struct t_index_command
@@ -59,22 +49,15 @@ struct t_index_command
t_index_command *next_index;
};
extern t_weechat_alias *weechat_alias;
extern t_index_command *index_commands;
extern t_index_command *index_command_new (char *);
extern void index_command_build ();
extern t_weechat_alias *alias_new (char *, char *);
extern int exec_weechat_command (t_irc_server *, char *);
extern void user_command (t_irc_server *, char *);
extern int weechat_cmd_alias (char *);
extern int weechat_cmd_clear (int, char **);
extern int weechat_cmd_connect (int, char **);
extern int weechat_cmd_disconnect (int, char **);
extern int weechat_cmd_alias(int, char **);
extern int weechat_cmd_clear(int, char **);
extern int weechat_cmd_help (int, char **);
extern int weechat_cmd_server (int, char **);
extern int weechat_cmd_save (int, char **);
extern int weechat_cmd_set (int, char **);
extern int weechat_cmd_unalias (char *);
extern int weechat_cmd_unalias (int, char **);
#endif /* command.h */
+97 -265
View File
@@ -31,7 +31,6 @@
#include "weechat.h"
#include "config.h"
#include "command.h"
#include "irc/irc.h"
#include "gui/gui.h"
@@ -45,13 +44,11 @@ t_config_section config_sections[CONFIG_NUMBER_SECTIONS] =
{ 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;
@@ -70,20 +67,16 @@ 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"),
{ { "look_startup_logo", N_("display " WEECHAT_NAME " logo at startup"),
N_("display " WEECHAT_NAME " 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"),
{ "look_startup_version", N_("display " WEECHAT_NAME " version at startup"),
N_("display " WEECHAT_NAME " 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)"),
{ "look_weechat_slogan", N_(WEECHAT_NAME "slogan"),
N_(WEECHAT_NAME "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"),
@@ -340,7 +333,7 @@ t_config_option weechat_options_log[] =
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"),
N_("path for " WEECHAT_NAME " log files"),
OPTION_TYPE_STRING, 0, 0, 0,
"~/.weechat/logs/", NULL, NULL, &cfg_log_path, NULL },
{ "log_name", N_("name for log files"),
@@ -448,10 +441,6 @@ t_config_option weechat_options_server[] =
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,
@@ -484,14 +473,6 @@ t_config_option weechat_options_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 }
};
@@ -500,7 +481,7 @@ t_config_option weechat_options_server[] =
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
weechat_options_server
};
@@ -525,6 +506,24 @@ get_pos_array_values (char **array, char *string)
return -1;
}
/*
* config_init_server: init server struct
*/
void
config_init_server ()
{
cfg_server.name = NULL;
cfg_server.address = NULL;
cfg_server.port = -1;
cfg_server.password = NULL;
cfg_server.nick1 = NULL;
cfg_server.nick2 = NULL;
cfg_server.nick3 = NULL;
cfg_server.username = NULL;
cfg_server.realname = NULL;
}
/*
* config_allocate_server: allocate a new server
*/
@@ -557,10 +556,9 @@ config_allocate_server (char *filename, int line_number)
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))
cfg_server.address, cfg_server.port, cfg_server.password,
cfg_server.nick1, cfg_server.nick2, cfg_server.nick3,
cfg_server.username, cfg_server.realname))
{
server_free_all ();
gui_printf (NULL,
@@ -568,9 +566,26 @@ config_allocate_server (char *filename, int line_number)
WEECHAT_WARNING, filename, line_number);
return 0;
}
if (cfg_server.name)
free (cfg_server.name);
if (cfg_server.address)
free (cfg_server.address);
if (cfg_server.password)
free (cfg_server.password);
if (cfg_server.nick1)
free (cfg_server.nick1);
if (cfg_server.nick2)
free (cfg_server.nick2);
if (cfg_server.nick3)
free (cfg_server.nick3);
if (cfg_server.username)
free (cfg_server.username);
if (cfg_server.realname)
free (cfg_server.realname);
if (cfg_server.nick)
free (cfg_server.nick);
server_destroy (&cfg_server);
server_init (&cfg_server);
config_init_server ();
return 1;
}
@@ -586,7 +601,7 @@ config_default_values ()
for (i = 0; i < CONFIG_NUMBER_SECTIONS; i++)
{
if ((i != CONFIG_SECTION_ALIAS) && (i != CONFIG_SECTION_SERVER))
if (i != CONFIG_SECTION_SERVER)
{
for (j = 0; weechat_options[i][j].option_name; j++)
{
@@ -655,7 +670,7 @@ config_read ()
}
config_default_values ();
server_init (&cfg_server);
config_init_server ();
/* read config file */
section = CONFIG_SECTION_NONE;
@@ -741,35 +756,29 @@ config_read ()
pos2 = strchr (pos, '\n');
if (pos2 != NULL)
pos2[0] = '\0';
if (section == CONFIG_SECTION_ALIAS)
option_number = -1;
for (i = 0;
weechat_options[section][i].option_name; i++)
{
if (alias_new (line, pos))
index_command_new (pos);
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);
fclose (file);
free (filename);
return -2;
}
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);
fclose (file);
free (filename);
return -2;
}
switch (weechat_options[section]
[option_number].option_type)
{
@@ -911,8 +920,6 @@ config_read ()
/*
* config_create_default: create default WeeChat config
* return: 0 if ok
* < 0 if error
*/
int
@@ -929,25 +936,24 @@ config_create_default ()
sprintf (filename, "%s/.weechat/" WEECHAT_CONFIG_NAME, getenv ("HOME"));
if ((file = fopen (filename, "wt")) == NULL)
{
free (filename);
gui_printf (NULL, _("%s cannot create file \"%s\"\n"),
WEECHAT_ERROR, filename);
free (filename);
return -1;
}
printf (_("%s: creating default config file...\n"), WEECHAT_NAME);
log_printf (_("creating default config file\n"));
printf (_(WEECHAT_NAME ": creating default config file...\n"));
current_time = time (NULL);
sprintf (line, _("#\n# %s configuration file, created by "
"%s v%s on %s#\n"),
WEECHAT_NAME, WEECHAT_NAME, WEECHAT_VERSION,
ctime (&current_time));
sprintf (line, _("#\n# " WEECHAT_NAME " configuration file, generated by "
WEECHAT_NAME " " WEECHAT_VERSION " on %s"), ctime (&current_time));
fputs (line, file);
fputs (_("# This file may be edited by user. Invalid syntax will prevent "
WEECHAT_NAME " from running!\n#\n"), file);
for (i = 0; i < CONFIG_NUMBER_SECTIONS; i++)
{
if ((i != CONFIG_SECTION_ALIAS) && (i != CONFIG_SECTION_SERVER))
if (i != CONFIG_SECTION_SERVER)
{
sprintf (line, "\n[%s]\n", config_sections[i].section_name);
fputs (line, file);
@@ -963,62 +969,33 @@ config_create_default ()
{
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;
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);
@@ -1027,8 +1004,6 @@ config_create_default ()
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);
@@ -1037,153 +1012,10 @@ config_create_default ()
/*
* config_write: write WeeChat configurtion
* return: 0 if ok
* < 0 if error
*/
int
config_write (char *config_name)
void
config_write ()
{
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"),
WEECHAT_NAME, WEECHAT_NAME, WEECHAT_VERSION,
ctime (&current_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;
/* TODO: write "config_write" function! */
}
+3 -5
View File
@@ -32,9 +32,8 @@
#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 CONFIG_SECTION_SERVER 6
#define CONFIG_NUMBER_SECTIONS 7
#define OPTION_TYPE_BOOLEAN 1 /* values: on/off */
#define OPTION_TYPE_INT 2 /* values: from min to max */
@@ -75,7 +74,6 @@ struct t_config_option
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;
@@ -152,6 +150,6 @@ extern t_config_option * weechat_options [CONFIG_NUMBER_SECTIONS];
extern int config_read ();
extern int config_create_default ();
extern int config_write ();
extern void config_write ();
#endif /* config.h */
+34 -86
View File
@@ -45,7 +45,7 @@ t_gui_window *last_gui_window = NULL; /* pointer to last window */
t_gui_window *gui_current_window = NULL; /* pointer to current window */
t_gui_color gui_colors[] =
{ { "default", -1 | A_NORMAL },
{ { "default", -1 },
{ "black", COLOR_BLACK | A_NORMAL },
{ "red", COLOR_RED | A_NORMAL },
{ "lightred", COLOR_RED | A_BOLD },
@@ -146,7 +146,7 @@ gui_get_color_by_value (int color_value)
void
gui_window_set_color (WINDOW *window, int num_color)
{
if (has_colors)
if (has_colors ())
{
if (color_attr[num_color - 1] & A_BOLD)
wattron (window, COLOR_PAIR (num_color) | A_BOLD);
@@ -611,8 +611,7 @@ gui_draw_window_nick (t_gui_window *window)
if (CHANNEL(window) && CHANNEL(window)->nicks)
{
max_length = nick_get_max_length (CHANNEL(window));
if ((window == gui_current_window) &&
((max_length + 2) != window->win_nick_width))
if ((max_length + 2) != window->win_nick_width)
{
gui_calculate_pos_size (window);
delwin (window->win_chat);
@@ -625,6 +624,7 @@ gui_draw_window_nick (t_gui_window *window)
window->win_nick_width,
window->win_nick_y,
window->win_nick_x);
//scrollok (window->win_chat, TRUE);
gui_redraw_window_chat (window);
}
sprintf (format, "%%-%ds", max_length);
@@ -752,7 +752,6 @@ void
gui_draw_window_status (t_gui_window *window)
{
t_gui_window *ptr_win;
char format_more[32];
/* TODO: manage splitted windows! */
if (window != gui_current_window)
@@ -854,12 +853,9 @@ gui_draw_window_status (t_gui_window *window)
/* display "*MORE*" if last line is not displayed */
gui_window_set_color (window->win_status, COLOR_WIN_STATUS_MORE);
if (window->sub_lines > 0)
mvwprintw (window->win_status, 0, COLS - 7, _("-MORE-"));
mvwprintw (window->win_status, 0, COLS - 7, "-MORE-");
else
{
sprintf (format_more, "%%-%ds", strlen (_("-MORE")));
mvwprintw (window->win_status, 0, COLS - 7, format_more, " ");
}
mvwprintw (window->win_status, 0, COLS - 7, " ");
wrefresh (window->win_status);
refresh ();
@@ -962,34 +958,17 @@ gui_draw_window_input (t_gui_window *window)
}
else
{
if (SERVER(window))
{
sprintf (format, "%%s> %%-%ds", input_width);
if (SERVER(window) && (SERVER(window)->is_connected))
ptr_nickname = SERVER(window)->nick;
else
ptr_nickname = cfg_look_no_nickname;
mvwprintw (window->win_input, 0, 0, format,
ptr_nickname,
window->input_buffer + window->input_buffer_1st_display);
wclrtoeol (window->win_input);
move (LINES - 1, strlen (ptr_nickname) + 2 +
(window->input_buffer_pos - window->input_buffer_1st_display));
}
sprintf (format, "%%s> %%-%ds", input_width);
if (SERVER(window) && (SERVER(window)->is_connected))
ptr_nickname = SERVER(window)->nick;
else
{
sprintf (format, "%%s> %%-%ds", input_width);
if (SERVER(window) && (SERVER(window)->is_connected))
ptr_nickname = SERVER(window)->nick;
else
ptr_nickname = cfg_look_no_nickname;
mvwprintw (window->win_input, 0, 0, format,
ptr_nickname,
window->input_buffer + window->input_buffer_1st_display);
wclrtoeol (window->win_input);
move (LINES - 1, strlen (ptr_nickname) + 2 +
(window->input_buffer_pos - window->input_buffer_1st_display));
}
ptr_nickname = cfg_look_no_nickname;
mvwprintw (window->win_input, 0, 0, format,
ptr_nickname,
window->input_buffer + window->input_buffer_1st_display);
wclrtoeol (window->win_input);
move (LINES - 1, strlen (ptr_nickname) + 2 +
(window->input_buffer_pos - window->input_buffer_1st_display));
}
wrefresh (window->win_input);
@@ -1110,17 +1089,17 @@ gui_switch_to_window (t_gui_window *window)
}
}
gui_calculate_pos_size (window);
/* first time creation for windows */
if (!another_window)
{
/* create new windows */
gui_calculate_pos_size (window);
window->win_title = newwin (1, COLS, 0, 0);
window->win_chat = newwin (window->win_chat_height,
window->win_chat_width,
window->win_chat_y,
window->win_chat_x);
//scrollok (window->win_chat, TRUE);
if (CHANNEL(window))
window->win_nick = newwin (window->win_nick_height,
window->win_nick_width,
@@ -1133,33 +1112,34 @@ gui_switch_to_window (t_gui_window *window)
}
else
{
gui_calculate_pos_size (window);
/* create chat & nick windows */
if (WIN_IS_CHANNEL(window))
if (WIN_IS_CHANNEL(window) && !(window->win_nick))
{
/* (re)create nicklist window */
if (window->win_nick)
delwin (window->win_nick);
/* add nick list window */
delwin (window->win_chat);
window->win_chat = newwin (window->win_chat_height,
window->win_chat_width,
window->win_chat_y,
window->win_chat_x);
//scrollok (window->win_chat, TRUE);
window->win_nick = newwin (window->win_nick_height,
window->win_nick_width,
window->win_nick_y,
window->win_nick_x);
}
if (!(WIN_IS_CHANNEL(window)))
if (!(WIN_IS_CHANNEL(window)) && window->win_nick)
{
/* remove nick list window */
if (window->win_nick)
delwin (window->win_nick);
delwin (window->win_nick);
window->win_nick = NULL;
delwin (window->win_chat);
window->win_chat = newwin (window->win_chat_height,
window->win_chat_width,
window->win_chat_y,
window->win_chat_x);
//scrollok (window->win_chat, TRUE);
}
}
@@ -1249,31 +1229,17 @@ gui_window_new (void *server, void *channel
/*int x, int y, int width, int height*/)
{
t_gui_window *new_window;
if (gui_windows)
{
if (!SERVER(gui_windows))
{
if (server)
((t_irc_server *)(server))->window = gui_windows;
if (channel)
((t_irc_channel *)(channel))->window = gui_windows;
SERVER(gui_windows) = server;
CHANNEL(gui_windows) = channel;
return gui_windows;
}
}
if ((new_window = (t_gui_window *)(malloc (sizeof (t_gui_window)))))
{
/* assign server and channel to window */
SERVER(new_window) = server;
CHANNEL(new_window) = channel;
new_window->server = server;
new_window->channel = channel;
/* assign window to server and channel */
if (server && !channel)
SERVER(new_window)->window = new_window;
((t_irc_server *)new_window->server)->window = new_window;
if (channel)
CHANNEL(new_window)->window = new_window;
((t_irc_channel *)new_window->channel)->window = new_window;
gui_calculate_pos_size (new_window);
@@ -1324,7 +1290,6 @@ gui_window_new (void *server, void *channel
}
else
return NULL;
return new_window;
}
@@ -1337,13 +1302,9 @@ gui_window_free (t_gui_window *window)
{
t_gui_line *ptr_line;
t_gui_message *ptr_message;
int create_new;
create_new = (window->server || window->channel);
/* TODO: manage splitted windows! */
if ((window == gui_current_window) &&
((window->next_window) || (window->prev_window)))
if (window == gui_current_window)
gui_switch_to_previous_window ();
/* free lines and messages */
@@ -1378,10 +1339,6 @@ gui_window_free (t_gui_window *window)
last_gui_window = window->prev_window;
free (window);
/* always at least one window */
if (!gui_windows && create_new)
gui_window_new (NULL, NULL);
}
/*
@@ -1392,13 +1349,10 @@ void
gui_resize_term_handler ()
{
t_gui_window *ptr_win;
int width, height;
endwin ();
refresh ();
getmaxyx (stdscr, height, width);
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
{
gui_calculate_pos_size (ptr_win);
@@ -1549,12 +1503,6 @@ gui_init ()
signal (SIGWINCH, gui_resize_term_handler);
#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");
#endif
gui_ready = 1;
}
@@ -1583,7 +1531,7 @@ gui_end ()
/* TODO: free input buffer, lines, messages, completion */
}
/* end of curses output */
/* end of ncurses output */
refresh ();
endwin ();
}
@@ -1643,7 +1591,7 @@ gui_new_message (t_gui_window *window)
}
else
{
log_printf (_("not enough memory!\n"));
log_printf ("not enough memory!\n");
return NULL;
}
return new_message;
+141 -227
View File
@@ -29,7 +29,6 @@
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <sys/utsname.h>
#include "../weechat.h"
#include "irc.h"
@@ -103,8 +102,7 @@ t_irc_command irc_commands[] =
" o: operator flag\n"),
1, MAX_ARGS, 1, NULL, irc_cmd_send_mode, irc_cmd_recv_mode },
{ "msg", N_("send message to a nick or channel"),
N_("receiver[,receiver] text"),
N_("receiver: nick or channel (may be mask, '*' = current channel)"
N_("receiver[,receiver] text"), N_("receiver: nick or channel (may be mask)"
"\ntext: text to send"),
1, MAX_ARGS, 1, NULL, irc_cmd_send_msg, NULL },
{ "names", N_("list nicknames on channels"),
@@ -124,7 +122,7 @@ t_irc_command irc_commands[] =
N_("user/password: used to get privileges on current IRC server"),
2, 2, 1, irc_cmd_send_oper, NULL, NULL },
{ "part", N_("leave a channel"),
N_("[channel[,channel]]"), N_("channel: channel name to leave"),
N_("[channel[,channel]]"), N_("channel: channel name to join"),
0, MAX_ARGS, 1, NULL, irc_cmd_send_part, irc_cmd_recv_part },
{ "ping", N_("ping server"),
N_("server1 [server2]"),
@@ -136,7 +134,7 @@ t_irc_command irc_commands[] =
1, 2, 1, irc_cmd_send_pong, NULL, NULL },
{ "privmsg", N_("message received"),
"", "",
0, 0, 1, NULL, NULL, irc_cmd_recv_privmsg },
0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_privmsg },
{ "quit", N_("close all connections & quit " WEECHAT_NAME),
N_("[quit_message]"),
N_("quit_message: quit message (displayed to other users)"),
@@ -145,12 +143,6 @@ t_irc_command irc_commands[] =
N_("data"),
N_("data: raw data to send"),
1, MAX_ARGS, 1, NULL, irc_cmd_send_quote, NULL },
{ "rehash", N_("tell the server to reload its config file"),
"", "",
0, 0, 1, NULL, irc_cmd_send_rehash, NULL },
{ "restart", N_("tell the server to restart itself"),
"", "",
0, 0, 1, NULL, irc_cmd_send_restart, NULL },
{ "topic", N_("get/set channel topic"),
N_("[channel] [topic]"), N_("channel: channel name\ntopic: new topic for channel "
"(if topic is \"-delete\" then topic is deleted)"),
@@ -331,6 +323,11 @@ irc_recv_command (t_irc_server *server,
{
int i, cmd_found;
#if DEBUG >= 2
gui_printf (server->window, "recv_irc_command: cmd=%s args=%s\n",
command, arguments);
#endif
if (command == NULL)
return -2;
@@ -370,8 +367,8 @@ irc_login (t_irc_server *server)
if (!hostname[0])
strcpy (hostname, _("unknown"));
gui_printf (server->window,
_("%s: using local hostname \"%s\"\n"),
WEECHAT_NAME, hostname);
_(WEECHAT_NAME ": using local hostname \"%s\"\n"),
hostname);
server_sendf (server,
"NICK %s\r\n"
"USER %s %s %s :%s\r\n",
@@ -487,8 +484,8 @@ irc_cmd_send_deop (t_irc_server *server, int argc, char **argv)
}
else
gui_printf (server->window,
_("%s \"%s\" command can only be executed in a channel window\n"),
WEECHAT_ERROR, "deop");
_("%s \"deop\" command can only be executed in a channel window\n"),
WEECHAT_ERROR);
return 0;
}
@@ -511,8 +508,8 @@ irc_cmd_send_devoice (t_irc_server *server, int argc, char **argv)
else
{
gui_printf (server->window,
_("%s \"%s\" command can only be executed in a channel window\n"),
WEECHAT_ERROR, "devoice");
_("%s \"devoice\" command can only be executed in a channel window\n"),
WEECHAT_ERROR);
return -1;
}
return 0;
@@ -560,8 +557,8 @@ irc_cmd_send_kick (t_irc_server *server, char *arguments)
else
{
gui_printf (server->window,
_("%s \"%s\" command can only be executed in a channel window\n"),
WEECHAT_ERROR, "kick");
_("%s \"kick\" command can only be executed in a channel window\n"),
WEECHAT_ERROR);
return -1;
}
}
@@ -603,8 +600,8 @@ irc_cmd_send_me (t_irc_server *server, char *arguments)
if (WIN_IS_SERVER(gui_current_window))
{
gui_printf (server->window,
_("%s \"%s\" command can not be executed on a server window\n"),
WEECHAT_ERROR, "me");
_("%s \"me\" command can not be executed on a server window\n"),
WEECHAT_ERROR);
return -1;
}
server_sendf (server, "PRIVMSG %s :\01ACTION %s\01\r\n",
@@ -655,97 +652,66 @@ irc_cmd_send_msg (t_irc_server *server, char *arguments)
pos_comma[0] = '\0';
pos_comma++;
}
if (strcmp (arguments, "*") == 0)
if (string_is_channel (arguments))
{
if (WIN_IS_SERVER(gui_current_window))
ptr_channel = channel_search (server, arguments);
if (ptr_channel)
{
gui_printf (server->window,
_("%s \"%s\" command can not be executed on a server window\n"),
WEECHAT_ERROR, "msg *");
return -1;
ptr_nick = nick_search (ptr_channel, server->nick);
if (ptr_nick)
{
irc_display_nick (ptr_channel->window, ptr_nick,
MSG_TYPE_NICK, 1, 1, 0);
gui_printf_color_type (ptr_channel->window,
MSG_TYPE_MSG,
COLOR_WIN_CHAT, "%s\n", pos);
}
else
gui_printf (server->window,
_("%s nick not found for \"privmsg\" command\n"),
WEECHAT_ERROR);
}
ptr_channel = CHANNEL(gui_current_window);
ptr_nick = nick_search (ptr_channel, server->nick);
if (ptr_nick)
{
irc_display_nick (ptr_channel->window, ptr_nick,
MSG_TYPE_NICK, 1, 1, 0);
gui_printf_color_type (ptr_channel->window,
MSG_TYPE_MSG,
COLOR_WIN_CHAT, "%s\n", pos);
}
else
gui_printf (server->window,
_("%s nick not found for \"%s\" command\n"),
WEECHAT_ERROR, "msg");
server_sendf (server, "PRIVMSG %s :%s\r\n", ptr_channel->name, pos);
server_sendf (server, "PRIVMSG %s :%s\r\n", arguments, pos);
}
else
{
if (string_is_channel (arguments))
ptr_channel = channel_search (server, arguments);
if (!ptr_channel)
{
ptr_channel = channel_search (server, arguments);
if (ptr_channel)
{
ptr_nick = nick_search (ptr_channel, server->nick);
if (ptr_nick)
{
irc_display_nick (ptr_channel->window, ptr_nick,
MSG_TYPE_NICK, 1, 1, 0);
gui_printf_color_type (ptr_channel->window,
MSG_TYPE_MSG,
COLOR_WIN_CHAT, "%s\n", pos);
}
else
gui_printf (server->window,
_("%s nick not found for \"%s\" command\n"),
WEECHAT_ERROR, "msg");
}
server_sendf (server, "PRIVMSG %s :%s\r\n", arguments, pos);
}
else
{
ptr_channel = channel_search (server, arguments);
ptr_channel = channel_new (server, CHAT_PRIVATE, arguments);
if (!ptr_channel)
{
ptr_channel = channel_new (server, CHAT_PRIVATE, arguments);
if (!ptr_channel)
{
gui_printf (server->window,
_("%s cannot create new private window \"%s\"\n"),
WEECHAT_ERROR,
arguments);
return -1;
}
gui_redraw_window_title (ptr_channel->window);
gui_printf (server->window,
_("%s cannot create new private window \"%s\"\n"),
WEECHAT_ERROR,
arguments);
return -1;
}
gui_printf_color_type (ptr_channel->window,
MSG_TYPE_NICK,
COLOR_WIN_CHAT_DARK, "<");
gui_printf_color_type (ptr_channel->window,
MSG_TYPE_NICK,
COLOR_WIN_NICK_SELF,
"%s", server->nick);
gui_printf_color_type (ptr_channel->window,
MSG_TYPE_NICK,
COLOR_WIN_CHAT_DARK, "> ");
gui_printf_color_type (ptr_channel->window,
MSG_TYPE_MSG,
COLOR_WIN_CHAT, "%s\n", pos);
server_sendf (server, "PRIVMSG %s :%s\r\n", arguments, pos);
gui_redraw_window_title (ptr_channel->window);
}
gui_printf_color_type (ptr_channel->window,
MSG_TYPE_NICK,
COLOR_WIN_CHAT_DARK, "<");
gui_printf_color_type (ptr_channel->window,
MSG_TYPE_NICK,
COLOR_WIN_NICK_SELF,
"%s", server->nick);
gui_printf_color_type (ptr_channel->window,
MSG_TYPE_NICK,
COLOR_WIN_CHAT_DARK, "> ");
gui_printf_color_type (ptr_channel->window,
MSG_TYPE_MSG,
COLOR_WIN_CHAT, "%s\n", pos);
server_sendf (server, "PRIVMSG %s :%s\r\n", arguments, pos);
}
arguments = pos_comma;
}
}
else
{
gui_printf (server->window,
_("%s wrong argument count for \"%s\" command\n"),
WEECHAT_ERROR, "msg");
return -1;
}
_("%s wrong number of args for \"privmsg\" command\n"),
WEECHAT_ERROR);
return 0;
}
@@ -763,8 +729,8 @@ irc_cmd_send_names (t_irc_server *server, char *arguments)
if (!WIN_IS_CHANNEL(gui_current_window))
{
gui_printf (server->window,
_("%s \"%s\" command can only be executed in a channel window\n"),
WEECHAT_ERROR, "names");
_("%s \"names\" command can only be executed in a channel window\n"),
WEECHAT_ERROR);
return -1;
}
else
@@ -817,8 +783,8 @@ irc_cmd_send_op (t_irc_server *server, int argc, char **argv)
else
{
gui_printf (server->window,
_("%s \"%s\" command can only be executed in a channel window\n"),
WEECHAT_ERROR, "op");
_("%s \"op\" command can only be executed in a channel window\n"),
WEECHAT_ERROR);
return -1;
}
return 0;
@@ -866,8 +832,8 @@ irc_cmd_send_part (t_irc_server *server, char *arguments)
if (WIN_IS_SERVER(gui_current_window))
{
gui_printf (server->window,
_("%s \"%s\" command can not be executed on a server window\n"),
WEECHAT_ERROR, "part");
_("%s \"part\" command can not be executed on a server window\n"),
WEECHAT_ERROR);
return -1;
}
channel_name = CHANNEL(gui_current_window)->name;
@@ -879,8 +845,8 @@ irc_cmd_send_part (t_irc_server *server, char *arguments)
if (WIN_IS_SERVER(gui_current_window))
{
gui_printf (server->window,
_("%s \"%s\" command can not be executed on a server window\n"),
WEECHAT_ERROR, "part");
_("%s \"part\" command can not be executed on a server window\n"),
WEECHAT_ERROR);
return -1;
}
if (WIN_IS_PRIVATE(gui_current_window))
@@ -962,34 +928,6 @@ irc_cmd_send_quote (t_irc_server *server, char *arguments)
return 0;
}
/*
* irc_cmd_send_rehash: tell the server to reload its config file
*/
int
irc_cmd_send_rehash (t_irc_server *server, char *arguments)
{
/* make gcc happy */
(void) arguments;
server_sendf (server, "REHASH\r\n");
return 0;
}
/*
* irc_cmd_send_restart: tell the server to restart itself
*/
int
irc_cmd_send_restart (t_irc_server *server, char *arguments)
{
/* make gcc happy */
(void) arguments;
server_sendf (server, "RESTART\r\n");
return 0;
}
/*
* irc_cmd_send_topic: get/set topic for a channel
*/
@@ -1027,8 +965,8 @@ irc_cmd_send_topic (t_irc_server *server, char *arguments)
if (WIN_IS_SERVER(gui_current_window))
{
gui_printf (server->window,
_("%s \"%s\" command can not be executed on a server window\n"),
WEECHAT_ERROR, "topic");
_("%s \"topic\" command can not be executed on a server window\n"),
WEECHAT_ERROR);
return -1;
}
channel_name = CHANNEL(gui_current_window)->name;
@@ -1066,7 +1004,7 @@ irc_cmd_send_version (t_irc_server *server, char *arguments)
else
{
irc_display_prefix (server->window, PREFIX_INFO);
gui_printf (server->window, _("%s, compiled on %s %s\n"),
gui_printf (server->window, "%s, compiled on %s %s\n",
WEECHAT_NAME_AND_VERSION,
__DATE__, __TIME__);
server_sendf (server, "VERSION\r\n");
@@ -1093,8 +1031,8 @@ irc_cmd_send_voice (t_irc_server *server, int argc, char **argv)
else
{
gui_printf (server->window,
_("%s \"%s\" command can only be executed in a channel window\n"),
WEECHAT_ERROR, "voice");
_("%s \"voice\" command can only be executed in a channel window\n"),
WEECHAT_ERROR);
return -1;
}
return 0;
@@ -1254,8 +1192,8 @@ irc_cmd_recv_kick (t_irc_server *server, char *host, char *arguments)
if (!ptr_channel)
{
gui_printf (server->window,
_("%s channel not found for \"%s\" command\n"),
WEECHAT_ERROR, "kick");
_("%s channel not found for \"kick\" command\n"),
WEECHAT_ERROR);
return -1;
}
@@ -1286,8 +1224,8 @@ irc_cmd_recv_kick (t_irc_server *server, char *host, char *arguments)
else
{
gui_printf (server->window,
_("%s nick not found for \"%s\" command\n"),
WEECHAT_ERROR, "kick");
_("%s nick not found for \"kick\" command\n"),
WEECHAT_ERROR);
return -1;
}
ptr_nick = nick_search (ptr_channel, pos_nick);
@@ -1315,8 +1253,8 @@ irc_cmd_recv_mode (t_irc_server *server, char *host, char *arguments)
if (host == NULL)
{
gui_printf (server->window,
_("%s \"%s\" command received without host\n"),
WEECHAT_ERROR, "mode");
_("%s \"mode\" command received without host\n"),
WEECHAT_ERROR);
return -1;
}
@@ -1329,8 +1267,8 @@ irc_cmd_recv_mode (t_irc_server *server, char *host, char *arguments)
if (!pos)
{
gui_printf (server->window,
_("%s \"%s\" command received without channel or nickname\n"),
WEECHAT_ERROR, "mode");
_("%s \"mode\" command received without channel or nickname\n"),
WEECHAT_ERROR);
return -1;
}
pos[0] = '\0';
@@ -1470,8 +1408,8 @@ irc_cmd_recv_mode (t_irc_server *server, char *host, char *arguments)
else
{
gui_printf (server->window,
_("%s channel not found for \"%s\" command\n"),
WEECHAT_ERROR, "mode");
_("%s channel not found for \"mode\" command\n"),
WEECHAT_ERROR);
return -1;
}
}
@@ -1499,8 +1437,8 @@ irc_cmd_recv_nick (t_irc_server *server, char *host, char *arguments)
if (host == NULL)
{
gui_printf (server->window,
_("%s \"%s\" command received without host\n"),
WEECHAT_ERROR, "nick");
_("%s \"nick\" command received without host\n"),
WEECHAT_ERROR);
return -1;
}
@@ -1581,8 +1519,8 @@ irc_cmd_recv_notice (t_irc_server *server, char *host, char *arguments)
else
{
gui_printf (server->window,
_("%s nickname not found for \"%s\" command\n"),
WEECHAT_ERROR, "notice");
_("%s nickname not found for \"notice\" command\n"),
WEECHAT_ERROR);
return -1;
}
irc_display_prefix (server->window, PREFIX_SERVER);
@@ -1593,9 +1531,9 @@ irc_cmd_recv_notice (t_irc_server *server, char *host, char *arguments)
if (pos2)
pos2[0] = '\0';
gui_printf_color (server->window, COLOR_WIN_CHAT, "CTCP ");
gui_printf_color (server->window, COLOR_WIN_CHAT_CHANNEL, "VERSION ");
gui_printf_color (server->window, COLOR_WIN_CHAT, _("reply from"));
gui_printf_color (server->window, COLOR_WIN_CHAT_NICK, " %s", host);
gui_printf_color (server->window, COLOR_WIN_CHAT_CHANNEL, "VERSION");
gui_printf_color (server->window, COLOR_WIN_CHAT, " reply from ");
gui_printf_color (server->window, COLOR_WIN_CHAT_NICK, "%s", host);
gui_printf_color (server->window, COLOR_WIN_CHAT, ": %s\n", pos);
}
else
@@ -1618,8 +1556,8 @@ irc_cmd_recv_part (t_irc_server *server, char *host, char *arguments)
if (!host || !arguments)
{
gui_printf (server->window,
_("%s \"%s\" command received without host or channel\n"),
WEECHAT_ERROR, "part");
_("%s \"part\" command received without host or channel\n"),
WEECHAT_ERROR);
return -1;
}
@@ -1692,8 +1630,8 @@ irc_cmd_recv_part (t_irc_server *server, char *host, char *arguments)
else
{
gui_printf (server->window,
_("%s channel not found for \"%s\" command\n"),
WEECHAT_ERROR, "part");
_("%s channel not found for \"part\" command\n"),
WEECHAT_ERROR);
return -1;
}
@@ -1727,14 +1665,13 @@ irc_cmd_recv_privmsg (t_irc_server *server, char *host, char *arguments)
char *pos, *pos2, *host2;
t_irc_channel *ptr_channel;
t_irc_nick *ptr_nick;
struct utsname *buf;
/* no host => we can't identify sender of message! */
if (host == NULL)
{
gui_printf (server->window,
_("%s \"%s\" command received without host\n"),
WEECHAT_ERROR, "privmsg");
_("%s \"privmsg\" command received without host\n"),
WEECHAT_ERROR);
return -1;
}
@@ -1790,8 +1727,8 @@ irc_cmd_recv_privmsg (t_irc_server *server, char *host, char *arguments)
else
{
gui_printf (server->window,
_("%s nick not found for \"%s\" command\n"),
WEECHAT_ERROR, "privmsg");
_("%s nick not found for \"privmsg\" command\n"),
WEECHAT_ERROR);
return -1;
}
}
@@ -1799,8 +1736,8 @@ irc_cmd_recv_privmsg (t_irc_server *server, char *host, char *arguments)
else
{
gui_printf (server->window,
_("%s channel not found for \"%s\" command\n"),
WEECHAT_ERROR, "privmsg");
_("%s channel not found for \"privmsg\" command\n"),
WEECHAT_ERROR);
return -1;
}
}
@@ -1822,27 +1759,11 @@ irc_cmd_recv_privmsg (t_irc_server *server, char *host, char *arguments)
pos++;
if (strcmp (pos, "\01VERSION\01") == 0)
{
buf = (struct utsname *) malloc (sizeof (struct utsname));
uname (buf);
server_sendf (server,
_("NOTICE %s :%sVERSION %s v%s"
" compiled on %s, host \"%s\" is running "
"%s %s / %s%s"),
host, "\01", WEECHAT_NAME, WEECHAT_VERSION, __DATE__,
&buf->nodename, &buf->sysname,
&buf->release, &buf->machine, "\01\r\n");
free (buf);
irc_display_prefix (server->window, PREFIX_INFO);
gui_printf_color (server->window,
COLOR_WIN_CHAT, _("Received a "));
gui_printf_color (server->window,
COLOR_WIN_CHAT_CHANNEL, _("CTCP VERSION "));
gui_printf_color (server->window,
COLOR_WIN_CHAT, _("from"));
gui_printf_color (server->window,
COLOR_WIN_CHAT_NICK, " %s\n", host);
}
"NOTICE %s :\01VERSION "
WEECHAT_NAME " v"
WEECHAT_VERSION ", compiled on " __DATE__ "\01\r\n",
host);
else
{
/* private message received */
@@ -1882,8 +1803,8 @@ irc_cmd_recv_privmsg (t_irc_server *server, char *host, char *arguments)
else
{
gui_printf (server->window,
_("%s cannot parse \"%s\" command\n"),
WEECHAT_ERROR, "privmsg");
_("%s cannot parse \"privmsg\" command\n"),
WEECHAT_ERROR);
return -1;
}
}
@@ -1905,8 +1826,8 @@ irc_cmd_recv_quit (t_irc_server *server, char *host, char *arguments)
if (host == NULL)
{
gui_printf (server->window,
_("%s \"%s\" command received without host\n"),
WEECHAT_ERROR, "quit");
_("%s \"quit\" command received without host\n"),
WEECHAT_ERROR);
return -1;
}
@@ -1935,11 +1856,11 @@ irc_cmd_recv_quit (t_irc_server *server, char *host, char *arguments)
gui_printf_color (ptr_channel->window,
COLOR_WIN_CHAT_HOST, "%s", pos + 1);
gui_printf_color (ptr_channel->window,
COLOR_WIN_CHAT_DARK, ") ");
COLOR_WIN_CHAT_DARK, ")");
gui_printf_color (ptr_channel->window,
COLOR_WIN_CHAT, _("has quit"));
COLOR_WIN_CHAT, _(" has quit "));
gui_printf_color (ptr_channel->window,
COLOR_WIN_CHAT_DARK, " (");
COLOR_WIN_CHAT_DARK, "(");
gui_printf_color (ptr_channel->window,
COLOR_WIN_CHAT, "%s",
arguments);
@@ -2054,11 +1975,11 @@ irc_cmd_recv_topic (t_irc_server *server, char *host, char *arguments)
if (pos)
pos[0] = '\0';
if (!string_is_channel (arguments))
if (string_is_channel (arguments))
{
gui_printf (server->window,
_("%s \"%s\" command received without channel\n"),
WEECHAT_ERROR, "topic");
_("%s \"topic\" command received without channel\n"),
WEECHAT_ERROR);
return -1;
}
@@ -2117,7 +2038,7 @@ irc_cmd_recv_topic (t_irc_server *server, char *host, char *arguments)
}
/*
* irc_cmd_recv_004: '004' command (connected to irc server)
* irc_cmd_recv_004: '004' command (connected to irc server ?????)
*/
int
@@ -2133,15 +2054,6 @@ irc_cmd_recv_004 (t_irc_server *server, char *host, char *arguments)
server->is_connected = 1;
gui_redraw_window_status (server->window);
gui_redraw_window_input (server->window);
/* execute command once connected */
if (server->command && server->command[0])
user_command(server, server->command);
/* autojoin */
if (server->autojoin && server->autojoin[0])
return irc_cmd_send_join (server, server->autojoin);
return 0;
}
@@ -2761,8 +2673,8 @@ irc_cmd_recv_332 (t_irc_server *server, char *host, char *arguments)
else
{
gui_printf (server->window,
_("%s channel not found for \"%s\" command\n"),
WEECHAT_ERROR, "332");
_("%s channel not found for \"332\" command\n"),
WEECHAT_ERROR);
return -1;
}
}
@@ -2770,8 +2682,8 @@ irc_cmd_recv_332 (t_irc_server *server, char *host, char *arguments)
else
{
gui_printf (server->window,
_("%s cannot identify channel for \"%s\" command\n"),
WEECHAT_ERROR, "332");
_("%s cannot identify channel for \"332\" command\n"),
WEECHAT_ERROR);
return -1;
}
return 0;
@@ -2826,32 +2738,32 @@ irc_cmd_recv_333 (t_irc_server *server, char *host, char *arguments)
else
{
gui_printf (server->window,
_("%s channel not found for \"%s\" command\n"),
WEECHAT_ERROR, "333");
_("%s channel not found for \"333\" command\n"),
WEECHAT_ERROR);
return -1;
}
}
else
{
gui_printf (server->window,
_("%s cannot identify date/time for \"%s\" command\n"),
WEECHAT_ERROR, "333");
_("%s cannot identify date/time for \"333\" command\n"),
WEECHAT_ERROR);
return -1;
}
}
else
{
gui_printf (server->window,
_("%s cannot identify nickname for \"%s\" command\n"),
WEECHAT_ERROR, "333");
_("%s cannot identify nickname for \"333\" command\n"),
WEECHAT_ERROR);
return -1;
}
}
else
{
gui_printf (server->window,
_("%s cannot identify channel for \"%s\" command\n"),
WEECHAT_ERROR, "333");
_("%s cannot identify channel for \"333\" command\n"),
WEECHAT_ERROR);
return -1;
}
return 0;
@@ -2926,8 +2838,8 @@ irc_cmd_recv_353 (t_irc_server *server, char *host, char *arguments)
if (pos[0] != ':')
{
gui_printf (server->window,
_("%s cannot parse \"%s\" command\n"),
WEECHAT_ERROR, "353");
_("%s cannot parse \"353\" command\n"),
WEECHAT_ERROR);
return -1;
}
pos++;
@@ -2966,8 +2878,8 @@ irc_cmd_recv_353 (t_irc_server *server, char *host, char *arguments)
else
{
gui_printf (server->window,
_("%s cannot parse \"%s\" command\n"),
WEECHAT_ERROR, "353");
_("%s cannot parse \"353\" command\n"),
WEECHAT_ERROR);
return -1;
}
return 0;
@@ -3108,9 +3020,10 @@ irc_cmd_recv_433 (t_irc_server *server, char *host, char *arguments)
if (strcmp (server->nick, server->nick1) == 0)
{
gui_printf (server->window,
_("%s: nickname \"%s\" is already in use, "
_(WEECHAT_NAME
": nickname \"%s\" is already in use, "
"trying 2nd nickname \"%s\"\n"),
WEECHAT_NAME, server->nick, server->nick2);
server->nick, server->nick2);
free (server->nick);
server->nick = strdup (server->nick2);
}
@@ -3119,18 +3032,19 @@ irc_cmd_recv_433 (t_irc_server *server, char *host, char *arguments)
if (strcmp (server->nick, server->nick2) == 0)
{
gui_printf (server->window,
_("%s: nickname \"%s\" is already in use, "
_(WEECHAT_NAME
": nickname \"%s\" is already in use, "
"trying 3rd nickname \"%s\"\n"),
WEECHAT_NAME, server->nick, server->nick3);
server->nick, server->nick3);
free (server->nick);
server->nick = strdup (server->nick3);
}
else
{
gui_printf (server->window,
_("%s: all declared nicknames are already in use, "
"closing connection with server!\n"),
WEECHAT_NAME);
_(WEECHAT_NAME
": all declared nicknames are already in use, "
"closing connection with server!\n"));
server_disconnect (server);
return 0;
}
+65 -116
View File
@@ -49,36 +49,6 @@ t_irc_message *recv_msgq, *msgq_last_msg;
char *unterminated_message = NULL;
/*
* server_init: init server struct with default values
*/
void
server_init (t_irc_server *server)
{
server->name = NULL;
server->autoconnect = 0;
server->address = NULL;
server->port = -1;
server->password = NULL;
server->nick1 = NULL;
server->nick2 = NULL;
server->nick3 = NULL;
server->username = NULL;
server->realname = NULL;
server->command = NULL;
server->autojoin = NULL;
server->nick = NULL;
server->is_connected = 0;
server->sock4 = -1;
server->is_away = 0;
server->server_read = -1;
server->server_write = -1;
server->window = NULL;
server->channels = NULL;
server->last_channel = NULL;
}
/*
* server_alloc: allocate a new server and add it to the servers queue
*/
@@ -95,12 +65,28 @@ server_alloc ()
/* alloc memory for new server */
if ((new_server = (t_irc_server *) malloc (sizeof (t_irc_server))) == NULL)
{
fprintf (stderr, _("%s cannot allocate new server\n"), WEECHAT_ERROR);
fprintf (stderr, _("%s cannot allocate new server"), WEECHAT_ERROR);
return NULL;
}
/* initialize new server */
server_init (new_server);
new_server->name = NULL;
new_server->address = NULL;
new_server->password = NULL;
new_server->nick1 = NULL;
new_server->nick2 = NULL;
new_server->nick3 = NULL;
new_server->username = NULL;
new_server->realname = NULL;
new_server->nick = NULL;
new_server->is_connected = 0;
new_server->sock4 = -1;
new_server->is_away = 0;
new_server->server_read = -1;
new_server->server_write = -1;
new_server->window = NULL;
new_server->channels = NULL;
new_server->last_channel = NULL;
/* add new server to queue */
new_server->prev_server = last_irc_server;
@@ -116,12 +102,42 @@ server_alloc ()
}
/*
* server_destroy: free server data (not struct himself)
* server_create_window: create windows for a server
*/
void
server_destroy (t_irc_server *server)
server_create_window (t_irc_server *server)
{
if (!SERVER(gui_windows))
{
server->window = gui_windows;
gui_windows->server = server;
}
else
gui_window_new (server, NULL);
}
/*
* server_free: free a server and remove it from servers queue
*/
void
server_free (t_irc_server *server)
{
t_irc_server *new_irc_servers;
/* remove server from queue */
if (server->prev_server)
{
(server->prev_server)->next_server = server->next_server;
new_irc_servers = irc_servers;
}
else
new_irc_servers = server->next_server;
if (server->next_server)
(server->next_server)->prev_server = server->prev_server;
/* free data */
if (server->name)
free (server->name);
@@ -139,42 +155,12 @@ server_destroy (t_irc_server *server)
free (server->username);
if (server->realname)
free (server->realname);
if (server->command)
free (server->command);
if (server->autojoin)
free (server->autojoin);
if (server->nick)
free (server->nick);
if (server->channels)
channel_free_all (server);
}
/*
* server_free: free a server and remove it from servers queue
*/
void
server_free (t_irc_server *server)
{
t_irc_server *new_irc_servers;
/* remove server from queue */
if (last_irc_server == server)
last_irc_server = server->prev_server;
if (server->prev_server)
{
(server->prev_server)->next_server = server->next_server;
new_irc_servers = irc_servers;
}
else
new_irc_servers = server->next_server;
if (server->next_server)
(server->next_server)->prev_server = server->prev_server;
server_destroy (server);
if (server->window)
gui_window_free (server->window);
/* TODO: free weechat window (???) */
/* (...) */
free (server);
irc_servers = new_irc_servers;
}
@@ -196,29 +182,26 @@ server_free_all ()
*/
t_irc_server *
server_new (char *name, int autoconnect, char *address, int port,
char *password, char *nick1, char *nick2, char *nick3,
char *username, char *realname, char *command, char *autojoin)
server_new (char *name, char *address, int port, char *password,
char *nick1, char *nick2, char *nick3,
char *username, char *realname)
{
t_irc_server *new_server;
if (!name || !address || (port < 0))
if (!name || !address || (port < 0) || !nick1 || !nick2 || !nick3
|| !username || !realname)
return NULL;
#if DEBUG >= 1
log_printf ("creating new server (name:%s, address:%s, port:%d, pwd:%s, "
"nick1:%s, nick2:%s, nick3:%s, username:%s, realname:%s, "
"command:%s, autojoin:%s)\n",
name, address, port, (password) ? password : "",
(nick1) ? nick1 : "", (nick2) ? nick2 : "", (nick3) ? nick3 : "",
(username) ? username : "", (realname) ? realname : "",
(command) ? command : "", (autojoin) ? autojoin : "");
"nick1:%s, nick2:%s, nick3:%s, username:%s, realname:%s)\n",
name, address, port, password, nick1, nick2, nick3,
username, realname);
#endif
if ((new_server = server_alloc ()))
{
new_server->name = strdup (name);
new_server->autoconnect = autoconnect;
new_server->address = strdup (address);
new_server->port = port;
new_server->password = (password) ? strdup (password) : strdup ("");
@@ -229,10 +212,6 @@ server_new (char *name, int autoconnect, char *address, int port,
(username) ? strdup (username) : strdup ("weechat");
new_server->realname =
(realname) ? strdup (realname) : strdup ("realname");
new_server->command =
(command) ? strdup (command) : NULL;
new_server->autojoin =
(autojoin) ? strdup (autojoin) : NULL;
new_server->nick = strdup (new_server->nick1);
}
else
@@ -479,9 +458,9 @@ server_connect (t_irc_server *server)
int server_pipe[2];
gui_printf (server->window,
_("%s: connecting to %s:%d...\n"),
WEECHAT_NAME, server->address, server->port);
log_printf (_("connecting to server %s:%d...\n"),
_(WEECHAT_NAME ": connecting to %s:%d...\n"),
server->address, server->port);
log_printf ("connecting to server %s:%d...\n",
server->address, server->port);
server->is_connected = 0;
@@ -503,7 +482,7 @@ server_connect (t_irc_server *server)
(server->sock4, SOL_SOCKET, SO_REUSEADDR, (char *) &set,
sizeof (set)) == -1)
gui_printf (server->window,
_("%s cannot set socket option \"SO_REUSEADDR\"\n"),
_("%s cannot set socket option 'SO_REUSEADDR'\n"),
WEECHAT_ERROR);
set = 1;
if (setsockopt
@@ -551,7 +530,7 @@ server_connect (t_irc_server *server)
/* connection to server */
gui_printf (server->window,
_("%s: server IP is: %s\n"), WEECHAT_NAME, ip_address);
_(WEECHAT_NAME ": server IP is: %s\n"), ip_address);
error = connect (server->sock4, (struct sockaddr *) &addr, sizeof (addr));
if (error != 0)
@@ -576,24 +555,12 @@ server_connect (t_irc_server *server)
void
server_disconnect (t_irc_server *server)
{
t_irc_channel *ptr_channel;
if (server->is_connected)
{
/* write disconnection message on each channel/private window */
for (ptr_channel = server->channels; ptr_channel;
ptr_channel = ptr_channel->next_channel)
{
irc_display_prefix (ptr_channel->window, PREFIX_INFO);
gui_printf (ptr_channel->window, _("Disconnected from server!\n"));
}
/* close communication with server */
close (server->server_read);
close (server->server_write);
close (server->sock4);
server->is_connected = 0;
server->sock4 = -1;
}
}
@@ -610,24 +577,6 @@ server_disconnect_all ()
server_disconnect (ptr_server);
}
/*
* server_search: return pointer on a server with a name
*/
t_irc_server *
server_search (char *servername)
{
t_irc_server *ptr_server;
for (ptr_server = irc_servers; ptr_server;
ptr_server = ptr_server->next_server)
{
if (strcmp (ptr_server->name, servername) == 0)
return ptr_server;
}
return NULL;
}
/*
* server_get_number_connected: returns number of connected server
*/
+3 -10
View File
@@ -78,7 +78,6 @@ struct t_irc_server
{
/* user choices */
char *name; /* name of server (only for display) */
int autoconnect; /* = 1 if auto connect at startup */
char *address; /* address of server (IP or name) */
int port; /* port for server (6667 by default) */
char *password; /* password for server */
@@ -87,8 +86,6 @@ struct t_irc_server
char *nick3; /* 2nd alternate nickname */
char *username; /* user name */
char *realname; /* real name */
char *command; /* command to run once connected */
char *autojoin; /* channels to automatically join */
/* internal vars */
char *nick; /* current nickname */
@@ -140,20 +137,18 @@ extern t_irc_channel *current_channel;
/* server functions (irc-server.c) */
extern void server_init (t_irc_server *);
extern t_irc_server *server_alloc ();
extern void server_destroy (t_irc_server *);
extern void server_create_window (t_irc_server *);
extern void server_free (t_irc_server *);
extern void server_free_all ();
extern t_irc_server *server_new (char *, int, char *, int, char *, char *,
char *, char *, char *, char *, char *, char *);
extern t_irc_server *server_new (char *, char *, int, char *, char *, char *,
char *, char *, char *);
extern int server_send (t_irc_server *, char *, int);
extern int server_sendf (t_irc_server *, char *, ...);
extern void server_recv (t_irc_server *);
extern int server_connect ();
extern void server_disconnect (t_irc_server *);
extern void server_disconnect_all ();
extern t_irc_server *server_search (char *);
extern int server_get_number_connected ();
extern int server_name_already_exists (char *);
@@ -210,8 +205,6 @@ extern int irc_cmd_send_ping (t_irc_server *, int, char **);
extern int irc_cmd_send_pong (t_irc_server *, int, char **);
extern int irc_cmd_send_quit (t_irc_server *, char *);
extern int irc_cmd_send_quote (t_irc_server *, char *);
extern int irc_cmd_send_rehash (t_irc_server *, char *);
extern int irc_cmd_send_restart (t_irc_server *, char *);
extern int irc_cmd_send_topic (t_irc_server *, char *);
extern int irc_cmd_send_version (t_irc_server *, char *);
extern int irc_cmd_send_voice (t_irc_server *, int, char **);
+8 -18
View File
@@ -211,8 +211,8 @@ wee_init_log ()
void
wee_shutdown ()
{
server_free_all ();
gui_end ();
server_free_all ();
if (log_file)
fclose (log_file);
exit (0);
@@ -227,10 +227,6 @@ main (int argc, char *argv[])
{
t_irc_server *ptr_server;
setlocale (LC_ALL, "");
bindtextdomain (PACKAGE, "/usr/share/locale");
textdomain (PACKAGE);
/* initialize variables */
wee_init_vars ();
@@ -243,9 +239,6 @@ main (int argc, char *argv[])
/* init log file */
wee_init_log ();
/* build commands index (sorted), for completion */
index_command_build ();
/* read configuration */
switch (config_read ())
{
@@ -263,6 +256,9 @@ main (int argc, char *argv[])
/* init gui */
gui_init ();
/* build commands index (sorted), for completion */
index_command_build ();
/* Welcome message - yeah! */
if (cfg_look_startup_logo)
{
@@ -296,23 +292,17 @@ main (int argc, char *argv[])
gui_printf_color (NULL, COLOR_WIN_CHAT_PREFIX1,
"-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n");
/* connect to all servers (with autoconnect flag) */
/* connect to all servers */
for (ptr_server = irc_servers; ptr_server;
ptr_server = ptr_server->next_server)
{
if (ptr_server->autoconnect)
{
gui_window_new (ptr_server, NULL);
if (server_connect (ptr_server))
irc_login (ptr_server);
}
server_create_window (ptr_server);
if (server_connect (ptr_server))
irc_login (ptr_server);
}
gui_main_loop ();
server_disconnect_all ();
/* save config file */
config_write (NULL);
/* program ending */
wee_shutdown ();
+1 -3
View File
@@ -24,15 +24,13 @@
#define __WEECHAT_H 1
#include <stdio.h>
#include <locale.h>
#include <libintl.h>
#define PACKAGE "weechat"
#define _(string) gettext(string)
#define N_(string) (string)
#define WEECHAT_NAME "WeeChat"
#define WEECHAT_VERSION "0.0.2"
#define WEECHAT_VERSION "0.0.1"
#define WEECHAT_NAME_AND_VERSION WEECHAT_NAME " " WEECHAT_VERSION
#define WEECHAT_COPYRIGHT WEECHAT_NAME " (c) 2003 by Wee Team"
+4 -14
View File
@@ -1,7 +1,7 @@
.TH WEECHAT 1 "October 2003" "FlashCode"
.TH WEECHAT 1 "September 2003" "FlashCode"
.SH NAME
weechat \- Wee Enhanced Environment for Chat
weechat \- wee enhanced environment for chat
.SH SYNOPSIS
.B weechat
@@ -9,11 +9,8 @@ weechat \- Wee Enhanced Environment for Chat
.br
.SH DESCRIPTION
Fast, light and extensible IRC client for many operating systems.
.br
Everything can be done with a keyboard. It is customizable and extensible with scripts.
Many GUIs are available (Curses, Gtk, Qt, and text).
It is compliant with RFCs 1459, 2810, 2811, 2812, and 2813.
Fast, light and extensible IRC client for many operating systems. Everything can be
done with a keyboard. It is customizable and extensible with scripts.
.SH OPTIONS
.TP
@@ -33,9 +30,6 @@ display WeeChat version
.TP
.B $HOME/.weechat/weechat.rc
configuration file for WeeChat
.TP
.B $HOME/.weechat/weechat.log
WeeChat log file
.SH AUTHOR
WeeChat is written by:
@@ -47,8 +41,4 @@ WeeChat is written by:
WeeChat on the web:
.UR
http://weechat.flashtux.org
.br
Get support there:
.UR
http://weechat.flashtux.org/support.php
.UE
+2 -4
View File
@@ -1,5 +1,5 @@
%define name weechat
%define version 0.0.2
%define version 0.0.1
%define release 1
Name: %{name}
@@ -37,7 +37,5 @@ rm -rf $RPM_BUILD_ROOT
/usr/local/bin/weechat
%changelog
* Sun Oct 05 2003 FlashCode <flashcode@flashtux.org> 0.0.2-1
- Released version 0.0.2
* Sat Sep 27 2003 FlashCode <flashcode@flashtux.org> 0.0.1-1
* Thu Sep 27 2003 FlashCode <flashcode@flashtux.org> 0.0.1-1
- Released version 0.0.1
+7 -6
View File
@@ -1,16 +1,17 @@
WeeChat - Wee Enhanced Environment for Chat
===========================================
WeeChat known bugs, 2003-10-05
WeeChat known bugs, 2003-09-27
- too much nicks in the channel (> height of window) => display bug
- some IRC commands are marked as 'unknown' when received
(IRC protocol is under dev!)
(irc protocol is under dev!)
- bug in nicklist resize (sometimes resize doesn't work and there is display
problem)
- alias/unalias commands doesn't work
- config is not saved (to ~/.weechat/weechatrc)
- intercept Ctrl-C (do not quit immediately if Ctrl-C pressed!)
- program is stopped when bad option in config file (it should not, only display
warning)
- too much opened channels => display bug
- too much opened channel => display bug
- when kicked, channel is not prefixed by '(' and sufixed by ')'
- when function key (non used by WeeChat) is pressed, prompt is deleted
- when quitting WeeChat term title is not restored (if look_set_title is ON)
- command name for /server can not contain spaces
+82 -25
View File
@@ -1,31 +1,88 @@
WeeChat - Wee Enhanced Environment for Chat
===========================================
ChangeLog - 2003-10-05
ChangeLog - 2003-09-27
* 2003-09-27:
- WeeChat 0.0.1 released!
Version 0.0.2 (2003-10-05):
* added commands /rehash and /restart
* command & auto-join channels when connected to server
* new commands for alias: /alias, /unalias (new section in config file)
* config is now saved automatically when quitting WeeChat, /save command added
* new commands for servers: /server, /connect, /disconnect
* added autoconnect flag for each server in config file
* added "look_set_title" option in config file
* term window title is modified with WeeChat name and version
* fixed nicklist display bug
* fixed crash when sending command which can only be received
* CTCP version returns more info (about OS)
* 2003-09-26:
- added completor prefix (in config: look_nick_completor)
- fixef log_printf command (bug with year & month)
- added "/kill" command
- fixed /version and /ctcp commands (missing ":" before message)
Version 0.0.1 (2003-09-27):
* ncurses GUI with color output
* multi-servers
* channel windows, with nicklist (position: top, bottom, left or right)
* private windows
* IRC commands: away, ctcp, deop, devoice, invite, join, kick, kill, list,
me, mode, msg, names, nick, notice, op, oper, part, ping, pong, quit,
quote, topic, version, voice, whois
* WeeChat commands: clear, help, set (partial)
* many config options
* log file (~/.weechat/weechat.log)
* nicklist can be moved on top, bottom, left or right of window
* 2003-09-25:
- added "/kick" command
- added IRC errors 402 to 407
- added "/invite" command
* 2003-09-24:
- "ctcp version" received is now correctly displayed
- "/version" command is ok
* 2003-09-23:
- log file (~/.weechat/weechat.log)
- renamed config file (~/.weechat/weechatrc to ~/.weechat/weechat.rc)
* 2003-09-21:
- "demi-highlight": 2 types of windows highlight: lightred for windows with
unread messages (from other users), lightmagenta for windows with other
unread data (join, part, quit, away, ...)
- "320" IRC message management
- "/clear" command
* 2003-09-19:
- préparation des sources pour l'internationalisation avec gettext
- "301" IRC command (away message)
- functions renamed in rc-commands.c, irc-server.c,
command.c and config.c (all functions are beginning with a prefix:
irc_cmd_recv_xxx, irc_cmd_send_xxx, server_xxx, weechat_cmd_xxx and
config_xxx). Moreover, all commands (sent and received) return a value
(success or not)
- "/quote" command
- "/whois" command (and colored display of /whois result in server window)
* 2003-09-18:
- use of alternate nickname (and 2nd alternate) if nick is already used
on server (changed/added in config file: options "nick1", "nick2", "nick3"
for a server, all are mandatory)
- "433" IRC error management (nickname already in use)
- "mode" command received correctly for "channel flags" and
op/deop/voice/devoice actions for a nick
- "401" IRC error management (no such nick/channel)
- private windows management (when received and opened, with /privmsg),
"/privmsg" completed consequently
* 2003-09-17:
- nickmode display ((half)op/voice) before nicks (as option, look at config
options beginning with "look_nickmode")
- windows history is now ok (pgup/pgdn on any window type)
- "/me" command (and OK when received)
- display nicks count when joining channel or with "/names" command
(total, ops, halfops, voices et normaux)
* 2003-09-16:
- added and normalized chat window colors
(new colors in config file)
- "/topic" command
- nicklist can be moved on top, bottom, left or right of window
* 2003-09-15:
- auto-resize of nicklist, according to nick max length
- IRC multi-servers is OK
* 2003-09-14:
- no hangup if "/part" command is executed on server window
- continue if no server is declared in config file
(empty window will be opened for executing WeeChat commands)
- string array for strings in config file
example: cfg_look_nicklist_position can take values "left", "right",
"top", "bottom", which are converted to int (from 0 for "left" to 3 for
"bottom")
- messages are aligned under time (server window) or under time + nick
(channel window)
* 2003-09-13:
- sources exploded in many directories: ./irc, ./gui/curses, ./gui/gtk,
./gui/qt and ./gui/text
+2 -6
View File
@@ -1,10 +1,6 @@
WeeChat - Wee Enhanced Environment for Chat
===========================================
* FlashCode, 2003-10-05
FlashCode, 2003-09-27
WeeChat 0.0.2 released.
* FlashCode, 2003-09-27
WeeChat 0.0.1 released.
WeeChat 0.0.1 released.
+54 -23
View File
@@ -1,7 +1,7 @@
WeeChat - Wee Enhanced Environment for Chat
===========================================
TODO - 2003-10-05
TODO - 2003-09-27
Legend:
# done
@@ -10,40 +10,70 @@ Legend:
? is this really necessary?
v0.0.2:
------
v0.0.1:
* IRC protocol:
# "/rehash" command: tell the server to reload its config file
# "/restart" command: tell the server to restart itself
# "/quote" command: send a raw string to the server without parsing it
# "/me" command (for user actions description)
# "/away" command (to toggle the away status)
# "/op", "/deop", "/voice", "/devoice" commands
# "/invite" command
# "/kick", "/ban", "/unban" commands
# "/kill" command
# "/list" command: list of channels
# "/names" command: view who is on a given channel without being
on it (for example /names #weechat gives all the nicks present on
#weechat, except those who have the +i flag (server side))
# "/oper" command: become operator on the irc network
# "/topic" command: change the topic of a channel
# "/version" command: give the irc client version (CTCP VERSION)
of a given nick/channel (without parameter: gives WeeChat version)
# "/whois" command
* WeeChat commands:
# "/connect" and "/disconnect" commands (for multiservers use)
# "/server" command to add, remove or list servers
# "/save" command: save configuration to disk
# "/alias" and "/unalias" commands
# "/clear": to clear window content
* Interface:
# "demi-highlight" when joins/quits etc
# log messages/warning/errors to ~/.weechat/log file
# improve editing zone (left arrow <> backspace)
# sort nick list
# choose nick list position (top, left, right (default), bottom)
# auto-resize nicklist (when nick too long)
# do pretty cutting of long lines (align on the nick or after hour for server)
# keep history of commands and call them again with up/down arrow
# text GUI
# ncurses GUI:
# one window for each channel
# color display
# private windows
# redraw window when term size is modified
# chat history (pgup/pgdn for displaying history)
# switch to other channel window
* TCP/IP communication:
# IPv4 protocol implementation
* Configuration:
# write config file
# add alias definition
# add an option for each server in order to run commands on join
(example: /msg nickserv identify password)
# channel list for auto-join (for each server)
# write default config file
Future versions:
---------------
* IRC protocol:
- implement RFC 2812
+ "/mode" command: change the user/channels modes
- "/dcc" command (for chat and sending/receiving files)
- manage "halfop" status
- complete "/list" command: add regexp search, display only channels that
match regexp
- "/connect" and "/disconnect" commands (for multiservers use)
- "/ignore" and "/unignore" commands: hide all that is write by a given
nick/host
- when we're away, WeeChat should log all the lines begenning by our nick.
When we come back from our away it should print it to the current window
- "/rehash" command: tell the server to reload its config file
- "/restart" command: tell the server to restart itself
- "/notify" and "/unnotify" command to be warn by WeeChat when a given
nick/host connect to the given irc network
- "/wallops" command: write the same string to all the
@@ -57,15 +87,15 @@ Future versions:
like -o could send the output to the server, on the current
channel/private
- "/reload" command: reload the WeeChat's config file
- "/highlight" command: highlight a given word when it appears on
channels/privates
+ "/set" command: allow the user to set the WeeChat variables
- "/set" command: allow the user to set the WeeChat variables
under WeeChat without editing the config file (colours, time
format, etc)
- "/highlight" command: highlight a given word when it appears on
channels/privates
* Interface:
- display current channel modes (example : #weechat(+nt))
- interpret special chars in messages (color & bold for example)
- interpret ^B in messages (this means bold text)
- internationalization (traduce WeeChat in many languages)
- many channel windows in one window/term (window split)
- add lag indicator
@@ -79,14 +109,15 @@ Future versions:
? Qt GUI
* TCP/IP communication:
- connect to server with child process (background)
- SSL support
- IPv6 protocol implementation
* Configuration:
- add key bindings to config file
- add missing options for config file
- wrong alias is not created and not saved when quitting WeeChat
- write config file
- add an option for each server in order to run commands on join
(example: /msg nickserv identify password)
- channel list for auto-join (for each server)
- do not stop program if problem with options in config file
- load config file after GUI (so init values by default (colors, ...) before
loading config)
+1 -7
View File
@@ -1,11 +1,5 @@
weechat (0.0.2-1) unstable; urgency=low
* WeeChat version 0.0.2, see ChangeLog for detail.
-- FlashCode <flashcode@flashtux.org> Sun, 05 Oct 2003 12:00:00 +0200
weechat (0.0.1-1) unstable; urgency=low
* First version.
-- FlashCode <flashcode@flashtux.org> Sat, 27 Sep 2003 12:00:00 +0200
-- FlashCode <flashcode@flashtux.org> Sat, 27 Jun 2003 12:00:00 +0200
+1 -1
View File
@@ -1,5 +1,5 @@
This package was debianized by FlashCode <flashcode@flashtux.org> on
Sun, 05 Oct 2003 12:00:00 +0200.
Sat, 27 Sep 2003 10:00:00 +0200.
It was downloaded from http://weechat.flashtux.org/download
+1 -1
View File
@@ -1 +1 @@
weechat_0.0.2-1_i386.deb net optional
weechat_0.0.1-1_i386.deb net optional
+2 -2
View File
@@ -84,8 +84,8 @@ command.o: command.c weechat.h command.h irc/irc.h gui/gui.h completion.h \
history.h config.h
completion.o: completion.c weechat.h completion.h irc/irc.h gui/gui.h \
history.h command.h
config.o: config.c weechat.h config.h command.h irc/irc.h gui/gui.h \
completion.h history.h
config.o: config.c weechat.h config.h irc/irc.h gui/gui.h completion.h \
history.h
history.o: history.c weechat.h history.h gui/gui.h completion.h
weechat.o: weechat.c weechat.h config.h command.h irc/irc.h gui/gui.h \
completion.h history.h
+58 -774
View File
File diff suppressed because it is too large Load Diff
+3 -20
View File
@@ -40,16 +40,6 @@ struct t_weechat_command
int (*cmd_function_1arg)(char *);
};
typedef struct t_weechat_alias t_weechat_alias;
struct t_weechat_alias
{
char *alias_name;
char *alias_command;
t_weechat_alias *prev_alias;
t_weechat_alias *next_alias;
};
typedef struct t_index_command t_index_command;
struct t_index_command
@@ -59,22 +49,15 @@ struct t_index_command
t_index_command *next_index;
};
extern t_weechat_alias *weechat_alias;
extern t_index_command *index_commands;
extern t_index_command *index_command_new (char *);
extern void index_command_build ();
extern t_weechat_alias *alias_new (char *, char *);
extern int exec_weechat_command (t_irc_server *, char *);
extern void user_command (t_irc_server *, char *);
extern int weechat_cmd_alias (char *);
extern int weechat_cmd_clear (int, char **);
extern int weechat_cmd_connect (int, char **);
extern int weechat_cmd_disconnect (int, char **);
extern int weechat_cmd_alias(int, char **);
extern int weechat_cmd_clear(int, char **);
extern int weechat_cmd_help (int, char **);
extern int weechat_cmd_server (int, char **);
extern int weechat_cmd_save (int, char **);
extern int weechat_cmd_set (int, char **);
extern int weechat_cmd_unalias (char *);
extern int weechat_cmd_unalias (int, char **);
#endif /* command.h */
+97 -265
View File
@@ -31,7 +31,6 @@
#include "weechat.h"
#include "config.h"
#include "command.h"
#include "irc/irc.h"
#include "gui/gui.h"
@@ -45,13 +44,11 @@ t_config_section config_sections[CONFIG_NUMBER_SECTIONS] =
{ 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;
@@ -70,20 +67,16 @@ 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"),
{ { "look_startup_logo", N_("display " WEECHAT_NAME " logo at startup"),
N_("display " WEECHAT_NAME " 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"),
{ "look_startup_version", N_("display " WEECHAT_NAME " version at startup"),
N_("display " WEECHAT_NAME " 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)"),
{ "look_weechat_slogan", N_(WEECHAT_NAME "slogan"),
N_(WEECHAT_NAME "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"),
@@ -340,7 +333,7 @@ t_config_option weechat_options_log[] =
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"),
N_("path for " WEECHAT_NAME " log files"),
OPTION_TYPE_STRING, 0, 0, 0,
"~/.weechat/logs/", NULL, NULL, &cfg_log_path, NULL },
{ "log_name", N_("name for log files"),
@@ -448,10 +441,6 @@ t_config_option weechat_options_server[] =
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,
@@ -484,14 +473,6 @@ t_config_option weechat_options_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 }
};
@@ -500,7 +481,7 @@ t_config_option weechat_options_server[] =
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
weechat_options_server
};
@@ -525,6 +506,24 @@ get_pos_array_values (char **array, char *string)
return -1;
}
/*
* config_init_server: init server struct
*/
void
config_init_server ()
{
cfg_server.name = NULL;
cfg_server.address = NULL;
cfg_server.port = -1;
cfg_server.password = NULL;
cfg_server.nick1 = NULL;
cfg_server.nick2 = NULL;
cfg_server.nick3 = NULL;
cfg_server.username = NULL;
cfg_server.realname = NULL;
}
/*
* config_allocate_server: allocate a new server
*/
@@ -557,10 +556,9 @@ config_allocate_server (char *filename, int line_number)
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))
cfg_server.address, cfg_server.port, cfg_server.password,
cfg_server.nick1, cfg_server.nick2, cfg_server.nick3,
cfg_server.username, cfg_server.realname))
{
server_free_all ();
gui_printf (NULL,
@@ -568,9 +566,26 @@ config_allocate_server (char *filename, int line_number)
WEECHAT_WARNING, filename, line_number);
return 0;
}
if (cfg_server.name)
free (cfg_server.name);
if (cfg_server.address)
free (cfg_server.address);
if (cfg_server.password)
free (cfg_server.password);
if (cfg_server.nick1)
free (cfg_server.nick1);
if (cfg_server.nick2)
free (cfg_server.nick2);
if (cfg_server.nick3)
free (cfg_server.nick3);
if (cfg_server.username)
free (cfg_server.username);
if (cfg_server.realname)
free (cfg_server.realname);
if (cfg_server.nick)
free (cfg_server.nick);
server_destroy (&cfg_server);
server_init (&cfg_server);
config_init_server ();
return 1;
}
@@ -586,7 +601,7 @@ config_default_values ()
for (i = 0; i < CONFIG_NUMBER_SECTIONS; i++)
{
if ((i != CONFIG_SECTION_ALIAS) && (i != CONFIG_SECTION_SERVER))
if (i != CONFIG_SECTION_SERVER)
{
for (j = 0; weechat_options[i][j].option_name; j++)
{
@@ -655,7 +670,7 @@ config_read ()
}
config_default_values ();
server_init (&cfg_server);
config_init_server ();
/* read config file */
section = CONFIG_SECTION_NONE;
@@ -741,35 +756,29 @@ config_read ()
pos2 = strchr (pos, '\n');
if (pos2 != NULL)
pos2[0] = '\0';
if (section == CONFIG_SECTION_ALIAS)
option_number = -1;
for (i = 0;
weechat_options[section][i].option_name; i++)
{
if (alias_new (line, pos))
index_command_new (pos);
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);
fclose (file);
free (filename);
return -2;
}
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);
fclose (file);
free (filename);
return -2;
}
switch (weechat_options[section]
[option_number].option_type)
{
@@ -911,8 +920,6 @@ config_read ()
/*
* config_create_default: create default WeeChat config
* return: 0 if ok
* < 0 if error
*/
int
@@ -929,25 +936,24 @@ config_create_default ()
sprintf (filename, "%s/.weechat/" WEECHAT_CONFIG_NAME, getenv ("HOME"));
if ((file = fopen (filename, "wt")) == NULL)
{
free (filename);
gui_printf (NULL, _("%s cannot create file \"%s\"\n"),
WEECHAT_ERROR, filename);
free (filename);
return -1;
}
printf (_("%s: creating default config file...\n"), WEECHAT_NAME);
log_printf (_("creating default config file\n"));
printf (_(WEECHAT_NAME ": creating default config file...\n"));
current_time = time (NULL);
sprintf (line, _("#\n# %s configuration file, created by "
"%s v%s on %s#\n"),
WEECHAT_NAME, WEECHAT_NAME, WEECHAT_VERSION,
ctime (&current_time));
sprintf (line, _("#\n# " WEECHAT_NAME " configuration file, generated by "
WEECHAT_NAME " " WEECHAT_VERSION " on %s"), ctime (&current_time));
fputs (line, file);
fputs (_("# This file may be edited by user. Invalid syntax will prevent "
WEECHAT_NAME " from running!\n#\n"), file);
for (i = 0; i < CONFIG_NUMBER_SECTIONS; i++)
{
if ((i != CONFIG_SECTION_ALIAS) && (i != CONFIG_SECTION_SERVER))
if (i != CONFIG_SECTION_SERVER)
{
sprintf (line, "\n[%s]\n", config_sections[i].section_name);
fputs (line, file);
@@ -963,62 +969,33 @@ config_create_default ()
{
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;
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);
@@ -1027,8 +1004,6 @@ config_create_default ()
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);
@@ -1037,153 +1012,10 @@ config_create_default ()
/*
* config_write: write WeeChat configurtion
* return: 0 if ok
* < 0 if error
*/
int
config_write (char *config_name)
void
config_write ()
{
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"),
WEECHAT_NAME, WEECHAT_NAME, WEECHAT_VERSION,
ctime (&current_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;
/* TODO: write "config_write" function! */
}
+3 -5
View File
@@ -32,9 +32,8 @@
#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 CONFIG_SECTION_SERVER 6
#define CONFIG_NUMBER_SECTIONS 7
#define OPTION_TYPE_BOOLEAN 1 /* values: on/off */
#define OPTION_TYPE_INT 2 /* values: from min to max */
@@ -75,7 +74,6 @@ struct t_config_option
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;
@@ -152,6 +150,6 @@ extern t_config_option * weechat_options [CONFIG_NUMBER_SECTIONS];
extern int config_read ();
extern int config_create_default ();
extern int config_write ();
extern void config_write ();
#endif /* config.h */
+28 -77
View File
@@ -611,8 +611,7 @@ gui_draw_window_nick (t_gui_window *window)
if (CHANNEL(window) && CHANNEL(window)->nicks)
{
max_length = nick_get_max_length (CHANNEL(window));
if ((window == gui_current_window) &&
((max_length + 2) != window->win_nick_width))
if ((max_length + 2) != window->win_nick_width)
{
gui_calculate_pos_size (window);
delwin (window->win_chat);
@@ -625,6 +624,7 @@ gui_draw_window_nick (t_gui_window *window)
window->win_nick_width,
window->win_nick_y,
window->win_nick_x);
//scrollok (window->win_chat, TRUE);
gui_redraw_window_chat (window);
}
sprintf (format, "%%-%ds", max_length);
@@ -752,7 +752,6 @@ void
gui_draw_window_status (t_gui_window *window)
{
t_gui_window *ptr_win;
char format_more[32];
/* TODO: manage splitted windows! */
if (window != gui_current_window)
@@ -854,12 +853,9 @@ gui_draw_window_status (t_gui_window *window)
/* display "*MORE*" if last line is not displayed */
gui_window_set_color (window->win_status, COLOR_WIN_STATUS_MORE);
if (window->sub_lines > 0)
mvwprintw (window->win_status, 0, COLS - 7, _("-MORE-"));
mvwprintw (window->win_status, 0, COLS - 7, "-MORE-");
else
{
sprintf (format_more, "%%-%ds", strlen (_("-MORE")));
mvwprintw (window->win_status, 0, COLS - 7, format_more, " ");
}
mvwprintw (window->win_status, 0, COLS - 7, " ");
wrefresh (window->win_status);
refresh ();
@@ -962,34 +958,17 @@ gui_draw_window_input (t_gui_window *window)
}
else
{
if (SERVER(window))
{
sprintf (format, "%%s> %%-%ds", input_width);
if (SERVER(window) && (SERVER(window)->is_connected))
ptr_nickname = SERVER(window)->nick;
else
ptr_nickname = cfg_look_no_nickname;
mvwprintw (window->win_input, 0, 0, format,
ptr_nickname,
window->input_buffer + window->input_buffer_1st_display);
wclrtoeol (window->win_input);
move (LINES - 1, strlen (ptr_nickname) + 2 +
(window->input_buffer_pos - window->input_buffer_1st_display));
}
sprintf (format, "%%s> %%-%ds", input_width);
if (SERVER(window) && (SERVER(window)->is_connected))
ptr_nickname = SERVER(window)->nick;
else
{
sprintf (format, "%%s> %%-%ds", input_width);
if (SERVER(window) && (SERVER(window)->is_connected))
ptr_nickname = SERVER(window)->nick;
else
ptr_nickname = cfg_look_no_nickname;
mvwprintw (window->win_input, 0, 0, format,
ptr_nickname,
window->input_buffer + window->input_buffer_1st_display);
wclrtoeol (window->win_input);
move (LINES - 1, strlen (ptr_nickname) + 2 +
(window->input_buffer_pos - window->input_buffer_1st_display));
}
ptr_nickname = cfg_look_no_nickname;
mvwprintw (window->win_input, 0, 0, format,
ptr_nickname,
window->input_buffer + window->input_buffer_1st_display);
wclrtoeol (window->win_input);
move (LINES - 1, strlen (ptr_nickname) + 2 +
(window->input_buffer_pos - window->input_buffer_1st_display));
}
wrefresh (window->win_input);
@@ -1110,17 +1089,17 @@ gui_switch_to_window (t_gui_window *window)
}
}
gui_calculate_pos_size (window);
/* first time creation for windows */
if (!another_window)
{
/* create new windows */
gui_calculate_pos_size (window);
window->win_title = newwin (1, COLS, 0, 0);
window->win_chat = newwin (window->win_chat_height,
window->win_chat_width,
window->win_chat_y,
window->win_chat_x);
//scrollok (window->win_chat, TRUE);
if (CHANNEL(window))
window->win_nick = newwin (window->win_nick_height,
window->win_nick_width,
@@ -1133,33 +1112,34 @@ gui_switch_to_window (t_gui_window *window)
}
else
{
gui_calculate_pos_size (window);
/* create chat & nick windows */
if (WIN_IS_CHANNEL(window))
if (WIN_IS_CHANNEL(window) && !(window->win_nick))
{
/* (re)create nicklist window */
if (window->win_nick)
delwin (window->win_nick);
/* add nick list window */
delwin (window->win_chat);
window->win_chat = newwin (window->win_chat_height,
window->win_chat_width,
window->win_chat_y,
window->win_chat_x);
//scrollok (window->win_chat, TRUE);
window->win_nick = newwin (window->win_nick_height,
window->win_nick_width,
window->win_nick_y,
window->win_nick_x);
}
if (!(WIN_IS_CHANNEL(window)))
if (!(WIN_IS_CHANNEL(window)) && window->win_nick)
{
/* remove nick list window */
if (window->win_nick)
delwin (window->win_nick);
delwin (window->win_nick);
window->win_nick = NULL;
delwin (window->win_chat);
window->win_chat = newwin (window->win_chat_height,
window->win_chat_width,
window->win_chat_y,
window->win_chat_x);
//scrollok (window->win_chat, TRUE);
}
}
@@ -1249,21 +1229,7 @@ gui_window_new (void *server, void *channel
/*int x, int y, int width, int height*/)
{
t_gui_window *new_window;
if (gui_windows)
{
if (!SERVER(gui_windows))
{
if (server)
((t_irc_server *)(server))->window = gui_windows;
if (channel)
((t_irc_channel *)(channel))->window = gui_windows;
SERVER(gui_windows) = server;
CHANNEL(gui_windows) = channel;
return gui_windows;
}
}
if ((new_window = (t_gui_window *)(malloc (sizeof (t_gui_window)))))
{
/* assign server and channel to window */
@@ -1324,7 +1290,6 @@ gui_window_new (void *server, void *channel
}
else
return NULL;
return new_window;
}
@@ -1337,13 +1302,9 @@ gui_window_free (t_gui_window *window)
{
t_gui_line *ptr_line;
t_gui_message *ptr_message;
int create_new;
create_new = (window->server || window->channel);
/* TODO: manage splitted windows! */
if ((window == gui_current_window) &&
((window->next_window) || (window->prev_window)))
if (window == gui_current_window)
gui_switch_to_previous_window ();
/* free lines and messages */
@@ -1378,10 +1339,6 @@ gui_window_free (t_gui_window *window)
last_gui_window = window->prev_window;
free (window);
/* always at least one window */
if (!gui_windows && create_new)
gui_window_new (NULL, NULL);
}
/*
@@ -1549,12 +1506,6 @@ gui_init ()
signal (SIGWINCH, gui_resize_term_handler);
#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");
#endif
gui_ready = 1;
}
@@ -1583,7 +1534,7 @@ gui_end ()
/* TODO: free input buffer, lines, messages, completion */
}
/* end of curses output */
/* end of ncurses output */
refresh ();
endwin ();
}
@@ -1643,7 +1594,7 @@ gui_new_message (t_gui_window *window)
}
else
{
log_printf (_("not enough memory!\n"));
log_printf ("not enough memory!\n");
return NULL;
}
return new_message;
+141 -227
View File
@@ -29,7 +29,6 @@
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <sys/utsname.h>
#include "../weechat.h"
#include "irc.h"
@@ -103,8 +102,7 @@ t_irc_command irc_commands[] =
" o: operator flag\n"),
1, MAX_ARGS, 1, NULL, irc_cmd_send_mode, irc_cmd_recv_mode },
{ "msg", N_("send message to a nick or channel"),
N_("receiver[,receiver] text"),
N_("receiver: nick or channel (may be mask, '*' = current channel)"
N_("receiver[,receiver] text"), N_("receiver: nick or channel (may be mask)"
"\ntext: text to send"),
1, MAX_ARGS, 1, NULL, irc_cmd_send_msg, NULL },
{ "names", N_("list nicknames on channels"),
@@ -124,7 +122,7 @@ t_irc_command irc_commands[] =
N_("user/password: used to get privileges on current IRC server"),
2, 2, 1, irc_cmd_send_oper, NULL, NULL },
{ "part", N_("leave a channel"),
N_("[channel[,channel]]"), N_("channel: channel name to leave"),
N_("[channel[,channel]]"), N_("channel: channel name to join"),
0, MAX_ARGS, 1, NULL, irc_cmd_send_part, irc_cmd_recv_part },
{ "ping", N_("ping server"),
N_("server1 [server2]"),
@@ -136,7 +134,7 @@ t_irc_command irc_commands[] =
1, 2, 1, irc_cmd_send_pong, NULL, NULL },
{ "privmsg", N_("message received"),
"", "",
0, 0, 1, NULL, NULL, irc_cmd_recv_privmsg },
0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_privmsg },
{ "quit", N_("close all connections & quit " WEECHAT_NAME),
N_("[quit_message]"),
N_("quit_message: quit message (displayed to other users)"),
@@ -145,12 +143,6 @@ t_irc_command irc_commands[] =
N_("data"),
N_("data: raw data to send"),
1, MAX_ARGS, 1, NULL, irc_cmd_send_quote, NULL },
{ "rehash", N_("tell the server to reload its config file"),
"", "",
0, 0, 1, NULL, irc_cmd_send_rehash, NULL },
{ "restart", N_("tell the server to restart itself"),
"", "",
0, 0, 1, NULL, irc_cmd_send_restart, NULL },
{ "topic", N_("get/set channel topic"),
N_("[channel] [topic]"), N_("channel: channel name\ntopic: new topic for channel "
"(if topic is \"-delete\" then topic is deleted)"),
@@ -331,6 +323,11 @@ irc_recv_command (t_irc_server *server,
{
int i, cmd_found;
#if DEBUG >= 2
gui_printf (server->window, "recv_irc_command: cmd=%s args=%s\n",
command, arguments);
#endif
if (command == NULL)
return -2;
@@ -370,8 +367,8 @@ irc_login (t_irc_server *server)
if (!hostname[0])
strcpy (hostname, _("unknown"));
gui_printf (server->window,
_("%s: using local hostname \"%s\"\n"),
WEECHAT_NAME, hostname);
_(WEECHAT_NAME ": using local hostname \"%s\"\n"),
hostname);
server_sendf (server,
"NICK %s\r\n"
"USER %s %s %s :%s\r\n",
@@ -487,8 +484,8 @@ irc_cmd_send_deop (t_irc_server *server, int argc, char **argv)
}
else
gui_printf (server->window,
_("%s \"%s\" command can only be executed in a channel window\n"),
WEECHAT_ERROR, "deop");
_("%s \"deop\" command can only be executed in a channel window\n"),
WEECHAT_ERROR);
return 0;
}
@@ -511,8 +508,8 @@ irc_cmd_send_devoice (t_irc_server *server, int argc, char **argv)
else
{
gui_printf (server->window,
_("%s \"%s\" command can only be executed in a channel window\n"),
WEECHAT_ERROR, "devoice");
_("%s \"devoice\" command can only be executed in a channel window\n"),
WEECHAT_ERROR);
return -1;
}
return 0;
@@ -560,8 +557,8 @@ irc_cmd_send_kick (t_irc_server *server, char *arguments)
else
{
gui_printf (server->window,
_("%s \"%s\" command can only be executed in a channel window\n"),
WEECHAT_ERROR, "kick");
_("%s \"kick\" command can only be executed in a channel window\n"),
WEECHAT_ERROR);
return -1;
}
}
@@ -603,8 +600,8 @@ irc_cmd_send_me (t_irc_server *server, char *arguments)
if (WIN_IS_SERVER(gui_current_window))
{
gui_printf (server->window,
_("%s \"%s\" command can not be executed on a server window\n"),
WEECHAT_ERROR, "me");
_("%s \"me\" command can not be executed on a server window\n"),
WEECHAT_ERROR);
return -1;
}
server_sendf (server, "PRIVMSG %s :\01ACTION %s\01\r\n",
@@ -655,97 +652,66 @@ irc_cmd_send_msg (t_irc_server *server, char *arguments)
pos_comma[0] = '\0';
pos_comma++;
}
if (strcmp (arguments, "*") == 0)
if (string_is_channel (arguments))
{
if (WIN_IS_SERVER(gui_current_window))
ptr_channel = channel_search (server, arguments);
if (ptr_channel)
{
gui_printf (server->window,
_("%s \"%s\" command can not be executed on a server window\n"),
WEECHAT_ERROR, "msg *");
return -1;
ptr_nick = nick_search (ptr_channel, server->nick);
if (ptr_nick)
{
irc_display_nick (ptr_channel->window, ptr_nick,
MSG_TYPE_NICK, 1, 1, 0);
gui_printf_color_type (ptr_channel->window,
MSG_TYPE_MSG,
COLOR_WIN_CHAT, "%s\n", pos);
}
else
gui_printf (server->window,
_("%s nick not found for \"privmsg\" command\n"),
WEECHAT_ERROR);
}
ptr_channel = CHANNEL(gui_current_window);
ptr_nick = nick_search (ptr_channel, server->nick);
if (ptr_nick)
{
irc_display_nick (ptr_channel->window, ptr_nick,
MSG_TYPE_NICK, 1, 1, 0);
gui_printf_color_type (ptr_channel->window,
MSG_TYPE_MSG,
COLOR_WIN_CHAT, "%s\n", pos);
}
else
gui_printf (server->window,
_("%s nick not found for \"%s\" command\n"),
WEECHAT_ERROR, "msg");
server_sendf (server, "PRIVMSG %s :%s\r\n", ptr_channel->name, pos);
server_sendf (server, "PRIVMSG %s :%s\r\n", arguments, pos);
}
else
{
if (string_is_channel (arguments))
ptr_channel = channel_search (server, arguments);
if (!ptr_channel)
{
ptr_channel = channel_search (server, arguments);
if (ptr_channel)
{
ptr_nick = nick_search (ptr_channel, server->nick);
if (ptr_nick)
{
irc_display_nick (ptr_channel->window, ptr_nick,
MSG_TYPE_NICK, 1, 1, 0);
gui_printf_color_type (ptr_channel->window,
MSG_TYPE_MSG,
COLOR_WIN_CHAT, "%s\n", pos);
}
else
gui_printf (server->window,
_("%s nick not found for \"%s\" command\n"),
WEECHAT_ERROR, "msg");
}
server_sendf (server, "PRIVMSG %s :%s\r\n", arguments, pos);
}
else
{
ptr_channel = channel_search (server, arguments);
ptr_channel = channel_new (server, CHAT_PRIVATE, arguments);
if (!ptr_channel)
{
ptr_channel = channel_new (server, CHAT_PRIVATE, arguments);
if (!ptr_channel)
{
gui_printf (server->window,
_("%s cannot create new private window \"%s\"\n"),
WEECHAT_ERROR,
arguments);
return -1;
}
gui_redraw_window_title (ptr_channel->window);
gui_printf (server->window,
_("%s cannot create new private window \"%s\"\n"),
WEECHAT_ERROR,
arguments);
return -1;
}
gui_printf_color_type (ptr_channel->window,
MSG_TYPE_NICK,
COLOR_WIN_CHAT_DARK, "<");
gui_printf_color_type (ptr_channel->window,
MSG_TYPE_NICK,
COLOR_WIN_NICK_SELF,
"%s", server->nick);
gui_printf_color_type (ptr_channel->window,
MSG_TYPE_NICK,
COLOR_WIN_CHAT_DARK, "> ");
gui_printf_color_type (ptr_channel->window,
MSG_TYPE_MSG,
COLOR_WIN_CHAT, "%s\n", pos);
server_sendf (server, "PRIVMSG %s :%s\r\n", arguments, pos);
gui_redraw_window_title (ptr_channel->window);
}
gui_printf_color_type (ptr_channel->window,
MSG_TYPE_NICK,
COLOR_WIN_CHAT_DARK, "<");
gui_printf_color_type (ptr_channel->window,
MSG_TYPE_NICK,
COLOR_WIN_NICK_SELF,
"%s", server->nick);
gui_printf_color_type (ptr_channel->window,
MSG_TYPE_NICK,
COLOR_WIN_CHAT_DARK, "> ");
gui_printf_color_type (ptr_channel->window,
MSG_TYPE_MSG,
COLOR_WIN_CHAT, "%s\n", pos);
server_sendf (server, "PRIVMSG %s :%s\r\n", arguments, pos);
}
arguments = pos_comma;
}
}
else
{
gui_printf (server->window,
_("%s wrong argument count for \"%s\" command\n"),
WEECHAT_ERROR, "msg");
return -1;
}
_("%s wrong number of args for \"privmsg\" command\n"),
WEECHAT_ERROR);
return 0;
}
@@ -763,8 +729,8 @@ irc_cmd_send_names (t_irc_server *server, char *arguments)
if (!WIN_IS_CHANNEL(gui_current_window))
{
gui_printf (server->window,
_("%s \"%s\" command can only be executed in a channel window\n"),
WEECHAT_ERROR, "names");
_("%s \"names\" command can only be executed in a channel window\n"),
WEECHAT_ERROR);
return -1;
}
else
@@ -817,8 +783,8 @@ irc_cmd_send_op (t_irc_server *server, int argc, char **argv)
else
{
gui_printf (server->window,
_("%s \"%s\" command can only be executed in a channel window\n"),
WEECHAT_ERROR, "op");
_("%s \"op\" command can only be executed in a channel window\n"),
WEECHAT_ERROR);
return -1;
}
return 0;
@@ -866,8 +832,8 @@ irc_cmd_send_part (t_irc_server *server, char *arguments)
if (WIN_IS_SERVER(gui_current_window))
{
gui_printf (server->window,
_("%s \"%s\" command can not be executed on a server window\n"),
WEECHAT_ERROR, "part");
_("%s \"part\" command can not be executed on a server window\n"),
WEECHAT_ERROR);
return -1;
}
channel_name = CHANNEL(gui_current_window)->name;
@@ -879,8 +845,8 @@ irc_cmd_send_part (t_irc_server *server, char *arguments)
if (WIN_IS_SERVER(gui_current_window))
{
gui_printf (server->window,
_("%s \"%s\" command can not be executed on a server window\n"),
WEECHAT_ERROR, "part");
_("%s \"part\" command can not be executed on a server window\n"),
WEECHAT_ERROR);
return -1;
}
if (WIN_IS_PRIVATE(gui_current_window))
@@ -962,34 +928,6 @@ irc_cmd_send_quote (t_irc_server *server, char *arguments)
return 0;
}
/*
* irc_cmd_send_rehash: tell the server to reload its config file
*/
int
irc_cmd_send_rehash (t_irc_server *server, char *arguments)
{
/* make gcc happy */
(void) arguments;
server_sendf (server, "REHASH\r\n");
return 0;
}
/*
* irc_cmd_send_restart: tell the server to restart itself
*/
int
irc_cmd_send_restart (t_irc_server *server, char *arguments)
{
/* make gcc happy */
(void) arguments;
server_sendf (server, "RESTART\r\n");
return 0;
}
/*
* irc_cmd_send_topic: get/set topic for a channel
*/
@@ -1027,8 +965,8 @@ irc_cmd_send_topic (t_irc_server *server, char *arguments)
if (WIN_IS_SERVER(gui_current_window))
{
gui_printf (server->window,
_("%s \"%s\" command can not be executed on a server window\n"),
WEECHAT_ERROR, "topic");
_("%s \"topic\" command can not be executed on a server window\n"),
WEECHAT_ERROR);
return -1;
}
channel_name = CHANNEL(gui_current_window)->name;
@@ -1066,7 +1004,7 @@ irc_cmd_send_version (t_irc_server *server, char *arguments)
else
{
irc_display_prefix (server->window, PREFIX_INFO);
gui_printf (server->window, _("%s, compiled on %s %s\n"),
gui_printf (server->window, "%s, compiled on %s %s\n",
WEECHAT_NAME_AND_VERSION,
__DATE__, __TIME__);
server_sendf (server, "VERSION\r\n");
@@ -1093,8 +1031,8 @@ irc_cmd_send_voice (t_irc_server *server, int argc, char **argv)
else
{
gui_printf (server->window,
_("%s \"%s\" command can only be executed in a channel window\n"),
WEECHAT_ERROR, "voice");
_("%s \"voice\" command can only be executed in a channel window\n"),
WEECHAT_ERROR);
return -1;
}
return 0;
@@ -1254,8 +1192,8 @@ irc_cmd_recv_kick (t_irc_server *server, char *host, char *arguments)
if (!ptr_channel)
{
gui_printf (server->window,
_("%s channel not found for \"%s\" command\n"),
WEECHAT_ERROR, "kick");
_("%s channel not found for \"kick\" command\n"),
WEECHAT_ERROR);
return -1;
}
@@ -1286,8 +1224,8 @@ irc_cmd_recv_kick (t_irc_server *server, char *host, char *arguments)
else
{
gui_printf (server->window,
_("%s nick not found for \"%s\" command\n"),
WEECHAT_ERROR, "kick");
_("%s nick not found for \"kick\" command\n"),
WEECHAT_ERROR);
return -1;
}
ptr_nick = nick_search (ptr_channel, pos_nick);
@@ -1315,8 +1253,8 @@ irc_cmd_recv_mode (t_irc_server *server, char *host, char *arguments)
if (host == NULL)
{
gui_printf (server->window,
_("%s \"%s\" command received without host\n"),
WEECHAT_ERROR, "mode");
_("%s \"mode\" command received without host\n"),
WEECHAT_ERROR);
return -1;
}
@@ -1329,8 +1267,8 @@ irc_cmd_recv_mode (t_irc_server *server, char *host, char *arguments)
if (!pos)
{
gui_printf (server->window,
_("%s \"%s\" command received without channel or nickname\n"),
WEECHAT_ERROR, "mode");
_("%s \"mode\" command received without channel or nickname\n"),
WEECHAT_ERROR);
return -1;
}
pos[0] = '\0';
@@ -1470,8 +1408,8 @@ irc_cmd_recv_mode (t_irc_server *server, char *host, char *arguments)
else
{
gui_printf (server->window,
_("%s channel not found for \"%s\" command\n"),
WEECHAT_ERROR, "mode");
_("%s channel not found for \"mode\" command\n"),
WEECHAT_ERROR);
return -1;
}
}
@@ -1499,8 +1437,8 @@ irc_cmd_recv_nick (t_irc_server *server, char *host, char *arguments)
if (host == NULL)
{
gui_printf (server->window,
_("%s \"%s\" command received without host\n"),
WEECHAT_ERROR, "nick");
_("%s \"nick\" command received without host\n"),
WEECHAT_ERROR);
return -1;
}
@@ -1581,8 +1519,8 @@ irc_cmd_recv_notice (t_irc_server *server, char *host, char *arguments)
else
{
gui_printf (server->window,
_("%s nickname not found for \"%s\" command\n"),
WEECHAT_ERROR, "notice");
_("%s nickname not found for \"notice\" command\n"),
WEECHAT_ERROR);
return -1;
}
irc_display_prefix (server->window, PREFIX_SERVER);
@@ -1593,9 +1531,9 @@ irc_cmd_recv_notice (t_irc_server *server, char *host, char *arguments)
if (pos2)
pos2[0] = '\0';
gui_printf_color (server->window, COLOR_WIN_CHAT, "CTCP ");
gui_printf_color (server->window, COLOR_WIN_CHAT_CHANNEL, "VERSION ");
gui_printf_color (server->window, COLOR_WIN_CHAT, _("reply from"));
gui_printf_color (server->window, COLOR_WIN_CHAT_NICK, " %s", host);
gui_printf_color (server->window, COLOR_WIN_CHAT_CHANNEL, "VERSION");
gui_printf_color (server->window, COLOR_WIN_CHAT, " reply from ");
gui_printf_color (server->window, COLOR_WIN_CHAT_NICK, "%s", host);
gui_printf_color (server->window, COLOR_WIN_CHAT, ": %s\n", pos);
}
else
@@ -1618,8 +1556,8 @@ irc_cmd_recv_part (t_irc_server *server, char *host, char *arguments)
if (!host || !arguments)
{
gui_printf (server->window,
_("%s \"%s\" command received without host or channel\n"),
WEECHAT_ERROR, "part");
_("%s \"part\" command received without host or channel\n"),
WEECHAT_ERROR);
return -1;
}
@@ -1692,8 +1630,8 @@ irc_cmd_recv_part (t_irc_server *server, char *host, char *arguments)
else
{
gui_printf (server->window,
_("%s channel not found for \"%s\" command\n"),
WEECHAT_ERROR, "part");
_("%s channel not found for \"part\" command\n"),
WEECHAT_ERROR);
return -1;
}
@@ -1727,14 +1665,13 @@ irc_cmd_recv_privmsg (t_irc_server *server, char *host, char *arguments)
char *pos, *pos2, *host2;
t_irc_channel *ptr_channel;
t_irc_nick *ptr_nick;
struct utsname *buf;
/* no host => we can't identify sender of message! */
if (host == NULL)
{
gui_printf (server->window,
_("%s \"%s\" command received without host\n"),
WEECHAT_ERROR, "privmsg");
_("%s \"privmsg\" command received without host\n"),
WEECHAT_ERROR);
return -1;
}
@@ -1790,8 +1727,8 @@ irc_cmd_recv_privmsg (t_irc_server *server, char *host, char *arguments)
else
{
gui_printf (server->window,
_("%s nick not found for \"%s\" command\n"),
WEECHAT_ERROR, "privmsg");
_("%s nick not found for \"privmsg\" command\n"),
WEECHAT_ERROR);
return -1;
}
}
@@ -1799,8 +1736,8 @@ irc_cmd_recv_privmsg (t_irc_server *server, char *host, char *arguments)
else
{
gui_printf (server->window,
_("%s channel not found for \"%s\" command\n"),
WEECHAT_ERROR, "privmsg");
_("%s channel not found for \"privmsg\" command\n"),
WEECHAT_ERROR);
return -1;
}
}
@@ -1822,27 +1759,11 @@ irc_cmd_recv_privmsg (t_irc_server *server, char *host, char *arguments)
pos++;
if (strcmp (pos, "\01VERSION\01") == 0)
{
buf = (struct utsname *) malloc (sizeof (struct utsname));
uname (buf);
server_sendf (server,
_("NOTICE %s :%sVERSION %s v%s"
" compiled on %s, host \"%s\" is running "
"%s %s / %s%s"),
host, "\01", WEECHAT_NAME, WEECHAT_VERSION, __DATE__,
&buf->nodename, &buf->sysname,
&buf->release, &buf->machine, "\01\r\n");
free (buf);
irc_display_prefix (server->window, PREFIX_INFO);
gui_printf_color (server->window,
COLOR_WIN_CHAT, _("Received a "));
gui_printf_color (server->window,
COLOR_WIN_CHAT_CHANNEL, _("CTCP VERSION "));
gui_printf_color (server->window,
COLOR_WIN_CHAT, _("from"));
gui_printf_color (server->window,
COLOR_WIN_CHAT_NICK, " %s\n", host);
}
"NOTICE %s :\01VERSION "
WEECHAT_NAME " v"
WEECHAT_VERSION ", compiled on " __DATE__ "\01\r\n",
host);
else
{
/* private message received */
@@ -1882,8 +1803,8 @@ irc_cmd_recv_privmsg (t_irc_server *server, char *host, char *arguments)
else
{
gui_printf (server->window,
_("%s cannot parse \"%s\" command\n"),
WEECHAT_ERROR, "privmsg");
_("%s cannot parse \"privmsg\" command\n"),
WEECHAT_ERROR);
return -1;
}
}
@@ -1905,8 +1826,8 @@ irc_cmd_recv_quit (t_irc_server *server, char *host, char *arguments)
if (host == NULL)
{
gui_printf (server->window,
_("%s \"%s\" command received without host\n"),
WEECHAT_ERROR, "quit");
_("%s \"quit\" command received without host\n"),
WEECHAT_ERROR);
return -1;
}
@@ -1935,11 +1856,11 @@ irc_cmd_recv_quit (t_irc_server *server, char *host, char *arguments)
gui_printf_color (ptr_channel->window,
COLOR_WIN_CHAT_HOST, "%s", pos + 1);
gui_printf_color (ptr_channel->window,
COLOR_WIN_CHAT_DARK, ") ");
COLOR_WIN_CHAT_DARK, ")");
gui_printf_color (ptr_channel->window,
COLOR_WIN_CHAT, _("has quit"));
COLOR_WIN_CHAT, _(" has quit "));
gui_printf_color (ptr_channel->window,
COLOR_WIN_CHAT_DARK, " (");
COLOR_WIN_CHAT_DARK, "(");
gui_printf_color (ptr_channel->window,
COLOR_WIN_CHAT, "%s",
arguments);
@@ -2054,11 +1975,11 @@ irc_cmd_recv_topic (t_irc_server *server, char *host, char *arguments)
if (pos)
pos[0] = '\0';
if (!string_is_channel (arguments))
if (string_is_channel (arguments))
{
gui_printf (server->window,
_("%s \"%s\" command received without channel\n"),
WEECHAT_ERROR, "topic");
_("%s \"topic\" command received without channel\n"),
WEECHAT_ERROR);
return -1;
}
@@ -2117,7 +2038,7 @@ irc_cmd_recv_topic (t_irc_server *server, char *host, char *arguments)
}
/*
* irc_cmd_recv_004: '004' command (connected to irc server)
* irc_cmd_recv_004: '004' command (connected to irc server ?????)
*/
int
@@ -2133,15 +2054,6 @@ irc_cmd_recv_004 (t_irc_server *server, char *host, char *arguments)
server->is_connected = 1;
gui_redraw_window_status (server->window);
gui_redraw_window_input (server->window);
/* execute command once connected */
if (server->command && server->command[0])
user_command(server, server->command);
/* autojoin */
if (server->autojoin && server->autojoin[0])
return irc_cmd_send_join (server, server->autojoin);
return 0;
}
@@ -2761,8 +2673,8 @@ irc_cmd_recv_332 (t_irc_server *server, char *host, char *arguments)
else
{
gui_printf (server->window,
_("%s channel not found for \"%s\" command\n"),
WEECHAT_ERROR, "332");
_("%s channel not found for \"332\" command\n"),
WEECHAT_ERROR);
return -1;
}
}
@@ -2770,8 +2682,8 @@ irc_cmd_recv_332 (t_irc_server *server, char *host, char *arguments)
else
{
gui_printf (server->window,
_("%s cannot identify channel for \"%s\" command\n"),
WEECHAT_ERROR, "332");
_("%s cannot identify channel for \"332\" command\n"),
WEECHAT_ERROR);
return -1;
}
return 0;
@@ -2826,32 +2738,32 @@ irc_cmd_recv_333 (t_irc_server *server, char *host, char *arguments)
else
{
gui_printf (server->window,
_("%s channel not found for \"%s\" command\n"),
WEECHAT_ERROR, "333");
_("%s channel not found for \"333\" command\n"),
WEECHAT_ERROR);
return -1;
}
}
else
{
gui_printf (server->window,
_("%s cannot identify date/time for \"%s\" command\n"),
WEECHAT_ERROR, "333");
_("%s cannot identify date/time for \"333\" command\n"),
WEECHAT_ERROR);
return -1;
}
}
else
{
gui_printf (server->window,
_("%s cannot identify nickname for \"%s\" command\n"),
WEECHAT_ERROR, "333");
_("%s cannot identify nickname for \"333\" command\n"),
WEECHAT_ERROR);
return -1;
}
}
else
{
gui_printf (server->window,
_("%s cannot identify channel for \"%s\" command\n"),
WEECHAT_ERROR, "333");
_("%s cannot identify channel for \"333\" command\n"),
WEECHAT_ERROR);
return -1;
}
return 0;
@@ -2926,8 +2838,8 @@ irc_cmd_recv_353 (t_irc_server *server, char *host, char *arguments)
if (pos[0] != ':')
{
gui_printf (server->window,
_("%s cannot parse \"%s\" command\n"),
WEECHAT_ERROR, "353");
_("%s cannot parse \"353\" command\n"),
WEECHAT_ERROR);
return -1;
}
pos++;
@@ -2966,8 +2878,8 @@ irc_cmd_recv_353 (t_irc_server *server, char *host, char *arguments)
else
{
gui_printf (server->window,
_("%s cannot parse \"%s\" command\n"),
WEECHAT_ERROR, "353");
_("%s cannot parse \"353\" command\n"),
WEECHAT_ERROR);
return -1;
}
return 0;
@@ -3108,9 +3020,10 @@ irc_cmd_recv_433 (t_irc_server *server, char *host, char *arguments)
if (strcmp (server->nick, server->nick1) == 0)
{
gui_printf (server->window,
_("%s: nickname \"%s\" is already in use, "
_(WEECHAT_NAME
": nickname \"%s\" is already in use, "
"trying 2nd nickname \"%s\"\n"),
WEECHAT_NAME, server->nick, server->nick2);
server->nick, server->nick2);
free (server->nick);
server->nick = strdup (server->nick2);
}
@@ -3119,18 +3032,19 @@ irc_cmd_recv_433 (t_irc_server *server, char *host, char *arguments)
if (strcmp (server->nick, server->nick2) == 0)
{
gui_printf (server->window,
_("%s: nickname \"%s\" is already in use, "
_(WEECHAT_NAME
": nickname \"%s\" is already in use, "
"trying 3rd nickname \"%s\"\n"),
WEECHAT_NAME, server->nick, server->nick3);
server->nick, server->nick3);
free (server->nick);
server->nick = strdup (server->nick3);
}
else
{
gui_printf (server->window,
_("%s: all declared nicknames are already in use, "
"closing connection with server!\n"),
WEECHAT_NAME);
_(WEECHAT_NAME
": all declared nicknames are already in use, "
"closing connection with server!\n"));
server_disconnect (server);
return 0;
}
+65 -116
View File
@@ -49,36 +49,6 @@ t_irc_message *recv_msgq, *msgq_last_msg;
char *unterminated_message = NULL;
/*
* server_init: init server struct with default values
*/
void
server_init (t_irc_server *server)
{
server->name = NULL;
server->autoconnect = 0;
server->address = NULL;
server->port = -1;
server->password = NULL;
server->nick1 = NULL;
server->nick2 = NULL;
server->nick3 = NULL;
server->username = NULL;
server->realname = NULL;
server->command = NULL;
server->autojoin = NULL;
server->nick = NULL;
server->is_connected = 0;
server->sock4 = -1;
server->is_away = 0;
server->server_read = -1;
server->server_write = -1;
server->window = NULL;
server->channels = NULL;
server->last_channel = NULL;
}
/*
* server_alloc: allocate a new server and add it to the servers queue
*/
@@ -95,12 +65,28 @@ server_alloc ()
/* alloc memory for new server */
if ((new_server = (t_irc_server *) malloc (sizeof (t_irc_server))) == NULL)
{
fprintf (stderr, _("%s cannot allocate new server\n"), WEECHAT_ERROR);
fprintf (stderr, _("%s cannot allocate new server"), WEECHAT_ERROR);
return NULL;
}
/* initialize new server */
server_init (new_server);
new_server->name = NULL;
new_server->address = NULL;
new_server->password = NULL;
new_server->nick1 = NULL;
new_server->nick2 = NULL;
new_server->nick3 = NULL;
new_server->username = NULL;
new_server->realname = NULL;
new_server->nick = NULL;
new_server->is_connected = 0;
new_server->sock4 = -1;
new_server->is_away = 0;
new_server->server_read = -1;
new_server->server_write = -1;
new_server->window = NULL;
new_server->channels = NULL;
new_server->last_channel = NULL;
/* add new server to queue */
new_server->prev_server = last_irc_server;
@@ -116,12 +102,42 @@ server_alloc ()
}
/*
* server_destroy: free server data (not struct himself)
* server_create_window: create windows for a server
*/
void
server_destroy (t_irc_server *server)
server_create_window (t_irc_server *server)
{
if (!SERVER(gui_windows))
{
server->window = gui_windows;
SERVER(gui_windows) = server;
}
else
gui_window_new (server, NULL);
}
/*
* server_free: free a server and remove it from servers queue
*/
void
server_free (t_irc_server *server)
{
t_irc_server *new_irc_servers;
/* remove server from queue */
if (server->prev_server)
{
(server->prev_server)->next_server = server->next_server;
new_irc_servers = irc_servers;
}
else
new_irc_servers = server->next_server;
if (server->next_server)
(server->next_server)->prev_server = server->prev_server;
/* free data */
if (server->name)
free (server->name);
@@ -139,42 +155,12 @@ server_destroy (t_irc_server *server)
free (server->username);
if (server->realname)
free (server->realname);
if (server->command)
free (server->command);
if (server->autojoin)
free (server->autojoin);
if (server->nick)
free (server->nick);
if (server->channels)
channel_free_all (server);
}
/*
* server_free: free a server and remove it from servers queue
*/
void
server_free (t_irc_server *server)
{
t_irc_server *new_irc_servers;
/* remove server from queue */
if (last_irc_server == server)
last_irc_server = server->prev_server;
if (server->prev_server)
{
(server->prev_server)->next_server = server->next_server;
new_irc_servers = irc_servers;
}
else
new_irc_servers = server->next_server;
if (server->next_server)
(server->next_server)->prev_server = server->prev_server;
server_destroy (server);
if (server->window)
gui_window_free (server->window);
/* TODO: free weechat window (???) */
/* (...) */
free (server);
irc_servers = new_irc_servers;
}
@@ -196,29 +182,26 @@ server_free_all ()
*/
t_irc_server *
server_new (char *name, int autoconnect, char *address, int port,
char *password, char *nick1, char *nick2, char *nick3,
char *username, char *realname, char *command, char *autojoin)
server_new (char *name, char *address, int port, char *password,
char *nick1, char *nick2, char *nick3,
char *username, char *realname)
{
t_irc_server *new_server;
if (!name || !address || (port < 0))
if (!name || !address || (port < 0) || !nick1 || !nick2 || !nick3
|| !username || !realname)
return NULL;
#if DEBUG >= 1
log_printf ("creating new server (name:%s, address:%s, port:%d, pwd:%s, "
"nick1:%s, nick2:%s, nick3:%s, username:%s, realname:%s, "
"command:%s, autojoin:%s)\n",
name, address, port, (password) ? password : "",
(nick1) ? nick1 : "", (nick2) ? nick2 : "", (nick3) ? nick3 : "",
(username) ? username : "", (realname) ? realname : "",
(command) ? command : "", (autojoin) ? autojoin : "");
"nick1:%s, nick2:%s, nick3:%s, username:%s, realname:%s)\n",
name, address, port, password, nick1, nick2, nick3,
username, realname);
#endif
if ((new_server = server_alloc ()))
{
new_server->name = strdup (name);
new_server->autoconnect = autoconnect;
new_server->address = strdup (address);
new_server->port = port;
new_server->password = (password) ? strdup (password) : strdup ("");
@@ -229,10 +212,6 @@ server_new (char *name, int autoconnect, char *address, int port,
(username) ? strdup (username) : strdup ("weechat");
new_server->realname =
(realname) ? strdup (realname) : strdup ("realname");
new_server->command =
(command) ? strdup (command) : NULL;
new_server->autojoin =
(autojoin) ? strdup (autojoin) : NULL;
new_server->nick = strdup (new_server->nick1);
}
else
@@ -479,9 +458,9 @@ server_connect (t_irc_server *server)
int server_pipe[2];
gui_printf (server->window,
_("%s: connecting to %s:%d...\n"),
WEECHAT_NAME, server->address, server->port);
log_printf (_("connecting to server %s:%d...\n"),
_(WEECHAT_NAME ": connecting to %s:%d...\n"),
server->address, server->port);
log_printf ("connecting to server %s:%d...\n",
server->address, server->port);
server->is_connected = 0;
@@ -503,7 +482,7 @@ server_connect (t_irc_server *server)
(server->sock4, SOL_SOCKET, SO_REUSEADDR, (char *) &set,
sizeof (set)) == -1)
gui_printf (server->window,
_("%s cannot set socket option \"SO_REUSEADDR\"\n"),
_("%s cannot set socket option 'SO_REUSEADDR'\n"),
WEECHAT_ERROR);
set = 1;
if (setsockopt
@@ -551,7 +530,7 @@ server_connect (t_irc_server *server)
/* connection to server */
gui_printf (server->window,
_("%s: server IP is: %s\n"), WEECHAT_NAME, ip_address);
_(WEECHAT_NAME ": server IP is: %s\n"), ip_address);
error = connect (server->sock4, (struct sockaddr *) &addr, sizeof (addr));
if (error != 0)
@@ -576,24 +555,12 @@ server_connect (t_irc_server *server)
void
server_disconnect (t_irc_server *server)
{
t_irc_channel *ptr_channel;
if (server->is_connected)
{
/* write disconnection message on each channel/private window */
for (ptr_channel = server->channels; ptr_channel;
ptr_channel = ptr_channel->next_channel)
{
irc_display_prefix (ptr_channel->window, PREFIX_INFO);
gui_printf (ptr_channel->window, _("Disconnected from server!\n"));
}
/* close communication with server */
close (server->server_read);
close (server->server_write);
close (server->sock4);
server->is_connected = 0;
server->sock4 = -1;
}
}
@@ -610,24 +577,6 @@ server_disconnect_all ()
server_disconnect (ptr_server);
}
/*
* server_search: return pointer on a server with a name
*/
t_irc_server *
server_search (char *servername)
{
t_irc_server *ptr_server;
for (ptr_server = irc_servers; ptr_server;
ptr_server = ptr_server->next_server)
{
if (strcmp (ptr_server->name, servername) == 0)
return ptr_server;
}
return NULL;
}
/*
* server_get_number_connected: returns number of connected server
*/
+3 -10
View File
@@ -78,7 +78,6 @@ struct t_irc_server
{
/* user choices */
char *name; /* name of server (only for display) */
int autoconnect; /* = 1 if auto connect at startup */
char *address; /* address of server (IP or name) */
int port; /* port for server (6667 by default) */
char *password; /* password for server */
@@ -87,8 +86,6 @@ struct t_irc_server
char *nick3; /* 2nd alternate nickname */
char *username; /* user name */
char *realname; /* real name */
char *command; /* command to run once connected */
char *autojoin; /* channels to automatically join */
/* internal vars */
char *nick; /* current nickname */
@@ -140,20 +137,18 @@ extern t_irc_channel *current_channel;
/* server functions (irc-server.c) */
extern void server_init (t_irc_server *);
extern t_irc_server *server_alloc ();
extern void server_destroy (t_irc_server *);
extern void server_create_window (t_irc_server *);
extern void server_free (t_irc_server *);
extern void server_free_all ();
extern t_irc_server *server_new (char *, int, char *, int, char *, char *,
char *, char *, char *, char *, char *, char *);
extern t_irc_server *server_new (char *, char *, int, char *, char *, char *,
char *, char *, char *);
extern int server_send (t_irc_server *, char *, int);
extern int server_sendf (t_irc_server *, char *, ...);
extern void server_recv (t_irc_server *);
extern int server_connect ();
extern void server_disconnect (t_irc_server *);
extern void server_disconnect_all ();
extern t_irc_server *server_search (char *);
extern int server_get_number_connected ();
extern int server_name_already_exists (char *);
@@ -210,8 +205,6 @@ extern int irc_cmd_send_ping (t_irc_server *, int, char **);
extern int irc_cmd_send_pong (t_irc_server *, int, char **);
extern int irc_cmd_send_quit (t_irc_server *, char *);
extern int irc_cmd_send_quote (t_irc_server *, char *);
extern int irc_cmd_send_rehash (t_irc_server *, char *);
extern int irc_cmd_send_restart (t_irc_server *, char *);
extern int irc_cmd_send_topic (t_irc_server *, char *);
extern int irc_cmd_send_version (t_irc_server *, char *);
extern int irc_cmd_send_voice (t_irc_server *, int, char **);
+8 -18
View File
@@ -211,8 +211,8 @@ wee_init_log ()
void
wee_shutdown ()
{
server_free_all ();
gui_end ();
server_free_all ();
if (log_file)
fclose (log_file);
exit (0);
@@ -227,10 +227,6 @@ main (int argc, char *argv[])
{
t_irc_server *ptr_server;
setlocale (LC_ALL, "");
bindtextdomain (PACKAGE, "/usr/share/locale");
textdomain (PACKAGE);
/* initialize variables */
wee_init_vars ();
@@ -243,9 +239,6 @@ main (int argc, char *argv[])
/* init log file */
wee_init_log ();
/* build commands index (sorted), for completion */
index_command_build ();
/* read configuration */
switch (config_read ())
{
@@ -263,6 +256,9 @@ main (int argc, char *argv[])
/* init gui */
gui_init ();
/* build commands index (sorted), for completion */
index_command_build ();
/* Welcome message - yeah! */
if (cfg_look_startup_logo)
{
@@ -296,23 +292,17 @@ main (int argc, char *argv[])
gui_printf_color (NULL, COLOR_WIN_CHAT_PREFIX1,
"-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n");
/* connect to all servers (with autoconnect flag) */
/* connect to all servers */
for (ptr_server = irc_servers; ptr_server;
ptr_server = ptr_server->next_server)
{
if (ptr_server->autoconnect)
{
gui_window_new (ptr_server, NULL);
if (server_connect (ptr_server))
irc_login (ptr_server);
}
server_create_window (ptr_server);
if (server_connect (ptr_server))
irc_login (ptr_server);
}
gui_main_loop ();
server_disconnect_all ();
/* save config file */
config_write (NULL);
/* program ending */
wee_shutdown ();
+1 -3
View File
@@ -24,15 +24,13 @@
#define __WEECHAT_H 1
#include <stdio.h>
#include <locale.h>
#include <libintl.h>
#define PACKAGE "weechat"
#define _(string) gettext(string)
#define N_(string) (string)
#define WEECHAT_NAME "WeeChat"
#define WEECHAT_VERSION "0.0.2"
#define WEECHAT_VERSION "0.0.1"
#define WEECHAT_NAME_AND_VERSION WEECHAT_NAME " " WEECHAT_VERSION
#define WEECHAT_COPYRIGHT WEECHAT_NAME " (c) 2003 by Wee Team"
+4 -14
View File
@@ -1,7 +1,7 @@
.TH WEECHAT 1 "October 2003" "FlashCode"
.TH WEECHAT 1 "September 2003" "FlashCode"
.SH NAME
weechat \- Wee Enhanced Environment for Chat
weechat \- wee enhanced environment for chat
.SH SYNOPSIS
.B weechat
@@ -9,11 +9,8 @@ weechat \- Wee Enhanced Environment for Chat
.br
.SH DESCRIPTION
Fast, light and extensible IRC client for many operating systems.
.br
Everything can be done with a keyboard. It is customizable and extensible with scripts.
Many GUIs are available (Curses, Gtk, Qt, and text).
It is compliant with RFCs 1459, 2810, 2811, 2812, and 2813.
Fast, light and extensible IRC client for many operating systems. Everything can be
done with a keyboard. It is customizable and extensible with scripts.
.SH OPTIONS
.TP
@@ -33,9 +30,6 @@ display WeeChat version
.TP
.B $HOME/.weechat/weechat.rc
configuration file for WeeChat
.TP
.B $HOME/.weechat/weechat.log
WeeChat log file
.SH AUTHOR
WeeChat is written by:
@@ -47,8 +41,4 @@ WeeChat is written by:
WeeChat on the web:
.UR
http://weechat.flashtux.org
.br
Get support there:
.UR
http://weechat.flashtux.org/support.php
.UE
+2 -4
View File
@@ -1,5 +1,5 @@
%define name weechat
%define version 0.0.2
%define version 0.0.1
%define release 1
Name: %{name}
@@ -37,7 +37,5 @@ rm -rf $RPM_BUILD_ROOT
/usr/local/bin/weechat
%changelog
* Sun Oct 05 2003 FlashCode <flashcode@flashtux.org> 0.0.2-1
- Released version 0.0.2
* Sat Sep 27 2003 FlashCode <flashcode@flashtux.org> 0.0.1-1
* Thu Sep 27 2003 FlashCode <flashcode@flashtux.org> 0.0.1-1
- Released version 0.0.1