mirror of
https://github.com/znc/znc.git
synced 2026-07-06 01:41:12 +02:00
modperl: remove given/when
new perl version removes this feature
This commit is contained in:
+22
-27
@@ -34,7 +34,7 @@ BEGIN {
|
||||
}
|
||||
|
||||
use IO::File;
|
||||
use feature 'switch', 'say';
|
||||
use feature 'say';
|
||||
|
||||
package ZNC::String;
|
||||
use overload '""' => sub {
|
||||
@@ -71,16 +71,15 @@ sub UnloadModule {
|
||||
my $cmod = $pmod->{_cmod};
|
||||
my $modpath = $cmod->GetModPath;
|
||||
my $modname = $cmod->GetModName;
|
||||
given ($cmod->GetType()) {
|
||||
when ($ZNC::CModInfo::NetworkModule) {
|
||||
$cmod->GetNetwork->GetModules->removeModule($cmod);
|
||||
}
|
||||
when ($ZNC::CModInfo::UserModule) {
|
||||
$cmod->GetUser->GetModules->removeModule($cmod);
|
||||
}
|
||||
when ($ZNC::CModInfo::GlobalModule) {
|
||||
ZNC::CZNC::Get()->GetModules->removeModule($cmod);
|
||||
}
|
||||
my $type = $cmod->GetType();
|
||||
if ($type == $ZNC::CModInfo::NetworkModule) {
|
||||
$cmod->GetNetwork->GetModules->removeModule($cmod);
|
||||
} elsif ($type == $ZNC::CModInfo::UserModule) {
|
||||
$cmod->GetUser->GetModules->removeModule($cmod);
|
||||
} elsif ($type == $ZNC::CModInfo::GlobalModule) {
|
||||
ZNC::CZNC::Get()->GetModules->removeModule($cmod);
|
||||
} else {
|
||||
die "UnloadModule: unknown module type $type for $modpath";
|
||||
}
|
||||
delete $pmod->{_cmod};
|
||||
delete $pmod->{_nv};
|
||||
@@ -110,16 +109,14 @@ sub LoadModule {
|
||||
my ($modname, $args, $type, $user, $network) = @_;
|
||||
$modname =~ /^\w+$/ or return ($ZNC::Perl_LoadError, "Module names can only contain letters, numbers and underscores, [$modname] is invalid.");
|
||||
my $container;
|
||||
given ($type) {
|
||||
when ($ZNC::CModInfo::NetworkModule) {
|
||||
$container = $network;
|
||||
}
|
||||
when ($ZNC::CModInfo::UserModule) {
|
||||
$container = $user;
|
||||
}
|
||||
when ($ZNC::CModInfo::GlobalModule) {
|
||||
$container = ZNC::CZNC::Get();
|
||||
}
|
||||
if ($type == $ZNC::CModInfo::NetworkModule) {
|
||||
$container = $network;
|
||||
} elsif ($type == $ZNC::CModInfo::UserModule) {
|
||||
$container = $user;
|
||||
} elsif ($type == $ZNC::CModInfo::GlobalModule) {
|
||||
$container = ZNC::CZNC::Get();
|
||||
} else {
|
||||
die "LoadModule: unknown module type $type for $modname";
|
||||
}
|
||||
return ($ZNC::Perl_LoadError, "Uhm? No container for the module? Wtf?") unless $container;
|
||||
$container = $container->GetModules;
|
||||
@@ -791,12 +788,10 @@ sub Listen {
|
||||
my %arg = @_;
|
||||
my $addrtype = $ZNC::ADDR_ALL;
|
||||
if (defined $arg{addrtype}) {
|
||||
given ($arg{addrtype}) {
|
||||
when (/^ipv4$/i) { $addrtype = $ZNC::ADDR_IPV4ONLY }
|
||||
when (/^ipv6$/i) { $addrtype = $ZNC::ADDR_IPV6ONLY }
|
||||
when (/^all$/i) { }
|
||||
default { die "Specified addrtype [$arg{addrtype}] isn't supported" }
|
||||
}
|
||||
if ($arg{addrtype} =~ /^ipv4$/i) { $addrtype = $ZNC::ADDR_IPV4ONLY }
|
||||
elsif ($arg{addrtype} =~ /^ipv6$/i) { $addrtype = $ZNC::ADDR_IPV6ONLY }
|
||||
elsif ($arg{addrtype} =~ /^all$/i) { }
|
||||
else { die "Specified addrtype [$arg{addrtype}] isn't supported" }
|
||||
}
|
||||
if (defined $arg{port}) {
|
||||
return $arg{port} if $self->GetModule->GetManager->ListenHost(
|
||||
|
||||
Reference in New Issue
Block a user