#!/usr/bin/perl -w # Read NFM files # editions Systeme D, 2007 # public domain # ===== Read faredata.dat open (DATA ,"faredata.dat") or die "Can't open faredata.dat: $!\n"; # ----- Find blocks seek (DATA,0x05,0); $offset=5; $reccount=0; while (!eof DATA) { read(DATA,$rectype,1); $rectype=ord $rectype; if ($rectype==0x43 or $rectype==0x42) { if ($rectype==0x43) { $w=6; } else { $w=10; } read (DATA,$reclen,2); $reclen=unpack("v",$reclen); # should be 2-byte # printf "* %02x\n",$reclen; $offset+=3; for ($i=0; $i<$reclen; $i++) { read (DATA,$block,$w); $offset+=$w; # if ($rectype==0x43) { Explain_String($block); } } } else { read (DATA,$reclen,1); $reclen=ord $reclen; read (DATA,$block,$reclen-2); if ($rectype==0x54) { printf "At %05x: %02x ",$offset,$rectype; printf "(%02x) ",$reclen; Explain_String($block); } $offset+=$reclen; $reccount++; } # $f=; } close DATA; exit; sub Explain_String { my $t=$_[0]; my $i; my $s; foreach $i (split //,$t) { printf "%02x ",ord($i); if ($i ge ' ' && ord($i)<127) { $s.=$i; } else { $s.='.';} } print "$s\n"; }