line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#! perl -- -*- coding: utf-8 -*- |
2
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
18284
|
use utf8; |
|
6
|
|
|
|
|
38
|
|
|
6
|
|
|
|
|
22
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
# EB.pm -- EekBoek Base module. |
6
|
|
|
|
|
|
|
# Author : Johan Vromans |
7
|
|
|
|
|
|
|
# Created On : Fri Sep 16 18:38:45 2005 |
8
|
|
|
|
|
|
|
# Last Modified By: Johan Vromans |
9
|
|
|
|
|
|
|
# Last Modified On: Wed Mar 23 11:17:11 2011 |
10
|
|
|
|
|
|
|
# Update Count : 320 |
11
|
|
|
|
|
|
|
# Status : Unknown, Use with caution! |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
package main; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our $app; |
16
|
|
|
|
|
|
|
our $cfg; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
package EB; |
19
|
|
|
|
|
|
|
|
20
|
6
|
|
|
6
|
|
309
|
use strict; |
|
6
|
|
|
|
|
6
|
|
|
6
|
|
|
|
|
134
|
|
21
|
6
|
|
|
6
|
|
21
|
use base qw(Exporter); |
|
6
|
|
|
|
|
7
|
|
|
6
|
|
|
|
|
553
|
|
22
|
|
|
|
|
|
|
|
23
|
6
|
|
|
6
|
|
1707
|
use EekBoek; |
|
6
|
|
|
|
|
7
|
|
|
6
|
|
|
|
|
2507
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
our @EXPORT; |
26
|
|
|
|
|
|
|
our @EXPORT_OK; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# Establish location of our run-time resources. |
29
|
|
|
|
|
|
|
my $lib; |
30
|
|
|
|
|
|
|
sub libfile { |
31
|
6
|
|
|
6
|
0
|
8
|
my ($f) = @_; |
32
|
|
|
|
|
|
|
|
33
|
6
|
50
|
|
|
|
18
|
unless ( $lib ) { |
34
|
|
|
|
|
|
|
# Cava. |
35
|
6
|
50
|
|
|
|
13
|
if ( $Cava::Packager::PACKAGED ) { |
36
|
0
|
|
|
|
|
0
|
return Cava::Packager::GetResourcePath()."/$f"; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
else { |
39
|
6
|
|
|
|
|
13
|
$lib = $INC{"EB.pm"}; |
40
|
6
|
|
|
|
|
30
|
$lib =~ s/EB\.pm$//; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
} |
43
|
6
|
|
|
|
|
23
|
$lib."EB/res/$f"; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub findlib { |
47
|
28
|
|
|
28
|
0
|
88097
|
my ($file, $section) = @_; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# The two-argument form supports locale-dependent paths. |
50
|
28
|
100
|
66
|
|
|
121
|
if ( $section && $cfg ) { |
|
|
50
|
|
|
|
|
|
51
|
6
|
|
|
|
|
22
|
my $lang = $cfg->val( qw( locale lang ), "" ); |
52
|
6
|
50
|
|
|
|
18
|
if ( $lang =~ /\./ ) { |
53
|
0
|
|
|
|
|
0
|
my $found = findlib( "$section/$lang/$file" ); |
54
|
0
|
0
|
|
|
|
0
|
return $found if $found; |
55
|
0
|
|
|
|
|
0
|
$lang =~ s/\..*//; # strip .utf8 |
56
|
|
|
|
|
|
|
} |
57
|
6
|
50
|
|
|
|
16
|
if ( $lang =~ /_/ ) { |
58
|
6
|
|
|
|
|
19
|
my $found = findlib( "$section/$lang/$file" ); |
59
|
6
|
50
|
|
|
|
18
|
return $found if $found; |
60
|
6
|
|
|
|
|
30
|
$lang =~ s/_.*//; # strip _US |
61
|
|
|
|
|
|
|
} |
62
|
6
|
50
|
|
|
|
15
|
if ( $lang ) { |
63
|
6
|
|
|
|
|
15
|
my $found = findlib( "$section/$lang/$file" ); |
64
|
6
|
50
|
|
|
|
20
|
return $found if $found; |
65
|
|
|
|
|
|
|
} |
66
|
0
|
|
|
|
|
0
|
return undef; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
elsif ( $section ) { |
69
|
0
|
|
|
|
|
0
|
$file = "$section/$file"; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
# Cava. |
73
|
22
|
50
|
|
|
|
40
|
if ( $Cava::Packager::PACKAGED ) { |
74
|
0
|
|
|
|
|
0
|
my $found = Cava::Packager::GetUserFile($file); |
75
|
0
|
0
|
|
|
|
0
|
return $found if -e $found; |
76
|
0
|
|
|
|
|
0
|
$found = Cava::Packager::GetResource($file); |
77
|
0
|
0
|
|
|
|
0
|
return $found if -e $found; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
22
|
|
|
|
|
34
|
foreach ( @INC ) { |
81
|
126
|
100
|
|
|
|
1269
|
return "$_/EB/user/$file" if -e "$_/EB/user/$file"; |
82
|
123
|
100
|
|
|
|
938
|
return "$_/EB/res/$file" if -e "$_/EB/res/$file"; |
83
|
122
|
100
|
|
|
|
985
|
return "$_/EB/$file" if -e "$_/EB/$file"; |
84
|
|
|
|
|
|
|
} |
85
|
6
|
|
|
|
|
14
|
undef; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
6
|
|
|
6
|
|
2810
|
use lib ( grep { defined } findlib("CPAN") ); |
|
6
|
|
|
|
|
2857
|
|
|
6
|
|
|
|
|
14
|
|
|
6
|
|
|
|
|
38
|
|
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
# Some standard modules (locale-free). |
91
|
6
|
|
|
6
|
|
2529
|
use EB::Globals; |
|
6
|
|
|
|
|
9
|
|
|
6
|
|
|
|
|
756
|
|
92
|
6
|
|
|
6
|
|
30
|
use Carp; |
|
6
|
|
|
|
|
7
|
|
|
6
|
|
|
|
|
299
|
|
93
|
6
|
|
|
6
|
|
2355
|
use Data::Dumper; |
|
6
|
|
|
|
|
28243
|
|
|
6
|
|
|
|
|
294
|
|
94
|
6
|
|
|
6
|
|
2143
|
use Carp::Assert; |
|
6
|
|
|
|
|
9
|
|
|
6
|
|
|
|
|
32
|
|
95
|
6
|
|
|
6
|
|
1948
|
use EB::Utils; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
3121
|
|
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
# Export our and the imported globals. |
98
|
|
|
|
|
|
|
@EXPORT = ( @EB::Globals::EXPORT, |
99
|
|
|
|
|
|
|
@EB::Utils::EXPORT, |
100
|
|
|
|
|
|
|
"_T", # @EB::Locale::EXPORT, |
101
|
|
|
|
|
|
|
qw(carp croak), # Carp |
102
|
|
|
|
|
|
|
qw(Dumper), # Data::Dumper |
103
|
|
|
|
|
|
|
qw(findlib libfile), # |
104
|
|
|
|
|
|
|
qw(assert affirm), # Carp::Assert |
105
|
|
|
|
|
|
|
); |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
our $ident; |
108
|
|
|
|
|
|
|
our $imsg; |
109
|
|
|
|
|
|
|
my $imsg_saved; |
110
|
|
|
|
|
|
|
our $url = "http://www.eekboek.nl"; |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
sub __init__ { |
113
|
6
|
|
50
|
6
|
|
30
|
$imsg_saved = $imsg || ""; |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
# The CLI and GUI use different EB::Locale modules. |
116
|
6
|
50
|
33
|
|
|
33
|
if ( $app || $Cava::Packager::PACKAGED && !Cava::Packager::IsLinux() ) { |
|
|
|
33
|
|
|
|
|
117
|
|
|
|
|
|
|
# We do not have a good gettext for Windows, so use Wx. |
118
|
|
|
|
|
|
|
# It's packaged anyway. |
119
|
0
|
|
|
|
|
0
|
require EB::Wx::Locale; # provides EB::Locale, really |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
else { |
122
|
6
|
|
|
|
|
1959
|
require EB::Locale; |
123
|
|
|
|
|
|
|
} |
124
|
6
|
|
|
|
|
157
|
EB::Locale::->import; |
125
|
6
|
|
|
|
|
27
|
EB::Locale->set_language($ENV{LANG}); |
126
|
|
|
|
|
|
|
|
127
|
6
|
|
|
|
|
17
|
my $year = 2005; |
128
|
6
|
|
|
|
|
114
|
my $thisyear = (localtime(time))[5] + 1900; |
129
|
6
|
50
|
|
|
|
36
|
$year .= "-$thisyear" unless $year == $thisyear; |
130
|
6
|
|
|
|
|
46
|
$ident = __x("{name} {version}", |
131
|
|
|
|
|
|
|
name => $EekBoek::PACKAGE, |
132
|
|
|
|
|
|
|
version => $EekBoek::VERSION); |
133
|
6
|
|
|
|
|
12
|
my @locextra; |
134
|
6
|
50
|
|
|
|
18
|
push(@locextra, _T("Nederlands")) if $EB::Locale::LOCALISER; |
135
|
6
|
50
|
|
|
|
43
|
$imsg = __x("{ident}{extra}{locale} -- Copyright {year} Squirrel Consultancy", |
|
|
50
|
|
|
|
|
|
136
|
|
|
|
|
|
|
ident => $ident, |
137
|
|
|
|
|
|
|
extra => ($app ? " Wx" : ""), |
138
|
|
|
|
|
|
|
locale => (@locextra ? " (".join(", ", @locextra).")" : ""), |
139
|
|
|
|
|
|
|
year => $year); |
140
|
6
|
50
|
33
|
|
|
105
|
if ( $imsg ne $imsg_saved |
|
|
|
33
|
|
|
|
|
141
|
|
|
|
|
|
|
&& !( @ARGV && $ARGV[0] =~ /-(P|-?printconfig)$/ ) |
142
|
|
|
|
|
|
|
) { |
143
|
6
|
|
|
|
|
614
|
warn($imsg, "\n"); |
144
|
|
|
|
|
|
|
} |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
eval { |
147
|
0
|
|
|
|
|
0
|
require Win32; |
148
|
0
|
|
|
|
|
0
|
my @a = Win32::GetOSVersion(); |
149
|
0
|
|
|
|
|
0
|
my ($id, $major) = @a[4,1]; |
150
|
0
|
0
|
|
|
|
0
|
die unless defined $id; |
151
|
0
|
|
|
|
|
0
|
warn(_T("EekBoek is VRIJE software, ontwikkeld om vrij over uw eigen gegevens te kunnen beschikken.")."\n"); |
152
|
0
|
|
|
|
|
0
|
warn(_T("Met uw keuze voor het Microsoft Windows besturingssysteem geeft u echter alle vrijheden weer uit handen. Dat is erg triest.")."\n"); |
153
|
6
|
50
|
33
|
|
|
82
|
} unless $imsg_saved eq $imsg || $ENV{AUTOMATED_TESTING}; |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
} |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
sub app_init { |
158
|
6
|
|
|
6
|
0
|
237310
|
shift; # 'EB' |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
# Load a config file. |
161
|
6
|
|
|
|
|
1572
|
require EB::Config; |
162
|
6
|
|
|
|
|
12
|
undef $::cfg; |
163
|
6
|
|
|
|
|
35
|
EB::Config->init_config( @_ ); |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
# Main initialisation. |
166
|
6
|
|
|
|
|
13
|
__init__(); |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
# Initialise locale-dependent formats. |
169
|
6
|
|
|
|
|
1418
|
require EB::Format; |
170
|
6
|
|
|
|
|
33
|
EB::Format->init_formats(); |
171
|
|
|
|
|
|
|
|
172
|
6
|
|
|
|
|
12
|
return $::cfg; # until we've got something better |
173
|
|
|
|
|
|
|
} |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
sub EB::Config::Handler::connect_db { |
176
|
|
|
|
|
|
|
# Connect to the data base. |
177
|
0
|
|
|
0
|
|
|
require EB::DB; |
178
|
0
|
|
|
|
|
|
EB::DB::->connect; |
179
|
|
|
|
|
|
|
} |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
1; |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
__END__ |