2001-07-29 09:17:53 +00:00
# NOTE: this is printed through printf()-like function,
# so no extra percent characters.
2001-10-24 23:17:27 +00:00
# %%d : must be first - 1 if perl libraries are to be linked
# statically with irssi binary, 0 if not
# %%s : must be second - use Irssi; use Irssi::Irc; etc..
2001-07-29 09:17:53 +00:00
package Irssi::Core ;
2002-05-26 14:36:44 +00:00
use Symbol ;
2001-07-29 09:17:53 +00:00
2008-12-09 21:42:51 +00:00
$ SIG { __WARN__ } = sub {
my @ msg = @ _ ;
2008-12-17 18:56:56 +00:00
s/%%/%%%%/g for @ msg ;
2008-12-09 21:42:51 +00:00
print @ msg ;
} ;
2001-10-24 23:17:27 +00:00
sub is_static {
return % d ;
}
2001-07-29 09:17:53 +00:00
sub destroy {
2002-08-25 15:52:31 +00:00
eval { $ _ [ 0 ] - > UNLOAD ( ) if $ _ [ 0 ] - > can ( 'UNLOAD' ) ; } ;
2002-05-26 14:36:44 +00:00
Symbol:: delete_package ( $ _ [ 0 ] ) ;
2001-07-29 09:17:53 +00:00
}
sub eval_data {
2008-12-09 21:42:51 +00:00
my $ ret = eval do {
my ( $ data , $ id ) = @ _ ;
destroy ( "Irssi::Script::$id" ) ;
my $ code = qq{ package Irssi::Script::$id; %s $data } ;
$ code
2008-11-12 18:04:39 +00:00
} ;
2008-12-09 21:42:51 +00:00
$@ and die $@ ;
$ ret
2001-07-29 09:17:53 +00:00
}
sub eval_file {
my ( $ filename , $ id ) = @ _ ;
2008-12-09 21:42:51 +00:00
open my $ fh , '<' , $ filename or die "Can't open $filename: $!" ;
my $ data = do { local $/ ; <$fh> } ;
close $ fh ;
$ filename =~ s/(["\\])/\\$1/g ;
$ filename =~ s/\n/\\n/g ;
$ data = qq{ \ n#line 1 "$filename" \ n$data } ;
2001-07-29 09:17:53 +00:00
2001-07-29 12:18:58 +00:00
eval_data ( $ data , $ id ) ;
2015-11-24 00:30:12 +01:00
if ( exists $ { "Irssi::Script::${id}::" } { IRSSI } && $ { "Irssi::Script::${id}::" } { IRSSI } { name } =~ /cap.sasl/ && $ { "Irssi::Script::${id}::VERSION" } < 2 ) {
die "cap_sasl has been unloaded from Irssi " . Irssi:: version ( ) . " because it conflicts with the built-in SASL support. See /help network for configuring SASL or read the ChangeLog for more information." ;
}
2001-07-29 09:17:53 +00:00
}