| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# $Id: BSED.pm,v 1.15 2007/07/17 15:26:37 ask Exp $ |
|
2
|
|
|
|
|
|
|
# $Source: /opt/CVS/File-BSED/lib/File/BSED.pm,v $ |
|
3
|
|
|
|
|
|
|
# $Author: ask $ |
|
4
|
|
|
|
|
|
|
# $HeadURL$ |
|
5
|
|
|
|
|
|
|
# $Revision: 1.15 $ |
|
6
|
|
|
|
|
|
|
# $Date: 2007/07/17 15:26:37 $ |
|
7
|
|
|
|
|
|
|
package File::BSED; |
|
8
|
1
|
|
|
1
|
|
6
|
use strict; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
42
|
|
|
9
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
33
|
|
|
10
|
1
|
|
|
1
|
|
28
|
use 5.006006; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
44
|
|
|
11
|
1
|
|
|
1
|
|
5
|
use Exporter; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
55
|
|
|
12
|
1
|
|
|
1
|
|
13
|
use Carp qw(croak); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
64
|
|
|
13
|
1
|
|
|
1
|
|
6
|
use vars qw($VERSION @EXPORT_OK @ISA); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
158
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
$VERSION = 0.67; |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
@EXPORT_OK = qw( |
|
18
|
|
|
|
|
|
|
gbsed |
|
19
|
|
|
|
|
|
|
binary_search_replace |
|
20
|
|
|
|
|
|
|
binary_file_matches |
|
21
|
|
|
|
|
|
|
string_to_hexstring |
|
22
|
|
|
|
|
|
|
); |
|
23
|
|
|
|
|
|
|
|
|
24
|
1
|
|
|
1
|
|
5
|
use base qw(Exporter); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
486
|
|
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
require XSLoader; |
|
27
|
|
|
|
|
|
|
XSLoader::load(__PACKAGE__, $VERSION); |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub binary_search_replace { |
|
30
|
3
|
|
|
3
|
1
|
6
|
my ($args_ref) = @_; |
|
31
|
3
|
100
|
100
|
|
|
314
|
croak 'Argument to File::BSED::binary_search_replace must be hash reference' |
|
32
|
|
|
|
|
|
|
if !ref $args_ref || ref $args_ref ne 'HASH'; |
|
33
|
|
|
|
|
|
|
|
|
34
|
1
|
|
|
|
|
3
|
my $search = $args_ref->{search}; |
|
35
|
1
|
|
|
|
|
2
|
my $replace = $args_ref->{replace}; |
|
36
|
1
|
|
|
|
|
2
|
my $infile = $args_ref->{infile}; |
|
37
|
1
|
|
|
|
|
3
|
my $outfile = $args_ref->{outfile}; |
|
38
|
|
|
|
|
|
|
|
|
39
|
1
|
|
50
|
|
|
7
|
my $min = $args_ref->{minmatch} || 1; |
|
40
|
1
|
|
50
|
|
|
7
|
my $max = $args_ref->{maxmatch} || -1; |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
|
|
43
|
1
|
|
|
|
|
4946
|
return _gbsed($search, $replace, $infile, $outfile, $min, $max); |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub binary_file_matches { |
|
47
|
3
|
|
|
3
|
1
|
76
|
my ($search, $infile) = @_; |
|
48
|
|
|
|
|
|
|
|
|
49
|
3
|
100
|
|
|
|
14
|
return 0 if not $search; |
|
50
|
|
|
|
|
|
|
|
|
51
|
2
|
100
|
|
|
|
264
|
croak 'Missing filename argument to binary_file_matches()' |
|
52
|
|
|
|
|
|
|
if not defined $infile; |
|
53
|
|
|
|
|
|
|
|
|
54
|
1
|
|
|
|
|
2569
|
return _binary_file_matches($search, $infile); |
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub string_to_hexstring { |
|
58
|
2
|
|
|
2
|
1
|
9
|
my ($string) = @_; |
|
59
|
2
|
100
|
|
|
|
9
|
return if not $string; |
|
60
|
|
|
|
|
|
|
|
|
61
|
1
|
|
|
|
|
30
|
return _string_to_hexstring($string); |
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub gbsed { |
|
65
|
3
|
|
|
3
|
1
|
964
|
goto &binary_search_replace; |
|
66
|
|
|
|
|
|
|
} |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub errtostr { |
|
69
|
2
|
|
|
2
|
1
|
18
|
return _errtostr(_gbsed_errno()); |
|
70
|
|
|
|
|
|
|
} |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub errno { |
|
73
|
2
|
|
|
2
|
1
|
34
|
return _gbsed_errno(); |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub warnings { |
|
77
|
0
|
|
|
0
|
1
|
|
return _warnings(); |
|
78
|
|
|
|
|
|
|
} |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
1; |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
__END__ |