Object type checking fixes

git-svn-id: http://svn.irssi.org/repos/irssi/trunk@638 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
Timo Sirainen 2000-08-30 22:29:55 +00:00 committed by cras
commit b4bdec4436
15 changed files with 78 additions and 75 deletions

View file

@ -181,6 +181,7 @@ static void sig_connected(SERVER_REC *server)
void irc_channels_init(void)
{
signal_add("server connected", (SIGNAL_FUNC) sig_connected);
signal_add("channel destroyed", (SIGNAL_FUNC) sig_channel_destroyed);
channel_events_init();
channel_rejoin_init();
@ -197,6 +198,7 @@ void irc_channels_init(void)
void irc_channels_deinit(void)
{
signal_remove("server connected", (SIGNAL_FUNC) sig_connected);
signal_remove("channel destroyed", (SIGNAL_FUNC) sig_channel_destroyed);
channel_events_deinit();
channel_rejoin_deinit();

View file

@ -4,14 +4,12 @@
#include "channels.h"
#include "irc-servers.h"
#define IS_IRC_CHANNEL(channel) \
((channel) != NULL && \
module_find_id("IRC CHANNEL", \
((IRC_CHANNEL_REC *) (channel))->chat_type) != -1)
/* Returns IRC_CHANNEL_REC if it's IRC channel, NULL if it isn't. */
#define IRC_CHANNEL(channel) \
(IS_IRC_CHANNEL(channel) ? (IRC_CHANNEL_REC *) (channel) : NULL)
MODULE_CHECK_CAST(channel, IRC_CHANNEL_REC, chat_type, "IRC CHANNEL")
#define IS_IRC_CHANNEL(channel) \
(IRC_CHANNEL(channel) ? TRUE : FALSE)
#define STRUCT_SERVER_REC IRC_SERVER_REC
typedef struct {

View file

@ -1,13 +1,14 @@
#ifndef __IRC_CHATNETS_H
#define __IRC_CHATNETS_H
#define IS_IRC_CHATNET(chatnet) \
((chatnet) != NULL && \
module_find_id("IRC CHATNET", (chatnet)->chat_type) != -1)
#include "modules.h"
/* returns IRC_CHATNET_REC if it's IRC network, NULL if it isn't */
#define IRC_CHATNET(chatnet) \
(IS_IRC_CHATNET(chatnet) ? (IRC_CHATNET_REC *) (chatnet) : NULL)
MODULE_CHECK_CAST(chatnet, IRC_CHATNET_REC, chat_type, "IRC CHATNET")
#define IS_IRC_CHATNET(chatnet) \
(IRC_CHATNET(chatnet) ? TRUE : FALSE)
#define IS_IRCNET(ircnet) IS_IRC_CHATNET(ircnet)
#define IRCNET(ircnet) IRC_CHATNET(ircnet)

View file

@ -86,7 +86,7 @@ IRC_SERVER_REC *irccmd_options_get_server(const char *cmd,
return (IRC_SERVER_REC *) server;
}
static SERVER_REC *connect_server(const char *data)
static SERVER_REC *irc_connect_server(const char *data)
{
SERVER_CONNECT_REC *conn;
SERVER_REC *server;
@ -137,7 +137,7 @@ static SERVER_REC *connect_server(const char *data)
static void cmd_connect(const char *data)
{
if (*data == '\0') cmd_return_error(CMDERR_NOT_ENOUGH_PARAMS);
connect_server(data);
irc_connect_server(data);
}
@ -202,7 +202,7 @@ static void cmd_server(const char *data, IRC_SERVER_REC *server)
cmd_disconnect("* Changing server", server);
}
server = IRC_SERVER(connect_server(data));
server = IRC_SERVER(irc_connect_server(data));
if (*addr == '+' || server == NULL ||
(ircnet != NULL && server->connrec->chatnet != NULL &&
g_strcasecmp(ircnet, server->connrec->chatnet) != 0)) {

View file

@ -4,14 +4,12 @@
#include "queries.h"
#include "irc-servers.h"
#define IS_IRC_QUERY(query) \
((query) != NULL && \
module_find_id("IRC QUERY", \
((QUERY_REC *) (query))->chat_type) != -1)
/* Returns IRC_QUERY_REC if it's IRC query, NULL if it isn't. */
#define IRC_QUERY(query) \
(IS_IRC_QUERY(query) ? (QUERY_REC *) (query) : NULL)
MODULE_CHECK_CAST(query, QUERY_REC, chat_type, "IRC QUERY")
#define IS_IRC_QUERY(query) \
(IRC_QUERY(query) ? TRUE : FALSE)
void irc_queries_init(void);
void irc_queries_deinit(void);

View file

@ -1,13 +1,13 @@
#ifndef __IRC_SERVERS_SETUP_H
#define __IRC_SERVERS_SETUP_H
#define IS_IRC_SERVER_SETUP(server) \
((server) != NULL && \
module_find_id("IRC SERVER SETUP", (server)->chat_type) != -1)
#define IRC_SERVER_SETUP(server) \
(IS_IRC_SERVER_SETUP(server) ? \
(IRC_SERVER_SETUP_REC *) (server) : NULL)
MODULE_CHECK_CAST(server, IRC_SERVER_SETUP_REC, \
chat_type, "IRC SERVER SETUP")
#define IS_IRC_SERVER_SETUP(server) \
(IRC_SERVER_SETUP(server) ? TRUE : FALSE)
typedef struct {
#include "server-setup-rec.h"

View file

@ -3,21 +3,19 @@
#include "servers.h"
#define IS_IRC_SERVER(server) \
((server) != NULL && \
module_find_id("IRC SERVER", (server)->chat_type) != -1)
#define IS_IRC_SERVER_CONNECT(conn) \
((conn) != NULL && \
module_find_id("IRC SERVER CONNECT", (conn)->chat_type) != -1)
/* returns IRC_SERVER_REC if it's IRC server, NULL if it isn't */
#define IRC_SERVER(server) \
(IS_IRC_SERVER(server) ? (IRC_SERVER_REC *) (server) : NULL)
MODULE_CHECK_CAST(server, IRC_SERVER_REC, chat_type, "IRC SERVER")
#define IRC_SERVER_CONNECT(conn) \
(IS_IRC_SERVER_CONNECT(conn) ? \
(IRC_SERVER_CONNECT_REC *) (conn) : NULL)
MODULE_CHECK_CAST(conn, IRC_SERVER_CONNECT_REC, \
chat_type, "IRC SERVER CONNECT")
#define IS_IRC_SERVER(server) \
(IRC_SERVER(server) ? TRUE : FALSE)
#define IS_IRC_SERVER_CONNECT(conn) \
(IRC_SERVER_CONNECT(conn) ? TRUE : FALSE)
/* all strings should be either NULL or dynamically allocated */
/* address and nick are mandatory, rest are optional */