diff options
author | Timo Sirainen <cras@irssi.org> | 2000-05-04 10:32:42 +0000 |
---|---|---|
committer | cras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2000-05-04 10:32:42 +0000 |
commit | d3dc9a1307adc40425bf162f1f867a39e535f501 (patch) | |
tree | d3c92a8e431391d679ae5341cb4e865f00449761 /src/perl | |
parent | bacfcb060c1b687f70db4d59797e1cbc8bfe0f62 (diff) | |
download | irssi-d3dc9a1307adc40425bf162f1f867a39e535f501.zip |
.. lots of changes ..
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@197 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src/perl')
-rw-r--r-- | src/perl/irssi-perl.c | 53 | ||||
-rw-r--r-- | src/perl/xs/Irssi-core.xs | 13 | ||||
-rw-r--r-- | src/perl/xs/Irssi-netsplit.xs | 23 | ||||
-rw-r--r-- | src/perl/xs/Irssi-server.xs | 2 | ||||
-rw-r--r-- | src/perl/xs/module.h | 1 | ||||
-rw-r--r-- | src/perl/xs/typemap | 1 |
6 files changed, 80 insertions, 13 deletions
diff --git a/src/perl/irssi-perl.c b/src/perl/irssi-perl.c index 49373684..e4f616e9 100644 --- a/src/perl/irssi-perl.c +++ b/src/perl/irssi-perl.c @@ -68,7 +68,9 @@ static void perl_signal_destroy(PERL_SIGNAL_REC *rec) { GHashTable *table; GSList *siglist; - void *signal_idp; + void *signal_idp; + + g_return_if_fail(rec != NULL); table = rec->last ? last_signals : first_signals; signal_idp = GINT_TO_POINTER(rec->signal_id); @@ -138,13 +140,14 @@ static void irssi_perl_start(void) static void signal_destroy_hash(void *key, GSList *list) { - GSList *next; - while (list != NULL) { - next = list->next; + PERL_SIGNAL_REC *rec = list->data; + + list = g_slist_remove(list, rec); - perl_signal_destroy(list->data); - list = next; + g_free(rec->signal); + g_free(rec->func); + g_free(rec); } } @@ -154,6 +157,17 @@ static void irssi_perl_stop(void) g_hash_table_destroy(first_signals); g_hash_table_foreach(last_signals, (GHFunc) signal_destroy_hash, NULL); g_hash_table_destroy(last_signals); + first_signals = last_signals = NULL; + + if (signal_grabbed) { + signal_grabbed = FALSE; + signal_remove("signal", (SIGNAL_FUNC) sig_signal); + } + + if (siglast_grabbed) { + siglast_grabbed = FALSE; + signal_remove("last signal", (SIGNAL_FUNC) sig_lastsignal); + } while (perl_timeouts != NULL) perl_timeout_destroy(perl_timeouts->data); @@ -222,12 +236,37 @@ static void cmd_flush(const char *data) irssi_perl_start(); } +static int perl_signal_find(const char *signal, const char *func, int last) +{ + GHashTable *table; + GSList *siglist; + int signal_id; + + table = last ? last_signals : first_signals; + + signal_id = module_get_uniq_id_str("signals", signal); + siglist = g_hash_table_lookup(table, GINT_TO_POINTER(signal_id)); + + while (siglist != NULL) { + PERL_SIGNAL_REC *rec = siglist->data; + + if (strcmp(rec->func, func) == 0) + return TRUE; + siglist = siglist->next; + } + + return FALSE; +} + static void perl_signal_to(const char *signal, const char *func, int last) { PERL_SIGNAL_REC *rec; GHashTable *table; GSList *siglist; - void *signal_idp; + void *signal_idp; + + if (perl_signal_find(signal, func, last)) + return; rec = g_new(PERL_SIGNAL_REC, 1); rec->signal_id = module_get_uniq_id_str("signals", signal); diff --git a/src/perl/xs/Irssi-core.xs b/src/perl/xs/Irssi-core.xs index b7cdcb6d..324637ae 100644 --- a/src/perl/xs/Irssi-core.xs +++ b/src/perl/xs/Irssi-core.xs @@ -88,8 +88,18 @@ command_bind(cmd, category, func) char *func CODE: char *signal; + GSList *tmp; - command_bind(cmd, *category ? category : "Perl scripts' commands", NULL); + /* Don't add the command twice */ + if (*category == '\0') category = "Perl scripts' commands"; + for (tmp = commands; tmp != NULL; tmp = tmp->next) { + COMMAND_REC *rec = tmp->data; + + if (g_strcasecmp(rec->cmd, cmd) == 0 && + g_strcasecmp(rec->category, category) == 0) + break; + } + if (tmp == NULL) command_bind(cmd, category, NULL); signal = g_strconcat("command ", cmd, NULL); perl_signal_add(signal, func); g_free(signal); @@ -101,7 +111,6 @@ command_unbind(cmd, func) CODE: char *signal; - command_unbind(cmd, NULL); signal = g_strconcat("command ", cmd, NULL); perl_signal_remove(signal, func); g_free(signal); diff --git a/src/perl/xs/Irssi-netsplit.xs b/src/perl/xs/Irssi-netsplit.xs index 0c1e998f..428cb61a 100644 --- a/src/perl/xs/Irssi-netsplit.xs +++ b/src/perl/xs/Irssi-netsplit.xs @@ -22,13 +22,30 @@ void values(netsplit) Irssi::Netsplit netsplit PREINIT: - HV *hv; + 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, "server", 6, new_pv(netsplit->server), 0); - hv_store(hv, "destserver", 10, new_pv(netsplit->destserver), 0); hv_store(hv, "destroy", 7, newSViv(netsplit->destroy), 0); + + stash = gv_stashpv("Irssi::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 PACKAGE = Irssi::Netsplitserver +#******************************* + +void +values(rec) + Irssi::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/xs/Irssi-server.xs b/src/perl/xs/Irssi-server.xs index 326b8d99..f53527ec 100644 --- a/src/perl/xs/Irssi-server.xs +++ b/src/perl/xs/Irssi-server.xs @@ -53,7 +53,7 @@ void values(server) Irssi::Server server PREINIT: - HV *hv, *stash; + HV *hv; char *type; PPCODE: type = "IRC"; diff --git a/src/perl/xs/module.h b/src/perl/xs/module.h index 350f3de0..3a55f787 100644 --- a/src/perl/xs/module.h +++ b/src/perl/xs/module.h @@ -44,6 +44,7 @@ typedef RECONNECT_REC *Irssi__Reconnect; typedef NICK_REC *Irssi__Nick; typedef BAN_REC *Irssi__Ban; typedef NETSPLIT_REC *Irssi__Netsplit; +typedef NETSPLIT_SERVER_REC *Irssi__Netsplitserver; typedef IGNORE_REC *Irssi__Ignore; typedef DCC_REC *Irssi__Dcc; diff --git a/src/perl/xs/typemap b/src/perl/xs/typemap index 0e61ce06..5173ebe4 100644 --- a/src/perl/xs/typemap +++ b/src/perl/xs/typemap @@ -9,6 +9,7 @@ Irssi::Nick T_PTROBJ Irssi::Ban T_PTROBJ Irssi::Dcc T_PTROBJ Irssi::Netsplit T_PTROBJ +Irssi::Netsplitserver T_PTROBJ Irssi::Autoignore T_PTROBJ Irssi::Log T_PTROBJ Irssi::Rawlog T_PTROBJ |