00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
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
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 }