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

htmz.cc

Go to the documentation of this file.
00001 /* 
00002  *      HT Editor
00003  *      htmz.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 "htendian.h"
00022 #include "htmz.h"
00023 #include "htmzhead.h"
00024 #include "htmzrel.h"
00025 #include "htmzimg.h"
00026 #include "mzstruct.h"
00027 #include "stream.h"
00028 
00029 static format_viewer_if *htmz_ifs[] = {
00030         &htmzheader_if,
00031 //      &htmzrel_if,
00032         &htmzimage_if,
00033         0
00034 };
00035 
00036 static ht_view *htmz_init(bounds *b, ht_streamfile *file, ht_format_group *format_group)
00037 {
00038         byte magic[2];
00039         file->seek(0);
00040         file->read(magic, 2);
00041         if ((magic[0] != IMAGE_MZ_MAGIC0) || (magic[1] != IMAGE_MZ_MAGIC1))
00042                 return NULL;
00043 
00044         ht_mz *g = new ht_mz();
00045         g->init(b, file, htmz_ifs, format_group);
00046         return g;
00047 }
00048 
00049 format_viewer_if htmz_if = {
00050         htmz_init,
00051         0
00052 };
00053 
00054 void ht_mz::init(bounds *b, ht_streamfile *file, format_viewer_if **ifs, ht_format_group *format_group)
00055 {
00056         ht_format_group::init(b, VO_SELECTABLE | VO_BROWSABLE | VO_RESIZE, DESC_MZ, file, false, true, 0, format_group);
00057         ht_mz_shared_data *mz_shared = (ht_mz_shared_data*)malloc(sizeof (ht_mz_shared_data));
00058         shared_data = mz_shared;
00059         file->seek(0);
00060         file->read(&mz_shared->header, sizeof mz_shared->header);
00061         create_host_struct(&mz_shared->header, MZ_HEADER_struct, little_endian);
00062         shared_data = mz_shared;
00063         ht_format_group::init_ifs(ifs);
00064 }
00065 
00066 void ht_mz::done()
00067 {
00068         free(shared_data);
00069         ht_format_group::done();
00070 }
00071 
00072 void ht_mz::loc_enum_start()
00073 {
00074         loc_enum=1;
00075 }
00076 
00077 bool ht_mz::loc_enum_next(ht_format_loc *loc)
00078 {
00079         ht_mz_shared_data *sh=(ht_mz_shared_data*)shared_data;
00080         if (loc_enum) {
00081                 loc->name="mz";
00082                 loc->start=0;
00083                 loc->length=sh->header.header_size*16+(sh->header.sizep-1)*512+
00084                 sh->header.sizelp;
00085 
00086                 loc_enum=0;
00087                 return true;
00088         }
00089         return false;
00090 }

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