(file) Return to chexify.pl CVS log (file) (dir) Up to [RizwankCVS] / group3

 1 rizwank 1.1 #!/usr/bin/perl
 2             # hexify.pl
 3             # Takes a list of filenames on stdin and create a C data array for each one.
 4             # Copyright Dan Kegel 2005
 5             # Licensed under LGPL
 6             
 7             # no input record separator
 8             undef $/;
 9             
10             foreach $file (@ARGV) {
11                    open FILE, $file || die;
12                    binmode FILE;
13             
14                    # munge filename into C variable name
15                    $varname = $file;
16                    $varname =~ s/\./_/;
17             
18                    print "const static char name_$varname"."[] = \"$file\";\n";
19                    print "const static char file_$varname"."[] = {\n";
20                    while (read(FILE, $buffer, 16)) {
21                            $buffer =~ s/(.|\n)/'0x' . unpack('H2', $1).', '/ge;
22 rizwank 1.1                print "\t$buffer\n";
23                    }
24                    close FILE;
25             
26                    print "};\n\n";
27             }

Rizwan Kassim
Powered by
ViewCVS 0.9.2