Debian Codegraph @

README

raw
1 NAME
2 Convert::BinHex - extract data from Macintosh BinHex files
3
4 *ALPHA WARNING: this code is currently in its Alpha release. Things may
5 change drastically until the interface is hammered out: if you have
6 suggestions or objections, please speak up now!*
7
8 SYNOPSIS
9 Simple functions:
10
11 use Convert::BinHex qw(binhex_crc macbinary_crc);
12
13 # Compute HQX7-style CRC for data, pumping in old CRC if desired:
14 $crc = binhex_crc($data, $crc);
15
16 # Compute the MacBinary-II-style CRC for the data:
17 $crc = macbinary_crc($data, $crc);
18
19
20 Hex to bin, low-level interface. Conversion is actually done via an
21 object (the section on "Convert::BinHex::Hex2Bin") which keeps internal
22 conversion state:
23
24 # Create and use a "translator" object:
25 my $H2B = Convert::BinHex->hex2bin; # get a converter object
26 while (<STDIN>) {
27 print $STDOUT $H2B->next($_); # convert some more input
28 }
29 print $STDOUT $H2B->done; # no more input: finish up
30
31
32 Hex to bin, OO interface. The following operations *must* be done in the
33 order shown!
34
35 # Read data in piecemeal:
36 $HQX = Convert::BinHex->open(FH=>\*STDIN) || die "open: $!";
37 $HQX->read_header; # read header info
38 @data = $HQX->read_data; # read in all the data
39 @rsrc = $HQX->read_resource; # read in all the resource
40
41
42 Bin to hex, low-level interface. Conversion is actually done via an
43 object (the section on "Convert::BinHex::Bin2Hex") which keeps internal
44 conversion state:
45
46 # Create and use a "translator" object:
47 my $B2H = Convert::BinHex->bin2hex; # get a converter object
48 while (<STDIN>) {
49 print $STDOUT $B2H->next($_); # convert some more input
50 }
51 print $STDOUT $B2H->done; # no more input: finish up
52
53
54 Bin to hex, file interface. Yes, you can convert *to* BinHex as well as
55 from it!
56
57 # Create new, empty object:
58 my $HQX = Convert::BinHex->new;
59
60 # Set header attributes:
61 $HQX->filename("logo.gif");
62 $HQX->type("GIFA");
63 $HQX->creator("CNVS");
64
65 # Give it the data and resource forks (either can be absent):
66 $HQX->data(Path => "/path/to/data"); # here, data is on disk
67 $HQX->resource(Data => $resourcefork); # here, resource is in core
68
69 # Output as a BinHex stream, complete with leading comment:
70 $HQX->encode(\*STDOUT);
71
72
73 PLANNED!!!! Bin to hex, "CAP" interface. *Thanks to Ken Lunde for
74 suggesting this*.
75
76 # Create new, empty object from CAP tree:
77 my $HQX = Convert::BinHex->from_cap("/path/to/root/file");
78 $HQX->encode(\*STDOUT);
79
80
81 DESCRIPTION
82 BinHex is a format used by Macintosh for transporting Mac files safely
83 through electronic mail, as short-lined, 7-bit, semi-compressed data
84 streams. Ths module provides a means of converting those data streams
85 back into into binary data.
86