1
0
mirror of https://github.com/irssi/irssi.git synced 2024-11-03 04:27:19 -05:00

forgot to add this

git-svn-id: http://svn.irssi.org/repos/irssi/trunk@887 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
Timo Sirainen 2000-11-27 01:23:28 +00:00 committed by cras
parent 0d8239e40e
commit 6aa8af346c

117
src/perl/common/Themes.xs Normal file
View File

@ -0,0 +1,117 @@
MODULE = Irssi PACKAGE = Irssi
void
theme_register(formats)
SV *formats
PREINIT:
AV *av;
SV *sv;
FORMAT_REC *formatrecs;
char *key, *value;
int len, n, fpos, count;
CODE:
if (!SvROK(formats))
croak("formats is not a reference to list");
av = (AV *) SvRV(formats);
len = av_len(av)+1;
if (len == 0 || (len & 1) != 0)
croak("formats list is invalid - not dividable by 3 (%d)", len);
formatrecs = g_new0(FORMAT_REC, len/2+2);
formatrecs[fpos].tag = g_strdup(perl_get_package());
formatrecs[fpos].def = g_strdup("Perl script");
for (fpos = 1, n = 0; n < len; n++, fpos++) {
key = SvPV(*av_fetch(av, n, 0), PL_na); n++;
value = SvPV(*av_fetch(av, n, 0), PL_na);
formatrecs[fpos].tag = g_strdup(key);
formatrecs[fpos].def = g_strdup(value);
formatrecs[fpos].params = MAX_FORMAT_PARAMS;
}
theme_register_module(perl_get_package(), formatrecs);
void
printformat(server, target, level, format, ...)
Irssi::Server server
char *target
int level
char *format
PREINIT:
TEXT_DEST_REC dest;
char *arglist[MAX_FORMAT_PARAMS];
int n;
CODE:
format_create_dest(&dest, server, target, level, NULL);
memset(arglist, 0, sizeof(arglist));
for (n = 4; n < 4+MAX_FORMAT_PARAMS; n++) {
arglist[n-4] = n < items ? SvPV(ST(n), PL_na) : "";
}
printformat_perl(&dest, format, arglist);
void
printformat_window(window, level, format, ...)
Irssi::Window window
int level
char *format
PREINIT:
TEXT_DEST_REC dest;
char *arglist[MAX_FORMAT_PARAMS];
int n;
CODE:
format_create_dest(&dest, NULL, NULL, level, window);
memset(arglist, 0, sizeof(arglist));
for (n = 3; n < 3+MAX_FORMAT_PARAMS; n++) {
arglist[n-3] = n < items ? SvPV(ST(n), PL_na) : "";
}
printformat_perl(&dest, format, arglist);
#*******************************
MODULE = Irssi PACKAGE = Irssi::Server
#*******************************
void
printformat(server, target, level, format, ...)
Irssi::Server server
char *target
int level
char *format
PREINIT:
TEXT_DEST_REC dest;
char *arglist[MAX_FORMAT_PARAMS];
int n;
CODE:
format_create_dest(&dest, server, target, level, NULL);
memset(arglist, 0, sizeof(arglist));
for (n = 4; n < 4+MAX_FORMAT_PARAMS; n++) {
arglist[n-4] = n < items ? SvPV(ST(n), PL_na) : "";
}
printformat_perl(&dest, format, arglist);
#*******************************
MODULE = Irssi PACKAGE = Irssi::Windowitem
#*******************************
void
printformat(item, level, format, ...)
Irssi::Windowitem item
int level
char *format
PREINIT:
TEXT_DEST_REC dest;
char *arglist[MAX_FORMAT_PARAMS];
int n;
CODE:
format_create_dest(&dest, item->server, item->name, level, NULL);
memset(arglist, 0, sizeof(arglist));
for (n = 3; n < 3+MAX_FORMAT_PARAMS; n++) {
arglist[n-3] = n < items ? SvPV(ST(n), PL_na) : "";
}
printformat_perl(&dest, format, arglist);