(file) Return to hexify.sh CVS log (file) (dir) Up to [RizwankCVS] / group3 / wine / dlls / cabinet / tests

 1 rizwank 1.1 #! /bin/sh
 2             # perl -pe 's/(.)/sprintf "%#x, ", ord $1/sge' would have done too! lovely ;p
 3             # or perl -0777 -ne 'print "{", join(", ", map sprintf("%#x", ord), split //), "}"'
 4             
 5             #trunc=`sed -e "s/\./g" "$1"`
 6             echo "Exports given file to <filename.ext.hex> - as a hex array"
 7             echo "(c) Rizwan Kassim 2006"
 8             echo "Bugs - Appends to outputfile, doesn't check for validity"
 9 rizwank 1.2 #echo "needs to remove any . from the arrayname when writing "
10 rizwank 1.1 echo "and needs to remove final comma. "
11             echo "later, I realized that it would be much easier to do this "
12             echo "in perl (see code for examples"
13             echo "appending to $1.hex!"
14 rizwank 1.2 echo "DONT FORGET TO remove final ,"
15 rizwank 1.1 echo " ============================================ "
16 rizwank 1.2 echo "static unsigned char file_$1 = {" >> $1.hex
17 rizwank 1.1 #| grep "s/cab/_/"
18 rizwank 1.2 od -h $1 | sed "s/^[0-9]\{7\}[ ]*//g" | sed "s/\([0-9a-f]\{2\}\)[ ]*/00x\U\1,/g" |  sed "s/\([.]*\),$//" | sed "s/.*/&,/" | sed "s/^,$//g" | sed "/^$/d" >> $1.hex
19 rizwank 1.1 #doesnt just remove end of file but end of every line - sed "s/.$[^^]//" | sed "s/.$//" | 
20             echo "};" >> $1.hex
21 rizwank 1.2 echo "static int szfile_$1 = sizeof(file_$1);" >> $1.hex
22             sed -i "s/\./_/g" $1.hex
23 rizwank 1.1 

Rizwan Kassim
Powered by
ViewCVS 0.9.2