Improve portability of modperl by trying several UUID generators.

git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@2146 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
darthgandalf
2010-09-27 14:29:40 +00:00
parent ae5e260849
commit 14ffd7c769
+28 -4
View File
@@ -9,21 +9,45 @@
use strict;
use warnings;
use ZNC;
use Data::UUID;
use IO::File;
use feature 'switch';
use feature 'switch', 'say';
package ZNC::Core;
my $uuidtype;
my $uuidgen;
our %pmods;
sub Init {
$uuidgen = new Data::UUID;
if (eval { require Data::UUID }) {
$uuidtype = 'Data::UUID';
$uuidgen = new Data::UUID;
} elsif (eval { require UUID }) {
$uuidtype = 'UUID';
} else {
$uuidtype = 'int';
$uuidgen = 0;
}
}
sub CreateUUID {
$uuidgen->create_str;
my $res;
given ($uuidtype) {
when ('Data::UUID') {
$res = $uuidgen->create_str;
}
when ('UUID') {
my ($uuid, $str);
UUID::generate($uuid);
UUID::unparse($uuid, $res);
}
when ('int') {
$uuidgen++;
$res = "$uuidgen";
}
}
say "Created new UUID for modperl with '$uuidtype': $res";
return $res;
}
sub unloadByIDUser {