| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
#include "EXTERN.h" |
|
2
|
|
|
|
|
|
|
#include "perl.h" |
|
3
|
|
|
|
|
|
|
#include "XSUB.h" |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
#include "cruncher.h" |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
MODULE = Archive::ByteBoozer PACKAGE = Archive::ByteBoozer |
|
8
|
|
|
|
|
|
|
PROTOTYPES: ENABLE |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# my $source = bb_source($data, $size); |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
File* |
|
13
|
|
|
|
|
|
|
bb_source(data, size) |
|
14
|
|
|
|
|
|
|
unsigned char *data |
|
15
|
|
|
|
|
|
|
size_t size |
|
16
|
|
|
|
|
|
|
CODE: |
|
17
|
|
|
|
|
|
|
File *source; |
|
18
|
17
|
|
|
|
|
|
Newxz(source, 1, File); |
|
19
|
17
|
50
|
|
|
|
|
if (source == NULL) |
|
20
|
0
|
|
|
|
|
|
XSRETURN_UNDEF; |
|
21
|
17
|
|
|
|
|
|
source->size = size; |
|
22
|
17
|
|
|
|
|
|
source->data = (byte *)data; |
|
23
|
17
|
|
|
|
|
|
RETVAL = source; |
|
24
|
|
|
|
|
|
|
OUTPUT: |
|
25
|
|
|
|
|
|
|
RETVAL |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# my $target = bb_crunch($source, $start_address); |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
File* |
|
30
|
|
|
|
|
|
|
bb_crunch(source, start_address) |
|
31
|
|
|
|
|
|
|
File *source |
|
32
|
|
|
|
|
|
|
unsigned int start_address |
|
33
|
|
|
|
|
|
|
CODE: |
|
34
|
|
|
|
|
|
|
File *target; |
|
35
|
17
|
|
|
|
|
|
Newxz(target, 1, File); |
|
36
|
|
|
|
|
|
|
|
|
37
|
17
|
|
|
|
|
|
decruncherType theDecrType = noDecr; |
|
38
|
17
|
100
|
|
|
|
|
if (start_address > 0) |
|
39
|
1
|
|
|
|
|
|
theDecrType = normalDecr; |
|
40
|
|
|
|
|
|
|
|
|
41
|
17
|
|
|
|
|
|
_bool isRelocated = _false; |
|
42
|
|
|
|
|
|
|
|
|
43
|
17
|
50
|
|
|
|
|
if (target == NULL) |
|
44
|
0
|
|
|
|
|
|
XSRETURN_UNDEF; |
|
45
|
17
|
100
|
|
|
|
|
if (!crunch(source, target, start_address, theDecrType, isRelocated)) |
|
46
|
1
|
|
|
|
|
|
XSRETURN_UNDEF; |
|
47
|
16
|
|
|
|
|
|
RETVAL = target; |
|
48
|
|
|
|
|
|
|
OUTPUT: |
|
49
|
|
|
|
|
|
|
RETVAL |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
# my $data = bb_data($file); |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
void |
|
54
|
|
|
|
|
|
|
bb_data(file) |
|
55
|
|
|
|
|
|
|
File *file |
|
56
|
|
|
|
|
|
|
PPCODE: |
|
57
|
|
|
|
|
|
|
# Push string (PV) with data on the stack and mortalize it: |
|
58
|
16
|
|
|
|
|
|
SV *fileData = sv_2mortal(newSVpv((const char *)file->data, file->size)); |
|
59
|
16
|
50
|
|
|
|
|
XPUSHs(fileData); |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
# my $size = bb_size($file); |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
void |
|
64
|
|
|
|
|
|
|
bb_size(file) |
|
65
|
|
|
|
|
|
|
File *file |
|
66
|
|
|
|
|
|
|
PPCODE: |
|
67
|
|
|
|
|
|
|
# Push unsigned integer (UV) with size on the stack and mortalize it: |
|
68
|
0
|
|
|
|
|
|
SV *fileSize = sv_2mortal(newSVuv(file->size)); |
|
69
|
0
|
0
|
|
|
|
|
XPUSHs(fileSize); |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
# bb_free($source, $target); |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
void |
|
74
|
|
|
|
|
|
|
bb_free(source, target) |
|
75
|
|
|
|
|
|
|
File *source |
|
76
|
|
|
|
|
|
|
File *target |
|
77
|
|
|
|
|
|
|
CODE: |
|
78
|
16
|
|
|
|
|
|
Safefree(source); |
|
79
|
16
|
|
|
|
|
|
Safefree(target); |
|
80
|
16
|
|
|
|
|
|
XSRETURN_UNDEF; |