From 36ab81f0443ec54229bbb7e2771b749e68f6d175 Mon Sep 17 00:00:00 2001 From: "Alexander S. Aganichev" Date: Tue, 3 Sep 2002 07:17:19 +0000 Subject: [PATCH] Fixed compilation issues caused by the last commit of SMB, fixed hang on broken SMB --- goldlib/gmb3/gmosmb1.cpp | 32 +++++++++++++++++--------------- goldlib/smblib/smbdefs.h | 6 ++++-- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/goldlib/gmb3/gmosmb1.cpp b/goldlib/gmb3/gmosmb1.cpp index 1f2b3ad..7d5304e 100644 --- a/goldlib/gmb3/gmosmb1.cpp +++ b/goldlib/gmb3/gmosmb1.cpp @@ -435,15 +435,16 @@ add: } common: fseek(data->sdt_fp, smsg.hdr.offset + smsg.dfield[i].offset, SEEK_SET); - fread(&xlat, 2, 1, data->sdt_fp); - l = 2; + l = sizeof(xlat); + fread(&xlat, sizeof(xlat), 1, data->sdt_fp); lzh = false; - while(xlat != XLAT_NONE) { - if(xlat == XLAT_LZH) - lzh = true; - fread(&xlat, 2, 1, data->sdt_fp); - l += 2; + if(xlat == XLAT_LZH) { + lzh = true; + fread(&xlat, sizeof(xlat), 1, data->sdt_fp); + l += sizeof(xlat); } + if(xlat != XLAT_NONE) /* no other translations currently supported */ + continue; if(lzh) { inbuf = (uchar *)throw_xmalloc(smsg.dfield[i].length); fread(inbuf, smsg.dfield[i].length - l, 1, data->sdt_fp); @@ -459,7 +460,7 @@ common: } else outlen = 0; - txt_len+=outlen; + txt_len += outlen; msg->txt[txt_len-1] = NUL; break; } @@ -1059,15 +1060,16 @@ Line* SMBArea::make_dump_msg(Line*& lin, gmsg* msg, char* lng_head) } common: fseek(data->sdt_fp, smsg.hdr.offset + smsg.dfield[i].offset, SEEK_SET); - fread(&xlat, 2, 1, data->sdt_fp); - l = 2; + l = sizeof(xlat); + fread(&xlat, sizeof(xlat), 1, data->sdt_fp); lzh = false; - while(xlat != XLAT_NONE) { - if(xlat == XLAT_LZH) - lzh = true; - fread(&xlat, 2, 1, data->sdt_fp); - l += 2; + if(xlat == XLAT_LZH) { + lzh = true; + fread(&xlat, sizeof(xlat), 1, data->sdt_fp); + l += sizeof(xlat); } + if(xlat != XLAT_NONE) /* no other translations currently supported */ + continue; if(lzh) { inbuf = (uchar *)throw_xmalloc(smsg.dfield[i].length); fread(inbuf, smsg.dfield[i].length - l, 1, data->sdt_fp); diff --git a/goldlib/smblib/smbdefs.h b/goldlib/smblib/smbdefs.h index 2aee469..5ae9609 100644 --- a/goldlib/smblib/smbdefs.h +++ b/goldlib/smblib/smbdefs.h @@ -377,7 +377,9 @@ enum { /************/ #if defined(_WIN32) || defined(__BORLANDC__) - #define PRAGMA_PACK + #ifndef PRAGMA_PACK + #define PRAGMA_PACK + #endif #endif #if defined(PRAGMA_PACK) @@ -487,7 +489,7 @@ typedef struct _PACK { // Network (type and address) #if defined(PRAGMA_PACK) #if defined(__GNUC__) -#define pack() +#pragma pack() #else #pragma pack(pop) /* original packing */ #endif