Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

htflt.cc

Go to the documentation of this file.
00001 /* 
00002  *      HT Editor
00003  *      htelf.cc
00004  *
00005  *      Copyright (C) 1999-2002 Stefan Weyergraf (stefan@weyergraf.de)
00006  *
00007  *      This program is free software; you can redistribute it and/or modify
00008  *      it under the terms of the GNU General Public License version 2 as
00009  *      published by the Free Software Foundation.
00010  *
00011  *      This program is distributed in the hope that it will be useful,
00012  *      but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *      GNU General Public License for more details.
00015  *
00016  *      You should have received a copy of the GNU General Public License
00017  *      along with this program; if not, write to the Free Software
00018  *      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00019  */
00020 
00021 #include "log.h"
00022 #include "htflt.h"
00023 #include "htflthd.h"
00024 #include "htfltimg.h"
00025 #include "htendian.h"
00026 #include "stream.h"
00027 #include "tools.h"
00028 
00029 #include "fltstruc.h"
00030 
00031 #include <stdlib.h>
00032 
00033 static format_viewer_if *htflt_ifs[] = {
00034         &htfltheader_if,
00035         &htfltimage_if,
00036         0
00037 };
00038 
00039 static ht_view *htflt_init(bounds *b, ht_streamfile *file, ht_format_group *format_group)
00040 {
00041         byte ident[4];
00042         file->seek(0);
00043         file->read(&ident, sizeof ident);
00044         if ((ident[0]!=FLTMAG0) || (ident[1]!=FLTMAG1) ||
00045                 (ident[2]!=FLTMAG2) || (ident[3]!=FLTMAG3) ) return 0;
00046                 
00047         ht_flt *g=new ht_flt();
00048         g->init(b, file, htflt_ifs, format_group, 0);
00049         return g;
00050 }
00051 
00052 format_viewer_if htflt_if = {
00053         htflt_init,
00054         0
00055 };
00056 
00057 /*
00058  *      CLASS ht_flt
00059  */
00060 void ht_flt::init(bounds *b, ht_streamfile *f, format_viewer_if **ifs, ht_format_group *format_group, FILEOFS header_ofs)
00061 {
00062         ht_format_group::init(b, VO_SELECTABLE | VO_BROWSABLE | VO_RESIZE, DESC_FLT, f, false, true, 0, format_group);
00063         VIEW_DEBUG_NAME("ht_flt");
00064 
00065         LOG("%s: FLAT: found header at %08x", file->get_filename(), header_ofs);
00066         
00067         ht_flt_shared_data *flt_shared=(ht_flt_shared_data *)malloc(sizeof(ht_flt_shared_data));
00068         
00069         shared_data=flt_shared;
00070         flt_shared->header_ofs=header_ofs;
00071 
00072         /* read header */
00073         file->seek(header_ofs);
00074         file->read(&flt_shared->header, sizeof flt_shared->header);
00075         create_host_struct(&flt_shared->header, FLAT_HEADER_struct, big_endian);
00076 
00077         flt_shared->code_start = sizeof flt_shared->header;
00078         flt_shared->code_end = flt_shared->header.data_start;
00079         flt_shared->data_start = flt_shared->header.data_start;
00080         flt_shared->data_end = flt_shared->header.data_end;
00081         flt_shared->bss_start = flt_shared->header.data_end;
00082         flt_shared->bss_end = flt_shared->header.bss_end;
00083         /* init ifs */
00084         ht_format_group::init_ifs(ifs);
00085 }
00086 
00087 void ht_flt::done()
00088 {
00089         ht_format_group::done();
00090         ht_flt_shared_data *flt_shared=(ht_flt_shared_data *)shared_data;
00091         free(flt_shared);
00092 }

Generated on Fri May 7 21:15:33 2004 by doxygen 1.3.5