| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Kolab::Util; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
## |
|
4
|
|
|
|
|
|
|
## Copyright (c) 2003 Code Fusion cc |
|
5
|
|
|
|
|
|
|
## |
|
6
|
|
|
|
|
|
|
## Writen by Stuart Bingė |
|
7
|
|
|
|
|
|
|
## |
|
8
|
|
|
|
|
|
|
## This program is free software; you can redistribute it and/or |
|
9
|
|
|
|
|
|
|
## modify it under the terms of the GNU General Public License as |
|
10
|
|
|
|
|
|
|
## published by the Free Software Foundation; either version 2, or |
|
11
|
|
|
|
|
|
|
## (at your option) any later version. |
|
12
|
|
|
|
|
|
|
## |
|
13
|
|
|
|
|
|
|
## This program is distributed in the hope that it will be useful, |
|
14
|
|
|
|
|
|
|
## but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15
|
|
|
|
|
|
|
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
16
|
|
|
|
|
|
|
## General Public License for more details. |
|
17
|
|
|
|
|
|
|
## |
|
18
|
|
|
|
|
|
|
## You can view the GNU General Public License, online, at the GNU |
|
19
|
|
|
|
|
|
|
## Project's homepage; see . |
|
20
|
|
|
|
|
|
|
## |
|
21
|
|
|
|
|
|
|
|
|
22
|
1
|
|
|
1
|
|
20368
|
use 5.008; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
49
|
|
|
23
|
1
|
|
|
1
|
|
7
|
use strict; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
32
|
|
|
24
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
|
1
|
|
|
|
|
7
|
|
|
|
1
|
|
|
|
|
39
|
|
|
25
|
1
|
|
|
1
|
|
1009
|
use IO::File; |
|
|
1
|
|
|
|
|
20018
|
|
|
|
1
|
|
|
|
|
595
|
|
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
require Exporter; |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( |
|
32
|
|
|
|
|
|
|
'all' => [ qw( |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
) ] |
|
35
|
|
|
|
|
|
|
); |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
our @EXPORT = qw( |
|
40
|
|
|
|
|
|
|
&trim |
|
41
|
|
|
|
|
|
|
&ldapDateToEpoch |
|
42
|
|
|
|
|
|
|
&readConfig |
|
43
|
|
|
|
|
|
|
&readList |
|
44
|
|
|
|
|
|
|
); |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
our $VERSION = sprintf('%d.%02d', q$Revision: 1.1.1.1 $ =~ /(\d+)\.(\d+)/); |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub trim |
|
49
|
|
|
|
|
|
|
{ |
|
50
|
0
|
|
|
0
|
0
|
|
my $string = shift; |
|
51
|
|
|
|
|
|
|
|
|
52
|
0
|
0
|
|
|
|
|
if (defined $string) { |
|
53
|
0
|
|
|
|
|
|
$string =~ s/^\s+//g; |
|
54
|
0
|
|
|
|
|
|
$string =~ s/\s+$//g; |
|
55
|
0
|
|
|
|
|
|
chomp $string; |
|
56
|
|
|
|
|
|
|
} |
|
57
|
|
|
|
|
|
|
|
|
58
|
0
|
|
|
|
|
|
return $string; |
|
59
|
|
|
|
|
|
|
} |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub ldapDateToEpoch |
|
62
|
|
|
|
|
|
|
{ |
|
63
|
0
|
|
|
0
|
0
|
|
my $ldapdate = shift; |
|
64
|
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
(my $y, my $m, my $d, my $h, my $mi, my $se) = unpack('A4A2A2A2A2A2', $ldapdate); |
|
66
|
|
|
|
|
|
|
|
|
67
|
0
|
|
|
|
|
|
return timelocal($se, $mi, $h, $d, $m, $y); |
|
68
|
|
|
|
|
|
|
} |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub readConfig |
|
71
|
|
|
|
|
|
|
{ |
|
72
|
0
|
|
|
0
|
0
|
|
my $ref = shift; |
|
73
|
0
|
|
|
|
|
|
my (%cfg, $file); |
|
74
|
|
|
|
|
|
|
|
|
75
|
0
|
0
|
|
|
|
|
if (ref($ref) eq 'HASH') { |
|
76
|
0
|
|
|
|
|
|
%cfg = %$ref; |
|
77
|
0
|
|
0
|
|
|
|
$file = shift || 0; |
|
78
|
|
|
|
|
|
|
} else { |
|
79
|
0
|
|
|
|
|
|
$file = $ref; |
|
80
|
|
|
|
|
|
|
} |
|
81
|
|
|
|
|
|
|
|
|
82
|
0
|
0
|
|
|
|
|
if (!$file) { return %cfg; } |
|
|
0
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
|
|
84
|
0
|
|
0
|
|
|
|
my $sep = shift || ':'; |
|
85
|
0
|
0
|
0
|
|
|
|
$sep = '\s' if ($sep eq ' ' || $sep eq '#'); |
|
86
|
|
|
|
|
|
|
|
|
87
|
0
|
|
|
|
|
|
my $fd; |
|
88
|
0
|
0
|
|
|
|
|
if (!($fd = IO::File->new($file, 'r'))) { return %cfg; } |
|
|
0
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
|
|
90
|
0
|
|
|
|
|
|
foreach (<$fd>) { |
|
91
|
0
|
0
|
|
|
|
|
if (/^([^$sep#]+)$sep+([^#]*)/) { |
|
92
|
0
|
|
|
|
|
|
$cfg{trim($1)} = trim($2); |
|
93
|
|
|
|
|
|
|
} |
|
94
|
|
|
|
|
|
|
} |
|
95
|
|
|
|
|
|
|
|
|
96
|
0
|
|
|
|
|
|
return %cfg; |
|
97
|
|
|
|
|
|
|
} |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub readList |
|
100
|
|
|
|
|
|
|
{ |
|
101
|
0
|
|
|
0
|
0
|
|
my @list; |
|
102
|
|
|
|
|
|
|
|
|
103
|
0
|
|
0
|
|
|
|
my $file = shift || 0; |
|
104
|
0
|
0
|
|
|
|
|
if (!$file) { return @list; } |
|
|
0
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
|
|
106
|
0
|
|
|
|
|
|
my $fd; |
|
107
|
0
|
0
|
|
|
|
|
if (!($fd = IO::File->new($file, 'r'))) { return @list; } |
|
|
0
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
|
|
109
|
0
|
|
|
|
|
|
foreach (<$fd>) { |
|
110
|
0
|
0
|
|
|
|
|
if (/^([^#]+)/) { |
|
111
|
0
|
|
|
|
|
|
my $temp = trim($1); |
|
112
|
0
|
0
|
|
|
|
|
next if $temp eq ''; |
|
113
|
0
|
|
|
|
|
|
push(@list, ($temp)); |
|
114
|
|
|
|
|
|
|
} |
|
115
|
|
|
|
|
|
|
} |
|
116
|
|
|
|
|
|
|
|
|
117
|
0
|
|
|
|
|
|
return @list; |
|
118
|
|
|
|
|
|
|
} |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
1; |
|
121
|
|
|
|
|
|
|
__END__ |