diff options
Diffstat (limited to '')
-rw-r--r-- | src/perl/irc/Channel.xs | 64 | ||||
-rw-r--r-- | src/perl/irc/Client.xs | 6 | ||||
-rw-r--r-- | src/perl/irc/Ctcp.xs | 21 | ||||
-rw-r--r-- | src/perl/irc/Dcc.xs | 103 | ||||
-rw-r--r-- | src/perl/irc/Irc.pm | 26 | ||||
-rw-r--r-- | src/perl/irc/Irc.xs | 283 | ||||
-rw-r--r-- | src/perl/irc/Makefile.PL.in | 8 | ||||
-rw-r--r-- | src/perl/irc/Modes.xs | 47 | ||||
-rw-r--r-- | src/perl/irc/Netsplit.xs | 18 | ||||
-rw-r--r-- | src/perl/irc/Notifylist.xs | 59 | ||||
-rw-r--r-- | src/perl/irc/Query.xs | 11 | ||||
-rw-r--r-- | src/perl/irc/Server.xs | 175 | ||||
-rw-r--r-- | src/perl/irc/meson.build | 41 | ||||
-rw-r--r-- | src/perl/irc/module.h | 43 | ||||
-rw-r--r-- | src/perl/irc/typemap | 40 |
15 files changed, 945 insertions, 0 deletions
diff --git a/src/perl/irc/Channel.xs b/src/perl/irc/Channel.xs new file mode 100644 index 0000000..782fa1d --- /dev/null +++ b/src/perl/irc/Channel.xs @@ -0,0 +1,64 @@ +#define PERL_NO_GET_CONTEXT +#include "module.h" + +MODULE = Irssi::Irc::Channel PACKAGE = Irssi::Irc PREFIX = irc_ +PROTOTYPES: ENABLE + +char * +irc_get_mask(nick, address, flags) + char *nick + char *address + int flags + +int +MASK_NICK() +CODE: + RETVAL = IRC_MASK_NICK; +OUTPUT: + RETVAL + +int +MASK_USER() +CODE: + RETVAL = IRC_MASK_USER; +OUTPUT: + RETVAL + +int +MASK_HOST() +CODE: + RETVAL = IRC_MASK_HOST; +OUTPUT: + RETVAL + +int +MASK_DOMAIN() +CODE: + RETVAL = IRC_MASK_DOMAIN; +OUTPUT: + RETVAL + +MODULE = Irssi::Irc::Channel PACKAGE = Irssi::Irc::Channel PREFIX = irc_ + +void +bans(channel) + Irssi::Irc::Channel channel +PREINIT: + GSList *tmp; +PPCODE: + for (tmp = channel->banlist; tmp != NULL; tmp = tmp->next) { + XPUSHs(sv_2mortal(plain_bless(tmp->data, "Irssi::Irc::Ban"))); + } + +Irssi::Irc::Nick +irc_nick_insert(channel, nick, op, halfop, voice, send_massjoin) + Irssi::Irc::Channel channel + char *nick + int op + int halfop + int voice + int send_massjoin +CODE: + RETVAL = irc_nicklist_insert(channel, nick, op, halfop, voice, send_massjoin, NULL); +OUTPUT: + RETVAL diff --git a/src/perl/irc/Client.xs b/src/perl/irc/Client.xs new file mode 100644 index 0000000..05616af --- /dev/null +++ b/src/perl/irc/Client.xs @@ -0,0 +1,6 @@ +#define PERL_NO_GET_CONTEXT +#include "module.h" + +MODULE = Irssi::Irc::Client PACKAGE = Irssi::Irc +PROTOTYPES: ENABLE + diff --git a/src/perl/irc/Ctcp.xs b/src/perl/irc/Ctcp.xs new file mode 100644 index 0000000..3497887 --- /dev/null +++ b/src/perl/irc/Ctcp.xs @@ -0,0 +1,21 @@ +#define PERL_NO_GET_CONTEXT +#include "module.h" +#include <irssi/src/irc/core/ctcp.h> + +MODULE = Irssi::Irc::Ctcp PACKAGE = Irssi +PROTOTYPES: ENABLE + +void +ctcp_register(name) + char *name + +void +ctcp_unregister(name) + char *name + +MODULE = Irssi::Irc::Ctcp PACKAGE = Irssi::Irc::Server PREFIX = irc_server_ + +void +ctcp_send_reply(server, data) + Irssi::Irc::Server server + char *data diff --git a/src/perl/irc/Dcc.xs b/src/perl/irc/Dcc.xs new file mode 100644 index 0000000..c078a1b --- /dev/null +++ b/src/perl/irc/Dcc.xs @@ -0,0 +1,103 @@ +#define PERL_NO_GET_CONTEXT +#include "module.h" + +MODULE = Irssi::Irc::Dcc PACKAGE = Irssi::Irc +PROTOTYPES: ENABLE + +void +dccs() +PREINIT: + GSList *tmp; +PPCODE: + for (tmp = dcc_conns; tmp != NULL; tmp = tmp->next) + XPUSHs(sv_2mortal(simple_iobject_bless((DCC_REC *) tmp->data))); + +void +dcc_register_type(type) + char *type + +void +dcc_unregister_type(type) + char *type + +int +dcc_str2type(str) + char *str + +char * +dcc_type2str(type) + int type +CODE: + RETVAL = (char *) module_find_id_str("DCC", type); +OUTPUT: + RETVAL + +Irssi::Irc::Dcc +dcc_find_request_latest(type) + int type + +Irssi::Irc::Dcc +dcc_find_request(type, nick, arg) + int type + char *nick + char *arg + +Irssi::Irc::Dcc::Chat +dcc_chat_find_id(id) + char *id + +void +dcc_chat_send(dcc, data) + Irssi::Irc::Dcc::Chat dcc + char *data + +void +dcc_ctcp_message(server, target, chat, notice, msg) + Irssi::Irc::Server server + char *target + Irssi::Irc::Dcc::Chat chat + int notice + char *msg + +void +dcc_get_download_path(fname) + char *fname +PREINIT: + char *ret; +PPCODE: + ret = dcc_get_download_path(fname); + XPUSHs(sv_2mortal(new_pv(ret))); + g_free(ret); + +#******************************* +MODULE = Irssi::Irc::Dcc PACKAGE = Irssi::Irc::Dcc PREFIX = dcc_ +#******************************* + +void +dcc_init_rec(dcc, server, chat, nick, arg) + Irssi::Irc::Dcc dcc + Irssi::Irc::Server server + Irssi::Irc::Dcc::Chat chat + char *nick + char *arg + +void +dcc_destroy(dcc) + Irssi::Irc::Dcc dcc + +void +dcc_close(dcc) + Irssi::Irc::Dcc dcc + +void +dcc_reject(dcc, server) + Irssi::Irc::Dcc dcc + Irssi::Irc::Server server + +#******************************* +MODULE = Irssi::Irc::Dcc PACKAGE = Irssi::Windowitem PREFIX = item_ +#******************************* + +Irssi::Irc::Dcc::Chat +item_get_dcc(item) + Irssi::Windowitem item diff --git a/src/perl/irc/Irc.pm b/src/perl/irc/Irc.pm new file mode 100644 index 0000000..1d95462 --- /dev/null +++ b/src/perl/irc/Irc.pm @@ -0,0 +1,26 @@ +# +# Perl interface to irssi functions. +# + +package Irssi::Irc; + +use strict; +use vars qw($VERSION @ISA @EXPORT @EXPORT_OK); + +$VERSION = "0.9"; + +require Exporter; +require DynaLoader; + +@ISA = qw(Exporter DynaLoader); +@EXPORT = qw(); +@EXPORT_OK = qw(); + +bootstrap Irssi::Irc $VERSION if (!Irssi::Core::is_static()); + +Irssi::Irc::init(); + +Irssi::EXPORT_ALL(); + +1; + diff --git a/src/perl/irc/Irc.xs b/src/perl/irc/Irc.xs new file mode 100644 index 0000000..33be93d --- /dev/null +++ b/src/perl/irc/Irc.xs @@ -0,0 +1,283 @@ +#define PERL_NO_GET_CONTEXT +#include "module.h" + +static int initialized = FALSE; + +static void perl_irc_chatnet_fill_hash(HV *hv, IRC_CHATNET_REC *chatnet) +{ + perl_chatnet_fill_hash(hv, (CHATNET_REC *) chatnet); + (void) hv_store(hv, "usermode", 8, new_pv(chatnet->usermode), 0); +} + +static void perl_irc_connect_fill_hash(HV *hv, IRC_SERVER_CONNECT_REC *conn) +{ + perl_connect_fill_hash(hv, (SERVER_CONNECT_REC *) conn); + (void) hv_store(hv, "alternate_nick", 14, new_pv(conn->alternate_nick), 0); +} + +static void perl_irc_server_fill_hash(HV *hv, IRC_SERVER_REC *server) +{ + AV *av; + HV *hv_; + GSList *tmp; + GHashTableIter iter; + gpointer key_, val_; + + perl_irc_connect_fill_hash(hv, server->connrec); + perl_server_fill_hash(hv, (SERVER_REC *) server); + + (void) hv_store(hv, "real_address", 12, new_pv(server->real_address), 0); + (void) hv_store(hv, "usermode", 8, new_pv(server->usermode), 0); + (void) hv_store(hv, "userhost", 8, new_pv(server->userhost), 0); + + (void) hv_store(hv, "max_message_len", 15, newSViv(server->max_message_len), 0); + + (void) hv_store(hv, "max_cmds_at_once", 16, newSViv(server->max_cmds_at_once), 0); + (void) hv_store(hv, "cmd_queue_speed", 15, newSViv(server->cmd_queue_speed), 0); + (void) hv_store(hv, "max_query_chans", 15, newSViv(server->max_query_chans), 0); + + (void) hv_store(hv, "max_kicks_in_cmd", 16, newSViv(server->max_kicks_in_cmd), 0); + (void) hv_store(hv, "max_msgs_in_cmd", 15, newSViv(server->max_msgs_in_cmd), 0); + (void) hv_store(hv, "max_modes_in_cmd", 16, newSViv(server->max_modes_in_cmd), 0); + (void) hv_store(hv, "max_whois_in_cmd", 16, newSViv(server->max_whois_in_cmd), 0); + (void) hv_store(hv, "isupport_sent", 13, newSViv(server->isupport_sent), 0); + + (void) hv_store(hv, "cap_complete", 12, newSViv(server->cap_complete), 0); + (void) hv_store(hv, "sasl_success", 12, newSViv(server->sasl_success), 0); + + if (server->cap_supported != NULL) { + hv_ = newHV(); + g_hash_table_iter_init(&iter, server->cap_supported); + while (g_hash_table_iter_next(&iter, &key_, &val_)) { + char *key = (char *)key_; + char *val = (char *)val_; + hv_store(hv_, key, strlen(key), new_pv(val), 0); + } + (void) hv_store(hv, "cap_supported", 13, newRV_noinc((SV*)hv_), 0); + } + + av = newAV(); + for (tmp = server->cap_active; tmp != NULL; tmp = tmp->next) + av_push(av, new_pv(tmp->data)); + (void) hv_store(hv, "cap_active", 10, newRV_noinc((SV*)av), 0); +} + +static void perl_ban_fill_hash(HV *hv, BAN_REC *ban) +{ + (void) hv_store(hv, "ban", 3, new_pv(ban->ban), 0); + (void) hv_store(hv, "setby", 5, new_pv(ban->setby), 0); + (void) hv_store(hv, "time", 4, newSViv(ban->time), 0); +} + +static void perl_dcc_fill_hash(HV *hv, DCC_REC *dcc) +{ + (void) hv_store(hv, "type", 4, new_pv(dcc_type2str(dcc->type)), 0); + (void) hv_store(hv, "orig_type", 9, new_pv(dcc_type2str(dcc->orig_type)), 0); + (void) hv_store(hv, "created", 7, newSViv(dcc->created), 0); + + (void) hv_store(hv, "server", 6, iobject_bless(dcc->server), 0); + (void) hv_store(hv, "servertag", 9, new_pv(dcc->servertag), 0); + (void) hv_store(hv, "mynick", 6, new_pv(dcc->mynick), 0); + (void) hv_store(hv, "nick", 4, new_pv(dcc->nick), 0); + + (void) hv_store(hv, "chat", 4, simple_iobject_bless(dcc->chat), 0); + (void) hv_store(hv, "target", 6, new_pv(dcc->target), 0); + (void) hv_store(hv, "arg", 3, new_pv(dcc->arg), 0); + + (void) hv_store(hv, "addr", 4, new_pv(dcc->addrstr), 0); + (void) hv_store(hv, "port", 4, newSViv(dcc->port), 0); + + (void) hv_store(hv, "starttime", 9, newSViv(dcc->starttime), 0); + (void) hv_store(hv, "transfd", 7, newSViv(dcc->transfd), 0); +} + +static void perl_dcc_chat_fill_hash(HV *hv, CHAT_DCC_REC *dcc) +{ + perl_dcc_fill_hash(hv, (DCC_REC *) dcc); + + (void) hv_store(hv, "id", 2, new_pv(dcc->id), 0); + (void) hv_store(hv, "mirc_ctcp", 9, newSViv(dcc->mirc_ctcp), 0); + (void) hv_store(hv, "connection_lost", 15, newSViv(dcc->connection_lost), 0); +} + +static void perl_dcc_file_fill_hash(HV *hv, FILE_DCC_REC *dcc) +{ + perl_dcc_fill_hash(hv, (DCC_REC *) dcc); + + (void) hv_store(hv, "size", 4, newSViv(dcc->size), 0); + (void) hv_store(hv, "skipped", 7, newSViv(dcc->skipped), 0); +} + +static void perl_dcc_get_fill_hash(HV *hv, GET_DCC_REC *dcc) +{ + perl_dcc_file_fill_hash(hv, (FILE_DCC_REC *) dcc); + + (void) hv_store(hv, "get_type", 8, newSViv(dcc->get_type), 0); + (void) hv_store(hv, "file", 4, new_pv(dcc->file), 0); + (void) hv_store(hv, "file_quoted", 11, newSViv(dcc->file_quoted), 0); +} + +static void perl_dcc_send_fill_hash(HV *hv, SEND_DCC_REC *dcc) +{ + perl_dcc_file_fill_hash(hv, (FILE_DCC_REC *) dcc); + + (void) hv_store(hv, "file_quoted", 11, newSViv(dcc->file_quoted), 0); + (void) hv_store(hv, "waitforend", 10, newSViv(dcc->waitforend), 0); + (void) hv_store(hv, "gotalldata", 10, newSViv(dcc->gotalldata), 0); +} + +static void perl_netsplit_fill_hash(HV *hv, NETSPLIT_REC *netsplit) +{ + AV *av; + GSList *tmp; + + (void) hv_store(hv, "nick", 4, new_pv(netsplit->nick), 0); + (void) hv_store(hv, "address", 7, new_pv(netsplit->address), 0); + (void) hv_store(hv, "destroy", 7, newSViv(netsplit->destroy), 0); + + (void) hv_store(hv, "server", 6, + plain_bless(netsplit->server, + "Irssi::Irc::Netsplitserver"), 0); + + av = newAV(); + for (tmp = netsplit->channels; tmp != NULL; tmp = tmp->next) { + av_push(av, plain_bless(tmp->data, + "Irssi::Irc::Netsplitchannel")); + } + (void) hv_store(hv, "channels", 8, newRV_noinc((SV*)av), 0); +} + +static void perl_netsplit_server_fill_hash(HV *hv, NETSPLIT_SERVER_REC *rec) +{ + (void) hv_store(hv, "server", 6, new_pv(rec->server), 0); + (void) hv_store(hv, "destserver", 10, new_pv(rec->destserver), 0); + (void) hv_store(hv, "count", 5, newSViv(rec->count), 0); +} + +static void perl_netsplit_channel_fill_hash(HV *hv, NETSPLIT_CHAN_REC *rec) +{ + (void) hv_store(hv, "name", 4, new_pv(rec->name), 0); + (void) hv_store(hv, "op", 2, newSViv(rec->op), 0); + (void) hv_store(hv, "halfop", 6, newSViv(rec->halfop), 0); + (void) hv_store(hv, "voice", 5, newSViv(rec->voice), 0); +} + +static void perl_notifylist_fill_hash(HV *hv, NOTIFYLIST_REC *notify) +{ + AV *av; + char **tmp; + + (void) hv_store(hv, "mask", 4, new_pv(notify->mask), 0); + (void) hv_store(hv, "away_check", 10, newSViv(notify->away_check), 0); + + av = newAV(); + if (notify->ircnets != NULL) { + for (tmp = notify->ircnets; *tmp != NULL; tmp++) { + av_push(av, new_pv(*tmp)); + } + } + (void) hv_store(hv, "ircnets", 7, newRV_noinc((SV*)av), 0); +} + +static void perl_client_fill_hash(HV *hv, CLIENT_REC *client) +{ + (void) hv_store(hv, "nick", 4, new_pv(client->nick), 0); + (void) hv_store(hv, "addr", 4, new_pv(client->addr), 0); + (void) hv_store(hv, "proxy_address", 13, new_pv(client->proxy_address), 0); + (void) hv_store(hv, "server", 6, iobject_bless(client->server), 0); + (void) hv_store(hv, "pass_sent", 9, newSViv(client->pass_sent), 0); + (void) hv_store(hv, "user_sent", 9, newSViv(client->user_sent), 0); + (void) hv_store(hv, "connected", 9, newSViv(client->connected), 0); + (void) hv_store(hv, "want_ctcp", 9, newSViv(client->want_ctcp), 0); + (void) hv_store(hv, "multiplex", 9, newSViv(client->multiplex), 0); + (void) hv_store(hv, "ircnet", 6, new_pv(client->listen->ircnet), 0); +} + +static PLAIN_OBJECT_INIT_REC irc_plains[] = { + { "Irssi::Irc::Ban", (PERL_OBJECT_FUNC) perl_ban_fill_hash }, + { "Irssi::Irc::Dcc", (PERL_OBJECT_FUNC) perl_dcc_fill_hash }, + { "Irssi::Irc::Netsplit", (PERL_OBJECT_FUNC) perl_netsplit_fill_hash }, + { "Irssi::Irc::Netsplitserver", (PERL_OBJECT_FUNC) perl_netsplit_server_fill_hash }, + { "Irssi::Irc::Netsplitchannel", (PERL_OBJECT_FUNC) perl_netsplit_channel_fill_hash }, + { "Irssi::Irc::Notifylist", (PERL_OBJECT_FUNC) perl_notifylist_fill_hash }, + { "Irssi::Irc::Client", (PERL_OBJECT_FUNC) perl_client_fill_hash }, + + { NULL, NULL } +}; + +MODULE = Irssi::Irc PACKAGE = Irssi::Irc PREFIX = irc_ + +PROTOTYPES: ENABLE + +void +irc_parse_message_tags(tags) + char *tags +PREINIT: + HV *hv; + GHashTable *hash; + GHashTableIter iter; + char *key; + char *val; +PPCODE: + hv = newHV(); + hash = irc_parse_message_tags(tags); + g_hash_table_iter_init(&iter, hash); + while (g_hash_table_iter_next(&iter, (gpointer *) &key, (gpointer *) &val)) { + (void) hv_store(hv, key, strlen(key), new_pv(val), 0); + } + g_hash_table_destroy(hash); + XPUSHs(sv_2mortal(newRV_noinc((SV *) hv))); + +void +init() +PREINIT: + int chat_type; +CODE: + if (initialized) return; + perl_api_version_check("Irssi::Irc"); + initialized = TRUE; + + chat_type = chat_protocol_lookup("IRC"); + + irssi_add_object(module_get_uniq_id("CHATNET", 0), chat_type, "Irssi::Irc::Chatnet", + (PERL_OBJECT_FUNC) perl_irc_chatnet_fill_hash); + irssi_add_object(module_get_uniq_id("SERVER CONNECT", 0), + chat_type, "Irssi::Irc::Connect", + (PERL_OBJECT_FUNC) perl_irc_connect_fill_hash); + irssi_add_object(module_get_uniq_id("SERVER", 0), + chat_type, "Irssi::Irc::Server", + (PERL_OBJECT_FUNC) perl_irc_server_fill_hash); + irssi_add_object(module_get_uniq_id_str("DCC", "CHAT"), + 0, "Irssi::Irc::Dcc::Chat", + (PERL_OBJECT_FUNC) perl_dcc_chat_fill_hash); + irssi_add_object(module_get_uniq_id_str("DCC", "GET"), + 0, "Irssi::Irc::Dcc::Get", + (PERL_OBJECT_FUNC) perl_dcc_get_fill_hash); + irssi_add_object(module_get_uniq_id_str("DCC", "SEND"), + 0, "Irssi::Irc::Dcc::Send", + (PERL_OBJECT_FUNC) perl_dcc_send_fill_hash); + irssi_add_object(module_get_uniq_id_str("DCC", "SERVER"), + 0, "Irssi::Irc::Dcc::Server", + (PERL_OBJECT_FUNC) perl_dcc_send_fill_hash); + irssi_add_plains(irc_plains); + perl_eval_pv("@Irssi::Irc::Dcc::Chat::ISA = qw(Irssi::Irc::Dcc);\n" + "@Irssi::Irc::Dcc::Get::ISA = qw(Irssi::Irc::Dcc);\n" + "@Irssi::Irc::Dcc::Send::ISA = qw(Irssi::Irc::Dcc);\n" + "@Irssi::Irc::Dcc::Server::ISA = qw(Irssi::Irc::Dcc);\n", + TRUE); + +void +deinit() +CODE: + initialized = FALSE; + +BOOT: + irssi_boot(Irc__Channel); + irssi_boot(Irc__Ctcp); + irssi_boot(Irc__Dcc); + irssi_boot(Irc__Modes); + irssi_boot(Irc__Netsplit); + irssi_boot(Irc__Notifylist); + irssi_boot(Irc__Query); + irssi_boot(Irc__Server); + irssi_boot(Irc__Client); diff --git a/src/perl/irc/Makefile.PL.in b/src/perl/irc/Makefile.PL.in new file mode 100644 index 0000000..561308c --- /dev/null +++ b/src/perl/irc/Makefile.PL.in @@ -0,0 +1,8 @@ +use ExtUtils::MakeMaker;our $AM_DEFAULT_VERBOSITY='@AM_DEFAULT_VERBOSITY@';require "@top_srcdir@/src/perl/Makefile_silent.pm"; + +WriteMakefile('NAME' => 'Irssi::Irc', + 'LIBS' => '', + 'OBJECT' => '$(O_FILES)', + 'TYPEMAPS' => ['../common/typemap'], + 'INC' => '-I../../.. @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 0000000..a53391b --- /dev/null +++ b/src/perl/irc/Modes.xs @@ -0,0 +1,47 @@ +#define PERL_NO_GET_CONTEXT +#include "module.h" + +MODULE = Irssi::Irc::Modes PACKAGE = Irssi::Irc +PROTOTYPES: ENABLE + +void +modes_join(server, old, mode, channel) + Irssi::Irc::Server server + char *old + char *mode + int channel +PREINIT: + char *ret; +PPCODE: + ret = modes_join(server, old, mode, channel); + XPUSHs(sv_2mortal(new_pv(ret))); + g_free(ret); + +#******************************* +MODULE = Irssi::Irc::Modes PACKAGE = Irssi::Irc::Channel PREFIX = channel_ +#******************************* + +void +ban_get_mask(channel, nick, ban_type) + Irssi::Irc::Channel channel + char *nick + int ban_type +PREINIT: + char *ret; +PPCODE: + ret = ban_get_mask(channel, nick, ban_type); + XPUSHs(sv_2mortal(new_pv(ret))); + g_free(ret); + +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, nick) + Irssi::Irc::Channel channel + char *ban + char *nick diff --git a/src/perl/irc/Netsplit.xs b/src/perl/irc/Netsplit.xs new file mode 100644 index 0000000..9fafaf7 --- /dev/null +++ b/src/perl/irc/Netsplit.xs @@ -0,0 +1,18 @@ +#define PERL_NO_GET_CONTEXT +#include "module.h" + +MODULE = Irssi::Irc::Netsplit PACKAGE = Irssi::Irc::Server +PROTOTYPES: ENABLE + +Irssi::Irc::Netsplit +netsplit_find(server, nick, address) + Irssi::Irc::Server server + char *nick + char *address + +Irssi::Irc::Netsplitchannel +netsplit_find_channel(server, nick, address, channel) + Irssi::Irc::Server server + char *nick + char *address + char *channel diff --git a/src/perl/irc/Notifylist.xs b/src/perl/irc/Notifylist.xs new file mode 100644 index 0000000..74747ba --- /dev/null +++ b/src/perl/irc/Notifylist.xs @@ -0,0 +1,59 @@ +#define PERL_NO_GET_CONTEXT +#include "module.h" + +MODULE = Irssi::Irc::Notifylist PACKAGE = Irssi::Irc +PROTOTYPES: ENABLE + +void +notifies() +PREINIT: + GSList *tmp; +PPCODE: + for (tmp = notifies; tmp != NULL; tmp = tmp->next) { + XPUSHs(sv_2mortal(plain_bless(tmp->data, "Irssi::Irc::Notifylist"))); + } + +Irssi::Irc::Notifylist +notifylist_add(mask, ircnets, away_check, idle_check_time) + char *mask + char *ircnets + int away_check + int idle_check_time +CODE: + if (idle_check_time != 0) + croak("Notify -idle has been removed"); + RETVAL = notifylist_add(mask, ircnets, away_check); +OUTPUT: + RETVAL + +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::Notifylist PACKAGE = Irssi::Irc::Server +#******************************* + +int +notifylist_ison_server(server, nick) + Irssi::Irc::Server server + char *nick + +#******************************* +MODULE = Irssi::Irc::Notifylist PACKAGE = Irssi::Irc::Notifylist PREFIX = notifylist_ +#******************************* + +int +notifylist_ircnets_match(rec, ircnet) + Irssi::Irc::Notifylist rec + char *ircnet diff --git a/src/perl/irc/Query.xs b/src/perl/irc/Query.xs new file mode 100644 index 0000000..e873d9a --- /dev/null +++ b/src/perl/irc/Query.xs @@ -0,0 +1,11 @@ +#define PERL_NO_GET_CONTEXT +#include "module.h" + +MODULE = Irssi::Irc::Query PACKAGE = Irssi::Irc::Server PREFIX = irc_ +PROTOTYPES: ENABLE + +Irssi::Irc::Query +irc_query_create(server_tag, nick, automatic) + char *server_tag + char *nick + int automatic diff --git a/src/perl/irc/Server.xs b/src/perl/irc/Server.xs new file mode 100644 index 0000000..63e3111 --- /dev/null +++ b/src/perl/irc/Server.xs @@ -0,0 +1,175 @@ +#define PERL_NO_GET_CONTEXT +#include "module.h" +#include <irssi/src/core/misc.h> + +static GSList *register_hash2list(HV *hv) +{ + HE *he; + GSList *list; + + if (hv == NULL) + return NULL; + + list = NULL; + hv_iterinit(hv); + while ((he = hv_iternext(hv)) != NULL) { + I32 len; + char *key = hv_iterkey(he, &len); + int value = (int)SvIV(HeVAL(he)); + + list = g_slist_append(list, g_strdup(key)); + list = g_slist_append(list, GINT_TO_POINTER(value)); + } + return list; +} + +static GSList *event_hash2list(HV *hv) +{ + HE *he; + GSList *list; + + if (hv == NULL) + return NULL; + + list = NULL; + hv_iterinit(hv); + while ((he = hv_iternext(hv)) != NULL) { + I32 len; + char *key = hv_iterkey(he, &len); + char *value = SvPV_nolen(HeVAL(he)); + + list = g_slist_append(list, g_strdup(key)); + list = g_slist_append(list, g_strdup(value)); + } + return list; +} + +MODULE = Irssi::Irc::Server PACKAGE = Irssi::Irc::Server PREFIX = irc_server_ +PROTOTYPES: ENABLE + +void +irc_server_get_channels(server, rejoin_channels_mode = "") + Irssi::Irc::Server server + char *rejoin_channels_mode +PREINIT: + char *ret; + int mode; + SETTINGS_REC *setting; +PPCODE: + setting = settings_get_record("rejoin_channels_on_reconnect"); + mode = strarray_find(setting->choices, rejoin_channels_mode); + if (mode < 0) + mode = setting->default_value.v_int; + + ret = irc_server_get_channels(server, mode); + XPUSHs(sv_2mortal(new_pv(ret))); + g_free(ret); + +void +send_raw(server, cmd) + Irssi::Irc::Server server + char *cmd +CODE: + irc_send_cmd(server, cmd); + +void +send_raw_now(server, cmd) + Irssi::Irc::Server server + char *cmd +CODE: + irc_send_cmd_now(server, cmd); + +void +send_raw_first(server, cmd) + Irssi::Irc::Server server + char *cmd +CODE: + irc_send_cmd_first(server, cmd); + +void +send_raw_later(server, cmd) + Irssi::Irc::Server server + char *cmd +CODE: + irc_send_cmd_later(server, cmd); + +void +send_raw_split(server, cmd, nickarg, max_nicks) + Irssi::Irc::Server server + char *cmd + int nickarg + int max_nicks +CODE: + irc_send_cmd_split(server, cmd, nickarg, max_nicks); + +MODULE = Irssi::Irc::Server PACKAGE = Irssi::Irc::Server PREFIX = server_ + +void +server_redirect_register(command, remote, timeout, start, stop, opt) + char *command + int remote + int timeout + SV *start + SV *stop + SV *opt +CODE: + server_redirect_register_list(command, remote, timeout, register_hash2list(hvref(start)), + register_hash2list(hvref(stop)), + register_hash2list(hvref(opt)), 1); + +void +server_redirect_event(server, command, count, arg, remote, failure_signal, signals) + Irssi::Irc::Server server + char *command + int count + char *arg + int remote + char *failure_signal + SV *signals +CODE: + server_redirect_event_list(server, command, count, *arg == '\0' ? NULL : arg, remote, + *failure_signal == '\0' ? NULL : failure_signal, + event_hash2list(hvref(signals))); + +char * +server_redirect_get_signal(server, prefix, event, args) + Irssi::Irc::Server server + char *prefix + char *event + char *args +CODE: + RETVAL = (char *) server_redirect_get_signal(server, prefix, event, args); +OUTPUT: + RETVAL + +char * +server_redirect_peek_signal(server, prefix, event, args) + Irssi::Irc::Server server + char *prefix + char *event + char *args +PREINIT: + int redirection; +CODE: + RETVAL = (char *) server_redirect_peek_signal(server, prefix, event, args, &redirection); +OUTPUT: + RETVAL + +char * +server_isupport(server, name) + Irssi::Irc::Server server + char *name +CODE: + RETVAL = (char *) g_hash_table_lookup(server->isupport, name); +OUTPUT: + RETVAL + +int +irc_server_cap_toggle(server, cap, enable) + Irssi::Irc::Server server + char *cap + int enable +CODE: + RETVAL = irc_cap_toggle(server, cap, enable); +OUTPUT: + RETVAL diff --git a/src/perl/irc/meson.build b/src/perl/irc/meson.build new file mode 100644 index 0000000..c83d4b4 --- /dev/null +++ b/src/perl/irc/meson.build @@ -0,0 +1,41 @@ +libperl_Irssi_Irc_a = shared_module('Irc', + [ xsubpp.process( + files( + 'Channel.xs', + 'Client.xs', + 'Ctcp.xs', + 'Dcc.xs', + 'Irc.xs', + 'Modes.xs', + 'Netsplit.xs', + 'Notifylist.xs', + 'Query.xs', + 'Server.xs', + ), + extra_args : [ + '-typemap', + '../common/typemap', + ], + ) ] + + files( + 'module.h', + ), + name_prefix : '', + name_suffix : perl_module_suffix, + install : true, + install_dir : perlmoddir / 'auto' / 'Irssi' / 'Irc', + include_directories : rootinc, + implicit_include_directories : true, + dependencies : dep + [ perl_dep ], + link_with : dl_cross_perl_core, +) + +install_headers( + files( + 'Irc.pm', + ), + install_dir : perlmoddir / 'Irssi', +) + +# 'Makefile.PL.in', +# 'typemap', diff --git a/src/perl/irc/module.h b/src/perl/irc/module.h new file mode 100644 index 0000000..3dcfb06 --- /dev/null +++ b/src/perl/irc/module.h @@ -0,0 +1,43 @@ +#include <irssi/src/perl/common/module.h> + +#include <irssi/src/irc/core/irc.h> +#include <irssi/src/irc/core/irc-chatnets.h> +#include <irssi/src/irc/core/irc-servers.h> +#include <irssi/src/irc/core/irc-channels.h> +#include <irssi/src/irc/core/irc-queries.h> +#include <irssi/src/irc/core/irc-nicklist.h> +#include <irssi/src/irc/core/irc-masks.h> +#include <irssi/src/irc/core/irc-cap.h> + +#include <irssi/src/irc/core/bans.h> +#include <irssi/src/irc/core/modes.h> +#include <irssi/src/irc/core/mode-lists.h> +#include <irssi/src/irc/core/netsplit.h> +#include <irssi/src/irc/core/servers-redirect.h> + +#include <irssi/src/irc/dcc/dcc.h> +#include <irssi/src/irc/dcc/dcc-file.h> +#include <irssi/src/irc/dcc/dcc-chat.h> +#include <irssi/src/irc/dcc/dcc-get.h> +#include <irssi/src/irc/dcc/dcc-send.h> +#include <irssi/src/irc/notifylist/notifylist.h> + +#include <irssi/src/irc/proxy/proxy.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 NICK_REC *Irssi__Irc__Nick; + +typedef BAN_REC *Irssi__Irc__Ban; +typedef DCC_REC *Irssi__Irc__Dcc; +typedef CHAT_DCC_REC *Irssi__Irc__Dcc__Chat; +typedef GET_DCC_REC *Irssi__Irc__Dcc__Get; +typedef SEND_DCC_REC *Irssi__Irc__Dcc__Send; +typedef NETSPLIT_REC *Irssi__Irc__Netsplit; +typedef NETSPLIT_SERVER_REC *Irssi__Irc__Netsplitserver; +typedef NETSPLIT_CHAN_REC *Irssi__Irc__Netsplitchannel; +typedef NOTIFYLIST_REC *Irssi__Irc__Notifylist; + +typedef CLIENT_REC *Irssi__Irc__Client; diff --git a/src/perl/irc/typemap b/src/perl/irc/typemap new file mode 100644 index 0000000..c8a9b67 --- /dev/null +++ b/src/perl/irc/typemap @@ -0,0 +1,40 @@ +TYPEMAP +Irssi::Irc::Server T_IrssiObj +Irssi::Irc::Connect T_IrssiObj +Irssi::Irc::Channel T_IrssiObj +Irssi::Irc::Query T_IrssiObj +Irssi::Irc::Nick T_IrssiObj + +Irssi::Irc::Ban T_PlainObj +Irssi::Irc::Dcc T_DccObj +Irssi::Irc::Dcc::Chat T_DccObj +Irssi::Irc::Dcc::Get T_DccObj +Irssi::Irc::Dcc::Send T_DccObj +Irssi::Irc::Netsplit T_PlainObj +Irssi::Irc::Netsplitserver T_PlainObj +Irssi::Irc::Netsplitchannel T_PlainObj +Irssi::Irc::Notifylist T_PlainObj +Irssi::Irc::Client T_IrssiObj + +INPUT + +T_IrssiObj + $var = irssi_ref_object($arg) + +T_DccObj + $var = irssi_ref_object($arg) + +T_PlainObj + $var = irssi_ref_object($arg) + +OUTPUT + +T_IrssiObj + $arg = iobject_bless((SERVER_REC *)$var); + +T_DccObj + $arg = simple_iobject_bless((DCC_REC *)$var); + +T_PlainObj + $arg = plain_bless($var, \"$ntype\"); + |