1
0
mirror of https://github.com/irssi/irssi.git synced 2024-12-04 14:46:39 -05:00

Moved some stuff from irc to core. Added command_bind_proto() function to

bind protocol-specific commands. Added #define command_bind_irc() for easier
access. CMD_IRC_SERVER(server) check should be done at the beginning of each
command requiring IRC server as active server, it handles it correctly the
cases when it is not. Did some other cleanups as well.


git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1955 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
Timo Sirainen 2001-11-02 01:05:14 +00:00 committed by cras
parent 95b94ed83c
commit f354fe54c7
70 changed files with 381 additions and 438 deletions

View File

@ -262,25 +262,25 @@ static void cmd_join(const char *data, SERVER_REC *server)
void *free_arg;
g_return_if_fail(data != NULL);
if (!IS_SERVER(server) || !server->connected)
cmd_return_error(CMDERR_NOT_CONNECTED);
if (!cmd_get_params(data, &free_arg, 1 | PARAM_FLAG_OPTIONS |
PARAM_FLAG_UNKNOWN_OPTIONS | PARAM_FLAG_GETREST,
"join", &optlist, &channels))
return;
/* -<server tag> */
server = cmd_options_get_server("join", optlist, server);
if (server == NULL || !server->connected)
cmd_param_error(CMDERR_NOT_CONNECTED);
if (g_hash_table_lookup(optlist, "invite"))
channels = server->last_invite;
else {
if (*channels == '\0')
cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
/* -<server tag> */
server = cmd_options_get_server("join", optlist, server);
}
if (server != NULL && channels != NULL)
if (channels != NULL)
server->channels_join(server, channels, FALSE);
cmd_params_free(free_arg);
}

View File

@ -111,8 +111,8 @@ int command_have_sub(const char *command)
return FALSE;
}
static COMMAND_MODULE_REC *command_module_get(COMMAND_REC *rec,
const char *module)
static COMMAND_MODULE_REC *
command_module_get(COMMAND_REC *rec, const char *module, int protocol)
{
COMMAND_MODULE_REC *modrec;
@ -122,14 +122,18 @@ static COMMAND_MODULE_REC *command_module_get(COMMAND_REC *rec,
if (modrec == NULL) {
modrec = g_new0(COMMAND_MODULE_REC, 1);
modrec->name = g_strdup(module);
modrec->protocol = -1;
rec->modules = g_slist_append(rec->modules, modrec);
}
if (protocol != -1)
modrec->protocol = protocol;
return modrec;
}
void command_bind_to(const char *module, int pos, const char *cmd,
const char *category, SIGNAL_FUNC func)
int protocol, const char *category, SIGNAL_FUNC func)
{
COMMAND_REC *rec;
COMMAND_MODULE_REC *modrec;
@ -145,7 +149,7 @@ void command_bind_to(const char *module, int pos, const char *cmd,
rec->category = category == NULL ? NULL : g_strdup(category);
commands = g_slist_append(commands, rec);
}
modrec = command_module_get(rec, module);
modrec = command_module_get(rec, module, protocol);
modrec->signals = g_slist_append(modrec->signals, func);
@ -433,7 +437,7 @@ void command_set_options_module(const char *module,
rec = command_find(cmd);
g_return_if_fail(rec != NULL);
modrec = command_module_get(rec, module);
modrec = command_module_get(rec, module, -1);
reload = modrec->options != NULL;
if (reload) {
@ -769,6 +773,28 @@ void commands_remove_module(const char *module)
}
}
static int cmd_protocol_match(COMMAND_REC *cmd, SERVER_REC *server)
{
GSList *tmp;
for (tmp = cmd->modules; tmp != NULL; tmp = tmp->next) {
COMMAND_MODULE_REC *rec = tmp->data;
if (rec->protocol == -1) {
/* at least one module accepts the command
without specific protocol */
return 1;
}
if (server != NULL && rec->protocol == server->chat_type) {
/* matching protocol found */
return 1;
}
}
return 0;
}
#define alias_runstack_push(alias) \
alias_runstack = g_slist_append(alias_runstack, alias)
@ -781,6 +807,7 @@ void commands_remove_module(const char *module)
static void parse_command(const char *command, int expand_aliases,
SERVER_REC *server, void *item)
{
COMMAND_REC *rec;
const char *alias, *newcmd;
char *cmd, *orig, *args, *oldcmd;
@ -810,6 +837,17 @@ static void parse_command(const char *command, int expand_aliases,
return;
}
rec = command_find(newcmd);
if (rec != NULL && !cmd_protocol_match(rec, server)) {
g_free(orig);
signal_emit("error command", 2,
GINT_TO_POINTER(server == NULL ?
CMDERR_NOT_CONNECTED :
CMDERR_ILLEGAL_PROTO));
return;
}
cmd = g_strconcat("command ", newcmd, NULL);
if (server != NULL)
server_redirect_default(SERVER(server), cmd);

View File

@ -6,6 +6,7 @@
typedef struct {
char *name;
char *options;
int protocol; /* chat protocol required for this command */
GSList *signals;
} COMMAND_MODULE_REC;
@ -26,10 +27,11 @@ enum {
CMDERR_ERRNO, /* get the error from errno */
CMDERR_NOT_ENOUGH_PARAMS, /* not enough parameters given */
CMDERR_NOT_CONNECTED, /* not connected to IRC server */
CMDERR_NOT_CONNECTED, /* not connected to server */
CMDERR_NOT_JOINED, /* not joined to any channels in this window */
CMDERR_CHAN_NOT_FOUND, /* channel not found */
CMDERR_CHAN_NOT_SYNCED, /* channel not fully synchronized yet */
CMDERR_ILLEGAL_PROTO, /* requires different chat protocol than the active server */
CMDERR_NOT_GOOD_IDEA /* not good idea to do, -yes overrides this */
};
@ -56,10 +58,14 @@ extern char *current_command; /* the command we're right now. */
/* Bind command to specified function. */
void command_bind_to(const char *module, int pos, const char *cmd,
const char *category, SIGNAL_FUNC func);
#define command_bind(a, b, c) command_bind_to(MODULE_NAME, 1, a, b, c)
#define command_bind_first(a, b, c) command_bind_to(MODULE_NAME, 0, a, b, c)
#define command_bind_last(a, b, c) command_bind_to(MODULE_NAME, 2, a, b, c)
int protocol, const char *category, SIGNAL_FUNC func);
#define command_bind(a, b, c) command_bind_to(MODULE_NAME, 1, a, -1, b, c)
#define command_bind_first(a, b, c) command_bind_to(MODULE_NAME, 0, a, -1, b, c)
#define command_bind_last(a, b, c) command_bind_to(MODULE_NAME, 2, a, -1, b, c)
#define command_bind_proto(a, b, c, d) command_bind_to(MODULE_NAME, 1, a, b, c, d)
#define command_bind_proto_first(a, b, c, d) command_bind_to(MODULE_NAME, 0, a, b, c, d)
#define command_bind_proto_last(a, b, c, d) command_bind_to(MODULE_NAME, 2, a, b, c, d)
void command_unbind(const char *cmd, SIGNAL_FUNC func);

View File

@ -22,10 +22,13 @@
#include "rawlog.h"
#include "modules.h"
#include "signals.h"
#include "commands.h"
#include "misc.h"
#include "write-buffer.h"
#include "settings.h"
#include "servers.h"
static int rawlog_lines;
static int signal_rawlog;
static int log_file_create_mode;
@ -158,6 +161,40 @@ static void read_settings(void)
log_file_create_mode = octal2dec(settings_get_int("log_create_mode"));
}
static void cmd_rawlog(const char *data, SERVER_REC *server, void *item)
{
command_runsub("rawlog", data, server, item);
}
/* SYNTAX: RAWLOG SAVE <file> */
static void cmd_rawlog_save(const char *data, SERVER_REC *server)
{
g_return_if_fail(data != NULL);
if (server == NULL || !server->connected) cmd_return_error(CMDERR_NOT_CONNECTED);
if (*data == '\0') cmd_return_error(CMDERR_NOT_ENOUGH_PARAMS);
rawlog_save(server->rawlog, data);
}
/* SYNTAX: RAWLOG OPEN <file> */
static void cmd_rawlog_open(const char *data, SERVER_REC *server)
{
g_return_if_fail(data != NULL);
if (server == NULL || !server->connected) cmd_return_error(CMDERR_NOT_CONNECTED);
if (*data == '\0') cmd_return_error(CMDERR_NOT_ENOUGH_PARAMS);
rawlog_open(server->rawlog, data);
}
/* SYNTAX: RAWLOG CLOSE */
static void cmd_rawlog_close(const char *data, SERVER_REC *server)
{
g_return_if_fail(data != NULL);
if (server == NULL || !server->connected) cmd_return_error(CMDERR_NOT_CONNECTED);
rawlog_close(server->rawlog);
}
void rawlog_init(void)
{
signal_rawlog = signal_get_uniq_id("rawlog");
@ -166,9 +203,19 @@ void rawlog_init(void)
read_settings();
signal_add("setup changed", (SIGNAL_FUNC) read_settings);
command_bind("rawlog", NULL, (SIGNAL_FUNC) cmd_rawlog);
command_bind("rawlog save", NULL, (SIGNAL_FUNC) cmd_rawlog_save);
command_bind("rawlog open", NULL, (SIGNAL_FUNC) cmd_rawlog_open);
command_bind("rawlog close", NULL, (SIGNAL_FUNC) cmd_rawlog_close);
}
void rawlog_deinit(void)
{
signal_remove("setup changed", (SIGNAL_FUNC) read_settings);
command_unbind("rawlog", (SIGNAL_FUNC) cmd_rawlog);
command_unbind("rawlog save", (SIGNAL_FUNC) cmd_rawlog_save);
command_unbind("rawlog open", (SIGNAL_FUNC) cmd_rawlog_open);
command_unbind("rawlog close", (SIGNAL_FUNC) cmd_rawlog_close);
}

View File

