line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!perl -w |
2
|
|
|
|
|
|
|
package Mac::Apps::MacPGP; |
3
|
|
|
|
|
|
|
require 5.004; |
4
|
1
|
|
|
1
|
|
1785
|
use vars qw($VERSION $be @ISA @EXPORT); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
96
|
|
5
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
56
|
|
6
|
1
|
|
|
1
|
|
6
|
use Exporter; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
47
|
|
7
|
1
|
|
|
1
|
|
7
|
use Carp; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
87
|
|
8
|
1
|
|
|
1
|
|
1821
|
use Mac::AppleEvents; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use Mac::Apps::Launch; |
10
|
|
|
|
|
|
|
@ISA = qw(Exporter); |
11
|
|
|
|
|
|
|
@EXPORT = (); |
12
|
|
|
|
|
|
|
$VERSION = sprintf("%d.%02d", q$Revision: 1.20 $ =~ /(\d+)\.(\d+)/); |
13
|
|
|
|
|
|
|
$be = ''; |
14
|
|
|
|
|
|
|
#================================================================= |
15
|
|
|
|
|
|
|
# Stuff |
16
|
|
|
|
|
|
|
#================================================================= |
17
|
|
|
|
|
|
|
sub new { |
18
|
|
|
|
|
|
|
my $self = shift; |
19
|
|
|
|
|
|
|
&_MpgpLaunchApp; |
20
|
|
|
|
|
|
|
return bless{}, $self; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
#----------------------------------------------------------------- |
23
|
|
|
|
|
|
|
sub DESTROY { |
24
|
|
|
|
|
|
|
my $self = shift; |
25
|
|
|
|
|
|
|
&_MpgpFrontApp($self->{MpgpMainApp}) if ($self->{MpgpSwitchApps} && $self->{MpgpSwitchApps} == 1 && $self->{MpgpMainApp}); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
#----------------------------------------------------------------- |
28
|
|
|
|
|
|
|
sub getresults { |
29
|
|
|
|
|
|
|
my($self,$res) = @_; |
30
|
|
|
|
|
|
|
$res = 'result' if (!$res); |
31
|
|
|
|
|
|
|
return $self->{results}->{$res}; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
#----------------------------------------------------------------- |
34
|
|
|
|
|
|
|
sub getresultsall { |
35
|
|
|
|
|
|
|
my($self) = shift; |
36
|
|
|
|
|
|
|
my($results) = $self->{results}; |
37
|
|
|
|
|
|
|
return %{$results}; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
#----------------------------------------------------------------- |
40
|
|
|
|
|
|
|
sub switchapp { |
41
|
|
|
|
|
|
|
my($self,$do,$app) = @_; |
42
|
|
|
|
|
|
|
if (defined $do) { |
43
|
|
|
|
|
|
|
$self->{MpgpSwitchApps} = $do; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
if ($app) { |
46
|
|
|
|
|
|
|
$self->{MpgpMainApp} = $app; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
&_MpgpFrontApp('MPGP') if ($self->{MpgpSwitchApps} == 1); |
49
|
|
|
|
|
|
|
return 1; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
#----------------------------------------------------------------- |
52
|
|
|
|
|
|
|
sub quitpgp { |
53
|
|
|
|
|
|
|
my($be) = AEBuildAppleEvent('aevt','quit',typeApplSignature,'MPGP',0,0,'') || croak $^E; |
54
|
|
|
|
|
|
|
AESend($be, kAEWaitReply) || croak $^E; |
55
|
|
|
|
|
|
|
AEDisposeDesc $be; |
56
|
|
|
|
|
|
|
return 1; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
#================================================================= |
59
|
|
|
|
|
|
|
# Main subroutines |
60
|
|
|
|
|
|
|
#================================================================= |
61
|
|
|
|
|
|
|
sub encrypt { |
62
|
|
|
|
|
|
|
my(@p) = @_; |
63
|
|
|
|
|
|
|
my($ev) = &_checkType($p[1],'encr','ncrd','cncr'); |
64
|
|
|
|
|
|
|
$be = &_MpgpAeBuild($ev); |
65
|
|
|
|
|
|
|
my($ae); |
66
|
|
|
|
|
|
|
if (scalar(@{$p[2]})) |
67
|
|
|
|
|
|
|
{&_dObjData($p[2],'a') } |
68
|
|
|
|
|
|
|
elsif ($p[2]) |
69
|
|
|
|
|
|
|
{&_dObjData($p[2],'t') } |
70
|
|
|
|
|
|
|
else {&_MpgpError('m','dObj') unless ($ev eq 'ncrd')} |
71
|
|
|
|
|
|
|
if ($ev ne 'cncr') { |
72
|
|
|
|
|
|
|
if (scalar(@{$p[3]})) |
73
|
|
|
|
|
|
|
{&_recvData($p[3],'a') } |
74
|
|
|
|
|
|
|
elsif ($p[3]) |
75
|
|
|
|
|
|
|
{&_recvData($p[3],'t') } else {&_MpgpError('m','recv')}} |
76
|
|
|
|
|
|
|
if ($p[3] && $ev eq 'cncr') |
77
|
|
|
|
|
|
|
{&_cpasData($p[3]) } |
78
|
|
|
|
|
|
|
if ($p[4]) {&_passData($p[4]) } |
79
|
|
|
|
|
|
|
if ($p[5]) {&_usidData($p[5]) } |
80
|
|
|
|
|
|
|
if ($p[6]) {&_signData($p[6],'e') } |
81
|
|
|
|
|
|
|
if ($p[7]) {&_readData($p[7]) } |
82
|
|
|
|
|
|
|
if ($p[8]) {&_outpData($p[8]) } else {&_outpData('asci')} |
83
|
|
|
|
|
|
|
if (defined $p[9]) {&_latiData($p[9]) } |
84
|
|
|
|
|
|
|
if (defined $p[10]) {&_wrapData($p[10]) } |
85
|
|
|
|
|
|
|
if (defined $p[11]) {&_alnsData($p[11]) } |
86
|
|
|
|
|
|
|
if (defined $p[12] && (AEGetParamDesc($be,'wrap') !=0)) |
87
|
|
|
|
|
|
|
{&_tabxData($p[12]) } |
88
|
|
|
|
|
|
|
if ($p[13]) {&_mdalData($p[13]) } |
89
|
|
|
|
|
|
|
if ($p[14] && $ev ne 'ncrd') |
90
|
|
|
|
|
|
|
{&_wsrcData($p[14]) } |
91
|
|
|
|
|
|
|
if ($p[15] && $ev eq 'cncr') |
92
|
|
|
|
|
|
|
{&_coptData($p[15]) } |
93
|
|
|
|
|
|
|
&_MpgpError('s','') |
94
|
|
|
|
|
|
|
if ((AEGetParamDesc($be,'sign') eq 'incl') && |
95
|
|
|
|
|
|
|
(AEGetParamDesc($be,'copt') =~ /sdf/)); |
96
|
|
|
|
|
|
|
return &_MpgpAeProcess($p[0]); |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
#----------------------------------------------------------------- |
99
|
|
|
|
|
|
|
sub decrypt { |
100
|
|
|
|
|
|
|
my(@p) = @_; |
101
|
|
|
|
|
|
|
my($ev) = &_checkType($p[1],'decr','dcrd'); |
102
|
|
|
|
|
|
|
$be = &_MpgpAeBuild($ev); |
103
|
|
|
|
|
|
|
if (scalar(@{$p[2]})) |
104
|
|
|
|
|
|
|
{&_dObjData($p[2],'a') } |
105
|
|
|
|
|
|
|
elsif ($p[2]) |
106
|
|
|
|
|
|
|
{&_dObjData($p[2],'t') } |
107
|
|
|
|
|
|
|
else {&_MpgpError('m','dObj') unless ($ev eq 'dcrd')} |
108
|
|
|
|
|
|
|
if ($p[3]) {&_passData($p[3]) } |
109
|
|
|
|
|
|
|
if (defined $p[4]) {&_screData($p[4]) } |
110
|
|
|
|
|
|
|
if (defined $p[5]) {&_nsigData($p[5]) } |
111
|
|
|
|
|
|
|
if ($p[6]) {&_apl2Data($p[6]) } |
112
|
|
|
|
|
|
|
if ($p[7] && $ev eq 'decr') |
113
|
|
|
|
|
|
|
{&_recvData($p[7],'t') } |
114
|
|
|
|
|
|
|
return &_MpgpAeProcess($p[0]); |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
#----------------------------------------------------------------- |
117
|
|
|
|
|
|
|
sub sign { |
118
|
|
|
|
|
|
|
my(@p) = @_; |
119
|
|
|
|
|
|
|
my($ev) = &_checkType($p[1],'sign','sigd'); |
120
|
|
|
|
|
|
|
$be = &_MpgpAeBuild($ev); |
121
|
|
|
|
|
|
|
my($ae); |
122
|
|
|
|
|
|
|
if (scalar(@{$p[2]})) |
123
|
|
|
|
|
|
|
{&_dObjData($p[2],'a') } |
124
|
|
|
|
|
|
|
elsif ($p[2]) |
125
|
|
|
|
|
|
|
{&_dObjData($p[2],'t') } |
126
|
|
|
|
|
|
|
else {&_MpgpError('m','dObj') unless ($ev eq 'sigd')} |
127
|
|
|
|
|
|
|
if ($p[3]) {&_passData($p[3]) } |
128
|
|
|
|
|
|
|
if ($p[4]) {&_usidData($p[4]) } |
129
|
|
|
|
|
|
|
if ($p[5]) {&_signData($p[5],'s') } |
130
|
|
|
|
|
|
|
if ($p[6]) {&_readData($p[6]) } |
131
|
|
|
|
|
|
|
if ($p[7]) {&_outpData($p[7]) } else {&_outpData('asci')} |
132
|
|
|
|
|
|
|
if (defined $p[8]) {&_latiData($p[8]) } |
133
|
|
|
|
|
|
|
if (defined $p[9]) {&_wrapData($p[9]) } |
134
|
|
|
|
|
|
|
if (defined $p[10]) {&_alnsData($p[10]) } |
135
|
|
|
|
|
|
|
if (defined $p[11] && (AEGetParamDesc($be,'wrap') !=0)) |
136
|
|
|
|
|
|
|
{&_tabxData($p[11],$ae) } |
137
|
|
|
|
|
|
|
if ($p[12]) {&_mdalData($p[12]) } |
138
|
|
|
|
|
|
|
if ($p[13]) {&_stfxData($p[13]) } |
139
|
|
|
|
|
|
|
return &_MpgpAeProcess($p[0]); |
140
|
|
|
|
|
|
|
} |
141
|
|
|
|
|
|
|
#----------------------------------------------------------------- |
142
|
|
|
|
|
|
|
sub asciify { |
143
|
|
|
|
|
|
|
my(@p) = @_; |
144
|
|
|
|
|
|
|
my($ev) = 'asci'; |
145
|
|
|
|
|
|
|
$be = &_MpgpAeBuild($ev); |
146
|
|
|
|
|
|
|
my($ae); |
147
|
|
|
|
|
|
|
if (scalar(@{$p[1]})) |
148
|
|
|
|
|
|
|
{&_dObjData($p[1],'a') } |
149
|
|
|
|
|
|
|
elsif ($p[1]) |
150
|
|
|
|
|
|
|
{&_dObjData($p[1],'t') } else {&_MpgpError('m','dObj')} |
151
|
|
|
|
|
|
|
if ($p[2]) {&_readData($p[2]) } |
152
|
|
|
|
|
|
|
if (defined $p[3]) {&_latiData($p[3]) } |
153
|
|
|
|
|
|
|
if (defined $p[4]) {&_wrapData($p[4]) } |
154
|
|
|
|
|
|
|
if (defined $p[5]) {&_alnsData($p[5]) } |
155
|
|
|
|
|
|
|
if (defined $p[6] && (AEGetParamDesc($be,'wrap') !=0)) |
156
|
|
|
|
|
|
|
{&_tabxData($p[6],$ae) } |
157
|
|
|
|
|
|
|
return &_MpgpAeProcess($p[0]); |
158
|
|
|
|
|
|
|
} |
159
|
|
|
|
|
|
|
#----------------------------------------------------------------- |
160
|
|
|
|
|
|
|
sub execute { |
161
|
|
|
|
|
|
|
my(@p) = @_; |
162
|
|
|
|
|
|
|
my($ev) = 'exec'; |
163
|
|
|
|
|
|
|
$be = &_MpgpAeBuild($ev); |
164
|
|
|
|
|
|
|
my($ae); |
165
|
|
|
|
|
|
|
if ($p[1]) {&_dObjData($p[1],'t') } else {&_MpgpError('m','dObj')} |
166
|
|
|
|
|
|
|
if ($p[2]) {&_passData($p[2]) } |
167
|
|
|
|
|
|
|
if (defined $p[3]) {&_latiData($p[3]) } |
168
|
|
|
|
|
|
|
if (defined $p[4]) {&_wrapData($p[4]) } |
169
|
|
|
|
|
|
|
if (defined $p[5]) {&_alnsData($p[5]) } |
170
|
|
|
|
|
|
|
if (defined $p[6] && (AEGetParamDesc($be,'wrap') !=0)) |
171
|
|
|
|
|
|
|
{&_tabxData($p[6],$ae) } |
172
|
|
|
|
|
|
|
if ($p[7]) {&_mdalData($p[7]) } |
173
|
|
|
|
|
|
|
return &_MpgpAeProcess($p[0]); |
174
|
|
|
|
|
|
|
} |
175
|
|
|
|
|
|
|
#----------------------------------------------------------------- |
176
|
|
|
|
|
|
|
sub keyring { |
177
|
|
|
|
|
|
|
my(@p) = @_; |
178
|
|
|
|
|
|
|
my($ev) = &_checkType($p[1],'selk','ckey','crfy','remv','addk','fing'); |
179
|
|
|
|
|
|
|
$be = &_MpgpAeBuild($ev); |
180
|
|
|
|
|
|
|
if ($p[2]) {&_dObjData($p[2],'t') } else {&_MpgpError('m','dObj')} |
181
|
|
|
|
|
|
|
if ($p[3]) {&_keyrData($p[3]) } |
182
|
|
|
|
|
|
|
if ($p[4] && $ev eq 'crfy') |
183
|
|
|
|
|
|
|
{&_usidData($p[4]) } |
184
|
|
|
|
|
|
|
return &_MpgpAeProcess($p[0]); |
185
|
|
|
|
|
|
|
} |
186
|
|
|
|
|
|
|
#----------------------------------------------------------------- |
187
|
|
|
|
|
|
|
sub extract { |
188
|
|
|
|
|
|
|
my(@p) = @_; |
189
|
|
|
|
|
|
|
my($ev) = 'extr'; |
190
|
|
|
|
|
|
|
$be = &_MpgpAeBuild($ev); |
191
|
|
|
|
|
|
|
if ($p[1]) {&_dObjData($p[1],'t') } else {&_MpgpError('m','dObj')} |
192
|
|
|
|
|
|
|
if ($p[2]) {&_recvData($p[2],'t') } else {&_MpgpError('m','recv')} |
193
|
|
|
|
|
|
|
if ($p[3]) {&_keyrData($p[3]) } |
194
|
|
|
|
|
|
|
if ($p[4]) {&_outpData($p[4]) } else {&_outpData('asci')} |
195
|
|
|
|
|
|
|
return &_MpgpAeProcess($p[0]); |
196
|
|
|
|
|
|
|
} |
197
|
|
|
|
|
|
|
#----------------------------------------------------------------- |
198
|
|
|
|
|
|
|
sub generate { |
199
|
|
|
|
|
|
|
my(@p) = @_; |
200
|
|
|
|
|
|
|
my($ev) = 'gene'; |
201
|
|
|
|
|
|
|
$be = &_MpgpAeBuild($ev); |
202
|
|
|
|
|
|
|
if ($p[1]) {&_dObjData($p[1],'t') } else {&_MpgpError('m','dObj')} |
203
|
|
|
|
|
|
|
if ($p[2]) {&_lengData($p[2]) } |
204
|
|
|
|
|
|
|
if ($p[3]) {&_ebitData($p[3]) } |
205
|
|
|
|
|
|
|
return &_MpgpAeProcess($p[0]); |
206
|
|
|
|
|
|
|
} |
207
|
|
|
|
|
|
|
#----------------------------------------------------------------- |
208
|
|
|
|
|
|
|
sub logfile { |
209
|
|
|
|
|
|
|
my(@p) = @_; |
210
|
|
|
|
|
|
|
my($ev) = 'logf'; |
211
|
|
|
|
|
|
|
$be = &_MpgpAeBuild($ev); |
212
|
|
|
|
|
|
|
my($ae); |
213
|
|
|
|
|
|
|
if ($p[1]) {&_dObjData($p[1],'b') } else {&_MpgpError('m','dObj')} |
214
|
|
|
|
|
|
|
if ($p[2]) {&_recvData($p[2],'t') } |
215
|
|
|
|
|
|
|
return &_MpgpAeProcess($p[0]); |
216
|
|
|
|
|
|
|
} |
217
|
|
|
|
|
|
|
#----------------------------------------------------------------- |
218
|
|
|
|
|
|
|
sub window { |
219
|
|
|
|
|
|
|
my(@p) = @_; |
220
|
|
|
|
|
|
|
my($ev) = 'wind'; |
221
|
|
|
|
|
|
|
$be = &_MpgpAeBuild($ev); |
222
|
|
|
|
|
|
|
my($ae); |
223
|
|
|
|
|
|
|
if ($p[1]) {&_windData($p[1]) } else {&_MpgpError('m','dObj')} |
224
|
|
|
|
|
|
|
return &_MpgpAeProcess($p[0]); |
225
|
|
|
|
|
|
|
} |
226
|
|
|
|
|
|
|
#----------------------------------------------------------------- |
227
|
|
|
|
|
|
|
sub create { |
228
|
|
|
|
|
|
|
my(@p) = @_; |
229
|
|
|
|
|
|
|
my($ev) = 'crea'; |
230
|
|
|
|
|
|
|
$be = &_MpgpAeBuild($ev); |
231
|
|
|
|
|
|
|
my($ae); |
232
|
|
|
|
|
|
|
if ($p[1]) {&_dObjData($p[1],'t') } else {&_MpgpError('m','dObj')} |
233
|
|
|
|
|
|
|
return &_MpgpAeProcess($p[0]); |
234
|
|
|
|
|
|
|
} |
235
|
|
|
|
|
|
|
#----------------------------------------------------------------- |
236
|
|
|
|
|
|
|
sub clip2file { |
237
|
|
|
|
|
|
|
my(@p) = @_; |
238
|
|
|
|
|
|
|
my($ev) = 'sc2f'; |
239
|
|
|
|
|
|
|
$be = &_MpgpAeBuild($ev); |
240
|
|
|
|
|
|
|
my($ae); |
241
|
|
|
|
|
|
|
if ($p[1]) {&_dObjData($p[1],'t') } else {&_MpgpError('m','dObj')} |
242
|
|
|
|
|
|
|
return &_MpgpAeProcess($p[0]); |
243
|
|
|
|
|
|
|
} |
244
|
|
|
|
|
|
|
#----------------------------------------------------------------- |
245
|
|
|
|
|
|
|
sub file2clip { |
246
|
|
|
|
|
|
|
my(@p) = @_; |
247
|
|
|
|
|
|
|
my($ev) = 'f2sc'; |
248
|
|
|
|
|
|
|
$be = &_MpgpAeBuild($ev); |
249
|
|
|
|
|
|
|
my($ae); |
250
|
|
|
|
|
|
|
if ($p[1]) {&_dObjData($p[1],'t') } else {&_MpgpError('m','dObj')} |
251
|
|
|
|
|
|
|
return &_MpgpAeProcess($p[0]); |
252
|
|
|
|
|
|
|
} |
253
|
|
|
|
|
|
|
#----------------------------------------------------------------- |
254
|
|
|
|
|
|
|
sub checksignresult { |
255
|
|
|
|
|
|
|
my(@p) = @_; |
256
|
|
|
|
|
|
|
my($ev) = 'cksg'; |
257
|
|
|
|
|
|
|
$be = &_MpgpAeBuild($ev); |
258
|
|
|
|
|
|
|
return &_MpgpAeProcess($p[0]); |
259
|
|
|
|
|
|
|
} |
260
|
|
|
|
|
|
|
#----------------------------------------------------------------- |
261
|
|
|
|
|
|
|
sub getlasterror { |
262
|
|
|
|
|
|
|
my(@p) = @_; |
263
|
|
|
|
|
|
|
my($ev) = 'gler'; |
264
|
|
|
|
|
|
|
$be = &_MpgpAeBuild($ev); |
265
|
|
|
|
|
|
|
return &_MpgpAeProcess($p[0]); |
266
|
|
|
|
|
|
|
} |
267
|
|
|
|
|
|
|
#----------------------------------------------------------------- |
268
|
|
|
|
|
|
|
sub getversion { |
269
|
|
|
|
|
|
|
my(@p) = @_; |
270
|
|
|
|
|
|
|
my($ev) = 'gver'; |
271
|
|
|
|
|
|
|
$be = &_MpgpAeBuild($ev); |
272
|
|
|
|
|
|
|
return &_MpgpAeProcess($p[0]); |
273
|
|
|
|
|
|
|
} |
274
|
|
|
|
|
|
|
#================================================================= |
275
|
|
|
|
|
|
|
# Check AE param ids |
276
|
|
|
|
|
|
|
#================================================================= |
277
|
|
|
|
|
|
|
sub _checkType { |
278
|
|
|
|
|
|
|
my($ev,@evs) = @_; |
279
|
|
|
|
|
|
|
return $ev if (&_oneOf('evType',$ev,\@evs)); |
280
|
|
|
|
|
|
|
} |
281
|
|
|
|
|
|
|
#================================================================= |
282
|
|
|
|
|
|
|
# Process data into AE descriptors |
283
|
|
|
|
|
|
|
#================================================================= |
284
|
|
|
|
|
|
|
sub _dObjData { |
285
|
|
|
|
|
|
|
my($data,$type) = @_; |
286
|
|
|
|
|
|
|
if ($type eq 't') { |
287
|
|
|
|
|
|
|
&_MpgpBText($data,'----'); |
288
|
|
|
|
|
|
|
} elsif ($type eq 'a') { |
289
|
|
|
|
|
|
|
&_MpgpBTextArray($data,'----'); |
290
|
|
|
|
|
|
|
} elsif ($type eq 'b') { |
291
|
|
|
|
|
|
|
&_MpgpBBool($data,'----'); |
292
|
|
|
|
|
|
|
} |
293
|
|
|
|
|
|
|
} |
294
|
|
|
|
|
|
|
#----------------------------------------------------------------- |
295
|
|
|
|
|
|
|
sub _recvData { |
296
|
|
|
|
|
|
|
my($data,$type) = @_; |
297
|
|
|
|
|
|
|
if ($type eq 'a') { |
298
|
|
|
|
|
|
|
&_MpgpBTextArray($data,'recv'); |
299
|
|
|
|
|
|
|
} elsif ($type eq 't') { |
300
|
|
|
|
|
|
|
&_MpgpBText($data,'recv'); |
301
|
|
|
|
|
|
|
} |
302
|
|
|
|
|
|
|
} |
303
|
|
|
|
|
|
|
#----------------------------------------------------------------- |
304
|
|
|
|
|
|
|
sub _passData { |
305
|
|
|
|
|
|
|
my($data) = @_; |
306
|
|
|
|
|
|
|
&_MpgpBText($data,'pass'); |
307
|
|
|
|
|
|
|
} |
308
|
|
|
|
|
|
|
#----------------------------------------------------------------- |
309
|
|
|
|
|
|
|
sub _cpasData { |
310
|
|
|
|
|
|
|
my($data) = @_; |
311
|
|
|
|
|
|
|
&_MpgpBText($data,'cpas'); |
312
|
|
|
|
|
|
|
} |
313
|
|
|
|
|
|
|
#----------------------------------------------------------------- |
314
|
|
|
|
|
|
|
sub _usidData { |
315
|
|
|
|
|
|
|
my($data) = @_; |
316
|
|
|
|
|
|
|
&_MpgpBText($data,'usid'); |
317
|
|
|
|
|
|
|
} |
318
|
|
|
|
|
|
|
#----------------------------------------------------------------- |
319
|
|
|
|
|
|
|
sub _apl2Data { |
320
|
|
|
|
|
|
|
my($data) = @_; |
321
|
|
|
|
|
|
|
&_MpgpBText($data,'apl2'); |
322
|
|
|
|
|
|
|
} |
323
|
|
|
|
|
|
|
#----------------------------------------------------------------- |
324
|
|
|
|
|
|
|
sub _keyrData { |
325
|
|
|
|
|
|
|
my($data) = @_; |
326
|
|
|
|
|
|
|
&_MpgpBText($data,'keyr'); |
327
|
|
|
|
|
|
|
} |
328
|
|
|
|
|
|
|
#----------------------------------------------------------------- |
329
|
|
|
|
|
|
|
sub _signData { |
330
|
|
|
|
|
|
|
my($data,$type) = @_; |
331
|
|
|
|
|
|
|
my(@datas); |
332
|
|
|
|
|
|
|
if ($type eq 'e') { |
333
|
|
|
|
|
|
|
@datas = qw(incl sepa omit); |
334
|
|
|
|
|
|
|
} elsif ($type eq 's') { |
335
|
|
|
|
|
|
|
@datas = qw(incl sepa clea); |
336
|
|
|
|
|
|
|
} |
337
|
|
|
|
|
|
|
&_MpgpBKeyw($data,'sign') if (&_oneOf('sign',$data,\@datas)); |
338
|
|
|
|
|
|
|
} |
339
|
|
|
|
|
|
|
#----------------------------------------------------------------- |
340
|
|
|
|
|
|
|
sub _readData { |
341
|
|
|
|
|
|
|
my($data) = @_; |
342
|
|
|
|
|
|
|
my(@datas) = qw(macb text norm); |
343
|
|
|
|
|
|
|
&_MpgpBKeyw($data,'read') if (&_oneOf('read',$data,\@datas)); |
344
|
|
|
|
|
|
|
} |
345
|
|
|
|
|
|
|
#----------------------------------------------------------------- |
346
|
|
|
|
|
|
|
sub _outpData { |
347
|
|
|
|
|
|
|
my($data) = @_; |
348
|
|
|
|
|
|
|
my(@datas) = qw(bina asci); |
349
|
|
|
|
|
|
|
&_MpgpBKeyw($data,'outp') if (&_oneOf('outp',$data,\@datas)); |
350
|
|
|
|
|
|
|
} |
351
|
|
|
|
|
|
|
#----------------------------------------------------------------- |
352
|
|
|
|
|
|
|
sub _windData { |
353
|
|
|
|
|
|
|
my($data) = @_; |
354
|
|
|
|
|
|
|
my(@datas) = qw(show hide); |
355
|
|
|
|
|
|
|
&_MpgpBKeyw($data,'----') if (&_oneOf('wind',$data,\@datas)); |
356
|
|
|
|
|
|
|
} |
357
|
|
|
|
|
|
|
#----------------------------------------------------------------- |
358
|
|
|
|
|
|
|
sub _coptData { |
359
|
|
|
|
|
|
|
my($data) = @_; |
360
|
|
|
|
|
|
|
my(@datas) = qw(sdf sdfb); |
361
|
|
|
|
|
|
|
&_MpgpBKeyw($data,'copt') if (&_oneOf('copt',$data,\@datas)); |
362
|
|
|
|
|
|
|
} |
363
|
|
|
|
|
|
|
#----------------------------------------------------------------- |
364
|
|
|
|
|
|
|
sub _mdalData { |
365
|
|
|
|
|
|
|
my($data) = @_; |
366
|
|
|
|
|
|
|
my(@datas) = qw(MD5 SHA1); |
367
|
|
|
|
|
|
|
&_MpgpBKeyw($data,'mdal') if (&_oneOf('mdal',$data,\@datas)); |
368
|
|
|
|
|
|
|
} |
369
|
|
|
|
|
|
|
#----------------------------------------------------------------- |
370
|
|
|
|
|
|
|
sub _wsrcData { |
371
|
|
|
|
|
|
|
my($data) = @_; |
372
|
|
|
|
|
|
|
&_MpgpBBool($data,'wsrc'); |
373
|
|
|
|
|
|
|
} |
374
|
|
|
|
|
|
|
#----------------------------------------------------------------- |
375
|
|
|
|
|
|
|
sub _latiData { |
376
|
|
|
|
|
|
|
my($data) = @_; |
377
|
|
|
|
|
|
|
&_MpgpBBool($data,'lati'); |
378
|
|
|
|
|
|
|
} |
379
|
|
|
|
|
|
|
#----------------------------------------------------------------- |
380
|
|
|
|
|
|
|
sub _screData { |
381
|
|
|
|
|
|
|
my($data) = @_; |
382
|
|
|
|
|
|
|
&_MpgpBBool($data,'scre'); |
383
|
|
|
|
|
|
|
} |
384
|
|
|
|
|
|
|
#----------------------------------------------------------------- |
385
|
|
|
|
|
|
|
sub _nsigData { |
386
|
|
|
|
|
|
|
my($data) = @_; |
387
|
|
|
|
|
|
|
&_MpgpBBool($data,'nsig'); |
388
|
|
|
|
|
|
|
} |
389
|
|
|
|
|
|
|
#----------------------------------------------------------------- |
390
|
|
|
|
|
|
|
sub _stfxData { |
391
|
|
|
|
|
|
|
my($data) = @_; |
392
|
|
|
|
|
|
|
&_MpgpBBool($data,'stfx'); |
393
|
|
|
|
|
|
|
} |
394
|
|
|
|
|
|
|
#----------------------------------------------------------------- |
395
|
|
|
|
|
|
|
sub _wrapData { |
396
|
|
|
|
|
|
|
my($data) = @_; |
397
|
|
|
|
|
|
|
my(@datas) = qw(30 100); |
398
|
|
|
|
|
|
|
&_MpgpBShort($data,'wrap') if (&_twixtOf('wrap',$data,\@datas)); |
399
|
|
|
|
|
|
|
} |
400
|
|
|
|
|
|
|
#----------------------------------------------------------------- |
401
|
|
|
|
|
|
|
sub _alnsData { |
402
|
|
|
|
|
|
|
my($data) = @_; |
403
|
|
|
|
|
|
|
my(@datas) = qw(0 1E+1000); |
404
|
|
|
|
|
|
|
&_MpgpBShort($data,'alns') if (&_twixtOf('alns',$data,\@datas)); |
405
|
|
|
|
|
|
|
} |
406
|
|
|
|
|
|
|
#----------------------------------------------------------------- |
407
|
|
|
|
|
|
|
sub _tabxData { |
408
|
|
|
|
|
|
|
my($data) = @_; |
409
|
|
|
|
|
|
|
my(@datas) = qw(0 9); |
410
|
|
|
|
|
|
|
&_MpgpBShort($data,'tabx') if (&_twixtOf('tabx',$data,\@datas)); |
411
|
|
|
|
|
|
|
} |
412
|
|
|
|
|
|
|
#----------------------------------------------------------------- |
413
|
|
|
|
|
|
|
sub _ebitData { |
414
|
|
|
|
|
|
|
my($data) = @_; |
415
|
|
|
|
|
|
|
my(@datas) = qw(0 1E+1000); |
416
|
|
|
|
|
|
|
&_MpgpBShort($data,'ebit') if (&_twixtOf('ebit',$data,\@datas)); |
417
|
|
|
|
|
|
|
} |
418
|
|
|
|
|
|
|
#----------------------------------------------------------------- |
419
|
|
|
|
|
|
|
sub _lengData { |
420
|
|
|
|
|
|
|
my($data) = @_; |
421
|
|
|
|
|
|
|
my(@datas); |
422
|
|
|
|
|
|
|
if ($data !~ /\D/) { |
423
|
|
|
|
|
|
|
@datas = qw(384 2048); |
424
|
|
|
|
|
|
|
&_MpgpBShort($data,'kbit') if (&_twixtOf('kbit',$data,\@datas)); |
425
|
|
|
|
|
|
|
} else { |
426
|
|
|
|
|
|
|
@datas = qw(casu comm mili); |
427
|
|
|
|
|
|
|
&_MpgpBKeyw($data,'leng') if (&_oneOf('leng',$data,\@datas)); |
428
|
|
|
|
|
|
|
} |
429
|
|
|
|
|
|
|
} |
430
|
|
|
|
|
|
|
#================================================================= |
431
|
|
|
|
|
|
|
# Error checking of data |
432
|
|
|
|
|
|
|
#================================================================= |
433
|
|
|
|
|
|
|
sub _twixtOf { |
434
|
|
|
|
|
|
|
my($type,$one,$of) = @_; |
435
|
|
|
|
|
|
|
&_MpgpError('d',$type) unless |
436
|
|
|
|
|
|
|
(($one !~ /\D/ && $one >= $$of[0] && $one <= $$of[1]) || ($one == 0)); |
437
|
|
|
|
|
|
|
return 1; |
438
|
|
|
|
|
|
|
} |
439
|
|
|
|
|
|
|
#----------------------------------------------------------------- |
440
|
|
|
|
|
|
|
sub _oneOf { |
441
|
|
|
|
|
|
|
my($type,$one,$of,$yes) = @_; |
442
|
|
|
|
|
|
|
foreach (@{$of}) { |
443
|
|
|
|
|
|
|
$yes = 1 if ($one eq $_); |
444
|
|
|
|
|
|
|
} |
445
|
|
|
|
|
|
|
if (!$yes) { |
446
|
|
|
|
|
|
|
&_MpgpError('t',$type); |
447
|
|
|
|
|
|
|
} |
448
|
|
|
|
|
|
|
return 1; |
449
|
|
|
|
|
|
|
} |
450
|
|
|
|
|
|
|
#================================================================= |
451
|
|
|
|
|
|
|
# Add AE descriptor records to event |
452
|
|
|
|
|
|
|
#================================================================= |
453
|
|
|
|
|
|
|
sub _MpgpBKeyw { |
454
|
|
|
|
|
|
|
my($data,$type) = @_; |
455
|
|
|
|
|
|
|
AEPutParamDesc($be,$type,(AEBuild($data))); |
456
|
|
|
|
|
|
|
} |
457
|
|
|
|
|
|
|
#----------------------------------------------------------------- |
458
|
|
|
|
|
|
|
sub _MpgpBShort { |
459
|
|
|
|
|
|
|
my($data,$type) = @_; |
460
|
|
|
|
|
|
|
AEPutParamDesc($be,$type,(AEBuild($data))); |
461
|
|
|
|
|
|
|
} |
462
|
|
|
|
|
|
|
#----------------------------------------------------------------- |
463
|
|
|
|
|
|
|
sub _MpgpBBool { |
464
|
|
|
|
|
|
|
my($data,$type) = @_; |
465
|
|
|
|
|
|
|
if ($data eq '1') { |
466
|
|
|
|
|
|
|
$data = 'true'; |
467
|
|
|
|
|
|
|
} elsif ($data eq '0') { |
468
|
|
|
|
|
|
|
$data = 'fals'; |
469
|
|
|
|
|
|
|
} else { |
470
|
|
|
|
|
|
|
&_MpgpError('b',$type); |
471
|
|
|
|
|
|
|
} |
472
|
|
|
|
|
|
|
AEPutParamDesc($be,$type,(AEBuild($data))); |
473
|
|
|
|
|
|
|
} |
474
|
|
|
|
|
|
|
#----------------------------------------------------------------- |
475
|
|
|
|
|
|
|
sub _MpgpBText { |
476
|
|
|
|
|
|
|
my($data,$type) = @_; |
477
|
|
|
|
|
|
|
AEPutParamDesc($be,$type,(AEBuild('TEXT(@)',$data))); |
478
|
|
|
|
|
|
|
} |
479
|
|
|
|
|
|
|
#----------------------------------------------------------------- |
480
|
|
|
|
|
|
|
sub _MpgpBTextArray { |
481
|
|
|
|
|
|
|
my($data,$type) = @_; |
482
|
|
|
|
|
|
|
my($ta) = '['; |
483
|
|
|
|
|
|
|
foreach (@{$data}) { |
484
|
|
|
|
|
|
|
$ta .= 'TEXT(@),'; |
485
|
|
|
|
|
|
|
} |
486
|
|
|
|
|
|
|
$ta =~ s/,$/]/; |
487
|
|
|
|
|
|
|
AEPutParamDesc($be,$type,(AEBuild($ta,@{$data}))); |
488
|
|
|
|
|
|
|
} |
489
|
|
|
|
|
|
|
#================================================================= |
490
|
|
|
|
|
|
|
# Main processing |
491
|
|
|
|
|
|
|
#================================================================= |
492
|
|
|
|
|
|
|
sub _MpgpLaunchApp { |
493
|
|
|
|
|
|
|
my($app) = shift || 'MPGP'; |
494
|
|
|
|
|
|
|
LaunchApps([$app],0); |
495
|
|
|
|
|
|
|
} |
496
|
|
|
|
|
|
|
#----------------------------------------------------------------- |
497
|
|
|
|
|
|
|
sub _MpgpFrontApp { |
498
|
|
|
|
|
|
|
my($app) = @_; |
499
|
|
|
|
|
|
|
LaunchApps([$app],1); |
500
|
|
|
|
|
|
|
} |
501
|
|
|
|
|
|
|
#----------------------------------------------------------------- |
502
|
|
|
|
|
|
|
sub _MpgpError { |
503
|
|
|
|
|
|
|
my($type,$info) = @_; |
504
|
|
|
|
|
|
|
if ($type eq 'm') { |
505
|
|
|
|
|
|
|
croak "Missing required element of type: $info.\n"; |
506
|
|
|
|
|
|
|
} elsif ($type eq 'd') { |
507
|
|
|
|
|
|
|
croak "Value of $info does not fall within acceptable bounds.\n"; |
508
|
|
|
|
|
|
|
} elsif ($type eq 't') { |
509
|
|
|
|
|
|
|
croak "Value of $info does not match acceptable parameters.\n"; |
510
|
|
|
|
|
|
|
} elsif ($type eq 'b') { |
511
|
|
|
|
|
|
|
croak "Value of $info must be either 1 or 0 (boolean).\n"; |
512
|
|
|
|
|
|
|
} elsif ($type eq 's') { |
513
|
|
|
|
|
|
|
croak "Cannot include signature in self-decrypting files.\n"; |
514
|
|
|
|
|
|
|
} else { |
515
|
|
|
|
|
|
|
croak "Unknown error ($type, $info).\n"; |
516
|
|
|
|
|
|
|
} |
517
|
|
|
|
|
|
|
} |
518
|
|
|
|
|
|
|
#----------------------------------------------------------------- |
519
|
|
|
|
|
|
|
sub _MpgpAeBuild { |
520
|
|
|
|
|
|
|
my($ev,$st) = @_; |
521
|
|
|
|
|
|
|
$st = 'MPGP' if (!$st); |
522
|
|
|
|
|
|
|
my($be) = AEBuildAppleEvent($st,$ev,typeApplSignature,'MPGP',0,0,'') || croak $^E; |
523
|
|
|
|
|
|
|
return $be; |
524
|
|
|
|
|
|
|
} |
525
|
|
|
|
|
|
|
#----------------------------------------------------------------- |
526
|
|
|
|
|
|
|
sub _MpgpAePrint { |
527
|
|
|
|
|
|
|
my($self,$rp) = @_; |
528
|
|
|
|
|
|
|
my(@ar,%ar,$ar,$at); |
529
|
|
|
|
|
|
|
@ar = ('----','errn','errs','outp'); |
530
|
|
|
|
|
|
|
foreach $ar(@ar) { |
531
|
|
|
|
|
|
|
if ($at = AEGetParamDesc($rp,$ar)) { |
532
|
|
|
|
|
|
|
$ar{$ar} = AEPrint($at); |
533
|
|
|
|
|
|
|
} |
534
|
|
|
|
|
|
|
} |
535
|
|
|
|
|
|
|
if (exists $ar{'----'}) { |
536
|
|
|
|
|
|
|
$ar{'----'} =~ s/^Ò(.*)Ó$/$1/s; |
537
|
|
|
|
|
|
|
$ar{'result'} = $ar{'----'}; |
538
|
|
|
|
|
|
|
} |
539
|
|
|
|
|
|
|
if ($ar{'errn'}) { |
540
|
|
|
|
|
|
|
$ar{'errs'} =~ s/^Ò(.*)Ó$/$1/ if (exists $ar{'errs'}); |
541
|
|
|
|
|
|
|
carp "MacPGP error $ar{'errn'}: $ar{'errs'}\n"; |
542
|
|
|
|
|
|
|
} |
543
|
|
|
|
|
|
|
if (exists $ar{'outp'}) { |
544
|
|
|
|
|
|
|
$ar{'outp'} =~ s/^\[alis\(\Ç(.*?)\È\)\]/$1/; |
545
|
|
|
|
|
|
|
# $ar{'outp'} = (pack("H*",$ar{'outp'})); |
546
|
|
|
|
|
|
|
} |
547
|
|
|
|
|
|
|
$self->{results} = \%ar; |
548
|
|
|
|
|
|
|
AEDisposeDesc $rp; |
549
|
|
|
|
|
|
|
return $ar{result}; |
550
|
|
|
|
|
|
|
} |
551
|
|
|
|
|
|
|
#----------------------------------------------------------------- |
552
|
|
|
|
|
|
|
sub _MpgpAeProcess { |
553
|
|
|
|
|
|
|
my($self) = shift; |
554
|
|
|
|
|
|
|
my($rp) = AESend($be, kAEWaitReply) || croak $^E; |
555
|
|
|
|
|
|
|
AEDisposeDesc $be; |
556
|
|
|
|
|
|
|
return &_MpgpAePrint($self,$rp); |
557
|
|
|
|
|
|
|
} |
558
|
|
|
|
|
|
|
#-----------------------------------------------------------------# |
559
|
|
|
|
|
|
|
1; |
560
|
|
|
|
|
|
|
__END__ |