Rev 288 |
Blame |
Compare with Previous |
Last modification |
View Log
| RSS feed
#include "imgtypes.h"
#include "garminimg.h"
#include "decoder.h"
#include "decode_img.h"
static class GarminImg *img;
static class ImgFile *ifile;
static class ImgGMP *gmp;
static class Decoder *dec;
void decode_gmp_header (class Decoder *dec_in, class ImgGMP *gmp_in)
{
udword_t length, offset;
uword_t rsize;
off_t soffset, eoffset;
int i= 0;
class ImgSubfile *sub= NULL;
class ImgSubfile *psub= NULL;
gmp= gmp_in;
dec= dec_in;
img= dec->img;
ifile= gmp->ifile;
soffset= gmp->offset();
img->seek(soffset);
dec->set_outfile("GMP", "header");
dec->banner("GMP: Header");
decode_common_header(dec, gmp);
dec->print("???", img->get_udword());
eoffset= 0xffffffff;
while ( offset= img->get_udword() ) {
const char *which;
offset+= soffset;
switch (i) {
case 0: // TRE
sub= ifile->subfile_add("TRE", soffset, 0);
which= "TRE";
break;
case 1: // RGN
sub= ifile->subfile_add("RGN", soffset, 0);
which= "RGN";
break;
case 2: // LBL
sub= ifile->subfile_add("LBL", soffset, 0);
which= "LBL";
break;
case 3: // NET
sub= ifile->subfile_add("NET", soffset, 0);
which= "NET";
break;
case 4: // NOD
sub= ifile->subfile_add("NOD", soffset, 0);
which= "NOD";
break;
default:
which= "unknown";
}
if ( sub ) {
sub->set_header_offset(offset);
}
psub= sub;
dec->print("%s header at 0x%08x", which, offset);
++i;
if ( offset < eoffset ) eoffset= offset;
}
dec->print("???");
while ( img->tell() < eoffset ) {
dec->print("%s", img->get_string().c_str());
}
}