head 1.2; access; symbols ePerl_2_2_14:1.1.1.1 RSE:1.1.1; locks; strict; comment @# @; 1.2 date 2000.07.03.09.05.26; author rse; state Exp; branches; next 1.1; 1.1 date 99.05.02.14.43.39; author rse; state Exp; branches 1.1.1.1; next ; 1.1.1.1 date 99.05.02.14.43.39; author rse; state Exp; branches; next ; desc @@ 1.2 log @*** empty log message *** @ text @: eval 'exec perl -S $0 ${1+"$@@"}' if $running_under_some_shell; ## ## bin2c -- convert an binary file into a statically initialised ## C array of characters ## ## Copyright (c) Ralf S. Engelschall, All Rights Reserved. ## $filein = $ARGV[0]; $fileout = $ARGV[1]; $name = $ARGV[2]; if ($#ARGV ne 2) { printf(STDERR "Usage: $0 binary-file c-file buffer-name\n"); exit(1); } ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size, $atime,$mtime,$ctime,$blksize,$blocks) = stat($filein); open(IN, "<$filein"); #open(OUTH, ">$fileout.h"); open(OUTC, ">$fileout.c"); print OUTC "/* $filein.c -- automatically generated by bin2c */\n"; print OUTC "\n"; print OUTC "int ${name}_size = " . $size . ";\n"; print OUTC "char ${name}_data[] = {\n"; $i = 1; while (read(IN, $c, 1)) { printf(OUTC "0x%02x", ord($c)); printf(OUTC ",") if ($i < $size); printf(OUTC "\n") if ($i % 15 == 0 && $i < $size); $i++; } print OUTC " };\n"; print OUTC "\n"; print OUTC "/*EOF*/\n"; $filename = "$fileout.h"; $filename =~ tr|a-z.|A-Z_|; #print OUTH "/* $fileout.h -- automatically generated by bin2c */\n"; #print OUTH "#ifndef __$filename\n"; #print OUTH "#define __$filename\n"; #print OUTH "\n"; #print OUTH "extern char *$name;\n"; #print OUTH "\n"; #print OUTH "#endif /* __$filename */\n"; close(IN); #close(OUTH); close(OUTC); ##EOF## @ 1.1 log @Initial revision @ text @d1 3 a3 1 #!/sw/bin/perl @ 1.1.1.1 log @Import of ePerl 2.2.14 @ text @@