diff options
-rw-r--r-- | src/perl/Makefile.am | 59 | ||||
-rw-r--r-- | src/perl/irc/.cvsignore | 7 | ||||
-rw-r--r-- | src/perl/irc/Bans.xs | 40 | ||||
-rw-r--r-- | src/perl/irc/Dcc.xs | 81 | ||||
-rw-r--r-- | src/perl/irc/Flood.xs | 29 | ||||
-rw-r--r-- | src/perl/irc/Ignore.xs | 74 | ||||
-rw-r--r-- | src/perl/irc/Irc.pm | 29 | ||||
-rw-r--r-- | src/perl/irc/Irc.xs | 17 | ||||
-rw-r--r-- | src/perl/irc/IrcChannel.xs | 44 | ||||
-rw-r--r-- | src/perl/irc/IrcQuery.xs | 7 | ||||
-rw-r--r-- | src/perl/irc/IrcServer.xs | 37 | ||||
-rw-r--r-- | src/perl/irc/Makefile.PL.in | 6 | ||||
-rw-r--r-- | src/perl/irc/Modes.xs | 67 | ||||
-rw-r--r-- | src/perl/irc/Netsplit.xs | 51 | ||||
-rw-r--r-- | src/perl/irc/Notifylist.xs | 71 | ||||
-rw-r--r-- | src/perl/irc/module.h | 28 | ||||
-rw-r--r-- | src/perl/irc/typemap | 14 | ||||
-rw-r--r-- | src/perl/irssi-perl.c | 5 | ||||
-rw-r--r-- | src/perl/perl-common.c | 240 | ||||
-rw-r--r-- | src/perl/perl-common.h | 21 |
20 files changed, 904 insertions, 23 deletions
diff --git a/src/perl/Makefile.am b/src/perl/Makefile.am index 8ef5ddf0..4272cdfe 100644 --- a/src/perl/Makefile.am +++ b/src/perl/Makefile.am @@ -11,39 +11,54 @@ INCLUDES = $(GLIB_CFLAGS) \ libirssi_perl_la_SOURCES = \ irssi-perl.c \ + perl-common.c \ xsinit.c perl-signals.h: $(top_srcdir)/docs/signals.txt $(srcdir)/get-signals.pl cat $(top_srcdir)/docs/signals.txt | $(perlpath) $(srcdir)/get-signals.pl > perl-signals.h -EXTRA_DIST = \ - libperl_dynaloader.la \ - get-signals.pl \ - core/Irssi-bans.xs \ - core/Irssi-channel.xs \ - core/Irssi-core.xs \ - core/Irssi-dcc.xs \ - core/Irssi-flood.xs \ - core/Irssi-ignore.xs \ - core/Irssi-log.xs \ - core/Irssi-masks.xs \ - core/Irssi-modes.xs \ - core/Irssi-netsplit.xs \ - core/Irssi-notifylist.xs \ - core/Irssi-query.xs \ - core/Irssi-rawlog.xs \ - core/Irssi-server.xs \ - core/Irssi-settings.xs \ - core/Irssi-window.xs \ +CORE_SOURCES = \ + core/Channel.xs \ + core/Core.xs \ + core/Log.xs \ + core/Masks.xs \ + core/Query.xs \ + core/Rawlog.xs \ + core/Server.xs \ + core/Settings.xs \ + core/Window.xs \ core/Irssi.xs \ core/Irssi.pm \ core/Makefile.PL.in \ - core/typemap + core/typemap \ + core/module.h + +IRC_SOURCES = \ + irc/Bans.xs \ + irc/Dcc.xs \ + irc/Flood.xs \ + irc/Ignore.xs \ + irc/IrcChannel.xs \ + irc/IrcQuery.xs \ + irc/IrcServer.xs \ + irc/Modes.xs \ + irc/Netsplit.xs \ + irc/Notifylist.xs \ + irc/Irc.xs \ + irc/Irc.pm \ + irc/Makefile.PL.in \ + irc/typemap \ + irc/module.h + +EXTRA_DIST = \ + libperl_dynaloader.la \ + get-signals.pl \ + $(CORE_SOURCES) \ + $(IRC_SOURCES) noinst_HEADERS = \ module.h \ - core/module.h \ - irc/module.h + perl-common.h all-local: for dir in core irc; do cd $$dir && if [ ! -f Makefile ]; then if [ "x$(PERL_LIB_DIR)" = "x" ]; then $(perlpath) Makefile.PL; else $(perlpath) Makefile.PL LIB=$(PERL_LIB_DIR); fi; fi && $(MAKE) && cd ..; done diff --git a/src/perl/irc/.cvsignore b/src/perl/irc/.cvsignore new file mode 100644 index 00000000..092c3980 --- /dev/null +++ b/src/perl/irc/.cvsignore @@ -0,0 +1,7 @@ +Makefile +Makefile.PL +Irc.c +Irc.bs +*.o +pm_to_blib +blib diff --git a/src/perl/irc/Bans.xs b/src/perl/irc/Bans.xs new file mode 100644 index 00000000..cd4ea9b8 --- /dev/null +++ b/src/perl/irc/Bans.xs @@ -0,0 +1,40 @@ +MODULE = Irssi::Irc PACKAGE = Irssi::Irc + +void +ban_set_type(type) + char *type + +#******************************* +MODULE = Irssi::Irc PACKAGE = Irssi::Irc::Channel +#******************************* + +char * +ban_get_mask(channel, nick) + Irssi::Irc::Channel channel + char *nick + +void +ban_set(channel, bans) + Irssi::Irc::Channel channel + char *bans + +void +ban_remove(channel, ban) + Irssi::Irc::Channel channel + char *ban + +#******************************* +MODULE = Irssi::Irc PACKAGE = Irssi::Irc::Ban +#******************************* + +void +values(ban) + Irssi::Irc::Ban ban +PREINIT: + HV *hv; +PPCODE: + hv = newHV(); + hv_store(hv, "ban", 3, new_pv(ban->ban), 0); + hv_store(hv, "setby", 5, new_pv(ban->setby), 0); + hv_store(hv, "time", 4, newSViv(ban->time), 0); + XPUSHs(sv_2mortal(newRV_noinc((SV*)hv))); diff --git a/src/perl/irc/Dcc.xs b/src/perl/irc/Dcc.xs new file mode 100644 index 00000000..4bc0a5b0 --- /dev/null +++ b/src/perl/irc/Dcc.xs @@ -0,0 +1,81 @@ +MODULE = Irssi::Irc PACKAGE = Irssi::Irc + +void +dccs() +PREINIT: + GSList *tmp; + HV *stash; +PPCODE: + stash = gv_stashpv("Irssi::Irc::Dcc", 0); + for (tmp = dcc_conns; tmp != NULL; tmp = tmp->next) { + XPUSHs(sv_2mortal(sv_bless(newRV_noinc(newSViv(GPOINTER_TO_INT(tmp->data))), stash))); + } + +Irssi::Irc::Dcc +dcc_find_item(type, nick, arg) + int type + char *nick + char *arg + +Irssi::Irc::Dcc +dcc_find_by_port(nick, port) + char *nick + int port + +void +dcc_ctcp_message(target, server, chat, notice, msg) + char *target + Irssi::Irc::Server server + Irssi::Irc::Dcc chat + int notice + char *msg + +Irssi::Irc::Dcc +item_get_dcc(item) + void *item + +#******************************* +MODULE = Irssi::Irc PACKAGE = Irssi::Irc::Dcc PREFIX = dcc_ +#******************************* + +void +dcc_destroy(dcc) + Irssi::Irc::Dcc dcc + +void +dcc_chat_send(dcc, data) + Irssi::Irc::Dcc dcc + char *data + +void +values(dcc) + Irssi::Irc::Dcc dcc +PREINIT: + HV *hv, *stash; +PPCODE: + hv = newHV(); + hv_store(hv, "type", 4, new_pv((char *) dcc_type2str(dcc->type)), 0); + hv_store(hv, "created", 7, newSViv(dcc->created), 0); + + hv_store(hv, "server", 6, sv_bless(newRV_noinc(newSViv(GPOINTER_TO_INT(dcc->server))), + irssi_get_stash(dcc->server)), 0); + hv_store(hv, "nick", 4, new_pv(dcc->nick), 0); + + stash = gv_stashpv("Irssi::Irc::Dcc", 0); + hv_store(hv, "chat", 4, sv_bless(newRV_noinc(newSViv(GPOINTER_TO_INT(dcc->chat))), stash), 0); + + hv_store(hv, "ircnet", 6, new_pv(dcc->ircnet), 0); + hv_store(hv, "mynick", 6, new_pv(dcc->mynick), 0); + + hv_store(hv, "arg", 3, new_pv(dcc->arg), 0); + hv_store(hv, "file", 4, new_pv(dcc->file), 0); + + hv_store(hv, "addr", 4, new_pv(dcc->addrstr), 0); + hv_store(hv, "port", 4, newSViv(dcc->port), 0); + + hv_store(hv, "size", 4, newSViv(dcc->size), 0); + hv_store(hv, "transfd", 7, newSViv(dcc->transfd), 0); + hv_store(hv, "skipped", 7, newSViv(dcc->skipped), 0); + hv_store(hv, "starttime", 9, newSViv(dcc->starttime), 0); + XPUSHs(sv_2mortal(newRV_noinc((SV*)hv))); + diff --git a/src/perl/irc/Flood.xs b/src/perl/irc/Flood.xs new file mode 100644 index 00000000..8738be04 --- /dev/null +++ b/src/perl/irc/Flood.xs @@ -0,0 +1,29 @@ +MODULE = Irssi::Irc PACKAGE = Irssi::Irc::Server + +void +autoignore_add(server, nick, level) + Irssi::Irc::Server server + char *nick + int level + +int +autoignore_remove(server, mask, level) + Irssi::Irc::Server server + char *mask + int level + +#******************************* +MODULE = Irssi::Irc PACKAGE = Irssi::Irc::Autoignore +#******************************* + +void +values(ai) + Irssi::Irc::Autoignore ai +PREINIT: + HV *hv; +PPCODE: + hv = newHV(); + hv_store(hv, "nick", 4, new_pv(ai->nick), 0); + hv_store(hv, "timeleft", 8, newSViv(ai->timeleft), 0); + hv_store(hv, "level", 5, newSViv(ai->level), 0); + XPUSHs(sv_2mortal(newRV_noinc((SV*)hv))); diff --git a/src/perl/irc/Ignore.xs b/src/perl/irc/Ignore.xs new file mode 100644 index 00000000..c19eb5c8 --- /dev/null +++ b/src/perl/irc/Ignore.xs @@ -0,0 +1,74 @@ +MODULE = Irssi::Irc PACKAGE = Irssi::Irc + +void +ignores() +PREINIT: + GSList *tmp; + HV *stash; +PPCODE: + stash = gv_stashpv("Irssi::Irc::Ignore", 0); + for (tmp = servers; tmp != NULL; tmp = tmp->next) { + XPUSHs(sv_2mortal(sv_bless(newRV_noinc(newSViv(GPOINTER_TO_INT(tmp->data))), stash))); + } + +int +ignore_check(nick, host, channel, text, level) + char *nick + char *host + char *channel + char *text + int level +CODE: + RETVAL = ignore_check(NULL, nick, host, channel, text, level); +OUTPUT: + RETVAL + +#******************************* +MODULE = Irssi::Irc PACKAGE = Irssi::Irc::Server +#******************************* + +int +ignore_check(server, nick, host, channel, text, level) + Irssi::Irc::Server server + char *nick + char *host + char *channel + char *text + int level + +#******************************* +MODULE = Irssi::Irc PACKAGE = Irssi::Irc::Ignore PREFIX = ignore_ +#******************************* + +void +values(ignore) + Irssi::Irc::Ignore ignore +PREINIT: + HV *hv; + AV *av; + char **tmp; +PPCODE: + hv = newHV(); + hv_store(hv, "mask", 4, new_pv(ignore->mask), 0); + hv_store(hv, "servertag", 9, new_pv(ignore->servertag), 0); + av = newAV(); + for (tmp = ignore->channels; *tmp != NULL; tmp++) { + av_push(av, new_pv(*tmp)); + } + hv_store(hv, "channels", 8, newRV_noinc((SV*)av), 0); + hv_store(hv, "pattern", 7, new_pv(ignore->pattern), 0); + + hv_store(hv, "level", 5, newSViv(ignore->level), 0); + hv_store(hv, "except_level", 12, newSViv(ignore->except_level), 0); + + hv_store(hv, "regexp", 6, newSViv(ignore->regexp), 0); + hv_store(hv, "fullword", 8, newSViv(ignore->fullword), 0); + XPUSHs(sv_2mortal(newRV_noinc((SV*)hv))); + +void +ignore_add_rec(rec) + Irssi::Irc::Ignore rec + +void +ignore_update_rec(rec) + Irssi::Irc::Ignore rec diff --git a/src/perl/irc/Irc.pm b/src/perl/irc/Irc.pm new file mode 100644 index 00000000..79cf88c5 --- /dev/null +++ b/src/perl/irc/Irc.pm @@ -0,0 +1,29 @@ +# +# Perl interface to irssi functions. +# + +package Irssi::Irc; + +use strict; +use vars qw($VERSION @ISA @EXPORT @EXPORT_OK); + +$VERSION = "0.20"; + +require Exporter; +require DynaLoader; + +@ISA = qw(Exporter DynaLoader); +@EXPORT = qw(); +@EXPORT_OK = qw(); + +bootstrap Irssi::Irc $VERSION; + +@Irssi::Irc::Chatnet::ISA = qw(Irssi::Chatnet); +@Irssi::Irc::Server::ISA = qw(Irssi::Server); +@Irssi::Irc::ServerConnect::ISA = qw(Irssi::ServerConnect); +@Irssi::Irc::ServerSetup::ISA = qw(Irssi::ServerSetup); +@Irssi::Irc::Channel::ISA = qw(Irssi::Channel); +@Irssi::Irc::Query::ISA = qw(Irssi::Query); + +1; + diff --git a/src/perl/irc/Irc.xs b/src/perl/irc/Irc.xs new file mode 100644 index 00000000..0d00e9ce --- /dev/null +++ b/src/perl/irc/Irc.xs @@ -0,0 +1,17 @@ +#include "module.h" + +MODULE = Irssi::Irc PACKAGE = Irssi::Irc + +PROTOTYPES: ENABLE + +INCLUDE: Bans.xs +INCLUDE: Ignore.xs +INCLUDE: IrcServer.xs +INCLUDE: IrcChannel.xs +INCLUDE: IrcQuery.xs +INCLUDE: Modes.xs +INCLUDE: Netsplit.xs + +INCLUDE: Dcc.xs +INCLUDE: Flood.xs +INCLUDE: Notifylist.xs diff --git a/src/perl/irc/IrcChannel.xs b/src/perl/irc/IrcChannel.xs new file mode 100644 index 00000000..7d2b1092 --- /dev/null +++ b/src/perl/irc/IrcChannel.xs @@ -0,0 +1,44 @@ +MODULE = Irssi::Irc PACKAGE = Irssi::Irc::Channel PREFIX = irc_channel_ + +void +bans(channel) + Irssi::Irc::Channel channel +PREINIT: + GSList *tmp; + HV *stash; +PPCODE: + stash = gv_stashpv("Irssi::Irc::Ban", 0); + for (tmp = channel->banlist; tmp != NULL; tmp = tmp->next) { + XPUSHs(sv_2mortal(sv_bless(newRV_noinc(newSViv(GPOINTER_TO_INT(tmp->data))), stash))); + } + +void +ebans(channel) + Irssi::Irc::Channel channel +PREINIT: + GSList *tmp; + HV *stash; +PPCODE: + stash = gv_stashpv("Irssi::Irc::Ban", 0); + for (tmp = channel->ebanlist; tmp != NULL; tmp = tmp->next) { + XPUSHs(sv_2mortal(sv_bless(newRV_noinc(newSViv(GPOINTER_TO_INT(tmp->data))), stash))); + } + +void +invites(channel) + Irssi::Irc::Channel channel +PREINIT: + GSList *tmp; + HV *stash; +PPCODE: + for (tmp = channel->invitelist; tmp != NULL; tmp = tmp->next) { + XPUSHs(new_pv(tmp->data)); + } + +MODULE = Irssi::Irc PACKAGE = Irssi::Irc::Server PREFIX = irc_ + +Irssi::Irc::Channel +irc_channel_create(server, name, automatic) + Irssi::Irc::Server server + char *name + int automatic diff --git a/src/perl/irc/IrcQuery.xs b/src/perl/irc/IrcQuery.xs new file mode 100644 index 00000000..3df52e86 --- /dev/null +++ b/src/perl/irc/IrcQuery.xs @@ -0,0 +1,7 @@ +MODULE = Irssi::Irc PACKAGE = Irssi::Irc::Server PREFIX = irc_ + +Irssi::Irc::Query +irc_query_create(server, nick, automatic) + Irssi::Irc::Server server + char *nick + int automatic diff --git a/src/perl/irc/IrcServer.xs b/src/perl/irc/IrcServer.xs new file mode 100644 index 00000000..5f609605 --- /dev/null +++ b/src/perl/irc/IrcServer.xs @@ -0,0 +1,37 @@ +MODULE = Irssi::Irc PACKAGE = Irssi::Irc::Server PREFIX = irc_server_ + +void +values(server) + Irssi::Irc::Server server +PREINIT: + HV *hv; +PPCODE: + hv = newHV(); + perl_server_fill_hash(hv, (SERVER_REC *) server); + + hv_store(hv, "real_address", 12, new_pv(server->real_address), 0); + hv_store(hv, "usermode", 8, new_pv(server->usermode), 0); + hv_store(hv, "userhost", 8, new_pv(server->userhost), 0); + XPUSHs(sv_2mortal(newRV_noinc((SV*)hv))); + +char * +irc_server_get_channels(server) + Irssi::Irc::Server server + +MODULE = Irssi::Irc PACKAGE = Irssi::Irc::Connect PREFIX = irc_server_ + +void +values(conn) + Irssi::Irc::Connect conn +PREINIT: + HV *hv; +PPCODE: + hv = newHV(); + perl_server_connect_fill_hash(hv, (SERVER_CONNECT_REC *) conn); + + hv_store(hv, "alternate_nick", 14, new_pv(conn->alternate_nick), 0); + XPUSHs(sv_2mortal(newRV_noinc((SV*)hv))); + +Irssi::Irc::Server +irc_server_connect(conn) + Irssi::Irc::Connect conn diff --git a/src/perl/irc/Makefile.PL.in b/src/perl/irc/Makefile.PL.in new file mode 100644 index 00000000..a3071c04 --- /dev/null +++ b/src/perl/irc/Makefile.PL.in @@ -0,0 +1,6 @@ +use ExtUtils::MakeMaker; + +WriteMakefile('NAME' => 'Irssi::Irc', + 'LIBS' => '', + 'INC' => '-I@top_srcdir@/src -I@top_srcdir@/src/core -I@top_srcdir@/src/irc/core -I@top_srcdir@/src/irc @GLIB_CFLAGS@', + 'VERSION_FROM' => '@srcdir@/Irc.pm'); diff --git a/src/perl/irc/Modes.xs b/src/perl/irc/Modes.xs new file mode 100644 index 00000000..ea26ceae --- /dev/null +++ b/src/perl/irc/Modes.xs @@ -0,0 +1,67 @@ +MODULE = Irssi::Irc PACKAGE = Irssi::Irc + +char * +modes_join(old, mode) + char *old + char *mode + +#******************************* +MODULE = Irssi::Irc PACKAGE = Irssi::Irc::Server +#******************************* + +void +channel_set_singlemode(server, channel, nicks, mode) + Irssi::Irc::Server server + char *channel + char *nicks + char *mode + +void +channel_set_mode(server, channel, mode) + Irssi::Irc::Server server + char *channel + char *mode + +#******************************* +MODULE = Irssi::Irc PACKAGE = Irssi::Irc::Channel PREFIX = channel_ +#******************************* + +void +parse_channel_modes(channel, setby, modestr) + Irssi::Irc::Channel channel + char *setby + char *modestr + +Irssi::Irc::Ban +banlist_add(channel, ban, nick, time) + Irssi::Irc::Channel channel + char *ban + char *nick + time_t time + +void +banlist_remove(channel, ban) + Irssi::Irc::Channel channel + char *ban + +Irssi::Irc::Ban +banlist_exception_add(channel, ban, nick, time) + Irssi::Irc::Channel channel + char *ban + char *nick + time_t time + +void +banlist_exception_remove(channel, ban) + Irssi::Irc::Channel channel + char *ban + +void +invitelist_add(channel, mask) + Irssi::Irc::Channel channel + char *mask + +void +invitelist_remove(channel, mask) + Irssi::Irc::Channel channel + char *mask diff --git a/src/perl/irc/Netsplit.xs b/src/perl/irc/Netsplit.xs new file mode 100644 index 00000000..4dad9c1d --- /dev/null +++ b/src/perl/irc/Netsplit.xs @@ -0,0 +1,51 @@ +MODULE = Irssi::Irc PACKAGE = Irssi::Irc::Server + +Irssi::Irc::Netsplit +netsplit_find(server, nick, address) + Irssi::Irc::Server server + char *nick + char *address + +Irssi::Nick +netsplit_find_channel(server, nick, address, channel) + Irssi::Irc::Server server + char *nick + char *address + char *channel + + +#******************************* +MODULE = Irssi::Irc PACKAGE = Irssi::Irc::Netsplit +#******************************* + +void +values(netsplit) + Irssi::Irc::Netsplit netsplit +PREINIT: + HV *hv, *stash; +PPCODE: + hv = newHV(); + hv_store(hv, "nick", 4, new_pv(netsplit->nick), 0); + hv_store(hv, "address", 7, new_pv(netsplit->address), 0); + hv_store(hv, "destroy", 7, newSViv(netsplit->destroy), 0); + + stash = gv_stashpv("Irssi::Irc::Netsplitserver", 0); + hv_store(hv, "server", 6, sv_bless(newRV_noinc(newSViv(GPOINTER_TO_INT(netsplit->server))), stash), 0); + /*FIXME: add GSList *channels;*/ + XPUSHs(sv_2mortal(newRV_noinc((SV*)hv))); + +#******************************* +MODULE = Irssi::Irc PACKAGE = Irssi::Irc::Netsplitserver +#******************************* + +void +values(rec) + Irssi::Irc::Netsplitserver rec +PREINIT: + HV *hv; +PPCODE: + hv = newHV(); + hv_store(hv, "server", 6, new_pv(rec->server), 0); + hv_store(hv, "destserver", 10, new_pv(rec->destserver), 0); + hv_store(hv, "count", 5, newSViv(rec->count), 0); + XPUSHs(sv_2mortal(newRV_noinc((SV*)hv))); diff --git a/src/perl/irc/Notifylist.xs b/src/perl/irc/Notifylist.xs new file mode 100644 index 00000000..4770aa12 --- /dev/null +++ b/src/perl/irc/Notifylist.xs @@ -0,0 +1,71 @@ +MODULE = Irssi::Irc PACKAGE = Irssi::Irc + +void +notifies() +PREINIT: + GSList *tmp; + HV *stash; +PPCODE: + stash = gv_stashpv("Irssi::Irc::Notifylist", 0); + for (tmp = notifies; tmp != NULL; tmp = tmp->next) { + XPUSHs(sv_2mortal(sv_bless(newRV_noinc(newSViv(GPOINTER_TO_INT(tmp->data))), stash))); + } + +Irssi::Irc::Notifylist +notifylist_add(mask, ircnets, away_check, idle_check_time) + char *mask + char *ircnets + int away_check + int idle_check_time + +void +notifylist_remove(mask) + char *mask + +Irssi::Irc::Server +notifylist_ison(nick, serverlist) + char *nick + char *serverlist + +Irssi::Irc::Notifylist +notifylist_find(mask, ircnet) + char *mask + char *ircnet + +#******************************* +MODULE = Irssi::Irc PACKAGE = Irssi::Irc::Server +#******************************* + +int +notifylist_ison_server(server, nick) + Irssi::Irc::Server server + char *nick + +#******************************* +MODULE = Irssi::Irc PACKAGE = Irssi::Irc::Notifylist PREFIX = notifylist_ +#******************************* + +void +values(notify) + Irssi::Irc::Notifylist notify +PREINIT: + HV *hv; + AV *av; + char **tmp; +PPCODE: + hv = newHV(); + hv_store(hv, "mask", 4, new_pv(notify->mask), 0); + hv_store(hv, "away_check", 10, newSViv(notify->away_check), 0); + hv_store(hv, "idle_check_time", 15, newSViv(notify->idle_check_time), 0); + + av = newAV(); + for (tmp = notify->ircnets; *tmp != NULL; tmp++) { + av_push(av, new_pv(*tmp)); + } + hv_store(hv, "ircnets", 7, newRV_noinc((SV*)av), 0); + XPUSHs(sv_2mortal(newRV_noinc((SV*)hv))); + +int +notifylist_ircnets_match(rec, ircnet) + Irssi::Irc::Notifylist rec + char *ircnet diff --git a/src/perl/irc/module.h b/src/perl/irc/module.h new file mode 100644 index 00000000..58a0b31f --- /dev/null +++ b/src/perl/irc/module.h @@ -0,0 +1,28 @@ +#include "../core/module.h" + +#include "irc-servers.h" +#include "irc-channels.h" +#include "irc-queries.h" + +#include "bans.h" +#include "modes.h" +#include "mode-lists.h" +#include "netsplit.h" +#include "ignore.h" + +#include "dcc/dcc.h" +#include "flood/autoignore.h" +#include "notifylist/notifylist.h" + +typedef IRC_SERVER_REC *Irssi__Irc__Server; +typedef IRC_SERVER_CONNECT_REC *Irssi__Irc__Connect; +typedef IRC_CHANNEL_REC *Irssi__Irc__Channel; +typedef QUERY_REC *Irssi__Irc__Query; + +typedef BAN_REC *Irssi__Irc__Ban; +typedef DCC_REC *Irssi__Irc__Dcc; +typedef NETSPLIT_REC *Irssi__Irc__Netsplit; +typedef NETSPLIT_SERVER_REC *Irssi__Irc__Netsplitserver; +typedef AUTOIGNORE_REC *Irssi__Irc__Autoignore; +typedef NOTIFYLIST_REC *Irssi__Irc__Notifylist; +typedef IGNORE_REC *Irssi__Irc__Ignore; diff --git a/src/perl/irc/typemap b/src/perl/irc/typemap new file mode 100644 index 00000000..58a8ce95 --- /dev/null +++ b/src/perl/irc/typemap @@ -0,0 +1,14 @@ +TYPEMAP +Irssi::Irc::Server T_PTROBJ +Irssi::Irc::Connect T_PTROBJ +Irssi::Irc::Channel T_PTROBJ +Irssi::Irc::Query T_PTROBJ +Irssi::Irc::Ban T_PTROBJ +Irssi::Irc::Dcc T_PTROBJ +Irssi::Irc::Netsplit T_PTROBJ +Irssi::Irc::Netsplitserver T_PTROBJ +Irssi::Irc::Autoignore T_PTROBJ +Irssi::Irc::Notifylist T_PTROBJ +Irssi::Irc::Ignore T_PTROBJ + +Irssi::Nick T_PTROBJ diff --git a/src/perl/irssi-perl.c b/src/perl/irssi-perl.c index c6efac8a..44dcd7b6 100644 --- a/src/perl/irssi-perl.c +++ b/src/perl/irssi-perl.c @@ -32,6 +32,7 @@ #include "signals.h" #include "commands.h" #include "misc.h" +#include "perl-common.h" /* For compatibility with perl 5.004 and older */ #ifndef ERRSV @@ -667,8 +668,9 @@ static void irssi_perl_autorun(void) void irssi_perl_init(void) { - perl_scripts = NULL; + perl_common_init(); + perl_scripts = NULL; command_bind("run", NULL, (SIGNAL_FUNC) cmd_run); command_bind_first("unload", NULL, (SIGNAL_FUNC) cmd_unload); command_bind("perlflush", NULL, (SIGNAL_FUNC) cmd_perlflush); @@ -682,6 +684,7 @@ void irssi_perl_init(void) void irssi_perl_deinit(void) { irssi_perl_stop(); + perl_common_deinit(); if (signal_grabbed) signal_remove("signal", (SIGNAL_FUNC) sig_signal); if (siglast_grabbed) signal_remove("last signal", (SIGNAL_FUNC) sig_lastsignal); diff --git a/src/perl/perl-common.c b/src/perl/perl-common.c new file mode 100644 index 00000000..ee4bc3c7 --- /dev/null +++ b/src/perl/perl-common.c @@ -0,0 +1,240 @@ +/* + perl-common.c : irssi + + Copyright (C) 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 <EXTERN.h> +#ifndef _SEM_SEMUN_UNDEFINED +#define HAS_UNION_SEMUN +#endif +#include <perl.h> + +#undef _ +#undef PACKAGE + +#include "module.h" +#include "modules.h" +#include "signals.h" + +#include "chat-protocols.h" +#include "servers.h" +#include "channels.h" +#include "queries.h" +#include "window-item-def.h" + +#include "perl-common.h" + +GHashTable *perl_stashes; + +HV *irssi_get_stash_item(int type, int chat_type) +{ + char *str; + + str = g_hash_table_lookup(perl_stashes, + GINT_TO_POINTER(type | (chat_type << 24))); + g_return_val_if_fail(str != NULL, gv_stashpv("", 0)); + return gv_stashpv(str, 1); +} + +void perl_connect_fill_hash(HV *hv, SERVER_CONNECT_REC *conn) +{ + char *type, *chat_type; + + type = "SERVER CONNECT"; + chat_type = (char *) chat_protocol_find_id(conn->chat_type)->name; + + hv_store(hv, "type", 4, new_pv(type), 0); + hv_store(hv, "chat_type", 9, new_pv(chat_type), 0); + + hv_store(hv, "address", 7, new_pv(conn->address), 0); + hv_store(hv, "port", 4, newSViv(conn->port), 0); + hv_store(hv, "chatnet", 7, new_pv(conn->chatnet), 0); + + hv_store(hv, "password", 8, new_pv(conn->password), 0); + hv_store(hv, "wanted_nick", 11, new_pv(conn->nick), 0); + hv_store(hv, "username", 8, new_pv(conn->username), 0); + hv_store(hv, "realname", 8, new_pv(conn->realname), 0); +} + +void perl_server_fill_hash(HV *hv, SERVER_REC *server) +{ + char *type, *chat_type; + HV *stash; + + perl_connect_fill_hash(hv, server->connrec); + + type = "SERVER"; + chat_type = (char *) chat_protocol_find_id(server->chat_type)->name; + + hv_store(hv, "type", 4, new_pv(type), 0); + hv_store(hv, "chat_type", 9, new_pv(chat_type), 0); + + hv_store(hv, "connect_time", 12, newSViv(server->connect_time), 0); + hv_store(hv, "real_connect_time", 17, newSViv(server->real_connect_time), 0); + + hv_store(hv, "tag", 3, new_pv(server->tag), 0); + hv_store(hv, "nick", 4, new_pv(server->nick), 0); + + hv_store(hv, "connected", 9, newSViv(server->connected), 0); + hv_store(hv, "connection_lost", 15, newSViv(server->connection_lost), 0); + + stash = gv_stashpv("Irssi::Rawlog", 0); + hv_store(hv, "rawlog", 6, sv_bless(newRV_noinc(newSViv(GPOINTER_TO_INT(server->rawlog))), stash), 0); + + hv_store(hv, "version", 7, new_pv(server->version), 0); + hv_store(hv, "away_reason", 11, new_pv(server->away_reason), 0); + hv_store(hv, "last_invite", 11, new_pv(server->last_invite), 0); + hv_store(hv, "server_operator", 15, newSViv(server->server_operator), 0); + hv_store(hv, "usermode_away", 13, newSViv(server->usermode_away), 0); + hv_store(hv, "banned", 6, newSViv(server->banned), 0); + + hv_store(hv, "lag", 3, newSViv(server->lag), 0); +} + +void perl_window_item_fill_hash(HV *hv, WI_ITEM_REC *item) +{ + char *type, *chat_type; + + type = (char *) module_find_id_str("WINDOW ITEM", item->type); + chat_type = (char *) chat_protocol_find_id(item->chat_type)->name; + + hv_store(hv, "type", 4, new_pv(type), 0); + hv_store(hv, "chat_type", 9, new_pv(chat_type), 0); + + if (item->server != NULL) { + hv_store(hv, "server", 6, sv_bless(newRV_noinc(newSViv(GPOINTER_TO_INT(item->server))), + irssi_get_stash(item->server)), 0); + } + hv_store(hv, "name", 4, new_pv(item->name), 0); + + hv_store(hv, "createtime", 10, newSViv(item->createtime), 0); + hv_store(hv, "new_data", 8, newSViv(item->new_data), 0); + hv_store(hv, "last_color", 10, newSViv(item->last_color), 0); +} + +void perl_channel_fill_hash(HV *hv, CHANNEL_REC *channel) +{ + perl_window_item_fill_hash(hv, (WI_ITEM_REC *) channel); + + hv_store(hv, "topic", 5, new_pv(channel->topic), 0); + + hv_store(hv, "no_modes", 8, newSViv(channel->no_modes), 0); + hv_store(hv, "mode", 4, new_pv(channel->mode), 0); + hv_store(hv, "limit", 5, newSViv(channel->limit), 0); + hv_store(hv, "key", 3, new_pv(channel->key), 0); + + hv_store(hv, "chanop", 6, newSViv(channel->chanop), 0); + hv_store(hv, "names_got", 9, newSViv(channel->names_got), 0); + hv_store(hv, "wholist", 7, newSViv(channel->wholist), 0); + hv_store(hv, "synced", 6, newSViv(channel->synced), 0); + + hv_store(hv, "joined", 6, newSViv(channel->joined), 0); + hv_store(hv, "left", 4, newSViv(channel->left), 0); + hv_store(hv, "kicked", 6, newSViv(channel->kicked), 0); +} + +void perl_query_fill_hash(HV *hv, QUERY_REC *query) +{ + perl_window_item_fill_hash(hv, (WI_ITEM_REC *) query); + + hv_store(hv, "address", 7, new_pv(query->address), 0); + hv_store(hv, "server_tag", 10, new_pv(query->server_tag), 0); + hv_store(hv, "unwanted", 8, newSViv(query->unwanted), 0); +} + +static void perl_register_protocol(CHAT_PROTOCOL_REC *rec) +{ + char *name, stash[100]; + int type, chat_type; + + chat_type = chat_protocol_lookup(rec->name); + g_return_if_fail(chat_type >= 0); + + name = g_strdup(rec->name); + g_strdown(name+1); + + /* window items: channel, query */ + type = module_get_uniq_id_str("WINDOW ITEM TYPE", "CHANNEL"); + g_snprintf(stash, sizeof(stash), "Irssi::%s::Channel", name); + irssi_add_stash(type, chat_type, stash); + + type = module_get_uniq_id_str("WINDOW ITEM TYPE", "QUERY"); + g_snprintf(stash, sizeof(stash), "Irssi::%s::Query", name); + irssi_add_stash(type, chat_type, stash); + + /* server specific */ + type = module_get_uniq_id("SERVER", 0); + g_snprintf(stash, sizeof(stash), "Irssi::%s::Server", name); + irssi_add_stash(type, chat_type, stash); + + type = module_get_uniq_id("SERVER CONNECT", 0); + g_snprintf(stash, sizeof(stash), "Irssi::%s::Connect", name); + irssi_add_stash(type, chat_type, stash); + + g_free(name); +} + +static int perl_free_protocol(void *key, void *value, void *chat_type) +{ + if ((GPOINTER_TO_INT(key) >> 24) == GPOINTER_TO_INT(chat_type)) { + g_free(value); + return TRUE; + } + + return FALSE; +} + +static void perl_unregister_protocol(CHAT_PROTOCOL_REC *rec) +{ + g_hash_table_foreach_remove(perl_stashes, (GHRFunc) perl_free_protocol, + GINT_TO_POINTER(rec->id)); +} + +static void free_perl_stash(void *key, void *value) +{ + g_free(value); +} + +static void sig_protocol_created(CHAT_PROTOCOL_REC *rec) +{ + perl_register_protocol(rec); +} + +static void sig_protocol_destroyed(CHAT_PROTOCOL_REC *rec) +{ + perl_unregister_protocol(rec); +} + +void perl_common_init(void) +{ + perl_stashes = g_hash_table_new((GHashFunc) g_direct_hash, + (GCompareFunc) g_direct_equal); + g_slist_foreach(chat_protocols, (GFunc) perl_register_protocol, NULL); + + signal_add("chat protocol created", (SIGNAL_FUNC) sig_protocol_created); + signal_add("chat protocol destroyed", (SIGNAL_FUNC) sig_protocol_destroyed); +} + +void perl_common_deinit(void) +{ + g_hash_table_foreach(perl_stashes, (GHFunc) free_perl_stash, NULL); + g_hash_table_destroy(perl_stashes); + + signal_remove("chat protocol created", (SIGNAL_FUNC) sig_protocol_created); + signal_remove("chat protocol destroyed", (SIGNAL_FUNC) sig_protocol_destroyed); +} diff --git a/src/perl/perl-common.h b/src/perl/perl-common.h new file mode 100644 index 00000000..c5eb9748 --- /dev/null +++ b/src/perl/perl-common.h @@ -0,0 +1,21 @@ +#ifndef __PERL_COMMON_H +#define __PERL_COMMON_H + +#define new_pv(a) \ + (newSVpv((a) == NULL ? "" : (a), (a) == NULL ? 0 : strlen(a))) + +extern GHashTable *perl_stashes; + +HV *irssi_get_stash_item(int type, int chat_type); + +#define irssi_get_stash(item) \ + irssi_get_stash_item((item)->type, (item)->chat_type) + +#define irssi_add_stash(type, chat_type, stash) \ + g_hash_table_insert(perl_stashes, GINT_TO_POINTER(type | \ + (chat_type << 24)), g_strdup(stash)) + +void perl_common_init(void); +void perl_common_deinit(void); + +#endif |