1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-05 09:13:14 +02:00

Move some functions from irc-server.c and irc-protocol.c to irc-message.c

This commit is contained in:
Sebastien Helleu
2010-11-21 13:06:37 +01:00
parent 428e160f02
commit c2fda185d8
12 changed files with 400 additions and 334 deletions
+2
View File
@@ -133,6 +133,8 @@
./src/plugins/irc/irc-info.h
./src/plugins/irc/irc-input.c
./src/plugins/irc/irc-input.h
./src/plugins/irc/irc-message.c
./src/plugins/irc/irc-message.h
./src/plugins/irc/irc-mode.c
./src/plugins/irc/irc-mode.h
./src/plugins/irc/irc-msgbuffer.c
+2
View File
@@ -134,6 +134,8 @@ SET(WEECHAT_SOURCES
./src/plugins/irc/irc-info.h
./src/plugins/irc/irc-input.c
./src/plugins/irc/irc-input.h
./src/plugins/irc/irc-message.c
./src/plugins/irc/irc-message.h
./src/plugins/irc/irc-mode.c
./src/plugins/irc/irc-mode.h
./src/plugins/irc/irc-msgbuffer.c
+1
View File
@@ -32,6 +32,7 @@ irc-display.c irc-display.h
irc-ignore.c irc-ignore.h
irc-info.c irc-info.h
irc-input.c irc-input.h
irc-message.c irc-message.h
irc-mode.c irc-mode.h
irc-msgbuffer.c irc-msgbuffer.h
irc-nick.c irc-nick.h
+2
View File
@@ -51,6 +51,8 @@ irc_la_SOURCES = irc.c \
irc-info.h \
irc-input.c \
irc-input.h \
irc-message.c \
irc-message.h \
irc-mode.c \
irc-mode.h \
irc-msgbuffer.c \
+4 -3
View File
@@ -30,6 +30,7 @@
#include "irc-channel.h"
#include "irc-config.h"
#include "irc-ignore.h"
#include "irc-message.h"
#include "irc-nick.h"
#include "irc-notify.h"
#include "irc-protocol.h"
@@ -97,7 +98,7 @@ irc_info_get_info_cb (void *data, const char *info_name,
}
else if (weechat_strcasecmp (info_name, "irc_nick_from_host") == 0)
{
return irc_protocol_get_nick_from_host (arguments);
return irc_message_get_nick_from_host (arguments);
}
else if (weechat_strcasecmp (info_name, "irc_nick_color") == 0)
{
@@ -149,7 +150,7 @@ irc_info_get_info_cb (void *data, const char *info_name,
{
free (channel);
channel = NULL;
nick = irc_protocol_get_nick_from_host (host);
nick = irc_message_get_nick_from_host (host);
if (nick)
channel = strdup (nick);
@@ -252,7 +253,7 @@ irc_info_get_info_hashtable_cb (void *data, const char *info_name,
"message");
if (message)
{
value = irc_server_parse_message_to_hashtable (message);
value = irc_message_parse_to_hashtable (message);
return value;
}
}
+329
View File
@@ -0,0 +1,329 @@
/*
* Copyright (C) 2003-2010 Sebastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
* WeeChat is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* WeeChat 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 WeeChat. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* irc-message.c: functions for IRC messages
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "../weechat-plugin.h"
#include "irc.h"
#include "irc-server.h"
#include "irc-channel.h"
/*
* irc_message_parse: parse IRC message and return pointer to host, command,
* channel, target nick and arguments (if any)
*/
void
irc_message_parse (const char *message, char **nick, char **host,
char **command, char **channel, char **arguments)
{
const char *pos, *pos2, *pos3, *pos4, *pos5;
if (nick)
*nick = NULL;
if (host)
*host = NULL;
if (command)
*command = NULL;
if (channel)
*channel = NULL;
if (arguments)
*arguments = NULL;
if (!message)
return;
/*
* we will use this message as example:
* :FlashCode!n=FlashCod@host.com PRIVMSG #channel :hello!
*/
if (message[0] == ':')
{
pos2 = strchr (message, '!');
pos = strchr (message, ' ');
if (pos2 && (!pos || pos > pos2))
{
if (nick)
*nick = weechat_strndup (message + 1, pos2 - (message + 1));
}
else if (pos)
{
if (nick)
*nick = weechat_strndup (message + 1, pos - (message + 1));
}
if (pos)
{
if (host)
*host = weechat_strndup (message + 1, pos - (message + 1));
pos++;
}
else
pos = message;
}
else
pos = message;
/* pos is pointer on PRIVMSG #channel :hello! */
if (pos && pos[0])
{
while (pos[0] == ' ')
{
pos++;
}
pos2 = strchr (pos, ' ');
if (pos2)
{
/* pos2 is pointer on #channel :hello! */
if (command)
*command = weechat_strndup (pos, pos2 - pos);
pos2++;
while (pos2[0] == ' ')
{
pos2++;
}
if (arguments)
*arguments = strdup (pos2);
if (pos2[0] != ':')
{
if (irc_channel_is_channel (pos2))
{
pos3 = strchr (pos2, ' ');
if (channel)
{
if (pos3)
*channel = weechat_strndup (pos2, pos3 - pos2);
else
*channel = strdup (pos2);
}
}
else
{
pos3 = strchr (pos2, ' ');
if (nick && !*nick)
{
if (pos3)
*nick = weechat_strndup (pos2, pos3 - pos2);
else
*nick = strdup (pos2);
}
if (pos3)
{
pos4 = pos3;
pos3++;
while (pos3[0] == ' ')
{
pos3++;
}
if (irc_channel_is_channel (pos3))
{
pos5 = strchr (pos3, ' ');
if (channel)
{
if (pos5)
*channel = weechat_strndup (pos3, pos5 - pos3);
else
*channel = strdup (pos3);
}
}
else if (channel && !*channel)
{
*channel = weechat_strndup (pos2, pos4 - pos2);
}
}
}
}
}
else
{
if (command)
*command = strdup (pos);
}
}
}
/*
* irc_message_parse_to_hashtable: parse IRC message and return hashtable with
* keys: nick, host, command, channel, arguments
* Note: hashtable has to be free()
* after use
*/
struct t_hashtable *
irc_message_parse_to_hashtable (const char *message)
{
char *nick, *host, *command, *channel, *arguments;
char empty_str[1] = { '\0' };
struct t_hashtable *hashtable;
irc_message_parse (message, &nick, &host, &command, &channel, &arguments);
hashtable = weechat_hashtable_new (8,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING,
NULL,
NULL);
if (!hashtable)
return NULL;
weechat_hashtable_set (hashtable, "nick", (nick) ? nick : empty_str);
weechat_hashtable_set (hashtable, "host", (host) ? host : empty_str);
weechat_hashtable_set (hashtable, "command", (command) ? command : empty_str);
weechat_hashtable_set (hashtable, "channel", (channel) ? channel : empty_str);
weechat_hashtable_set (hashtable, "arguments", (arguments) ? arguments : empty_str);
return hashtable;
}
/*
* irc_message_get_nick_from_host: get nick from host in an IRC message
*/
const char *
irc_message_get_nick_from_host (const char *host)
{
static char nick[128];
char host2[128], *pos_space, *pos;
const char *ptr_host;
if (!host)
return NULL;
nick[0] = '\0';
if (host)
{
ptr_host = host;
pos_space = strchr (host, ' ');
if (pos_space)
{
if (pos_space - host < (int)sizeof (host2))
{
strncpy (host2, host, pos_space - host);
host2[pos_space - host] = '\0';
}
else
snprintf (host2, sizeof (host2), "%s", host);
ptr_host = host2;
}
if (ptr_host[0] == ':')
ptr_host++;
pos = strchr (ptr_host, '!');
if (pos && (pos - ptr_host < (int)sizeof (nick)))
{
strncpy (nick, ptr_host, pos - ptr_host);
nick[pos - ptr_host] = '\0';
}
else
{
snprintf (nick, sizeof (nick), "%s", ptr_host);
}
}
return nick;
}
/*
* irc_message_get_address_from_host: get address from host in an IRC message
*/
const char *
irc_message_get_address_from_host (const char *host)
{
static char address[256];
char host2[256], *pos_space, *pos;
const char *ptr_host;
address[0] = '\0';
if (host)
{
ptr_host = host;
pos_space = strchr (host, ' ');
if (pos_space)
{
if (pos_space - host < (int)sizeof (host2))
{
strncpy (host2, host, pos_space - host);
host2[pos_space - host] = '\0';
}
else
snprintf (host2, sizeof (host2), "%s", host);
ptr_host = host2;
}
if (ptr_host[0] == ':')
ptr_host++;
pos = strchr (ptr_host, '!');
if (pos)
snprintf (address, sizeof (address), "%s", pos + 1);
else
snprintf (address, sizeof (address), "%s", ptr_host);
}
return address;
}
/*
* irc_message_replace_vars: replace special IRC vars ($nick, $channel,
* $server) in a string
* Note: result has to be free() after use
*/
char *
irc_message_replace_vars (struct t_irc_server *server,
struct t_irc_channel *channel, const char *string)
{
char *var_nick, *var_channel, *var_server;
char empty_string[1] = { '\0' };
char *res, *temp;
var_nick = (server && server->nick) ? server->nick : empty_string;
var_channel = (channel) ? channel->name : empty_string;
var_server = (server) ? server->name : empty_string;
/* replace nick */
temp = weechat_string_replace (string, "$nick", var_nick);
if (!temp)
return NULL;
res = temp;
/* replace channel */
temp = weechat_string_replace (res, "$channel", var_channel);
free (res);
if (!temp)
return NULL;
res = temp;
/* replace server */
temp = weechat_string_replace (res, "$server", var_server);
free (res);
if (!temp)
return NULL;
res = temp;
/* return result */
return res;
}
+33
View File
@@ -0,0 +1,33 @@
/*
* Copyright (C) 2003-2010 Sebastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
* WeeChat is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* WeeChat 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 WeeChat. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __WEECHAT_IRC_MESSAGE_H
#define __WEECHAT_IRC_MESSAGE_H 1
extern void irc_message_parse (const char *message, char **nick, char **host,
char **command, char **channel,
char **arguments);
extern struct t_hashtable *irc_message_parse_to_hashtable (const char *message);
extern const char *irc_message_get_nick_from_host (const char *host);
extern const char *irc_message_get_address_from_host (const char *host);
extern char *irc_message_replace_vars (struct t_irc_server *server,
struct t_irc_channel *channel,
const char *string);
#endif /* __WEECHAT_IRC_MESSAGE_H */
+5 -4
View File
@@ -30,6 +30,7 @@
#include "irc-notify.h"
#include "irc-color.h"
#include "irc-config.h"
#include "irc-message.h"
#include "irc-redirect.h"
#include "irc-server.h"
@@ -596,8 +597,8 @@ irc_notify_hsignal_cb (void *data, const char *signal,
}
for (i = 0; i < num_messages; i++)
{
irc_server_parse_message (messages[i], NULL, NULL, NULL, NULL,
&arguments);
irc_message_parse (messages[i], NULL, NULL, NULL, NULL,
&arguments);
if (arguments)
{
pos = strchr (arguments, ' ');
@@ -672,8 +673,8 @@ irc_notify_hsignal_cb (void *data, const char *signal,
{
for (i = 0; i < num_messages; i++)
{
irc_server_parse_message (messages[0], NULL, NULL,
&irc_cmd, NULL, &arguments);
irc_message_parse (messages[0], NULL, NULL, &irc_cmd, NULL,
&arguments);
if (irc_cmd && arguments)
{
if (strcmp (irc_cmd, "401") == 0)
+17 -147
View File
@@ -44,6 +44,7 @@
#include "irc-config.h"
#include "irc-ctcp.h"
#include "irc-ignore.h"
#include "irc-message.h"
#include "irc-mode.h"
#include "irc-msgbuffer.h"
#include "irc-nick.h"
@@ -67,95 +68,6 @@ irc_protocol_is_numeric_command (const char *str)
return 1;
}
/*
* irc_protocol_get_nick_from_host: get nick from host in an IRC message
*/
const char *
irc_protocol_get_nick_from_host (const char *host)
{
static char nick[128];
char host2[128], *pos_space, *pos;
const char *ptr_host;
if (!host)
return NULL;
nick[0] = '\0';
if (host)
{
ptr_host = host;
pos_space = strchr (host, ' ');
if (pos_space)
{
if (pos_space - host < (int)sizeof (host2))
{
strncpy (host2, host, pos_space - host);
host2[pos_space - host] = '\0';
}
else
snprintf (host2, sizeof (host2), "%s", host);
ptr_host = host2;
}
if (ptr_host[0] == ':')
ptr_host++;
pos = strchr (ptr_host, '!');
if (pos && (pos - ptr_host < (int)sizeof (nick)))
{
strncpy (nick, ptr_host, pos - ptr_host);
nick[pos - ptr_host] = '\0';
}
else
{
snprintf (nick, sizeof (nick), "%s", ptr_host);
}
}
return nick;
}
/*
* irc_protocol_get_address_from_host: get address from host in an IRC message
*/
const char *
irc_protocol_get_address_from_host (const char *host)
{
static char address[256];
char host2[256], *pos_space, *pos;
const char *ptr_host;
address[0] = '\0';
if (host)
{
ptr_host = host;
pos_space = strchr (host, ' ');
if (pos_space)
{
if (pos_space - host < (int)sizeof (host2))
{
strncpy (host2, host, pos_space - host);
host2[pos_space - host] = '\0';
}
else
snprintf (host2, sizeof (host2), "%s", host);
ptr_host = host2;
}
if (ptr_host[0] == ':')
ptr_host++;
pos = strchr (ptr_host, '!');
if (pos)
snprintf (address, sizeof (address), "%s", pos + 1);
else
snprintf (address, sizeof (address), "%s", ptr_host);
}
return address;
}
/*
* irc_protocol_log_level_for_command: get log level for IRC command
*/
@@ -221,48 +133,6 @@ irc_protocol_tags (const char *command, const char *tags, const char *nick)
return string;
}
/*
* irc_protocol_replace_vars: replace special IRC vars ($nick, $channel,
* $server) in a string
* Note: result has to be free() after use
*/
char *
irc_protocol_replace_vars (struct t_irc_server *server,
struct t_irc_channel *channel, const char *string)
{
char *var_nick, *var_channel, *var_server;
char empty_string[1] = { '\0' };
char *res, *temp;
var_nick = (server && server->nick) ? server->nick : empty_string;
var_channel = (channel) ? channel->name : empty_string;
var_server = (server) ? server->name : empty_string;
/* replace nick */
temp = weechat_string_replace (string, "$nick", var_nick);
if (!temp)
return NULL;
res = temp;
/* replace channel */
temp = weechat_string_replace (res, "$channel", var_channel);
free (res);
if (!temp)
return NULL;
res = temp;
/* replace server */
temp = weechat_string_replace (res, "$server", var_server);
free (res);
if (!temp)
return NULL;
res = temp;
/* return result */
return res;
}
/*
* irc_protocol_cb_authenticate: 'authenticate' message received
*/
@@ -1955,8 +1825,8 @@ IRC_PROTOCOL_CALLBACK(001)
{
for (ptr_cmd = commands; *ptr_cmd; ptr_cmd++)
{
vars_replaced = irc_protocol_replace_vars (server, NULL,
*ptr_cmd);
vars_replaced = irc_message_replace_vars (server, NULL,
*ptr_cmd);
weechat_command (server->buffer,
(vars_replaced) ? vars_replaced : *ptr_cmd);
if (vars_replaced)
@@ -2956,8 +2826,8 @@ IRC_PROTOCOL_CALLBACK(333)
IRC_PROTOCOL_MIN_ARGS(5);
topic_nick = (argc > 5) ? irc_protocol_get_nick_from_host (argv[4]) : NULL;
topic_address = (argc > 5) ? irc_protocol_get_address_from_host (argv[4]) : NULL;
topic_nick = (argc > 5) ? irc_message_get_nick_from_host (argv[4]) : NULL;
topic_address = (argc > 5) ? irc_message_get_address_from_host (argv[4]) : NULL;
if (topic_nick && topic_address && strcmp (topic_nick, topic_address) == 0)
topic_address = NULL;
@@ -3194,10 +3064,10 @@ IRC_PROTOCOL_CALLBACK(346)
argv[4],
IRC_COLOR_CHAT,
IRC_COLOR_CHAT_NICK,
irc_protocol_get_nick_from_host (argv[5]),
irc_message_get_nick_from_host (argv[5]),
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_HOST,
irc_protocol_get_address_from_host (argv[5]),
irc_message_get_address_from_host (argv[5]),
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT,
weechat_util_get_time_string (&datetime));
@@ -3217,10 +3087,10 @@ IRC_PROTOCOL_CALLBACK(346)
argv[4],
IRC_COLOR_CHAT,
IRC_COLOR_CHAT_NICK,
irc_protocol_get_nick_from_host (argv[5]),
irc_message_get_nick_from_host (argv[5]),
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_HOST,
irc_protocol_get_address_from_host (argv[5]),
irc_message_get_address_from_host (argv[5]),
IRC_COLOR_CHAT_DELIMITERS);
}
@@ -3304,10 +3174,10 @@ IRC_PROTOCOL_CALLBACK(348)
argv[4],
IRC_COLOR_CHAT,
IRC_COLOR_CHAT_NICK,
irc_protocol_get_nick_from_host (argv[5]),
irc_message_get_nick_from_host (argv[5]),
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_HOST,
irc_protocol_get_address_from_host (argv[5]),
irc_message_get_address_from_host (argv[5]),
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT,
weechat_util_get_time_string (&datetime));
@@ -3765,10 +3635,10 @@ IRC_PROTOCOL_CALLBACK(367)
argv[4],
IRC_COLOR_CHAT,
IRC_COLOR_CHAT_NICK,
irc_protocol_get_nick_from_host (argv[5]),
irc_message_get_nick_from_host (argv[5]),
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_HOST,
irc_protocol_get_address_from_host (argv[5]),
irc_message_get_address_from_host (argv[5]),
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT,
weechat_util_get_time_string (&datetime));
@@ -3788,10 +3658,10 @@ IRC_PROTOCOL_CALLBACK(367)
argv[4],
IRC_COLOR_CHAT,
IRC_COLOR_CHAT_NICK,
irc_protocol_get_nick_from_host (argv[5]),
irc_message_get_nick_from_host (argv[5]),
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_HOST,
irc_protocol_get_address_from_host (argv[5]),
irc_message_get_address_from_host (argv[5]),
IRC_COLOR_CHAT_DELIMITERS);
}
@@ -4308,8 +4178,8 @@ irc_protocol_recv_command (struct t_irc_server *server,
host1 = NULL;
if (irc_message && (irc_message[0] == ':'))
{
nick1 = irc_protocol_get_nick_from_host (irc_message);
address1 = irc_protocol_get_address_from_host (irc_message);
nick1 = irc_message_get_nick_from_host (irc_message);
address1 = irc_message_get_address_from_host (irc_message);
host1 = irc_message + 1;
}
nick = (nick1) ? strdup (nick1) : NULL;
-1
View File
@@ -77,7 +77,6 @@ struct t_irc_protocol_msg
t_irc_recv_func *recv_function; /* function called when msg is received */
};
extern const char *irc_protocol_get_nick_from_host (const char *host);
extern const char *irc_protocol_tags (const char *command, const char *tags,
const char *nick);
extern void irc_protocol_recv_command (struct t_irc_server *server,
+5 -175
View File
@@ -49,6 +49,7 @@
#include "irc-command.h"
#include "irc-config.h"
#include "irc-input.h"
#include "irc-message.h"
#include "irc-nick.h"
#include "irc-notify.h"
#include "irc-protocol.h"
@@ -1520,175 +1521,6 @@ irc_server_outqueue_send (struct t_irc_server *server)
}
}
/*
* irc_server_parse_message: parse IRC message and return pointer to
* host, command, channel, target nick and arguments
* (if any)
*/
void
irc_server_parse_message (const char *message, char **nick, char **host,
char **command, char **channel, char **arguments)
{
const char *pos, *pos2, *pos3, *pos4, *pos5;
if (nick)
*nick = NULL;
if (host)
*host = NULL;
if (command)
*command = NULL;
if (channel)
*channel = NULL;
if (arguments)
*arguments = NULL;
if (!message)
return;
/*
* we will use this message as example:
* :FlashCode!n=FlashCod@host.com PRIVMSG #channel :hello!
*/
if (message[0] == ':')
{
pos2 = strchr (message, '!');
pos = strchr (message, ' ');
if (pos2 && (!pos || pos > pos2))
{
if (nick)
*nick = weechat_strndup (message + 1, pos2 - (message + 1));
}
else if (pos)
{
if (nick)
*nick = weechat_strndup (message + 1, pos - (message + 1));
}
if (pos)
{
if (host)
*host = weechat_strndup (message + 1, pos - (message + 1));
pos++;
}
else
pos = message;
}
else
pos = message;
/* pos is pointer on PRIVMSG #channel :hello! */
if (pos && pos[0])
{
while (pos[0] == ' ')
{
pos++;
}
pos2 = strchr (pos, ' ');
if (pos2)
{
/* pos2 is pointer on #channel :hello! */
if (command)
*command = weechat_strndup (pos, pos2 - pos);
pos2++;
while (pos2[0] == ' ')
{
pos2++;
}
if (arguments)
*arguments = strdup (pos2);
if (pos2[0] != ':')
{
if (irc_channel_is_channel (pos2))
{
pos3 = strchr (pos2, ' ');
if (channel)
{
if (pos3)
*channel = weechat_strndup (pos2, pos3 - pos2);
else
*channel = strdup (pos2);
}
}
else
{
pos3 = strchr (pos2, ' ');
if (nick && !*nick)
{
if (pos3)
*nick = weechat_strndup (pos2, pos3 - pos2);
else
*nick = strdup (pos2);
}
if (pos3)
{
pos4 = pos3;
pos3++;
while (pos3[0] == ' ')
{
pos3++;
}
if (irc_channel_is_channel (pos3))
{
pos5 = strchr (pos3, ' ');
if (channel)
{
if (pos5)
*channel = weechat_strndup (pos3, pos5 - pos3);
else
*channel = strdup (pos3);
}
}
else if (channel && !*channel)
{
*channel = weechat_strndup (pos2, pos4 - pos2);
}
}
}
}
}
else
{
if (command)
*command = strdup (pos);
}
}
}
/*
* irc_server_parse_message_to_hashtable: parse IRC message and return hashtable
* with keys: nick, host, command,
* channel, arguments
* Note: hashtable has to be free()
* after use
*/
struct t_hashtable *
irc_server_parse_message_to_hashtable (const char *message)
{
char *nick, *host, *command, *channel, *arguments;
char empty_str[1] = { '\0' };
struct t_hashtable *hashtable;
irc_server_parse_message (message, &nick, &host, &command, &channel,
&arguments);
hashtable = weechat_hashtable_new (8,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING,
NULL,
NULL);
if (!hashtable)
return NULL;
weechat_hashtable_set (hashtable, "nick", (nick) ? nick : empty_str);
weechat_hashtable_set (hashtable, "host", (host) ? host : empty_str);
weechat_hashtable_set (hashtable, "command", (command) ? command : empty_str);
weechat_hashtable_set (hashtable, "channel", (channel) ? channel : empty_str);
weechat_hashtable_set (hashtable, "arguments", (arguments) ? arguments : empty_str);
return hashtable;
}
/*
* irc_server_send_one_msg: send one message to IRC server
* if flag contains outqueue priority value, then
@@ -1716,7 +1548,7 @@ irc_server_send_one_msg (struct t_irc_server *server, int flags,
rc = 1;
irc_server_parse_message (message, &nick, NULL, &command, &channel, NULL);
irc_message_parse (message, &nick, NULL, &command, &channel, NULL);
snprintf (str_modifier, sizeof (str_modifier),
"irc_out_%s",
(command) ? command : "unknown");
@@ -2074,8 +1906,7 @@ irc_server_msgq_flush ()
irc_raw_print (irc_recv_msgq->server, IRC_RAW_FLAG_RECV,
ptr_data);
irc_server_parse_message (ptr_data, NULL, NULL, &command,
NULL, NULL);
irc_message_parse (ptr_data, NULL, NULL, &command, NULL, NULL);
snprintf (str_modifier, sizeof (str_modifier),
"irc_in_%s",
(command) ? command : "unknown");
@@ -2111,9 +1942,8 @@ irc_server_msgq_flush ()
ptr_msg);
}
irc_server_parse_message (ptr_msg, &nick, &host,
&command, &channel,
&arguments);
irc_message_parse (ptr_msg, &nick, &host, &command,
&channel, &arguments);
/* convert charset for message */
if (channel)
-4
View File
@@ -237,10 +237,6 @@ extern void irc_server_send_signal (struct t_irc_server *server,
const char *signal, const char *command,
const char *full_message,
const char *tags);
extern void irc_server_parse_message (const char *message, char **nick,
char **host, char **command,
char **channel, char **arguments);
extern struct t_hashtable *irc_server_parse_message_to_hashtable (const char *message);
extern void irc_server_set_send_default_tags (const char *tags);
extern void irc_server_sendf (struct t_irc_server *server, int flags,
const char *tags, const char *format, ...);