@ -236,8 +236,11 @@ static void cmd_channel(const char *data, SERVER_REC *server, WI_ITEM_REC *item)
{
if (*data == '\0')
cmd_channel_list_joined();
else
else if (server_ischannel(server, data)) {
signal_emit("command join", 3, data, server, item);
} else {
command_runsub("channel", data, server, item);
}
}
/* SYNTAX: CHANNEL ADD [-auto | -noauto] [-bots <masks>] [-botcmd <command>]

View File

@ -45,6 +45,7 @@ static int ret_texts[] = {
TXT_NOT_JOINED,
TXT_CHAN_NOT_FOUND,
TXT_CHAN_NOT_SYNCED,
TXT_ILLEGAL_PROTO,
TXT_NOT_GOOD_IDEA
};
@ -145,6 +146,43 @@ static void cmd_beep(void)
signal_emit("beep", 0);
}
static void cmd_nick(const char *data, SERVER_REC *server)
{
g_return_if_fail(data != NULL);
if (*data != '\0') return;
if (server == NULL || !server->connected)
cmd_return_error(CMDERR_NOT_CONNECTED);
/* display current nick */
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, TXT_YOUR_NICK, server->nick);
signal_stop();
}
static void cmd_join(const char *data, SERVER_REC *server)
{
GHashTable *optlist;
char *channels;
void *free_arg;
g_return_if_fail(data != NULL);
if (!cmd_get_params(data, &free_arg, 1 | PARAM_FLAG_OPTIONS |
PARAM_FLAG_UNKNOWN_OPTIONS | PARAM_FLAG_GETREST,
"join", &optlist, &channels))
return;
server = cmd_options_get_server("join", optlist, server);
if (g_hash_table_lookup(optlist, "invite") &&
server != NULL && server->last_invite == NULL) {
/* ..all this trouble just to print this error message */
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, TXT_NOT_INVITED);
signal_stop();
}
cmd_params_free(free_arg);
}
static void sig_stop(void)
{
signal_stop();
@ -277,6 +315,8 @@ void fe_core_commands_init(void)
command_bind("version", NULL, (SIGNAL_FUNC) cmd_version);
command_bind("cat", NULL, (SIGNAL_FUNC) cmd_cat);
command_bind("beep", NULL, (SIGNAL_FUNC) cmd_beep);
command_bind_first("nick", NULL, (SIGNAL_FUNC) cmd_nick);
command_bind_first("join", NULL, (SIGNAL_FUNC) cmd_join);
signal_add("send command", (SIGNAL_FUNC) event_command);
signal_add_last("send command", (SIGNAL_FUNC) event_command_last);
@ -293,6 +333,8 @@ void fe_core_commands_deinit(void)
command_unbind("version", (SIGNAL_FUNC) cmd_version);
command_unbind("cat", (SIGNAL_FUNC) cmd_cat);
command_unbind("beep", (SIGNAL_FUNC) cmd_beep);
command_unbind("nick", (SIGNAL_FUNC) cmd_nick);
command_unbind("join", (SIGNAL_FUNC) cmd_join);
signal_remove("send command", (SIGNAL_FUNC) event_command);
signal_remove("send command", (SIGNAL_FUNC) event_command_last);

View File

@ -82,6 +82,7 @@ FORMAT_REC fecommon_core_formats[] = {
{ "setupserver_added", "Server {server $0} saved", 2, { 0, 1 } },
{ "setupserver_removed", "Server {server $0} removed", 2, { 0, 1 } },
{ "setupserver_not_found", "Server {server $0} not found", 2, { 0, 1 } },
{ "your_nick", "Your nickname is {nick $0}", 1, { 0 } },
/* ---- */
{ NULL, "Channels", 0 },
@ -92,6 +93,7 @@ FORMAT_REC fecommon_core_formats[] = {
{ "quit", "{channick $0} {chanhost $1} has quit {reason $2}", 4, { 0, 0, 0, 0 } },
{ "quit_once", "{channel $3} {channick $0} {chanhost $1} has quit {reason $2}", 4, { 0, 0, 0, 0 } },
{ "invite", "{nick $0} invites you to {channel $1}", 2, { 0, 0 } },
{ "not_invited", "You have not been invited to a channel!", 0 },
{ "new_topic", "{nick $0} changed the topic of {channel $1} to: $2", 3, { 0, 0, 0 } },
{ "topic_unset", "Topic unset by {nick $0} on {channel $1}", 2, { 0, 0 } },
{ "your_nick_changed", "You're now known as {nick $1}", 3, { 0, 0, 0 } },
@ -202,6 +204,7 @@ FORMAT_REC fecommon_core_formats[] = {
{ "not_joined", "Not joined to any channel", 0 },
{ "chan_not_found", "Not joined to such channel", 0 },
{ "chan_not_synced", "Channel not fully synchronized yet, try again after a while", 0 },
{ "illegal_proto", "Command isn't designed for the chat protocol of the active server", 0 },
{ "not_good_idea", "Doing this is not a good idea. Add -YES if you really mean it", 0 },
/* ---- */

View File

@ -59,6 +59,7 @@ enum {
TXT_SETUPSERVER_ADDED,
TXT_SETUPSERVER_REMOVED,
TXT_SETUPSERVER_NOT_FOUND,
TXT_YOUR_NICK,
TXT_FILL_3,
@ -68,6 +69,7 @@ enum {
TXT_QUIT,
TXT_QUIT_ONCE,
TXT_INVITE,
TXT_NOT_INVITED,
TXT_NEW_TOPIC,
TXT_TOPIC_UNSET,
TXT_YOUR_NICK_CHANGED,
@ -171,6 +173,7 @@ enum {
TXT_NOT_JOINED,
TXT_CHAN_NOT_FOUND,
TXT_CHAN_NOT_SYNCED,
TXT_ILLEGAL_PROTO,
TXT_NOT_GOOD_IDEA,
TXT_FILL_11,

View File

@ -29,6 +29,5 @@ libfe_common_irc_a_SOURCES = \
module-formats.c
noinst_HEADERS = \
fe-common-irc.h \
module.h \
module-formats.h

View File

@ -1,3 +1,4 @@
#include "common.h"
#include "irc.h"
#define MODULE_NAME "fe-common/irc/dcc"

View File

@ -23,7 +23,6 @@
#include "misc.h"
#include "settings.h"
#include "irc.h"
#include "levels.h"
#include "servers.h"
#include "channels.h"

View File

@ -23,10 +23,9 @@
#include "signals.h"
#include "misc.h"
#include "settings.h"
#include "irc.h"
#include "levels.h"
#include "servers.h"
#include "irc-servers.h"
#include "irc-channels.h"
#include "nicklist.h"

View File

@ -24,7 +24,6 @@
#include "misc.h"
#include "settings.h"
#include "irc.h"
#include "levels.h"
#include "servers.h"
#include "servers-redirect.h"
@ -32,12 +31,14 @@
#include "queries.h"
#include "ignore.h"
#include "fe-queries.h"
#include "irc-servers.h"
#include "irc-channels.h"
#include "irc-nicklist.h"
#include "irc-masks.h"
#include "fe-windows.h"
#include "printtext.h"
#include "fe-queries.h"
#include "fe-windows.h"
#include "completion.h"

View File

@ -21,16 +21,13 @@
#include "module.h"
#include "module-formats.h"
#include "signals.h"
#include "commands.h"
#include "levels.h"
#include "servers.h"
#include "irc.h"
#include "channel-rejoin.h"
#include "printtext.h"
static void sig_channel_rejoin(IRC_SERVER_REC *server, REJOIN_REC *rec)
static void sig_channel_rejoin(SERVER_REC *server, REJOIN_REC *rec)
{
g_return_if_fail(rec != NULL);
@ -38,22 +35,12 @@ static void sig_channel_rejoin(IRC_SERVER_REC *server, REJOIN_REC *rec)
IRCTXT_CHANNEL_REJOIN, rec->channel);
}
static void cmd_channel(const char *data, SERVER_REC *server)
{
if (ischannel(*data)) {
signal_emit("command join", 2, data, server);
signal_stop();
}
}
void fe_irc_channels_init(void)
{
signal_add("channel rejoin new", (SIGNAL_FUNC) sig_channel_rejoin);
command_bind("channel", NULL, (SIGNAL_FUNC) cmd_channel);
}
void fe_irc_channels_deinit(void)
{
signal_remove("channel rejoin new", (SIGNAL_FUNC) sig_channel_rejoin);
command_unbind("channel", (SIGNAL_FUNC) cmd_channel);
}

View File

@ -21,16 +21,16 @@
#include "module.h"
#include "module-formats.h"
#include "signals.h"
#include "commands.h"
#include "misc.h"
#include "special-vars.h"
#include "settings.h"
#include "levels.h"
#include "irc.h"
#include "servers.h"
#include "mode-lists.h"
#include "nicklist.h"
#include "irc-commands.h"
#include "irc-servers.h"
#include "irc-channels.h"
#include "irc-queries.h"
@ -56,8 +56,7 @@ static char *skip_target(char *target)
/* SYNTAX: ME <message> */
static void cmd_me(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *item)
{
g_return_if_fail(data != NULL);
CMD_IRC_SERVER(server);
if (!IS_IRC_ITEM(item))
return;
@ -76,9 +75,7 @@ static void cmd_action(const char *data, IRC_SERVER_REC *server)
char *target, *text;
void *free_arg;
g_return_if_fail(data != NULL);
if (server == NULL || !server->connected)
cmd_return_error(CMDERR_NOT_CONNECTED);
CMD_IRC_SERVER(server);
if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_GETREST,
&target, &text))
@ -98,9 +95,7 @@ static void cmd_notice(const char *data, IRC_SERVER_REC *server)
char *target, *msg;
void *free_arg;
g_return_if_fail(data != NULL);
if (server == NULL || !server->connected)
cmd_return_error(CMDERR_NOT_CONNECTED);
CMD_IRC_SERVER(server);
if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_GETREST,
&target, &msg))
@ -118,9 +113,7 @@ static void cmd_ctcp(const char *data, IRC_SERVER_REC *server)
char *target, *ctcpcmd, *ctcpdata;
void *free_arg;
g_return_if_fail(data != NULL);
if (server == NULL || !server->connected)
cmd_return_error(CMDERR_NOT_CONNECTED);
CMD_IRC_SERVER(server);
if (!cmd_get_params(data, &free_arg, 3 | PARAM_FLAG_GETREST,
&target, &ctcpcmd, &ctcpdata))
@ -148,9 +141,7 @@ static void cmd_nctcp(const char *data, IRC_SERVER_REC *server)
char *target, *text;
void *free_arg;
g_return_if_fail(data != NULL);
if (server == NULL || !server->connected)
cmd_return_error(CMDERR_NOT_CONNECTED);
CMD_IRC_SERVER(server);
if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_GETREST,
&target, &text))
@ -170,9 +161,7 @@ static void cmd_wall(const char *data, IRC_SERVER_REC *server,
char *channame, *msg;
void *free_arg;
g_return_if_fail(data != NULL);
if (server == NULL || !server->connected || !IS_IRC_SERVER(server))
cmd_return_error(CMDERR_NOT_CONNECTED);
CMD_IRC_SERVER(server);
if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_OPTCHAN |
PARAM_FLAG_GETREST, item, &channame, &msg))
@ -249,9 +238,7 @@ static void cmd_ban(const char *data, IRC_SERVER_REC *server,
char *channel, *nicks;
void *free_arg;
g_return_if_fail(data != NULL);
if (server == NULL || !server->connected)
cmd_return_error(CMDERR_NOT_CONNECTED);
CMD_IRC_SERVER(server);
if (!cmd_get_params(data, &free_arg, 2 |
PARAM_FLAG_OPTCHAN | PARAM_FLAG_GETREST,
@ -290,8 +277,7 @@ static void cmd_invitelist(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC
IRC_CHANNEL_REC *channel, *cur_channel;
GSList *tmp;
g_return_if_fail(data != NULL);
if (server == NULL || !server->connected) cmd_return_error(CMDERR_NOT_CONNECTED);
CMD_IRC_SERVER(server);
cur_channel = IRC_CHANNEL(item);
if (cur_channel == NULL) cmd_return_error(CMDERR_NOT_JOINED);
@ -317,28 +303,6 @@ static void cmd_invitelist(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC
}
}
static void cmd_join(const char *data, IRC_SERVER_REC *server)
{
if ((*data == '\0' || g_strncasecmp(data, "-invite", 7) == 0) &&
server != NULL && server->last_invite == NULL) {
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, IRCTXT_NOT_INVITED);
signal_stop();
}
}
static void cmd_nick(const char *data, IRC_SERVER_REC *server)
{
g_return_if_fail(data != NULL);
if (*data != '\0') return;
if (server == NULL || !server->connected)
cmd_return_error(CMDERR_NOT_CONNECTED);
/* display current nick */
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, IRCTXT_YOUR_NICK, server->nick);
signal_stop();
}
/* SYNTAX: VER [<target>] */
static void cmd_ver(gchar *data, IRC_SERVER_REC *server, WI_ITEM_REC *item)
{
@ -346,8 +310,7 @@ static void cmd_ver(gchar *data, IRC_SERVER_REC *server, WI_ITEM_REC *item)
g_return_if_fail(data != NULL);
if (!IS_IRC_SERVER(server) || !server->connected)
cmd_return_error(CMDERR_NOT_CONNECTED);
CMD_IRC_SERVER(server);
if (*data == '\0' && !IS_IRC_ITEM(item))
cmd_return_error(CMDERR_NOT_JOINED);
@ -465,21 +428,19 @@ static void cmd_sethost(const char *data, IRC_SERVER_REC *server)
void fe_irc_commands_init(void)
{
command_bind_last("me", NULL, (SIGNAL_FUNC) cmd_me);
command_bind_last("action", NULL, (SIGNAL_FUNC) cmd_action);
command_bind("notice", NULL, (SIGNAL_FUNC) cmd_notice);
command_bind("ctcp", NULL, (SIGNAL_FUNC) cmd_ctcp);
command_bind("nctcp", NULL, (SIGNAL_FUNC) cmd_nctcp);
command_bind("wall", NULL, (SIGNAL_FUNC) cmd_wall);
command_bind("ban", NULL, (SIGNAL_FUNC) cmd_ban);
command_bind("invitelist", NULL, (SIGNAL_FUNC) cmd_invitelist);
command_bind("join", NULL, (SIGNAL_FUNC) cmd_join);
command_bind("nick", NULL, (SIGNAL_FUNC) cmd_nick);
command_bind("ver", NULL, (SIGNAL_FUNC) cmd_ver);
command_bind("topic", NULL, (SIGNAL_FUNC) cmd_topic);
command_bind("ts", NULL, (SIGNAL_FUNC) cmd_ts);
command_bind("oper", NULL, (SIGNAL_FUNC) cmd_oper);
command_bind("sethost", NULL, (SIGNAL_FUNC) cmd_sethost);
command_bind_irc_last("me", NULL, (SIGNAL_FUNC) cmd_me);
command_bind_irc_last("action", NULL, (SIGNAL_FUNC) cmd_action);
command_bind_irc("notice", NULL, (SIGNAL_FUNC) cmd_notice);
command_bind_irc("ctcp", NULL, (SIGNAL_FUNC) cmd_ctcp);
command_bind_irc("nctcp", NULL, (SIGNAL_FUNC) cmd_nctcp);
command_bind_irc("wall", NULL, (SIGNAL_FUNC) cmd_wall);
command_bind_irc("ban", NULL, (SIGNAL_FUNC) cmd_ban);
command_bind_irc("invitelist", NULL, (SIGNAL_FUNC) cmd_invitelist);
command_bind_irc("ver", NULL, (SIGNAL_FUNC) cmd_ver);
command_bind_irc("topic", NULL, (SIGNAL_FUNC) cmd_topic);
command_bind_irc("ts", NULL, (SIGNAL_FUNC) cmd_ts);
command_bind_irc("oper", NULL, (SIGNAL_FUNC) cmd_oper);
command_bind_irc("sethost", NULL, (SIGNAL_FUNC) cmd_sethost);
}
void fe_irc_commands_deinit(void)
@ -492,8 +453,6 @@ void fe_irc_commands_deinit(void)
command_unbind("wall", (SIGNAL_FUNC) cmd_wall);
command_unbind("ban", (SIGNAL_FUNC) cmd_ban);
command_unbind("invitelist", (SIGNAL_FUNC) cmd_invitelist);
command_unbind("join", (SIGNAL_FUNC) cmd_join);
command_unbind("nick", (SIGNAL_FUNC) cmd_nick);
command_unbind("ver", (SIGNAL_FUNC) cmd_ver);
command_unbind("topic", (SIGNAL_FUNC) cmd_topic);
command_unbind("ts", (SIGNAL_FUNC) cmd_ts);

View File

@ -25,7 +25,7 @@
#include "ignore.h"
#include "settings.h"
#include "irc.h"
#include "irc-servers.h"
#include "irc-channels.h"
#include "irc-queries.h"

View File

@ -24,8 +24,6 @@
#include "queries.h"
#include "nicklist.h"
#include "irc.h"
static QUERY_REC *query_find_address(SERVER_REC *server, const char *address)
{
GSList *tmp;

View File

@ -165,7 +165,7 @@ static void cmd_ircnet_remove(const char *data)
}
}
static void cmd_ircnet(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *item)
static void cmd_ircnet(const char *data, SERVER_REC *server, WI_ITEM_REC *item)
{
if (*data == '\0')
cmd_ircnet_list();

View File

@ -25,7 +25,6 @@
#include "misc.h"
#include "settings.h"
#include "irc.h"
#include "irc-servers.h"
#include "irc-channels.h"
#include "modes.h"

View File

@ -25,7 +25,6 @@
#include "misc.h"
#include "settings.h"
#include "irc.h"
#include "irc-servers.h"
#include "modes.h"
#include "ignore.h"

View File

@ -21,12 +21,11 @@
#include "module.h"
#include "module-formats.h"
#include "signals.h"
#include "commands.h"
#include "levels.h"
#include "settings.h"
#include "irc.h"
#include "irc-servers.h"
#include "irc-commands.h"
#include "ignore.h"
#include "netsplit.h"
@ -322,8 +321,7 @@ static void cmd_netsplit(const char *data, IRC_SERVER_REC *server)
{
GSList *list;
if (!IS_IRC_SERVER(server) || !server->connected)
cmd_return_error(CMDERR_NOT_CONNECTED);
CMD_IRC_SERVER(server);
if (server->split_servers == NULL) {
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE,
@ -360,7 +358,7 @@ void fe_netsplit_init(void)
read_settings();
signal_add("netsplit new", (SIGNAL_FUNC) sig_netsplit_servers);
signal_add("setup changed", (SIGNAL_FUNC) read_settings);
command_bind("netsplit", NULL, (SIGNAL_FUNC) cmd_netsplit);
command_bind_irc("netsplit", NULL, (SIGNAL_FUNC) cmd_netsplit);
}
void fe_netsplit_deinit(void)

View File

@ -58,7 +58,6 @@ FORMAT_REC fecommon_irc_formats[] = {
{ "joinerror_duplicate", "Channel {channel $0} already exists - cannot create it", 1, { 0 } },
{ "channel_rejoin", "Channel {channel $0} is temporarily unavailable, this is normally because of netsplits. Irssi will now automatically try to rejoin back to this channel until the join is successful. Use /RMREJOINS command if you wish to abort this.", 1, { 0 } },
{ "inviting", "Inviting {nick $0} to {channel $1}", 2, { 0, 0 } },
{ "not_invited", "You have not been invited to a channel!", 0 },
{ "channel_created", "Channel {channelhilight $0} created $1", 2, { 0, 0 } },
{ "url", "Home page for {channelhilight $0}: $1", 2, { 0, 0 } },
{ "topic", "Topic for {channelhilight $0}: $1", 2, { 0, 0 } },
@ -87,7 +86,6 @@ FORMAT_REC fecommon_irc_formats[] = {
{ "unaway", "You are no longer marked as being away", 0 },
{ "nick_away", "{nick $0} is away: $1", 2, { 0, 0 } },
{ "no_such_nick", "{nick $0}: No such nick/channel", 1, { 0 } },
{ "your_nick", "Your nickname is {nick $0}", 1, { 0 } },
{ "nick_in_use", "Nick {nick $0} is already in use", 1, { 0 } },
{ "nick_unavailable", "Nick {nick $0} is temporarily unavailable", 1, { 0 } },
{ "your_nick_owned", "Your nick is owned by {nick $3} {comment $1@$2}", 4, { 0, 0, 0, 0 } },

View File

@ -35,7 +35,6 @@ enum {
IRCTXT_JOINERROR_DUPLICATE,
IRCTXT_CHANNEL_REJOIN,
IRCTXT_INVITING,
IRCTXT_NOT_INVITED,
IRCTXT_CHANNEL_CREATED,
IRCTXT_CHANNEL_URL,
IRCTXT_TOPIC,
@ -63,7 +62,6 @@ enum {
IRCTXT_UNAWAY,
IRCTXT_NICK_AWAY,
IRCTXT_NO_SUCH_NICK,
IRCTXT_YOUR_NICK,
IRCTXT_NICK_IN_USE,
IRCTXT_NICK_UNAVAILABLE,
IRCTXT_YOUR_NICK_OWNED,

View File

@ -1,3 +1,4 @@
#include "common.h"
#include "irc.h"
#define MODULE_NAME "fe-common/irc"

View File

@ -1,3 +1,4 @@
#include "common.h"
#include "irc.h"
#define MODULE_NAME "fe-common/irc/notifylist"

View File

@ -4,9 +4,7 @@ INCLUDES = \
$(GLIB_CFLAGS) \
-I$(top_srcdir)/src \
-I$(top_srcdir)/src/core/ \
-I$(top_srcdir)/src/irc/core/ \
-I$(top_srcdir)/src/fe-common/core/ \
-I$(top_srcdir)/src/fe-common/irc/ \
$(CURSES_INCLUDEDIR) \
-DLOCALEDIR=\""$(datadir)/locale"\"

View File

@ -29,7 +29,6 @@
#include "printtext.h"
#include "fe-common-core.h"
#include "fe-common-irc.h"
#include "themes.h"
#include "term.h"
@ -54,6 +53,9 @@ void fe_perl_deinit(void);
void irc_init(void);
void irc_deinit(void);
void fe_common_irc_init(void);
void fe_common_irc_deinit(void);
void gui_expandos_init(void);
void gui_expandos_deinit(void);

View File

@ -21,7 +21,6 @@ libirc_core_a_SOURCES = \
irc-masks.c \
irc-nicklist.c \
irc-queries.c \
irc-rawlog.c \
irc-servers.c \
irc-servers-reconnect.c \
irc-servers-setup.c \

View File

@ -20,14 +20,15 @@
#include "module.h"
#include "signals.h"
#include "commands.h"
#include "misc.h"
#include "settings.h"
#include "irc-servers.h"
#include "irc-channels.h"
#include "irc-masks.h"
#include "irc-commands.h"
#include "modes.h"
#include "mode-lists.h"
#include "irc.h"
#include "nicklist.h"
#define BAN_TYPE_NORMAL (IRC_MASK_USER | IRC_MASK_DOMAIN)
@ -253,6 +254,8 @@ static void cmd_ban(const char *data, IRC_SERVER_REC *server, void *item)
int ban_type;
void *free_arg;
CMD_IRC_SERVER(server);
if (!cmd_get_params(data, &free_arg, 1 |
PARAM_FLAG_OPTIONS | PARAM_FLAG_GETREST,
"ban", &optlist, &ban))
@ -286,6 +289,8 @@ static void cmd_unban(const char *data, IRC_SERVER_REC *server, void *item)
char *ban;
void *free_arg;
CMD_IRC_SERVER(server);
if (!cmd_get_params(data, &free_arg, 1 |
PARAM_FLAG_OPTIONS | PARAM_FLAG_GETREST,
"unban", &optlist, &ban))
@ -326,8 +331,8 @@ void bans_init(void)
default_ban_type_str = NULL;
settings_add_str("misc", "ban_type", "normal");
command_bind("ban", NULL, (SIGNAL_FUNC) cmd_ban);
command_bind("unban", NULL, (SIGNAL_FUNC) cmd_unban);
command_bind_irc("ban", NULL, (SIGNAL_FUNC) cmd_ban);
command_bind_irc("unban", NULL, (SIGNAL_FUNC) cmd_unban);
command_set_options("ban", "normal user host domain +custom");
command_set_options("unban", "first last");

View File

@ -1,8 +1,6 @@
#ifndef __BANS_H
#define __BANS_H
#include "irc-channels.h"
void bans_init(void);
void bans_deinit(void);

View File

@ -23,7 +23,7 @@
#include "misc.h"
#include "channels-setup.h"
#include "irc.h"
#include "irc-servers.h"
#include "irc-channels.h"
static void event_cannot_join(IRC_SERVER_REC *server, const char *data)

View File

@ -23,8 +23,9 @@
#include "signals.h"
#include "misc.h"
#include "irc.h"
#include "irc-servers.h"
#include "irc-channels.h"
#include "irc-commands.h"
#include "channel-rejoin.h"
#define REJOIN_TIMEOUT (1000*60*5) /* try to rejoin every 5 minutes */
@ -241,8 +242,7 @@ static int sig_rejoin(void)
static void cmd_rmrejoins(const char *data, IRC_SERVER_REC *server)
{
if (!IS_IRC_SERVER(server) || !server->connected)
cmd_return_error(CMDERR_NOT_CONNECTED);
CMD_IRC_SERVER(server);
while (server->rejoin_channels != NULL)
rejoin_destroy(server, server->rejoin_channels->data);
@ -253,7 +253,7 @@ void channel_rejoin_init(void)
rejoin_tag = g_timeout_add(REJOIN_TIMEOUT,
(GSourceFunc) sig_rejoin, NULL);
command_bind("rmrejoins", NULL, (SIGNAL_FUNC) cmd_rmrejoins);
command_bind_irc("rmrejoins", NULL, (SIGNAL_FUNC) cmd_rmrejoins);
signal_add_first("event 407", (SIGNAL_FUNC) event_duplicate_channel);
signal_add_first("event 437", (SIGNAL_FUNC) event_target_unavailable);
signal_add_first("channel joined", (SIGNAL_FUNC) sig_remove_rejoin);

View File

@ -43,12 +43,11 @@ loop:
#include "signals.h"
#include "settings.h"
#include "channels.h"
#include "irc.h"
#include "modes.h"
#include "mode-lists.h"
#include "nicklist.h"
#include "irc-servers.h"
#include "irc-channels.h"
#include "servers-redirect.h"
enum {

View File

@ -25,7 +25,6 @@
#include "special-vars.h"
#include "settings.h"
#include "irc.h"
#include "irc-servers.h"
#include "server-idle.h"
#include "ignore.h"

View File

@ -24,10 +24,10 @@
#include "levels.h"
#include "channels-setup.h"
#include "irc.h"
#include "bans.h"
#include "modes.h"
#include "mode-lists.h"
#include "irc-servers.h"
#include "irc-channels.h"
#include "irc-nicklist.h"
#include "channel-rejoin.h"

View File

@ -3,7 +3,6 @@
#include "chat-protocols.h"
#include "channels.h"
#include "irc-servers.h"
/* Returns IRC_CHANNEL_REC if it's IRC channel, NULL if it isn't. */
#define IRC_CHANNEL(channel) \
@ -13,7 +12,7 @@
(IRC_CHANNEL(channel) ? TRUE : FALSE)
#define STRUCT_SERVER_REC IRC_SERVER_REC
typedef struct {
struct _IRC_CHANNEL_REC {
#include "channel-rec.h"
GSList *banlist; /* list of bans */
@ -23,7 +22,7 @@ typedef struct {
time_t massjoin_start; /* Massjoin start time */
int massjoins; /* Number of nicks waiting for massjoin signal.. */
int last_massjoins; /* Massjoins when last checked in timeout function */
} IRC_CHANNEL_REC;
};
void irc_channels_init(void);
void irc_channels_deinit(void);

View File

@ -14,7 +14,7 @@
#define IS_IRCNET(ircnet) IS_IRC_CHATNET(ircnet)
#define IRCNET(ircnet) IRC_CHATNET(ircnet)
typedef struct {
struct _IRC_CHATNET_REC {
#include "chatnet-rec.h"
int max_cmds_at_once;
int cmd_queue_speed;
@ -23,7 +23,7 @@ typedef struct {
/* max. number of kicks/msgs/mode/whois per command */
int max_kicks, max_msgs, max_modes, max_whois;
} IRC_CHATNET_REC;
};
void ircnet_create(IRC_CHATNET_REC *rec);

View File

@ -19,7 +19,6 @@
*/
#include "module.h"
#include "commands.h"
#include "misc.h"
#include "special-vars.h"
#include "settings.h"
@ -31,7 +30,7 @@
#include "nicklist.h"
#include "bans.h"
#include "irc.h"
#include "irc-commands.h"
#include "irc-servers.h"
#include "irc-channels.h"
#include "irc-queries.h"
@ -65,9 +64,7 @@ static void cmd_notice(const char *data, IRC_SERVER_REC *server)
char *target, *msg;
void *free_arg;
g_return_if_fail(data != NULL);
if (!IS_IRC_SERVER(server) || !server->connected)
cmd_return_error(CMDERR_NOT_CONNECTED);
CMD_IRC_SERVER(server);
if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_GETREST, &target, &msg))
return;
@ -85,9 +82,7 @@ static void cmd_ctcp(const char *data, IRC_SERVER_REC *server)
char *target, *ctcpcmd, *ctcpdata;
void *free_arg;
g_return_if_fail(data != NULL);
if (!IS_IRC_SERVER(server) || !server->connected)
cmd_return_error(CMDERR_NOT_CONNECTED);
CMD_IRC_SERVER(server);
if (!cmd_get_params(data, &free_arg, 3 | PARAM_FLAG_GETREST, &target, &ctcpcmd, &ctcpdata))
return;
@ -109,9 +104,7 @@ static void cmd_nctcp(const char *data, IRC_SERVER_REC *server)
char *target, *ctcpcmd, *ctcpdata;
void *free_arg;
g_return_if_fail(data != NULL);
if (!IS_IRC_SERVER(server) || !server->connected)
cmd_return_error(CMDERR_NOT_CONNECTED);
CMD_IRC_SERVER(server);
if (!cmd_get_params(data, &free_arg, 3 | PARAM_FLAG_GETREST, &target, &ctcpcmd, &ctcpdata))
return;
@ -130,9 +123,7 @@ static void cmd_part(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *item
char *channame, *msg;
void *free_arg;
g_return_if_fail(data != NULL);
if (!IS_IRC_SERVER(server) || !server->connected)
cmd_return_error(CMDERR_NOT_CONNECTED);
CMD_IRC_SERVER(server);
if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_OPTCHAN | PARAM_FLAG_GETREST, item, &channame, &msg))
return;
@ -155,9 +146,7 @@ static void cmd_kick(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *item
char *channame, *nicks, *reason;
void *free_arg;
g_return_if_fail(data != NULL);
if (!IS_IRC_SERVER(server) || !server->connected)
cmd_return_error(CMDERR_NOT_CONNECTED);
CMD_IRC_SERVER(server);
if (!cmd_get_params(data, &free_arg, 3 | PARAM_FLAG_OPTCHAN | PARAM_FLAG_GETREST,
item, &channame, &nicks, &reason))
@ -179,9 +168,7 @@ static void cmd_topic(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *ite
char *channame, *topic;
void *free_arg;
g_return_if_fail(data != NULL);
if (!IS_IRC_SERVER(server) || !server->connected)
cmd_return_error(CMDERR_NOT_CONNECTED);
CMD_IRC_SERVER(server);
if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_OPTCHAN |
PARAM_FLAG_OPTIONS | PARAM_FLAG_GETREST,
@ -201,9 +188,7 @@ static void cmd_invite(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *it
char *nick, *channame;
void *free_arg;
g_return_if_fail(data != NULL);
if (!IS_IRC_SERVER(server) || !server->connected)
cmd_return_error(CMDERR_NOT_CONNECTED);
CMD_IRC_SERVER(server);
if (!cmd_get_params(data, &free_arg, 2, &nick, &channame))
return;
@ -228,9 +213,7 @@ static void cmd_list(const char *data, IRC_SERVER_REC *server,
char *str;
void *free_arg;
g_return_if_fail(data != NULL);
if (!IS_IRC_SERVER(server) || !server->connected)
cmd_return_error(CMDERR_NOT_CONNECTED);
CMD_IRC_SERVER(server);
if (!cmd_get_params(data, &free_arg, 1 | PARAM_FLAG_OPTIONS |
PARAM_FLAG_GETREST, "list", &optlist, &str))
@ -255,9 +238,7 @@ static void cmd_who(const char *data, IRC_SERVER_REC *server,
char *channel, *rest;
void *free_arg;
g_return_if_fail(data != NULL);
if (!IS_IRC_SERVER(server) || !server->connected)
cmd_return_error(CMDERR_NOT_CONNECTED);
CMD_IRC_SERVER(server);
if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_GETREST, &channel, &rest))
return;
@ -288,9 +269,7 @@ static void cmd_names(const char *data, IRC_SERVER_REC *server,
char *channel;
void *free_arg;
g_return_if_fail(data != NULL);
if (!IS_IRC_SERVER(server) || !server->connected)
cmd_return_error(CMDERR_NOT_CONNECTED);
CMD_IRC_SERVER(server);
if (!cmd_get_params(data, &free_arg, 1 | PARAM_FLAG_OPTIONS |
PARAM_FLAG_GETREST, "names", &optlist, &channel))
@ -321,8 +300,7 @@ static void cmd_nick(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *item
g_return_if_fail(data != NULL);
if (!IS_IRC_SERVER(server) || !server->connected)
cmd_return_error(CMDERR_NOT_CONNECTED);
CMD_IRC_SERVER(server);
if (!cmd_get_params(data, &free_arg, 1, &nick))
return;
@ -392,9 +370,7 @@ static void cmd_whois(const char *data, IRC_SERVER_REC *server,
void *free_arg;
int free_nick;
g_return_if_fail(data != NULL);
if (!IS_IRC_SERVER(server) || !server->connected)
cmd_return_error(CMDERR_NOT_CONNECTED);
CMD_IRC_SERVER(server);
if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_OPTIONS,
"whois", &optlist, &qserver, &query))
@ -480,9 +456,7 @@ static void cmd_whowas(const char *data, IRC_SERVER_REC *server)
void *free_arg;
int free_nick;
g_return_if_fail(data != NULL);
if (!IS_IRC_SERVER(server) || !server->connected)
cmd_return_error(CMDERR_NOT_CONNECTED);
CMD_IRC_SERVER(server);
if (!cmd_get_params(data, &free_arg, 2, &nicks, &count))
return;
@ -506,9 +480,7 @@ static void cmd_ping(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *item
GTimeVal tv;
char *str;
g_return_if_fail(data != NULL);
if (!IS_IRC_SERVER(server) || !server->connected)
cmd_return_error(CMDERR_NOT_CONNECTED);
CMD_IRC_SERVER(server);
if (*data == '\0' || strcmp(data, "*") == 0) {
if (!IS_IRC_ITEM(item))
@ -545,9 +517,7 @@ static void cmd_away(const char *data, IRC_SERVER_REC *server)
char *reason;
void *free_arg;
g_return_if_fail(data != NULL);
if (!IS_IRC_SERVER(server) || !server->connected)
cmd_return_error(CMDERR_NOT_CONNECTED);
CMD_IRC_SERVER(server);
if (!cmd_get_params(data, &free_arg, 1 | PARAM_FLAG_OPTIONS |
PARAM_FLAG_GETREST, "away", &optlist, &reason)) return;
@ -560,23 +530,10 @@ static void cmd_away(const char *data, IRC_SERVER_REC *server)
cmd_params_free(free_arg);
}
/* SYNTAX: DEOP <nicks> */
static void cmd_deop(const char *data, IRC_SERVER_REC *server)
{
g_return_if_fail(data != NULL);
if (!IS_IRC_SERVER(server) || !server->connected)
cmd_return_error(CMDERR_NOT_CONNECTED);
if (*data == '\0')
irc_send_cmdv(server, "MODE %s -o", server->nick);
}
/* SYNTAX: SCONNECT <new server> [[<port>] <existing server>] */
static void cmd_sconnect(const char *data, IRC_SERVER_REC *server)
{
g_return_if_fail(data != NULL);
if (!IS_IRC_SERVER(server) || !server->connected)
cmd_return_error(CMDERR_NOT_CONNECTED);
CMD_IRC_SERVER(server);
if (*data == '\0') cmd_return_error(CMDERR_NOT_ENOUGH_PARAMS);
irc_send_cmdv(server, "CONNECT %s", data);
@ -585,9 +542,7 @@ static void cmd_sconnect(const char *data, IRC_SERVER_REC *server)
/* SYNTAX: QUOTE <data> */
static void cmd_quote(const char *data, IRC_SERVER_REC *server)
{
g_return_if_fail(data != NULL);
if (server == NULL || !IS_IRC_SERVER(server))
cmd_return_error(CMDERR_NOT_CONNECTED);
CMD_IRC_SERVER(server);
irc_send_cmd(server, data);
}
@ -595,9 +550,7 @@ static void cmd_quote(const char *data, IRC_SERVER_REC *server)
/* SYNTAX: RAWQUOTE <data> */
static void cmd_rawquote(const char *data, IRC_SERVER_REC *server)
{
g_return_if_fail(data != NULL);
if (server == NULL || !IS_IRC_SERVER(server))
cmd_return_error(CMDERR_NOT_CONNECTED);
CMD_IRC_SERVER(server);
irc_send_cmd_full(server, data, FALSE, FALSE, TRUE);
}
@ -615,9 +568,7 @@ static void cmd_wait(const char *data, IRC_SERVER_REC *server)
void *free_arg;
int n;
g_return_if_fail(data != NULL);
if (!IS_SERVER(server) || !server->connected)
cmd_return_error(CMDERR_NOT_CONNECTED);
CMD_IRC_SERVER(server);
if (!cmd_get_params(data, &free_arg, 1 | PARAM_FLAG_OPTIONS |
PARAM_FLAG_UNKNOWN_OPTIONS | PARAM_FLAG_GETREST,
@ -652,9 +603,7 @@ static void cmd_wall(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *item
IRC_CHANNEL_REC *chanrec;
GSList *tmp, *nicks;
g_return_if_fail(data != NULL);
if (!IS_IRC_SERVER(server) || !server->connected)
cmd_return_error(CMDERR_NOT_CONNECTED);
CMD_IRC_SERVER(server);
if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_OPTCHAN |
PARAM_FLAG_GETREST, item, &channame, &msg))
@ -694,9 +643,7 @@ static void cmd_kickban(const char *data, IRC_SERVER_REC *server,
char **nicklist, *spacenicks;
void *free_arg;
g_return_if_fail(data != NULL);
if (!IS_IRC_SERVER(server) || !server->connected)
cmd_return_error(CMDERR_NOT_CONNECTED);
CMD_IRC_SERVER(server);
if (!cmd_get_params(data, &free_arg, 3 | PARAM_FLAG_OPTCHAN | PARAM_FLAG_GETREST,
item, &channel, &nicks, &reason))
@ -784,7 +731,8 @@ static void cmd_knockout(const char *data, IRC_SERVER_REC *server,
void *free_arg;
int timeleft;
g_return_if_fail(data != NULL);
CMD_IRC_SERVER(server);
if (!IS_IRC_CHANNEL(channel))
cmd_return_error(CMDERR_NOT_JOINED);
if (!channel->wholist)
@ -850,9 +798,7 @@ static void cmd_server_purge(const char *data, IRC_SERVER_REC *server)
char *target;
void *free_arg;
g_return_if_fail(data != NULL);
if (!IS_IRC_SERVER(server) || !server->connected)
cmd_return_error(CMDERR_NOT_CONNECTED);
CMD_IRC_SERVER(server);
if (!cmd_get_params(data, &free_arg, 1, &target))
return;
@ -897,9 +843,7 @@ static void cmd_oper(const char *data, IRC_SERVER_REC *server)
char *nick, *password;
void *free_arg;
g_return_if_fail(data != NULL);
if (!IS_IRC_SERVER(server) || !server->connected)
cmd_return_error(CMDERR_NOT_CONNECTED);
CMD_IRC_SERVER(server);
/* asking for password is handled by fe-common */
if (!cmd_get_params(data, &free_arg, 2, &nick, &password))
@ -913,9 +857,7 @@ static void cmd_oper(const char *data, IRC_SERVER_REC *server)
/* SYNTAX: UNSILENCE <nick!user@host> */
static void cmd_unsilence(const char *data, IRC_SERVER_REC *server)
{
g_return_if_fail(data != NULL);
if (!IS_IRC_SERVER(server) || !server->connected)
cmd_return_error(CMDERR_NOT_CONNECTED);
CMD_IRC_SERVER(server);
if (*data == '\0')
cmd_return_error(CMDERR_NOT_ENOUGH_PARAMS);
@ -925,9 +867,7 @@ static void cmd_unsilence(const char *data, IRC_SERVER_REC *server)
static void command_self(const char *data, IRC_SERVER_REC *server)
{
g_return_if_fail(data != NULL);
if (!IS_IRC_SERVER(server) || !server->connected)
cmd_return_error(CMDERR_NOT_CONNECTED);
CMD_IRC_SERVER(server);
irc_send_cmdv(server, *data == '\0' ? "%s" : "%s %s", current_command, data);
}
@ -947,9 +887,7 @@ static void command_2self(const char *data, IRC_SERVER_REC *server)
char *target, *text;
void *free_arg;
g_return_if_fail(data != NULL);
if (!IS_IRC_SERVER(server) || !server->connected)
cmd_return_error(CMDERR_NOT_CONNECTED);
CMD_IRC_SERVER(server);
if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_GETREST, &target, &text))
return;
@ -1011,85 +949,84 @@ void irc_commands_init(void)
knockout_tag = g_timeout_add(KNOCKOUT_TIMECHECK, (GSourceFunc) knockout_timeout, NULL);
command_bind("notice", NULL, (SIGNAL_FUNC) cmd_notice);
command_bind("ctcp", NULL, (SIGNAL_FUNC) cmd_ctcp);
command_bind("nctcp", NULL, (SIGNAL_FUNC) cmd_nctcp);
command_bind("part", NULL, (SIGNAL_FUNC) cmd_part);
command_bind("kick", NULL, (SIGNAL_FUNC) cmd_kick);
command_bind("topic", NULL, (SIGNAL_FUNC) cmd_topic);
command_bind("invite", NULL, (SIGNAL_FUNC) cmd_invite);
command_bind("list", NULL, (SIGNAL_FUNC) cmd_list);
command_bind("who", NULL, (SIGNAL_FUNC) cmd_who);
command_bind("names", NULL, (SIGNAL_FUNC) cmd_names);
command_bind("nick", NULL, (SIGNAL_FUNC) cmd_nick);
command_bind_irc("notice", NULL, (SIGNAL_FUNC) cmd_notice);
command_bind_irc("ctcp", NULL, (SIGNAL_FUNC) cmd_ctcp);
command_bind_irc("nctcp", NULL, (SIGNAL_FUNC) cmd_nctcp);
command_bind_irc("part", NULL, (SIGNAL_FUNC) cmd_part);
command_bind_irc("kick", NULL, (SIGNAL_FUNC) cmd_kick);
command_bind_irc("topic", NULL, (SIGNAL_FUNC) cmd_topic);
command_bind_irc("invite", NULL, (SIGNAL_FUNC) cmd_invite);
command_bind_irc("list", NULL, (SIGNAL_FUNC) cmd_list);
command_bind_irc("who", NULL, (SIGNAL_FUNC) cmd_who);
command_bind_irc("names", NULL, (SIGNAL_FUNC) cmd_names);
command_bind_irc("nick", NULL, (SIGNAL_FUNC) cmd_nick);
/* SYNTAX: NOTE <command> [&<password>] [+|-<flags>] [<arguments>] */
command_bind("note", NULL, (SIGNAL_FUNC) command_self);
command_bind("whois", NULL, (SIGNAL_FUNC) cmd_whois);
command_bind("whowas", NULL, (SIGNAL_FUNC) cmd_whowas);
command_bind("ping", NULL, (SIGNAL_FUNC) cmd_ping);
command_bind_irc("note", NULL, (SIGNAL_FUNC) command_self);
command_bind_irc("whois", NULL, (SIGNAL_FUNC) cmd_whois);
command_bind_irc("whowas", NULL, (SIGNAL_FUNC) cmd_whowas);
command_bind_irc("ping", NULL, (SIGNAL_FUNC) cmd_ping);
/* SYNTAX: KILL <nick> <reason> */
command_bind("kill", NULL, (SIGNAL_FUNC) command_2self);
command_bind("away", NULL, (SIGNAL_FUNC) cmd_away);
command_bind_irc("kill", NULL, (SIGNAL_FUNC) command_2self);
command_bind_irc("away", NULL, (SIGNAL_FUNC) cmd_away);
/* SYNTAX: ISON <nicks> */
command_bind("ison", NULL, (SIGNAL_FUNC) command_1self);
command_bind_irc("ison", NULL, (SIGNAL_FUNC) command_1self);
/* SYNTAX: ADMIN [<server>|<nickname>] */
command_bind("admin", NULL, (SIGNAL_FUNC) command_self);
command_bind_irc("admin", NULL, (SIGNAL_FUNC) command_self);
/* SYNTAX: INFO [<server>] */
command_bind("info", NULL, (SIGNAL_FUNC) command_self);
command_bind_irc("info", NULL, (SIGNAL_FUNC) command_self);
/* SYNTAX: LINKS [[<server>] <mask>] */
command_bind("links", NULL, (SIGNAL_FUNC) command_self);
command_bind_irc("links", NULL, (SIGNAL_FUNC) command_self);
/* SYNTAX: LUSERS [<server mask> [<remote server>]] */
command_bind("lusers", NULL, (SIGNAL_FUNC) command_self);
command_bind_irc("lusers", NULL, (SIGNAL_FUNC) command_self);
/* SYNTAX: MAP */
command_bind("map", NULL, (SIGNAL_FUNC) command_self);
command_bind_irc("map", NULL, (SIGNAL_FUNC) command_self);
/* SYNTAX: MOTD [<server>|<nick>] */
command_bind("motd", NULL, (SIGNAL_FUNC) command_self);
command_bind_irc("motd", NULL, (SIGNAL_FUNC) command_self);
/* SYNTAX: REHASH */
command_bind("rehash", NULL, (SIGNAL_FUNC) command_self);
command_bind_irc("rehash", NULL, (SIGNAL_FUNC) command_self);
/* SYNTAX: STATS <type> [<server>] */
command_bind("stats", NULL, (SIGNAL_FUNC) command_self);
command_bind_irc("stats", NULL, (SIGNAL_FUNC) command_self);
/* SYNTAX: TIME [<server>|<nick>] */
command_bind("time", NULL, (SIGNAL_FUNC) command_self);
command_bind_irc("time", NULL, (SIGNAL_FUNC) command_self);
/* SYNTAX: TRACE [<server>|<nick>] */
command_bind("trace", NULL, (SIGNAL_FUNC) command_self);
command_bind_irc("trace", NULL, (SIGNAL_FUNC) command_self);
/* SYNTAX: VERSION [<server>|<nick>] */
command_bind("version", NULL, (SIGNAL_FUNC) command_self);
command_bind_irc("version", NULL, (SIGNAL_FUNC) command_self);
/* SYNTAX: SERVLIST [<server mask>] */
command_bind("servlist", NULL, (SIGNAL_FUNC) command_self);
command_bind_irc("servlist", NULL, (SIGNAL_FUNC) command_self);
/* SYNTAX: SILENCE [[+|-]<nick!user@host>]
SILENCE [<nick>] */
command_bind("silence", NULL, (SIGNAL_FUNC) command_self);
command_bind("unsilence", NULL, (SIGNAL_FUNC) cmd_unsilence);
command_bind("sconnect", NULL, (SIGNAL_FUNC) cmd_sconnect);
command_bind_irc("silence", NULL, (SIGNAL_FUNC) command_self);
command_bind_irc("unsilence", NULL, (SIGNAL_FUNC) cmd_unsilence);
command_bind_irc("sconnect", NULL, (SIGNAL_FUNC) cmd_sconnect);
/* SYNTAX: SQUERY <service> [<commands>] */
command_bind("squery", NULL, (SIGNAL_FUNC) command_2self);
command_bind("deop", NULL, (SIGNAL_FUNC) cmd_deop);
command_bind_irc("squery", NULL, (SIGNAL_FUNC) command_2self);
/* SYNTAX: DIE */
command_bind("die", NULL, (SIGNAL_FUNC) command_self);
command_bind_irc("die", NULL, (SIGNAL_FUNC) command_self);
/* SYNTAX: HASH */
command_bind("hash", NULL, (SIGNAL_FUNC) command_self);
command_bind("oper", NULL, (SIGNAL_FUNC) cmd_oper);
command_bind_irc("hash", NULL, (SIGNAL_FUNC) command_self);
command_bind_irc("oper", NULL, (SIGNAL_FUNC) cmd_oper);
/* SYNTAX: RESTART */
command_bind("restart", NULL, (SIGNAL_FUNC) command_self);
command_bind_irc("restart", NULL, (SIGNAL_FUNC) command_self);
/* SYNTAX: RPING <server> */
command_bind("rping", NULL, (SIGNAL_FUNC) command_self);
command_bind_irc("rping", NULL, (SIGNAL_FUNC) command_self);
/* SYNTAX: SQUIT <server>|<mask> <reason> */
command_bind("squit", NULL, (SIGNAL_FUNC) command_2self);
command_bind_irc("squit", NULL, (SIGNAL_FUNC) command_2self);
/* SYNTAX: UPING <server> */
command_bind("uping", NULL, (SIGNAL_FUNC) command_self);
command_bind_irc("uping", NULL, (SIGNAL_FUNC) command_self);
/* SYNTAX: USERHOST <nicks> */
command_bind("userhost", NULL, (SIGNAL_FUNC) command_self);
command_bind("quote", NULL, (SIGNAL_FUNC) cmd_quote);
command_bind("rawquote", NULL, (SIGNAL_FUNC) cmd_rawquote);
command_bind("wall", NULL, (SIGNAL_FUNC) cmd_wall);
command_bind("wait", NULL, (SIGNAL_FUNC) cmd_wait);
command_bind_irc("userhost", NULL, (SIGNAL_FUNC) command_self);
command_bind_irc("quote", NULL, (SIGNAL_FUNC) cmd_quote);
command_bind_irc("rawquote", NULL, (SIGNAL_FUNC) cmd_rawquote);
command_bind_irc("wall", NULL, (SIGNAL_FUNC) cmd_wall);
command_bind_irc("wait", NULL, (SIGNAL_FUNC) cmd_wait);
/* SYNTAX: WALLOPS <message> */
command_bind("wallops", NULL, (SIGNAL_FUNC) command_1self);
command_bind_irc("wallops", NULL, (SIGNAL_FUNC) command_1self);
/* SYNTAX: WALLCHOPS <channel> <message> */
command_bind("wallchops", NULL, (SIGNAL_FUNC) command_2self);
command_bind("kickban", NULL, (SIGNAL_FUNC) cmd_kickban);
command_bind("knockout", NULL, (SIGNAL_FUNC) cmd_knockout);
command_bind("server purge", NULL, (SIGNAL_FUNC) cmd_server_purge);
command_bind_irc("wallchops", NULL, (SIGNAL_FUNC) command_2self);
command_bind_irc("kickban", NULL, (SIGNAL_FUNC) cmd_kickban);
command_bind_irc("knockout", NULL, (SIGNAL_FUNC) cmd_knockout);
command_bind_irc("server purge", NULL, (SIGNAL_FUNC) cmd_server_purge);
signal_add("channel destroyed", (SIGNAL_FUNC) sig_channel_destroyed);
signal_add("server disconnected", (SIGNAL_FUNC) sig_server_disconnected);
@ -1144,7 +1081,6 @@ void irc_commands_deinit(void)
command_unbind("unsilence", (SIGNAL_FUNC) cmd_unsilence);
command_unbind("sconnect", (SIGNAL_FUNC) cmd_sconnect);
command_unbind("squery", (SIGNAL_FUNC) command_2self);
command_unbind("deop", (SIGNAL_FUNC) cmd_deop);
command_unbind("die", (SIGNAL_FUNC) command_self);
command_unbind("hash", (SIGNAL_FUNC) command_self);
command_unbind("oper", (SIGNAL_FUNC) cmd_oper);

View File

@ -0,0 +1,26 @@
#ifndef __IRC_COMMANDS_H
#define __IRC_COMMANDS_H
#include "commands.h"
#define command_bind_irc(cmd, section, signal) \
command_bind_proto(cmd, IRC_PROTOCOL, section, signal)
#define command_bind_irc_first(cmd, section, signal) \
command_bind_proto_first(cmd, IRC_PROTOCOL, section, signal)
#define command_bind_irc_last(cmd, section, signal) \
command_bind_proto_last(cmd, IRC_PROTOCOL, section, signal)
/* Simply returns if server isn't for IRC protocol. Prints ERR_NOT_CONNECTED
error if there's no server or server isn't connected yet */
#define CMD_IRC_SERVER(server) \
G_STMT_START { \
if (server != NULL && !IS_IRC_SERVER(server)) \
return; \
if (server == NULL || !(server)->connected) \
cmd_return_error(CMDERR_NOT_CONNECTED); \
} G_STMT_END
void irc_commands_init(void);
void irc_commands_deinit(void);
#endif

View File

@ -30,15 +30,9 @@
#include "channels-setup.h"
#include "ctcp.h"
#include "irc.h"
#include "irc-commands.h"
#include "netsplit.h"
void irc_commands_init(void);
void irc_commands_deinit(void);
void irc_rawlog_init(void);
void irc_rawlog_deinit(void);
void irc_expandos_init(void);
void irc_expandos_deinit(void);
@ -116,7 +110,6 @@ void irc_core_init(void)
irc_irc_init();
lag_init();
netsplit_init();
irc_rawlog_init();
irc_expandos_init();
module_register("core", "irc");
@ -127,7 +120,6 @@ void irc_core_deinit(void)
signal_emit("chat protocol deinit", 1, chat_protocol_find("IRC"));
irc_expandos_deinit();
irc_rawlog_deinit();
netsplit_deinit();
lag_deinit();
irc_commands_deinit();

View File

@ -23,7 +23,6 @@
#include "expandos.h"
#include "settings.h"
#include "irc.h"
#include "irc-servers.h"
#include "channels.h"
#include "nicklist.h"

View File

@ -21,7 +21,6 @@
#include "module.h"
#include "network.h"
#include "irc.h"
#include "irc-masks.h"
static char *get_domain_mask(char *host)

View File

@ -22,7 +22,7 @@
#include "signals.h"
#include "misc.h"
#include "irc.h"
#include "irc-servers.h"
#include "irc-channels.h"
#include "irc-masks.h"
#include "irc-nicklist.h"

View File

@ -2,7 +2,6 @@
#define __IRC_NICKLIST_H
#include "nicklist.h"
#include "irc-channels.h"
/* Add new nick to list */
NICK_REC *irc_nicklist_insert(IRC_CHANNEL_REC *channel, const char *nick,

View File

@ -22,7 +22,7 @@
#include "signals.h"
#include "misc.h"
#include "irc.h"
#include "irc-servers.h"
#include "irc-queries.h"
QUERY_REC *irc_query_create(const char *server_tag,

View File

@ -3,7 +3,6 @@
#include "chat-protocols.h"
#include "queries.h"
#include "irc-servers.h"
/* Returns IRC_QUERY_REC if it's IRC query, NULL if it isn't. */
#define IRC_QUERY(query) \

View File

@ -1,79 +0,0 @@
/*
irc-rawlog.c : irssi
Copyright (C) 1999-2000 Timo Sirainen
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "module.h"
#include "rawlog.h"
#include "signals.h"
#include "misc.h"
#include "commands.h"
#include "servers.h"
#include "settings.h"
static void cmd_rawlog(const char *data, SERVER_REC *server, void *item)
{
command_runsub("rawlog", data, server, item);
}
/* SYNTAX: RAWLOG SAVE <file> */
static void cmd_rawlog_save(const char *data, SERVER_REC *server)
{
g_return_if_fail(data != NULL);
if (server == NULL || !server->connected) cmd_return_error(CMDERR_NOT_CONNECTED);
if (*data == '\0') cmd_return_error(CMDERR_NOT_ENOUGH_PARAMS);
rawlog_save(server->rawlog, data);
}
/* SYNTAX: RAWLOG OPEN <file> */
static void cmd_rawlog_open(const char *data, SERVER_REC *server)
{
g_return_if_fail(data != NULL);
if (server == NULL || !server->connected) cmd_return_error(CMDERR_NOT_CONNECTED);
if (*data == '\0') cmd_return_error(CMDERR_NOT_ENOUGH_PARAMS);
rawlog_open(server->rawlog, data);
}
/* SYNTAX: RAWLOG CLOSE */
static void cmd_rawlog_close(const char *data, SERVER_REC *server)
{
g_return_if_fail(data != NULL);
if (server == NULL || !server->connected) cmd_return_error(CMDERR_NOT_CONNECTED);
rawlog_close(server->rawlog);
}
void irc_rawlog_init(void)
{
command_bind("rawlog", NULL, (SIGNAL_FUNC) cmd_rawlog);
command_bind("rawlog save", NULL, (SIGNAL_FUNC) cmd_rawlog_save);
command_bind("rawlog open", NULL, (SIGNAL_FUNC) cmd_rawlog_open);
command_bind("rawlog close", NULL, (SIGNAL_FUNC) cmd_rawlog_close);
}
void irc_rawlog_deinit(void)
{
command_unbind("rawlog", (SIGNAL_FUNC) cmd_rawlog);
command_unbind("rawlog save", (SIGNAL_FUNC) cmd_rawlog_save);
command_unbind("rawlog open", (SIGNAL_FUNC) cmd_rawlog_open);
command_unbind("rawlog close", (SIGNAL_FUNC) cmd_rawlog_close);
}

View File

@ -23,7 +23,6 @@
#include "network.h"
#include "signals.h"
#include "irc.h"
#include "modes.h"
#include "irc-servers.h"

View File

@ -30,7 +30,6 @@
#include "channels.h"
#include "queries.h"
#include "irc.h"
#include "irc-servers-setup.h"
#include "irc-servers.h"
#include "channel-rejoin.h"

View File

@ -20,7 +20,7 @@
/* all strings should be either NULL or dynamically allocated */
/* address and nick are mandatory, rest are optional */
typedef struct {
struct _IRC_SERVER_CONNECT_REC {
#include "server-connect-rec.h"
char *usermode;
@ -31,10 +31,10 @@ typedef struct {
int max_query_chans;
int max_kicks, max_msgs, max_modes, max_whois;
} IRC_SERVER_CONNECT_REC;
};
#define STRUCT_SERVER_CONNECT_REC IRC_SERVER_CONNECT_REC
typedef struct {
struct _IRC_SERVER_REC {
#include "server-rec.h"
char *real_address; /* address the irc server gives */
@ -87,7 +87,7 @@ typedef struct {
channels go here if they're "temporarily unavailable"
because of netsplits */
void *chanqueries;
} IRC_SERVER_REC;
};
IRC_SERVER_REC *irc_server_connect(IRC_SERVER_CONNECT_REC *conn);

View File

@ -26,7 +26,6 @@
#include "rawlog.h"
#include "misc.h"
#include "irc.h"
#include "irc-servers.h"
#include "irc-channels.h"
#include "servers-redirect.h"

View File

@ -1,7 +1,10 @@
#ifndef __IRC_H
#define __IRC_H
#include "irc-servers.h"
typedef struct _IRC_CHATNET_REC IRC_CHATNET_REC;
typedef struct _IRC_SERVER_CONNECT_REC IRC_SERVER_CONNECT_REC;
typedef struct _IRC_SERVER_REC IRC_SERVER_REC;
typedef struct _IRC_CHANNEL_REC IRC_CHANNEL_REC;
/* From ircd 2.9.5:
none I line with ident
@ -26,6 +29,7 @@
(a) == '+') /* modeless */
#define IS_IRC_ITEM(rec) (IS_IRC_CHANNEL(rec) || IS_IRC_QUERY(rec))
#define IRC_PROTOCOL (chat_protocol_lookup("IRC"))
extern char *current_server_event; /* current server event being processed */

View File

@ -23,7 +23,6 @@
#include "misc.h"
#include "settings.h"
#include "irc.h"
#include "irc-servers.h"
typedef struct {

View File

@ -22,7 +22,6 @@
#include "signals.h"
#include "settings.h"
#include "irc.h"
#include "irc-servers.h"
#include "irc-channels.h"
#include "irc-nicklist.h"

View File

@ -22,7 +22,8 @@
#include "misc.h"
#include "signals.h"
#include "irc.h"
#include "irc-servers.h"
#include "irc-channels.h"
#include "mode-lists.h"
static void ban_free(GSList **list, BAN_REC *rec)

View File

@ -1,8 +1,6 @@
#ifndef __MODE_LISTS_H
#define __MODE_LISTS_H
#include "irc-channels.h"
typedef struct {
char *ban;
char *setby;

View File

@ -20,10 +20,11 @@
#include "module.h"
#include "signals.h"
#include "commands.h"
#include "settings.h"
#include "irc.h"
#include "irc-commands.h"
#include "irc-servers.h"
#include "irc-channels.h"
#include "modes.h"
#include "mode-lists.h"
#include "nicklist.h"
@ -590,8 +591,7 @@ static void cmd_op(const char *data, IRC_SERVER_REC *server,
{
char *nicks;
if (!IS_IRC_CHANNEL(channel))
return;
CMD_IRC_SERVER(server);
nicks = get_nicks(channel, data, 0, -1);
if (nicks != NULL && *nicks != '\0')
@ -605,8 +605,7 @@ static void cmd_deop(const char *data, IRC_SERVER_REC *server,
{
char *nicks;
if (!IS_IRC_CHANNEL(channel))
return;
CMD_IRC_SERVER(server);
nicks = get_nicks(channel, data, 1, -1);
if (nicks != NULL && *nicks != '\0')
@ -620,8 +619,7 @@ static void cmd_voice(const char *data, IRC_SERVER_REC *server,
{
char *nicks;
if (!IS_IRC_CHANNEL(channel))
return;
CMD_IRC_SERVER(server);
nicks = get_nicks(channel, data, 0, 0);
if (nicks != NULL && *nicks != '\0')
@ -635,8 +633,7 @@ static void cmd_devoice(const char *data, IRC_SERVER_REC *server,
{
char *nicks;
if (!IS_IRC_CHANNEL(channel))
return;
CMD_IRC_SERVER(server);
nicks = get_nicks(channel, data, -1, 1);
if (nicks != NULL && *nicks != '\0')
@ -651,9 +648,7 @@ static void cmd_mode(const char *data, IRC_SERVER_REC *server,
char *target, *mode;
void *free_arg;
g_return_if_fail(data != NULL);
if (server == NULL || !server->connected || !IS_IRC_SERVER(server))
cmd_return_error(CMDERR_NOT_CONNECTED);
CMD_IRC_SERVER(server);
if (*data == '+' || *data == '-') {
target = "*";
@ -692,11 +687,11 @@ void modes_init(void)
signal_add("event 381", (SIGNAL_FUNC) event_oper);
signal_add("event mode", (SIGNAL_FUNC) event_mode);
command_bind("op", NULL, (SIGNAL_FUNC) cmd_op);
command_bind("deop", NULL, (SIGNAL_FUNC) cmd_deop);
command_bind("voice", NULL, (SIGNAL_FUNC) cmd_voice);
command_bind("devoice", NULL, (SIGNAL_FUNC) cmd_devoice);
command_bind("mode", NULL, (SIGNAL_FUNC) cmd_mode);
command_bind_irc("op", NULL, (SIGNAL_FUNC) cmd_op);
command_bind_irc("deop", NULL, (SIGNAL_FUNC) cmd_deop);
command_bind_irc("voice", NULL, (SIGNAL_FUNC) cmd_voice);
command_bind_irc("devoice", NULL, (SIGNAL_FUNC) cmd_devoice);
command_bind_irc("mode", NULL, (SIGNAL_FUNC) cmd_mode);
}
void modes_deinit(void)

View File

@ -1,9 +1,6 @@
#ifndef __MODES_H
#define __MODES_H
#include "irc-servers.h"
#include "irc-channels.h"
/* modes that have argument always */
#define HAS_MODE_ARG_ALWAYS(mode) \
((mode) == 'b' || (mode) == 'e' || (mode) == 'I' || (mode) == 'k' || \

View File

@ -1,5 +1,4 @@
#include "common.h"
#include "irc.h"
#define MODULE_NAME "irc/core"
#define IRC_PROTOCOL (chat_protocol_lookup("IRC"))

View File

@ -24,7 +24,6 @@
#include "irc-servers.h"
#include "server-idle.h"
#include "servers-redirect.h"
#include "irc.h"
typedef struct {
char *event;

View File

@ -1,8 +1,6 @@
#ifndef __SERVER_IDLE_H
#define __SERVER_IDLE_H
#include "irc-servers.h"
/* Add new idle command to queue */
int server_idle_add(IRC_SERVER_REC *server, const char *cmd, const char *arg, int last, ...);

View File

@ -22,6 +22,7 @@
#include "signals.h"
#include "masks.h"
#include "settings.h"
#include "servers.h"
#include "dcc-get.h"

View File

@ -28,10 +28,10 @@
#include "misc.h"
#include "settings.h"
#include "masks.h"
#include "irc.h"
#include "servers-setup.h"
#include "irc-servers.h"
#include "irc-queries.h"
#include "servers-setup.h"
#include "masks.h"
#include "dcc-chat.h"
@ -199,7 +199,7 @@ static void cmd_msg(const char *data)
signal_stop();
}
static void cmd_me(const char *data, IRC_SERVER_REC *server, QUERY_REC *item)
static void cmd_me(const char *data, SERVER_REC *server, QUERY_REC *item)
{
CHAT_DCC_REC *dcc;
char *str;
@ -216,7 +216,7 @@ static void cmd_me(const char *data, IRC_SERVER_REC *server, QUERY_REC *item)
signal_stop();
}
static void cmd_action(const char *data, IRC_SERVER_REC *server)
static void cmd_action(const char *data, SERVER_REC *server)
{
CHAT_DCC_REC *dcc;
char *target, *text, *str;
@ -246,15 +246,13 @@ static void cmd_action(const char *data, IRC_SERVER_REC *server)
signal_stop();
}
static void cmd_ctcp(const char *data, IRC_SERVER_REC *server)
static void cmd_ctcp(const char *data, SERVER_REC *server)
{
CHAT_DCC_REC *dcc;
char *target, *ctcpcmd, *ctcpdata, *str;
void *free_arg;
g_return_if_fail(data != NULL);
if (server == NULL || !server->connected)
cmd_return_error(CMDERR_NOT_CONNECTED);
if (!cmd_get_params(data, &free_arg, 3 | PARAM_FLAG_GETREST,
&target, &ctcpcmd, &ctcpdata))
@ -425,7 +423,7 @@ static void cmd_dcc_chat(const char *data, IRC_SERVER_REC *server)
}
/* start listening */
if (server == NULL || !server->connected)
if (!IS_IRC_SERVER(server) || !server->connected)
cmd_param_error(CMDERR_NOT_CONNECTED);
handle = dcc_listen(net_sendbuffer_handle(server->handle),
@ -449,7 +447,7 @@ static void cmd_dcc_chat(const char *data, IRC_SERVER_REC *server)
}
/* SYNTAX: MIRCDCC ON|OFF */
static void cmd_mircdcc(const char *data, IRC_SERVER_REC *server,
static void cmd_mircdcc(const char *data, SERVER_REC *server,
QUERY_REC *item)
{
CHAT_DCC_REC *dcc;
@ -465,7 +463,7 @@ static void cmd_mircdcc(const char *data, IRC_SERVER_REC *server,
/* DCC CLOSE CHAT <nick> - check only from chat_ids in open DCC chats,
the default handler will check from DCC chat requests */
static void cmd_dcc_close(char *data, IRC_SERVER_REC *server)
static void cmd_dcc_close(char *data, SERVER_REC *server)
{
GSList *tmp, *next;
char *nick;
@ -488,8 +486,8 @@ static void cmd_dcc_close(char *data, IRC_SERVER_REC *server)
if (IS_DCC_CHAT(dcc) && dcc->id != NULL &&
g_strcasecmp(dcc->id, nick) == 0) {
found = TRUE;
if (!dcc_is_connected(dcc))
dcc_reject(DCC(dcc), server);
if (!dcc_is_connected(dcc) && IS_IRC_SERVER(server))
dcc_reject(DCC(dcc), IRC_SERVER(server));
else {
/* don't send DCC REJECT after DCC chat
is already open */
@ -503,7 +501,7 @@ static void cmd_dcc_close(char *data, IRC_SERVER_REC *server)
cmd_params_free(free_arg);
}
static void cmd_whois(const char *data, IRC_SERVER_REC *server,
static void cmd_whois(const char *data, SERVER_REC *server,
WI_ITEM_REC *item)
{
CHAT_DCC_REC *dcc;

View File

@ -25,7 +25,9 @@
#include "misc.h"
#include "settings.h"
#include "irc-servers.h"
#include "servers-setup.h"
#include "dcc-get.h"
static int dcc_file_create_mode;

View File

@ -26,6 +26,8 @@
#include "misc.h"
#include "settings.h"
#include "irc-servers.h"
#include "dcc-send.h"
#include "dcc-chat.h"
@ -189,6 +191,9 @@ static void cmd_dcc_send(const char *data, IRC_SERVER_REC *server,
g_strcasecmp(target, chat->nick) != 0))
chat = NULL;
if (!IS_IRC_SERVER(server))
server = NULL;
if ((server == NULL || !server->connected) && chat == NULL)
cmd_param_error(CMDERR_NOT_CONNECTED);

View File

@ -26,7 +26,7 @@
#include "misc.h"
#include "settings.h"
#include "irc.h"
#include "irc-servers.h"
#include "dcc-chat.h"
#include "dcc-get.h"

View File

@ -3,7 +3,6 @@
#include "modules.h"
#include "network.h"
#include "irc-servers.h"
#define DCC(dcc) ((DCC_REC *) (dcc))

View File

@ -1,3 +1,4 @@
#include "common.h"
#include "irc.h"
#define MODULE_NAME "irc/dcc"

View File

@ -1,4 +1,5 @@
#include "common.h"
#include "irc.h"
typedef struct {
/* Flood protection */

View File

@ -1,4 +1,5 @@
#include "common.h"
#include "irc.h"
#define MODULE_NAME "irc/notifylist"