#!/usr/bin/perl use Palm::Raw; $ARCH_HEADERLEN = 8 + 2 + 4 + 32 + 4 + 4; # Length of archive header $REC_HEADERLEN = 1 + 1 + 4 + 4; # Length of record header $now = time; # Current time # Filename is first argument $fname = shift; if (! -f $fname) { print STDERR <.pdb EOT exit 1; } $pdb = new Palm::Raw; open ARCH, "< $fname" or die "Can't open $fname: $!\n"; # Read the archive header read ARCH, $arch_header, $ARCH_HEADERLEN; ($magic, $header_len, $version, $pdbname, $type, $creator) = unpack("a8 n N a32 a4 a4", $arch_header); # print <{name} = $pdbname; $pdb->{version} = 1; # ? $pdb->{ctime} = $now; $pdb->{mtime} = $now; $pdb->{baktime} = 0; # Never backed up. $pdb->{modnum} = 1; $pdb->{type} = $type; $pdb->{creator} = $creator; while (!eof(ARCH)) { read ARCH, $rec_header, $REC_HEADERLEN; ($type, $hlen, $datalen, $ctime) = unpack("c c N N", $rec_header); # Here's how to select only records younger than one day: # next unless $ctime > ($now - 86400); # print <append_Record; $record->{data} = $rec_data; # last; } # XXX - Doesn't want to write to "MemoDB.pdb", for some reason. # Insists on creating "MemoDB" instead. $ofname = "./" . $pdb->{name} . ".pdb"; #print STDERR "Writing $ofname\n"; $pdb->Write($ofname);