1
0
mirror of https://github.com/irssi/irssi.git synced 2024-12-04 14:46:39 -05:00

Signal fixes

git-svn-id: http://svn.irssi.org/repos/irssi/trunk@767 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
Timo Sirainen 2000-10-18 01:32:14 +00:00 committed by cras
parent e23760fb25
commit ac6bfeba1f
3 changed files with 90 additions and 93 deletions

View File

@ -18,11 +18,10 @@ while (<STDIN>) {
s/int[^,]*/int/g; s/int[^,]*/int/g;
s/GSList of (\w+)s/gslist_\1/g; s/GSList of (\w+)s/gslist_\1/g;
s/SERVER_REC[^,]*/Irssi::Server/g; s/SERVER_REC[^,]*/iobject/g;
s/IRC_SERVER_REC[^,]*/Irssi::Server/g; s/RECONNECT_REC[^,]*/iobject/g;
s/RECONNECT_REC[^,]*/Irssi::Reconnect/g; s/CHANNEL_REC[^,]*/iobject/g;
s/CHANNEL_REC[^,]*/Irssi::Channel/g; s/QUERY_REC[^,]*/iobject/g;
s/QUERY_REC[^,]*/Irssi::Query/g;
s/COMMAND_REC[^,]*/Irssi::Command/g; s/COMMAND_REC[^,]*/Irssi::Command/g;
s/NICK_REC[^,]*/Irssi::Nick/g; s/NICK_REC[^,]*/Irssi::Nick/g;
s/BAN_REC[^,]*/Irssi::Ban/g; s/BAN_REC[^,]*/Irssi::Ban/g;
@ -34,7 +33,7 @@ while (<STDIN>) {
s/NOTIFYLIST_REC[^,]*/Irssi::Notifylist/g; s/NOTIFYLIST_REC[^,]*/Irssi::Notifylist/g;
s/IGNORE_REC[^,]*/Irssi::Ignore/g; s/IGNORE_REC[^,]*/Irssi::Ignore/g;
s/WINDOW_REC[^,]*/Irssi::Window/g; s/WINDOW_REC[^,]*/Irssi::Window/g;
s/WI_ITEM_REC[^,]*/Irssi::Windowitem/g; s/WI_ITEM_REC[^,]*/iobject/g;
s/([\w:]+)(,|$)/"\1"\2/g; s/([\w:]+)(,|$)/"\1"\2/g;
print " { -1, \"$signal\", { $_, NULL } },\n"; print " { -1, \"$signal\", { $_, NULL } },\n";

View File

@ -4,6 +4,9 @@
#define new_pv(a) \ #define new_pv(a) \
(newSVpv((a) == NULL ? "" : (a), (a) == NULL ? 0 : strlen(a))) (newSVpv((a) == NULL ? "" : (a), (a) == NULL ? 0 : strlen(a)))
#define new_bless(obj, stash) \
sv_bless(newRV_noinc(newSViv(GPOINTER_TO_INT(obj))), stash)
extern GHashTable *perl_stashes; extern GHashTable *perl_stashes;
HV *irssi_get_stash_item(int type, int chat_type); HV *irssi_get_stash_item(int type, int chat_type);

View File

@ -33,6 +33,7 @@
#include "commands.h" #include "commands.h"
#include "misc.h" #include "misc.h"
#include "perl-common.h" #include "perl-common.h"
#include "servers.h"
/* For compatibility with perl 5.004 and older */ /* For compatibility with perl 5.004 and older */
#ifndef ERRSV #ifndef ERRSV
@ -493,113 +494,107 @@ void perl_timeout_remove(int tag)
} }
} }
static PERL_SIGNAL_ARGS_REC *perl_signal_find(int signal)
{
const char *signame;
int n;
for (n = 0; perl_signal_args[n].signal != NULL; n++) {
if (signal == perl_signal_args[n].signal_id)
return &perl_signal_args[n];
}
/* try to find by name */
signame = module_find_id_str("signals", signal);
for (n = 0; perl_signal_args[n].signal != NULL; n++) {
if (strncmp(signame, perl_signal_args[n].signal,
strlen(perl_signal_args[n].signal)) == 0)
return &perl_signal_args[n];
}
return NULL;
}
static int call_perl(const char *func, int signal, va_list va) static int call_perl(const char *func, int signal, va_list va)
{ {
dSP; dSP;
PERL_SIGNAL_ARGS_REC *rec; PERL_SIGNAL_ARGS_REC *rec;
int retcount, n, ret; int retcount, ret;
void *arg;
HV *stash; HV *stash;
void *arg;
int n;
/* first check if we find exact match */ /* first check if we find exact match */
rec = NULL; rec = perl_signal_find(signal);
for (n = 0; perl_signal_args[n].signal != NULL; n++)
{
if (signal == perl_signal_args[n].signal_id)
{
rec = &perl_signal_args[n];
break;
}
}
if (rec == NULL) ENTER;
{ SAVETMPS;
/* try to find by name */
const char *signame;
signame = module_find_id_str("signals", signal); PUSHMARK(sp);
for (n = 0; perl_signal_args[n].signal != NULL; n++)
{
if (strncmp(signame, perl_signal_args[n].signal,
strlen(perl_signal_args[n].signal)) == 0)
{
rec = &perl_signal_args[n];
break;
}
}
}
ENTER; if (rec != NULL) {
SAVETMPS; /* push the arguments to perl stack */
for (n = 0; n < 7 && rec->args[n] != NULL; n++) {
arg = va_arg(va, void *);
PUSHMARK(sp); if (strcmp(rec->args[n], "string") == 0)
XPUSHs(sv_2mortal(new_pv(arg)));
else if (strcmp(rec->args[n], "int") == 0)
XPUSHs(sv_2mortal(newSViv(GPOINTER_TO_INT(arg))));
else if (strcmp(rec->args[n], "ulongptr") == 0)
XPUSHs(sv_2mortal(newSViv(*(unsigned long *) arg)));
else if (strncmp(rec->args[n], "gslist_", 7) == 0) {
/* linked list - push as AV */
GSList *tmp;
AV *av;
if (rec != NULL) av = newAV();
{ stash = gv_stashpv(rec->args[n]+7, 0);
/* put the arguments to perl stack */ for (tmp = arg; tmp != NULL; tmp = tmp->next)
for (n = 0; n < 7; n++) av_push(av, sv_2mortal(new_bless(tmp->data, stash)));
{ XPUSHs(newRV_noinc((SV*)av));
arg = va_arg(va, gpointer); } else if (arg == NULL) {
/* don't bless NULL arguments */
if (rec->args[n] == NULL) XPUSHs(sv_2mortal(newSViv(0)));
break; } else if (strcmp(rec->args[n], "iobject") == 0) {
/* "irssi object" - any struct that has
if (strcmp(rec->args[n], "string") == 0) "int type; int chat_type" as its first
XPUSHs(sv_2mortal(newSVpv(arg == NULL ? "" : arg, arg == NULL ? 0 : strlen(arg)))); variables (server, channel, ..) */
else if (strcmp(rec->args[n], "int") == 0) stash = irssi_get_stash((SERVER_REC *) arg);
XPUSHs(sv_2mortal(newSViv(GPOINTER_TO_INT(arg)))); XPUSHs(sv_2mortal(new_bless(arg, stash)));
else if (strcmp(rec->args[n], "ulongptr") == 0) } else {
XPUSHs(sv_2mortal(newSViv(*(gulong *) arg))); /* blessed object */
else if (strncmp(rec->args[n], "gslist_", 7) == 0) stash = gv_stashpv(rec->args[n], 0);
{ XPUSHs(sv_2mortal(new_bless(arg, stash)));
GSList *tmp; }
stash = gv_stashpv(rec->args[n]+7, 0);
for (tmp = arg; tmp != NULL; tmp = tmp->next)
XPUSHs(sv_2mortal(sv_bless(newRV_noinc(newSViv(GPOINTER_TO_INT(tmp->data))), stash)));
}
else
{
if (arg == NULL)
XPUSHs(sv_2mortal(newSViv(0)));
else {
stash = gv_stashpv(rec->args[n], 0);
XPUSHs(sv_2mortal(sv_bless(newRV_noinc(newSViv(GPOINTER_TO_INT(arg))), stash)));
} }
}
} }
}
PUTBACK; PUTBACK;
retcount = perl_call_pv((char *) func, G_EVAL|G_SCALAR); retcount = perl_call_pv((char *) func, G_EVAL|G_SCALAR);
SPAGAIN; SPAGAIN;
ret = 0; ret = 0;
if (SvTRUE(ERRSV)) if (SvTRUE(ERRSV)) {
{ STRLEN n_a;
STRLEN n_a;
signal_emit("gui dialog", 2, "error", SvPV(ERRSV, n_a)); signal_emit("gui dialog", 2, "error", SvPV(ERRSV, n_a));
(void)POPs; (void)POPs;
} } else if (retcount > 0) {
else SV *sv = POPs;
{
SV *sv;
if (retcount > 0) if (SvIOK(sv) && SvIV(sv) == 1) ret = 1;
{ while (--retcount > 0)
sv = POPs; (void)POPi;
if (SvIOK(sv) && SvIV(sv) == 1) ret = 1;
} }
for (n = 2; n <= retcount; n++)
(void)POPi;
}
PUTBACK; PUTBACK;
FREETMPS; FREETMPS;
LEAVE; LEAVE;
return ret; return ret;
} }
static void sig_signal(void *signal, ...) static void sig_signal(void *signal, ...)