line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Win32::MailboxGUID; |
2
|
|
|
|
|
|
|
BEGIN { |
3
|
1
|
|
|
1
|
|
27412
|
$Win32::MailboxGUID::VERSION = '0.02'; |
4
|
|
|
|
|
|
|
} |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
#ABSTRACT: functions to convert Exchange mailbox GUIDs |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
10
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
29
|
|
9
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
357
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our @ISA = qw[Exporter]; |
12
|
|
|
|
|
|
|
our @EXPORT_OK = qw[ad_to_exch exch_to_ad]; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
my $guidre = qr/^\{[[:xdigit:]]{8}-[[:xdigit:]]{4}-[[:xdigit:]]{4}-[[:xdigit:]]{4}-[[:xdigit:]]{12}\}$/i; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub ad_to_exch { |
17
|
2
|
|
|
2
|
1
|
681
|
my $guid = shift; |
18
|
2
|
100
|
|
|
|
3
|
$guid = shift if eval { $guid->isa(__PACKAGE__) }; |
|
2
|
|
|
|
|
57
|
|
19
|
2
|
50
|
|
|
|
8
|
return unless $guid; |
20
|
2
|
|
|
|
|
18
|
my @vals = map { sprintf("%.2X", ord $_) } unpack "(a1)*", $guid; |
|
32
|
|
|
|
|
66
|
|
21
|
2
|
50
|
|
|
|
13
|
return unless scalar @vals == 16; |
22
|
2
|
|
|
|
|
19
|
return join '', '{', @vals[3,2,1,0], '-', @vals[5,4], '-', @vals[7,6], '-', @vals[8,9], '-', @vals[10..$#vals], '}'; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub exch_to_ad { |
26
|
2
|
|
|
2
|
1
|
833
|
my $guid = shift; |
27
|
2
|
100
|
|
|
|
3
|
$guid = shift if eval { $guid->isa(__PACKAGE__) }; |
|
2
|
|
|
|
|
14
|
|
28
|
2
|
50
|
|
|
|
7
|
return unless $guid; |
29
|
2
|
50
|
|
|
|
13
|
return unless $guid =~ /$guidre/i; |
30
|
2
|
|
|
|
|
10
|
$guid =~ s/[\{\}]+//g; |
31
|
2
|
|
|
|
|
3
|
my $string = ''; |
32
|
2
|
|
|
|
|
2
|
my $count = 0; |
33
|
|
|
|
|
|
|
|
34
|
2
|
|
|
|
|
9
|
$string .= "\\$_" for |
|
10
|
|
|
|
|
9
|
|
35
|
10
|
100
|
|
|
|
50
|
map { $count++; ( $count >= 4 ? ( unpack "(A2)*", $_ ) : ( reverse unpack "(A2)*", $_ ) ) } |
36
|
|
|
|
|
|
|
split /\-/, $guid; |
37
|
|
|
|
|
|
|
|
38
|
2
|
|
|
|
|
9
|
return $string; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
q"GUID! GUID, GUID, gum gum"; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
__END__ |