summaryrefslogtreecommitdiff
path: root/src/perl/irc
diff options
context:
space:
mode:
authorTimo Sirainen <cras@irssi.org>2001-11-12 09:13:12 +0000
committercras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564>2001-11-12 09:13:12 +0000
commit1b2f3a6d4c305a4301e91f40b5ad8bd385c76aeb (patch)
treefd86474c47866906a2315f856a8964d48de34742 /src/perl/irc
parent65f92c5e9df3d72fbdaa1b56f05c02baacff4fdf (diff)
downloadirssi-1b2f3a6d4c305a4301e91f40b5ad8bd385c76aeb.zip
Added Irssi::redirect_get_signal() and Irssi::redirect_peek_signal().
Changed syntax of Irssi::redirect_register() and Irssi::redirect_event(). git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1989 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src/perl/irc')
-rw-r--r--src/perl/irc/Server.xs96
1 files changed, 74 insertions, 22 deletions
diff --git a/src/perl/irc/Server.xs b/src/perl/irc/Server.xs
index f1d9f62f..40405955 100644
--- a/src/perl/irc/Server.xs
+++ b/src/perl/irc/Server.xs
@@ -1,5 +1,48 @@
#include "module.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;
+ STRLEN n_a;
+
+ 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(HeVAL(he), n_a);
+
+ 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
@@ -38,40 +81,49 @@ ctcp_send_reply(server, data)
MODULE = Irssi::Irc::Server PACKAGE = Irssi::Irc::Server PREFIX = server_
void
-server_redirect_register(command, remote, timeout, ...)
+server_redirect_register(command, remote, timeout, start, stop)
char *command
int remote
int timeout
-PREINIT:
- STRLEN n_a;
- GSList *start, *stop, **list;
- int n;
+ void *start
+ void *stop
CODE:
- start = stop = NULL; list = &start;
- for (n = 3; n < items; n++) {
- if (ST(n) == &PL_sv_undef) list = &stop;
- if (SvPOK(ST(n)))
- *list = g_slist_append(*list, SvPV(ST(n), n_a));
- }
- server_redirect_register_list(command, remote, timeout, start, stop);
+ server_redirect_register_list(command, remote, timeout,
+ register_hash2list(hvref(ST(3))),
+ register_hash2list(hvref(ST(4))));
void
-server_redirect_event(server, command, arg, remote, failure_signal, ...)
+server_redirect_event(server, command, arg, remote, failure_signal, signals)
Irssi::Irc::Server server
char *command
char *arg
int remote
char *failure_signal
-PREINIT:
- STRLEN n_a;
- GSList *list;
- int n;
+ void *signals
CODE:
- list = NULL;
- for (n = 5; n < items; n++) {
- list = g_slist_append(list, SvPV(ST(n), n_a));
- }
- server_redirect_event_list(server, command, arg, remote, failure_signal, list);
+ server_redirect_event_list(server, command, arg, remote,
+ failure_signal,
+ event_hash2list(hvref(ST(5))));
+
+char *
+server_redirect_get_signal(server, event, args)
+ Irssi::Irc::Server server
+ char *event
+ char *args
+CODE:
+ RETVAL = (char *) server_redirect_get_signal(server, event, args);
+OUTPUT:
+ RETVAL
+
+char *
+server_redirect_peek_signal(server, event, args)
+ Irssi::Irc::Server server
+ char *event
+ char *args
+CODE:
+ RETVAL = (char *) server_redirect_peek_signal(server, event, args);
+OUTPUT:
+ RETVAL
MODULE = Irssi::Irc::Server PACKAGE = Irssi::Irc::Connect PREFIX = irc_server_