#include #include #include "../include/wlib.h" #ifdef WINDOWS #include #include "mswint.h" #endif #define HEWHDROFFSET (0x3C) static FILE * openfile( const char * fn, const char * mode, long * fileSize ) { unsigned short PageCnt; long FileSize; FILE *fp; struct stat Stat; fp = fopen( fn, mode ); if (fp == NULL) { perror( "fopen" ); return NULL; } fread( &PageCnt, sizeof(PageCnt), 1, fp ); /* Read past signature */ fread( &PageCnt, sizeof(PageCnt), 1, fp ); /* Read past pagesize */ FileSize = PageCnt; fread( &PageCnt, sizeof(PageCnt), 1, fp ); /* Read past pagesize */ if ( FileSize == 0L ) FileSize = PageCnt * 512L; else FileSize += (PageCnt - 1) * 512L; *fileSize = FileSize; stat( fn, &Stat ); *fileSize = (long)Stat.st_size; fprintf( stderr, "size1 = %ld, size2 = %ld\n", FileSize, (long)Stat.st_size ); return fp; } static unsigned short mswCheck16( FILE * fp, long FileSize, unsigned short * sum16stored ) { unsigned short int sum16, NxtInt; long x; unsigned char NxtChar; sum16 = 0; fseek(fp, 0, SEEK_SET); for (x=0L; x