diff --git a/src/sbbs3/writemsg.cpp b/src/sbbs3/writemsg.cpp index 80476576b0ae016fd4f31737a53605a53d86c97b..7bb98687f2a601d26a0c2f24fc1a00f5d86f7116 100644 --- a/src/sbbs3/writemsg.cpp +++ b/src/sbbs3/writemsg.cpp @@ -268,8 +268,8 @@ bool sbbs_t::writemsg(const char *fname, const char *top, char *subj, int mode, char draft[MAX_PATH + 1]; char tmp[512]; int i,j,file,linesquoted=0; - long length,qlen=0,qtime=0,ex_mode=0; - ulong l; + int length,qlen=0,qtime=0,ex_mode=0; + uint l; FILE* stream; FILE* fp; unsigned lines; diff --git a/src/smblib/smbadd.c b/src/smblib/smbadd.c index c82f9ff9d3bf6c498322c01099f40b90683358bc..753c692df772a82d565f5793bf4b51d6ca7c5e30 100644 --- a/src/smblib/smbadd.c +++ b/src/smblib/smbadd.c @@ -29,11 +29,11 @@ /****************************************************************************/ /****************************************************************************/ -int smb_addmsg(smb_t* smb, smbmsg_t* msg, int storage, long dupechk_hashes +int smb_addmsg(smb_t* smb, smbmsg_t* msg, int storage, int dupechk_hashes ,uint16_t xlat, const uchar* body, const uchar* tail) { uchar* lzhbuf=NULL; - long lzhlen; + int lzhlen; int retval; size_t n; off_t l; @@ -80,7 +80,7 @@ int smb_addmsg(smb_t* smb, smbmsg_t* msg, int storage, long dupechk_hashes ,__FUNCTION__ ,smb_hashsourcetype(found.source) ,smb_hashsource(msg,found.source) - ,(ulong)found.number); + ,(uint)found.number); retval=SMB_DUPE_MSG; break; } @@ -190,7 +190,7 @@ int smb_addmsg(smb_t* smb, smbmsg_t* msg, int storage, long dupechk_hashes safe_snprintf(smb->last_error,sizeof(smb->last_error) ,"%s writing body (%ld bytes)" ,__FUNCTION__ - ,(long)bodylen); + ,(int)bodylen); retval=SMB_ERR_WRITE; break; } @@ -213,7 +213,7 @@ int smb_addmsg(smb_t* smb, smbmsg_t* msg, int storage, long dupechk_hashes safe_snprintf(smb->last_error,sizeof(smb->last_error) ,"%s writing tail (%ld bytes)" ,__FUNCTION__ - ,(long)(taillen-sizeof(xlat))); + ,(int)(taillen-sizeof(xlat))); retval=SMB_ERR_WRITE; break; } diff --git a/src/smblib/smballoc.c b/src/smblib/smballoc.c index 05b424ce9b3b7f7775e41432979597f64e666848..bca338a0b8e78b3e8e617681c855801e585609be 100644 --- a/src/smblib/smballoc.c +++ b/src/smblib/smballoc.c @@ -34,8 +34,8 @@ off_t smb_allocdat(smb_t* smb, off_t length, uint16_t refs) { uint16_t i; - ulong j,l,blocks; - off_t offset=0; + uint j,l,blocks; + off_t offset=0; if(smb->sda_fp==NULL) { safe_snprintf(smb->last_error, sizeof(smb->last_error), "%s msgbase not open", __FUNCTION__); @@ -45,7 +45,7 @@ off_t smb_allocdat(smb_t* smb, off_t length, uint16_t refs) j=0; /* j is consecutive unused block counter */ fflush(smb->sda_fp); rewind(smb->sda_fp); - while(!feof(smb->sda_fp) && (long)offset>=0) { + while(!feof(smb->sda_fp) && (int)offset>=0) { if(smb_fread(smb,&i,sizeof(i),smb->sda_fp)!=sizeof(i)) break; offset+=SDT_BLOCK_LEN; @@ -56,7 +56,7 @@ off_t smb_allocdat(smb_t* smb, off_t length, uint16_t refs) break; } } - if((long)offset<0) { + if((int)offset<0) { safe_snprintf(smb->last_error,sizeof(smb->last_error),"%s invalid data offset: %" PRIdOFF, __FUNCTION__, offset); return(SMB_ERR_DAT_OFFSET); } @@ -83,8 +83,8 @@ off_t smb_allocdat(smb_t* smb, off_t length, uint16_t refs) /****************************************************************************/ off_t smb_fallocdat(smb_t* smb, off_t length, uint16_t refs) { - ulong l,blocks; - off_t offset; + uint l,blocks; + off_t offset; if(smb->sda_fp==NULL) { safe_snprintf(smb->last_error, sizeof(smb->last_error), "%s msgbase not open", __FUNCTION__); @@ -98,7 +98,7 @@ off_t smb_fallocdat(smb_t* smb, off_t length, uint16_t refs) return(SMB_ERR_SEEK); } offset=(ftell(smb->sda_fp)/sizeof(refs))*SDT_BLOCK_LEN; - if((long)offset<0) { + if((int)offset<0) { safe_snprintf(smb->last_error,sizeof(smb->last_error) ,"%s invalid data offset: %" PRIdOFF, __FUNCTION__, offset); return(SMB_ERR_DAT_OFFSET); @@ -120,12 +120,12 @@ off_t smb_fallocdat(smb_t* smb, off_t length, uint16_t refs) /* Returns non-zero on error */ /* Always unlocks the SMB header (when not hyper-alloc) */ /****************************************************************************/ -int smb_freemsgdat(smb_t* smb, off_t offset, ulong length, uint16_t refs) +int smb_freemsgdat(smb_t* smb, off_t offset, uint length, uint16_t refs) { BOOL da_opened=FALSE; int retval=SMB_SUCCESS; uint16_t i; - long l,blocks; + int l,blocks; off_t sda_offset; off_t flen; @@ -178,7 +178,7 @@ int smb_freemsgdat(smb_t* smb, off_t offset, ulong length, uint16_t refs) // Completely free? and at end of SDA? Just truncate record from end of file if(i == 0 && ftell(smb->sda_fp) == flen) { - if(chsize(fileno(smb->sda_fp), (long)sda_offset) == 0) { + if(chsize(fileno(smb->sda_fp), (int)sda_offset) == 0) { flen = sda_offset; continue; } @@ -200,8 +200,8 @@ int smb_freemsgdat(smb_t* smb, off_t offset, ulong length, uint16_t refs) } } fflush(smb->sda_fp); - if(filelength(fileno(smb->sdt_fp)) / SDT_BLOCK_LEN > (long)(filelength(fileno(smb->sda_fp)) / sizeof(uint16_t))) - if(chsize(fileno(smb->sdt_fp), (long)(filelength(fileno(smb->sda_fp)) / sizeof(uint16_t)) * SDT_BLOCK_LEN) != 0) + if(filelength(fileno(smb->sdt_fp)) / SDT_BLOCK_LEN > (int)(filelength(fileno(smb->sda_fp)) / sizeof(uint16_t))) + if(chsize(fileno(smb->sdt_fp), (int)(filelength(fileno(smb->sda_fp)) / sizeof(uint16_t)) * SDT_BLOCK_LEN) != 0) retval = SMB_ERR_TRUNCATE; if(da_opened) smb_close_da(smb); @@ -214,10 +214,10 @@ int smb_freemsgdat(smb_t* smb, off_t offset, ulong length, uint16_t refs) /* SMB header should be locked before calling this function */ /* Returns non-zero on error */ /****************************************************************************/ -int smb_incdat(smb_t* smb, off_t offset, ulong length, uint16_t refs) +int smb_incdat(smb_t* smb, off_t offset, uint length, uint16_t refs) { uint16_t i; - ulong l,blocks; + uint l,blocks; if(smb->sda_fp==NULL) { safe_snprintf(smb->last_error, sizeof(smb->last_error), "%s msgbase not open", __FUNCTION__); @@ -239,7 +239,7 @@ int smb_incdat(smb_t* smb, off_t offset, ulong length, uint16_t refs) } i+=refs; if(fseek(smb->sda_fp,-(int)sizeof(i),SEEK_CUR)) { - safe_snprintf(smb->last_error,sizeof(smb->last_error),"%s rewinding %ld", __FUNCTION__, -(long)sizeof(i)); + safe_snprintf(smb->last_error,sizeof(smb->last_error),"%s rewinding %ld", __FUNCTION__, -(int)sizeof(i)); return(SMB_ERR_SEEK); } if(!fwrite(&i,sizeof(i),1,smb->sda_fp)) { @@ -293,10 +293,10 @@ int smb_incmsg_dfields(smb_t* smb, smbmsg_t* msg, uint16_t refs) /* De-allocates blocks for header record */ /* Returns non-zero on error */ /****************************************************************************/ -int smb_freemsghdr(smb_t* smb, off_t offset, ulong length) +int smb_freemsghdr(smb_t* smb, off_t offset, uint length) { uchar c=0; - long l,blocks; + int l,blocks; off_t sha_offset; if(smb->sha_fp==NULL) { @@ -310,15 +310,15 @@ int smb_freemsghdr(smb_t* smb, off_t offset, ulong length) sha_offset = offset/SHD_BLOCK_LEN; if(filelength(fileno(smb->sha_fp)) <= (sha_offset + blocks)) { - if(chsize(fileno(smb->sha_fp), (long)sha_offset) == 0) { - if(chsize(fileno(smb->shd_fp), (long)(smb->status.header_offset + offset)) != 0) + if(chsize(fileno(smb->sha_fp), (int)sha_offset) == 0) { + if(chsize(fileno(smb->shd_fp), (int)(smb->status.header_offset + offset)) != 0) return SMB_ERR_TRUNCATE; return SMB_SUCCESS; } } if(fseeko(smb->sha_fp, sha_offset, SEEK_SET)) { - safe_snprintf(smb->last_error,sizeof(smb->last_error),"%s seeking to %ld", __FUNCTION__, (long)sha_offset); + safe_snprintf(smb->last_error,sizeof(smb->last_error),"%s seeking to %ld", __FUNCTION__, (int)sha_offset); return(SMB_ERR_SEEK); } for(l=0;l<blocks;l++) @@ -334,7 +334,7 @@ int smb_freemsghdr(smb_t* smb, off_t offset, ulong length) /****************************************************************************/ int smb_freemsg_dfields(smb_t* smb, smbmsg_t* msg, uint16_t refs) { - int i; + int i; uint16_t x; for(x=0;x<msg->hdr.total_dfields;x++) { @@ -374,10 +374,10 @@ int smb_freemsg(smb_t* smb, smbmsg_t* msg) /* smb_close_ha() should be called after */ /* Returns negative value on error */ /****************************************************************************/ -off_t smb_allochdr(smb_t* smb, ulong length) +off_t smb_allochdr(smb_t* smb, uint length) { uchar c; - ulong i,l,blocks,offset=0; + uint i,l,blocks,offset=0; if(smb->sha_fp==NULL) { safe_snprintf(smb->last_error, sizeof(smb->last_error), "%s msgbase not open", __FUNCTION__); @@ -417,10 +417,10 @@ off_t smb_allochdr(smb_t* smb, ulong length) /* Allocates space for header, but doesn't search for unused blocks */ /* Returns negative value on error */ /****************************************************************************/ -off_t smb_fallochdr(smb_t* smb, ulong length) +off_t smb_fallochdr(smb_t* smb, uint length) { uchar c=1; - ulong l,blocks,offset; + uint l,blocks,offset; if(smb->sha_fp==NULL) { safe_snprintf(smb->last_error, sizeof(smb->last_error), "%s msgbase not open", __FUNCTION__); @@ -451,7 +451,7 @@ off_t smb_fallochdr(smb_t* smb, ulong length) /************************************************************************/ off_t smb_hallochdr(smb_t* smb) { - ulong offset; + uint offset; if(smb->shd_fp==NULL) { safe_snprintf(smb->last_error, sizeof(smb->last_error), "%s msgbase not open", __FUNCTION__); @@ -510,5 +510,5 @@ off_t smb_hallocdat(smb_t* smb) /* Make sure even block boundry */ offset+=PAD_LENGTH_FOR_ALIGNMENT(offset,SDT_BLOCK_LEN); - return (long)offset; + return offset; } diff --git a/src/smblib/smbdefs.h b/src/smblib/smbdefs.h index 0412dc058afaaa17eb01c9554103f227934c95e7..7311b3b07363ca709fe4f958a00966eaed6c893e 100644 --- a/src/smblib/smbdefs.h +++ b/src/smblib/smbdefs.h @@ -53,9 +53,7 @@ #ifdef __GLIBC__ #include <sys/types.h> #else - #ifndef ushort - #define ushort unsigned short - #define ulong unsigned long + #ifndef uint #define uint unsigned int #endif #endif diff --git a/src/smblib/smbfile.c b/src/smblib/smbfile.c index f23ce9ec437c687ab98da9a68346998e41553d1f..07be5fcfcdd4de928477668ed15ed116f193d29f 100644 --- a/src/smblib/smbfile.c +++ b/src/smblib/smbfile.c @@ -61,7 +61,7 @@ off_t smb_fgetlength(FILE* fp) return(filelength(fileno(fp))); } -int smb_fsetlength(FILE* fp, long length) +int smb_fsetlength(FILE* fp, off_t length) { return(chsize(fileno(fp),length)); } diff --git a/src/smblib/smbhash.c b/src/smblib/smbhash.c index 3e6198a3a139cb3f294ebe7436f2c29784f215a1..57c2a691bcadf3f154b328ae7badeb3f14e0493f 100644 --- a/src/smblib/smbhash.c +++ b/src/smblib/smbhash.c @@ -31,7 +31,7 @@ /* If return value is SMB_ERR_NOT_FOUND, hash file is left open */ int smb_findhash(smb_t* smb, hash_t** compare, hash_t* found_hash, - long source_mask, BOOL mark) + int source_mask, BOOL mark) { int retval; BOOL found=FALSE; @@ -176,7 +176,7 @@ static char* strip_ctrla(uchar* dst, const uchar* src) /* Allocates and calculates hashes of data (based on flags) */ /* Returns NULL on failure */ -hash_t* smb_hash(ulong msgnum, uint32_t t, unsigned source, unsigned flags +hash_t* smb_hash(uint msgnum, uint32_t t, unsigned source, unsigned flags ,const void* data, size_t length) { hash_t* hash; @@ -208,7 +208,7 @@ hash_t* smb_hash(ulong msgnum, uint32_t t, unsigned source, unsigned flags /* Allocates and calculates hashes of data (based on flags) */ /* Supports string hash "pre-processing" (e.g. lowercase, strip whitespace) */ /* Returns NULL on failure */ -hash_t* smb_hashstr(ulong msgnum, uint32_t t, unsigned source, unsigned flags +hash_t* smb_hashstr(uint msgnum, uint32_t t, unsigned source, unsigned flags ,const char* str) { char* p=NULL; @@ -236,7 +236,7 @@ hash_t* smb_hashstr(ulong msgnum, uint32_t t, unsigned source, unsigned flags /* Allocates and calculates all hashes for a single message */ /* Returns NULL on failure */ -hash_t** smb_msghashes(smbmsg_t* msg, const uchar* body, long source_mask) +hash_t** smb_msghashes(smbmsg_t* msg, const uchar* body, int source_mask) { size_t h=0; uchar flags=SMB_HASH_CRC16|SMB_HASH_CRC32|SMB_HASH_MD5|SMB_HASH_SHA1; @@ -306,7 +306,7 @@ int smb_hashmsg(smb_t* smb, smbmsg_t* msg, const uchar* text, BOOL update) ,"%s duplicate %s: %s found in message #%lu", __FUNCTION__ ,smb_hashsourcetype(found.source) ,smb_hashsource(msg,found.source) - ,(ulong)found.number); + ,(uint)found.number); } else if((retval=smb_addhashes(smb,hashes,/* skip_marked? */TRUE))==SMB_SUCCESS) msg->flags|=MSG_FLAG_HASHED; diff --git a/src/smblib/smblib.c b/src/smblib/smblib.c index 6aff1a778ac00a36c251e33f14b7a71210133871..ef2b8cb7ff05420ad5fd7a434fe7ada9140b6a90 100644 --- a/src/smblib/smblib.c +++ b/src/smblib/smblib.c @@ -87,7 +87,7 @@ int smb_open(smb_t* smb) return(i); memset(&(smb->status),0,sizeof(smb->status)); - if(filelength(fileno(smb->shd_fp))>=(long)sizeof(smbhdr_t)) { + if(filelength(fileno(smb->shd_fp))>=(int)sizeof(smbhdr_t)) { if(smb_locksmbhdr(smb)!=SMB_SUCCESS) { smb_close(smb); /* smb_locksmbhdr set last_error */ @@ -252,7 +252,7 @@ int smb_trunchdr(smb_t* smb) if(time(NULL)-start>=(time_t)smb->retry_time) { /* Time-out */ safe_snprintf(smb->last_error,sizeof(smb->last_error) ,"%s timeout changing header file size (retry_time=%lu)", __FUNCTION__ - ,(ulong)smb->retry_time); + ,(uint)smb->retry_time); return(SMB_ERR_TIMEOUT); } SLEEP(smb->retry_delay); @@ -380,7 +380,7 @@ int smb_unlocksmbhdr(smb_t* smb) /****************************************************************************/ /* Is the offset a valid message header offset? */ /****************************************************************************/ -BOOL smb_valid_hdr_offset(smb_t* smb, ulong offset) +BOOL smb_valid_hdr_offset(smb_t* smb, uint offset) { if(offset<sizeof(smbhdr_t)+sizeof(smbstatus_t) || offset<smb->status.header_offset) { @@ -433,8 +433,8 @@ int smb_lockmsghdr(smb_t* smb, smbmsg_t* msg) int smb_getmsgidx(smb_t* smb, smbmsg_t* msg) { idxrec_t idx; - long byte_offset; - ulong l,total,bot,top; + int byte_offset; + uint l,total,bot,top; off_t length; size_t idxreclen = smb_idxreclen(smb); @@ -445,12 +445,12 @@ int smb_getmsgidx(smb_t* smb, smbmsg_t* msg) clearerr(smb->sid_fp); length=filelength(fileno(smb->sid_fp)); - if(length<(long)idxreclen) { + if(length<(int)idxreclen) { safe_snprintf(smb->last_error,sizeof(smb->last_error) ,"%s invalid index file length: %" PRIdOFF, __FUNCTION__,length); return(SMB_ERR_FILE_LEN); } - total=(ulong)(length/idxreclen); + total=(uint)(length/idxreclen); if(!total) { safe_snprintf(smb->last_error,sizeof(smb->last_error) ,"%s invalid index file length: %" PRIdOFF, __FUNCTION__,length); @@ -459,13 +459,13 @@ int smb_getmsgidx(smb_t* smb, smbmsg_t* msg) if(!msg->hdr.number) { if(msg->idx_offset<0) - byte_offset=(long)(length-((-msg->idx_offset)*idxreclen)); + byte_offset=(int)(length-((-msg->idx_offset)*idxreclen)); else byte_offset=msg->idx_offset*idxreclen; if(byte_offset>=length) { safe_snprintf(smb->last_error,sizeof(smb->last_error) ,"%s invalid index offset: %ld, byte offset: %ld, length: %" PRIdOFF, __FUNCTION__ - ,(long)msg->idx_offset, byte_offset, length); + ,(int)msg->idx_offset, byte_offset, length); return(SMB_ERR_HDR_OFFSET); } if(ftell(smb->sid_fp) != byte_offset) { @@ -473,14 +473,14 @@ int smb_getmsgidx(smb_t* smb, smbmsg_t* msg) safe_snprintf(smb->last_error,sizeof(smb->last_error) ,"%s %d '%s' seeking to offset %ld (byte %lu) in index file", __FUNCTION__ ,get_errno(),STRERROR(get_errno()) - ,(long)msg->idx_offset,byte_offset); + ,(int)msg->idx_offset,byte_offset); return(SMB_ERR_SEEK); } } if(smb_fread(smb,&msg->idx,sizeof(msg->idx),smb->sid_fp)!=sizeof(msg->idx)) { safe_snprintf(smb->last_error,sizeof(smb->last_error) ,"%s reading index at offset %ld (byte %lu)", __FUNCTION__ - ,(long)msg->idx_offset,byte_offset); + ,(int)msg->idx_offset,byte_offset); return(SMB_ERR_READ); } /* Save the correct offset (from the beginning of the file) */ @@ -494,7 +494,7 @@ int smb_getmsgidx(smb_t* smb, smbmsg_t* msg) while(1) { if(l>=total) { safe_snprintf(smb->last_error,sizeof(smb->last_error),"%s msg %lu not found" - , __FUNCTION__, (ulong)msg->hdr.number); + , __FUNCTION__, (uint)msg->hdr.number); return(SMB_ERR_NOT_FOUND); } if(fseek(smb->sid_fp,l*idxreclen,SEEK_SET)) { @@ -512,7 +512,7 @@ int smb_getmsgidx(smb_t* smb, smbmsg_t* msg) } if(bot==top-1 && idx.number!=msg->hdr.number) { safe_snprintf(smb->last_error,sizeof(smb->last_error),"%s msg %lu not found" - , __FUNCTION__, (ulong)msg->hdr.number); + , __FUNCTION__, (uint)msg->hdr.number); return(SMB_ERR_NOT_FOUND); } if(idx.number>msg->hdr.number) { @@ -599,7 +599,7 @@ int smb_getlastidx(smb_t* smb, idxrec_t *idx) } clearerr(smb->sid_fp); length=filelength(fileno(smb->sid_fp)); - if(length<(long)idxreclen) { + if(length<(int)idxreclen) { safe_snprintf(smb->last_error,sizeof(smb->last_error) ,"%s invalid index file length: %" PRIdOFF, __FUNCTION__,length); return(SMB_ERR_FILE_LEN); @@ -625,11 +625,11 @@ int smb_getlastidx(smb_t* smb, idxrec_t *idx) /* must call smb_locksmbhdr() before, smb_unlocksmbhdr() after. */ /* Returns >= 0 on success, negative (SMB_* error) on failure. */ /****************************************************************************/ -long smb_getmsgidx_by_time(smb_t* smb, idxrec_t* match, time_t t) +int smb_getmsgidx_by_time(smb_t* smb, idxrec_t* match, time_t t) { int result; - long match_offset; - ulong total, bot, top; + int match_offset; + uint total, bot, top; idxrec_t idx; size_t idxreclen = smb_idxreclen(smb); @@ -641,7 +641,7 @@ long smb_getmsgidx_by_time(smb_t* smb, idxrec_t* match, time_t t) if(t <= 0) return SMB_BAD_PARAMETER; - total = (ulong)(filelength(fileno(smb->sid_fp))/idxreclen); + total = (uint)(filelength(fileno(smb->sid_fp))/idxreclen); if(!total) /* Empty base */ return SMB_ERR_NOT_FOUND; @@ -660,7 +660,7 @@ long smb_getmsgidx_by_time(smb_t* smb, idxrec_t* match, time_t t) top = total-1; clearerr(smb->sid_fp); while(bot <= top) { - long idx_offset = (bot + top) / 2; + int idx_offset = (bot + top) / 2; if(fseek(smb->sid_fp, idx_offset * idxreclen, SEEK_SET) != 0) return SMB_ERR_SEEK; if(fread(&idx, 1, sizeof(idx), smb->sid_fp) != sizeof(idx)) @@ -685,10 +685,10 @@ long smb_getmsgidx_by_time(smb_t* smb, idxrec_t* match, time_t t) /* Figures out the total length of the header record for 'msg' */ /* Returns length */ /****************************************************************************/ -ulong smb_getmsghdrlen(smbmsg_t* msg) +uint smb_getmsghdrlen(smbmsg_t* msg) { int i; - ulong length; + uint length; /* fixed portion */ length=sizeof(msghdr_t); @@ -706,10 +706,10 @@ ulong smb_getmsghdrlen(smbmsg_t* msg) /* Figures out the total length of the data buffer for 'msg' */ /* Returns length */ /****************************************************************************/ -ulong smb_getmsgdatlen(smbmsg_t* msg) +uint smb_getmsgdatlen(smbmsg_t* msg) { int i; - ulong length=0L; + uint length=0L; for(i=0;i<msg->hdr.total_dfields;i++) length+=msg->dfield[i].length; @@ -720,10 +720,10 @@ ulong smb_getmsgdatlen(smbmsg_t* msg) /* Figures out the total length of the text buffer for 'msg' */ /* Returns length */ /****************************************************************************/ -ulong smb_getmsgtxtlen(smbmsg_t* msg) +uint smb_getmsgtxtlen(smbmsg_t* msg) { int i; - ulong length=0L; + uint length=0L; for(i=0;i<msg->total_hfields;i++) { switch(msg->hfield[i].type) { @@ -973,7 +973,7 @@ int smb_getmsghdr(smb_t* smb, smbmsg_t* msg) { void *vp,**vpp; size_t i; - long l,offset; + int l,offset; fileidxrec_t idx; if(smb->shd_fp==NULL) { @@ -990,7 +990,7 @@ int smb_getmsghdr(smb_t* smb, smbmsg_t* msg) safe_snprintf(smb->last_error,sizeof(smb->last_error) ,"%s %d '%s' seeking to offset %lu in header file", __FUNCTION__ ,get_errno(),STRERROR(get_errno()) - ,(ulong)msg->idx.offset); + ,(uint)msg->idx.offset); return(SMB_ERR_SEEK); } } @@ -1002,7 +1002,7 @@ int smb_getmsghdr(smb_t* smb, smbmsg_t* msg) msg->idx_offset=offset; if(smb_fread(smb,&msg->hdr,sizeof(msghdr_t),smb->shd_fp)!=sizeof(msghdr_t)) { safe_snprintf(smb->last_error,sizeof(smb->last_error) - ,"%s reading msg header at offset %lu", __FUNCTION__, (ulong)msg->idx.offset); + ,"%s reading msg header at offset %lu", __FUNCTION__, (uint)msg->idx.offset); return(SMB_ERR_READ); } if(memcmp(msg->hdr.msghdr_id,SHD_HEADER_ID,LEN_HEADER_ID)) { @@ -1012,13 +1012,13 @@ int smb_getmsghdr(smb_t* smb, smbmsg_t* msg) ,msg->hdr.msghdr_id[1] ,msg->hdr.msghdr_id[2] ,msg->hdr.msghdr_id[3] - ,(ulong)msg->idx.offset); + ,(uint)msg->idx.offset); return(SMB_ERR_HDR_ID); } if(msg->hdr.version<0x110) { safe_snprintf(smb->last_error,sizeof(smb->last_error) ,"%s insufficient header version: %X at offset %lu", __FUNCTION__ - ,msg->hdr.version, (ulong)msg->idx.offset); + ,msg->hdr.version, (uint)msg->idx.offset); return(SMB_ERR_HDR_VER); } l=sizeof(msg->hdr); @@ -1027,7 +1027,7 @@ int smb_getmsghdr(smb_t* smb, smbmsg_t* msg) smb_freemsgmem(msg); safe_snprintf(smb->last_error,sizeof(smb->last_error) ,"%s malloc failure of %ld bytes for %u data fields", __FUNCTION__ - ,(long)(sizeof(*msg->dfield) * msg->hdr.total_dfields), msg->hdr.total_dfields); + ,(int)(sizeof(*msg->dfield) * msg->hdr.total_dfields), msg->hdr.total_dfields); return(SMB_ERR_MEM); } i = fread(msg->dfield, sizeof(*msg->dfield), msg->hdr.total_dfields, smb->shd_fp); @@ -1039,7 +1039,7 @@ int smb_getmsghdr(smb_t* smb, smbmsg_t* msg) return(SMB_ERR_READ); } l += msg->hdr.total_dfields * sizeof(*msg->dfield); - while(l < (long)msg->hdr.length) { + while(l < (int)msg->hdr.length) { i=msg->total_hfields; if((vpp=(void* *)realloc(msg->hfield_dat,sizeof(void* )*(i+1)))==NULL) { smb_freemsgmem(msg); @@ -1166,7 +1166,7 @@ int smb_copymsgmem(smb_t* smb, smbmsg_t* msg, smbmsg_t* srcmsg) if(smb!=NULL) safe_snprintf(smb->last_error,sizeof(smb->last_error) ,"%s malloc failure of %ld bytes for %d data fields", __FUNCTION__ - ,(long)(msg->hdr.total_dfields*sizeof(dfield_t)), msg->hdr.total_dfields); + ,(int)(msg->hdr.total_dfields*sizeof(dfield_t)), msg->hdr.total_dfields); return(SMB_ERR_MEM); } memcpy(msg->dfield,srcmsg->dfield,msg->hdr.total_dfields*sizeof(dfield_t)); @@ -1178,7 +1178,7 @@ int smb_copymsgmem(smb_t* smb, smbmsg_t* msg, smbmsg_t* srcmsg) if(smb!=NULL) safe_snprintf(smb->last_error,sizeof(smb->last_error) ,"%s malloc failure of %ld bytes for %d header fields", __FUNCTION__ - ,(long)(msg->total_hfields*sizeof(hfield_t)), msg->total_hfields); + ,(int)(msg->total_hfields*sizeof(hfield_t)), msg->total_hfields); return(SMB_ERR_MEM); } memcpy(msg->hfield,srcmsg->hfield,msg->total_hfields*sizeof(hfield_t)); @@ -1188,7 +1188,7 @@ int smb_copymsgmem(smb_t* smb, smbmsg_t* msg, smbmsg_t* srcmsg) if(smb!=NULL) safe_snprintf(smb->last_error,sizeof(smb->last_error) ,"%s malloc failure of %ld bytes for %d header fields", __FUNCTION__ - ,(long)(msg->total_hfields*sizeof(void*)), msg->total_hfields); + ,(int)(msg->total_hfields*sizeof(void*)), msg->total_hfields); return(SMB_ERR_MEM); } @@ -1468,7 +1468,7 @@ int smb_new_hfield_str(smbmsg_t* msg, uint16_t type, const char* str) /* Automatically figures out the offset into the data buffer from existing */ /* dfield lengths */ /****************************************************************************/ -int smb_dfield(smbmsg_t* msg, uint16_t type, ulong length) +int smb_dfield(smbmsg_t* msg, uint16_t type, uint length) { dfield_t* dp; int i,j; @@ -1497,8 +1497,8 @@ int smb_addcrc(smb_t* smb, uint32_t crc) int wr; int result = SMB_SUCCESS; off_t length; - long newlen; - ulong l; + int newlen; + uint l; uint32_t *buf; time_t start=0; @@ -1521,7 +1521,7 @@ int smb_addcrc(smb_t* smb, uint32_t crc) if(time(NULL)-start>=(time_t)smb->retry_time) { safe_snprintf(smb->last_error,sizeof(smb->last_error) ,"%s timeout opening %s (retry_time=%lu)", __FUNCTION__ - ,str, (ulong)smb->retry_time); + ,str, (uint)smb->retry_time); return(SMB_ERR_TIMEOUT); } SLEEP(smb->retry_delay); @@ -1564,7 +1564,7 @@ int smb_addcrc(smb_t* smb, uint32_t crc) return(SMB_DUPE_MSG); } - if(length>=(long)(smb->status.max_crcs*sizeof(int32_t))) { + if(length>=(int)(smb->status.max_crcs*sizeof(int32_t))) { newlen=(smb->status.max_crcs-1)*sizeof(int32_t); if(chsize(file,0) != 0) { /* truncate it */ result = SMB_ERR_TRUNCATE; @@ -1582,7 +1582,7 @@ int smb_addcrc(smb_t* smb, uint32_t crc) if(wr!=sizeof(crc)) { safe_snprintf(smb->last_error,sizeof(smb->last_error) ,"%s %d '%s' writing %ld bytes", __FUNCTION__ - ,get_errno(),STRERROR(get_errno()),(long)sizeof(crc)); + ,get_errno(),STRERROR(get_errno()),(int)sizeof(crc)); return(SMB_ERR_WRITE); } @@ -1600,7 +1600,7 @@ int smb_addmsghdr(smb_t* smb, smbmsg_t* msg, int storage) { int i; off_t l; - ulong hdrlen; + uint hdrlen; off_t idxlen; size_t idxreclen = smb_idxreclen(smb); @@ -1849,10 +1849,10 @@ int smb_putmsgidx(smb_t* smb, smbmsg_t* msg) } clearerr(smb->sid_fp); length = filelength(fileno(smb->sid_fp)); - if(length < (long)(msg->idx_offset*idxreclen)) { + if(length < (int)(msg->idx_offset*idxreclen)) { safe_snprintf(smb->last_error,sizeof(smb->last_error) ,"%s invalid index offset: %ld, byte offset: %lu, length: %" PRIdOFF, __FUNCTION__ - ,(long)msg->idx_offset, msg->idx_offset*idxreclen, length); + ,(int)msg->idx_offset, msg->idx_offset*idxreclen, length); return(SMB_ERR_HDR_OFFSET); } if(fseek(smb->sid_fp,msg->idx_offset*idxreclen,SEEK_SET)) { @@ -1889,7 +1889,7 @@ int smb_putmsgidx(smb_t* smb, smbmsg_t* msg) int smb_putmsghdr(smb_t* smb, smbmsg_t* msg) { uint16_t i; - ulong hdrlen; + uint hdrlen; if(smb->shd_fp==NULL) { safe_snprintf(smb->last_error,sizeof(smb->last_error),"%s msgbase not open", __FUNCTION__); @@ -1903,7 +1903,7 @@ int smb_putmsghdr(smb_t* smb, smbmsg_t* msg) if(fseek(smb->shd_fp,msg->idx.offset,SEEK_SET)) { safe_snprintf(smb->last_error,sizeof(smb->last_error) ,"%s %d '%s' seeking to %lu in header file", __FUNCTION__ - ,get_errno(),STRERROR(get_errno()), (ulong)msg->idx.offset); + ,get_errno(),STRERROR(get_errno()), (uint)msg->idx.offset); return(SMB_ERR_SEEK); } /* Verify that the number of blocks required to stored the actual @@ -1955,7 +1955,7 @@ int smb_putmsghdr(smb_t* smb, smbmsg_t* msg) ,"%s writing header field", __FUNCTION__); return(SMB_ERR_WRITE); } - if(msg->hfield[i].length /* more then 0 bytes long */ + if(msg->hfield[i].length /* more then 0 bytes int */ && !fwrite(msg->hfield_dat[i],msg->hfield[i].length,1,smb->shd_fp)) { safe_snprintf(smb->last_error,sizeof(smb->last_error) ,"%s writing header field data", __FUNCTION__); @@ -1985,7 +1985,7 @@ int smb_initsmbhdr(smb_t* smb) safe_snprintf(smb->last_error,sizeof(smb->last_error),"%s msgbase not open", __FUNCTION__); return(SMB_ERR_NOT_OPEN); } - if(filelength(fileno(smb->shd_fp))>=(long)(sizeof(smbhdr_t)+sizeof(smbstatus_t)) + if(filelength(fileno(smb->shd_fp))>=(int)(sizeof(smbhdr_t)+sizeof(smbstatus_t)) && smb_locksmbhdr(smb)!=SMB_SUCCESS) /* header exists, so lock it */ return(SMB_ERR_LOCK); memset(&hdr,0,sizeof(smbhdr_t)); @@ -2030,7 +2030,7 @@ int smb_create(smb_t* smb) SAFEPRINTF(str,"%s.ini",smb->file); if((fp = fopen(str, "w")) != NULL) { - fprintf(fp, "Created = 0x%lx\n", (long)time(NULL)); + fprintf(fp, "Created = 0x%lx\n", (int)time(NULL)); fclose(fp); } SAFEPRINTF(str,"%s.sda",smb->file); @@ -2048,11 +2048,11 @@ int smb_create(smb_t* smb) /****************************************************************************/ /* Returns number of data blocks required to store "length" amount of data */ /****************************************************************************/ -ulong smb_datblocks(off_t length) +uint smb_datblocks(off_t length) { - ulong blocks; + uint blocks; - blocks=(ulong)(length / SDT_BLOCK_LEN); + blocks=(uint)(length / SDT_BLOCK_LEN); if(length%SDT_BLOCK_LEN) blocks++; return(blocks); @@ -2061,9 +2061,9 @@ ulong smb_datblocks(off_t length) /****************************************************************************/ /* Returns number of header blocks required to store "length" size header */ /****************************************************************************/ -ulong smb_hdrblocks(ulong length) +uint smb_hdrblocks(uint length) { - ulong blocks; + uint blocks; blocks=length/SHD_BLOCK_LEN; if(length%SHD_BLOCK_LEN) @@ -2095,10 +2095,10 @@ int smb_tzutc(int16_t zone) /****************************************************************************/ /* The caller needs to call smb_unlockmsghdr(smb,remsg) */ /****************************************************************************/ -int smb_updatethread(smb_t* smb, smbmsg_t* remsg, ulong newmsgnum) +int smb_updatethread(smb_t* smb, smbmsg_t* remsg, uint newmsgnum) { int retval=SMB_ERR_NOT_FOUND; - ulong nextmsgnum; + uint nextmsgnum; smbmsg_t nextmsg; if(!remsg->hdr.thread_first) { /* New msg is first reply */ diff --git a/src/smblib/smblib.h b/src/smblib/smblib.h index 95493f7487018d5976f9f82b43695ccf4821129e..61dcd207d8a5591de9ee8e2d1607f53058e35e50 100644 --- a/src/smblib/smblib.h +++ b/src/smblib/smblib.h @@ -123,9 +123,9 @@ SMBEXPORT int smb_unlocksmbhdr(smb_t*); SMBEXPORT int smb_getmsgidx(smb_t*, smbmsg_t*); SMBEXPORT int smb_getfirstidx(smb_t*, idxrec_t*); SMBEXPORT int smb_getlastidx(smb_t*, idxrec_t*); -SMBEXPORT ulong smb_getmsghdrlen(smbmsg_t*); -SMBEXPORT ulong smb_getmsgdatlen(smbmsg_t*); -SMBEXPORT ulong smb_getmsgtxtlen(smbmsg_t*); +SMBEXPORT uint smb_getmsghdrlen(smbmsg_t*); +SMBEXPORT uint smb_getmsgdatlen(smbmsg_t*); +SMBEXPORT uint smb_getmsgtxtlen(smbmsg_t*); SMBEXPORT int smb_lockmsghdr(smb_t*, smbmsg_t*); SMBEXPORT int smb_getmsghdr(smb_t*, smbmsg_t*); SMBEXPORT int smb_unlockmsghdr(smb_t*, smbmsg_t*); @@ -147,7 +147,7 @@ SMBEXPORT int smb_hfield_string(smbmsg_t*, uint16_t type, const char*); #define smb_hfield_str(msg, type, str) smb_hfield_add_str(msg, type, str, /* insert: */FALSE) #define smb_hfield_netaddr(msg, type, str, nettype) smb_hfield_add_netaddr(msg, type, str, nettype, /* insert: */FALSE) -SMBEXPORT int smb_dfield(smbmsg_t*, uint16_t type, ulong length); +SMBEXPORT int smb_dfield(smbmsg_t*, uint16_t type, uint length); SMBEXPORT void* smb_get_hfield(smbmsg_t*, uint16_t type, hfield_t** hfield); SMBEXPORT int smb_new_hfield(smbmsg_t*, uint16_t type, size_t, void* data); SMBEXPORT int smb_new_hfield_str(smbmsg_t*, uint16_t type, const char*); @@ -157,13 +157,13 @@ SMBEXPORT int smb_putmsgidx(smb_t*, smbmsg_t*); SMBEXPORT int smb_putmsghdr(smb_t*, smbmsg_t*); SMBEXPORT void smb_freemsgmem(smbmsg_t*); SMBEXPORT void smb_freemsghdrmem(smbmsg_t*); -SMBEXPORT ulong smb_hdrblocks(ulong length); -SMBEXPORT ulong smb_datblocks(off_t length); +SMBEXPORT uint smb_hdrblocks(uint length); +SMBEXPORT uint smb_datblocks(off_t length); SMBEXPORT int smb_copymsgmem(smb_t*, smbmsg_t* destmsg, smbmsg_t* srcmsg); SMBEXPORT int smb_tzutc(int16_t timezone); -SMBEXPORT int smb_updatethread(smb_t*, smbmsg_t* remsg, ulong newmsgnum); +SMBEXPORT int smb_updatethread(smb_t*, smbmsg_t* remsg, uint newmsgnum); SMBEXPORT int smb_updatemsg(smb_t*, smbmsg_t*); -SMBEXPORT BOOL smb_valid_hdr_offset(smb_t*, ulong offset); +SMBEXPORT BOOL smb_valid_hdr_offset(smb_t*, uint offset); SMBEXPORT int smb_init_idx(smb_t*, smbmsg_t*); SMBEXPORT uint16_t smb_voted_already(smb_t*, uint32_t msgnum, const char* name, enum smb_net_type, void* net_addr); SMBEXPORT BOOL smb_msg_is_from(smbmsg_t*, const char* name, enum smb_net_type net_type, const void* net_addr); @@ -178,42 +178,42 @@ SMBEXPORT size_t smb_msg_count(smb_t*, unsigned types); SMBEXPORT enum smb_msg_type smb_msg_type(smb_msg_attr_t); /* smbadd.c */ -SMBEXPORT int smb_addmsg(smb_t*, smbmsg_t*, int storage, long dupechk_hashes +SMBEXPORT int smb_addmsg(smb_t*, smbmsg_t*, int storage, int dupechk_hashes ,uint16_t xlat, const uchar* body, const uchar* tail); SMBEXPORT int smb_addvote(smb_t*, smbmsg_t*, int storage); SMBEXPORT int smb_addpoll(smb_t*, smbmsg_t*, int storage); SMBEXPORT int smb_addpollclosure(smb_t*, smbmsg_t*, int storage); /* smballoc.c */ -SMBEXPORT off_t smb_allochdr(smb_t*, ulong length); -SMBEXPORT off_t smb_fallochdr(smb_t*, ulong length); +SMBEXPORT off_t smb_allochdr(smb_t*, uint length); +SMBEXPORT off_t smb_fallochdr(smb_t*, uint length); SMBEXPORT off_t smb_hallochdr(smb_t*); SMBEXPORT off_t smb_allocdat(smb_t*, off_t length, uint16_t int16_trefs); SMBEXPORT off_t smb_fallocdat(smb_t*, off_t length, uint16_t refs); SMBEXPORT off_t smb_hallocdat(smb_t*); SMBEXPORT int smb_incmsg_dfields(smb_t*, smbmsg_t*, uint16_t refs); -SMBEXPORT int smb_incmsgdat(smb_t*, off_t offset, ulong length, uint16_t refs); +SMBEXPORT int smb_incmsgdat(smb_t*, off_t offset, uint length, uint16_t refs); SMBEXPORT int smb_freemsg(smb_t*, smbmsg_t*); SMBEXPORT int smb_freemsg_dfields(smb_t*, smbmsg_t*, uint16_t refs); -SMBEXPORT int smb_freemsgdat(smb_t*, off_t offset, ulong length, uint16_t refs); -SMBEXPORT int smb_freemsghdr(smb_t*, off_t offset, ulong length); +SMBEXPORT int smb_freemsgdat(smb_t*, off_t offset, uint length, uint16_t refs); +SMBEXPORT int smb_freemsghdr(smb_t*, off_t offset, uint length); SMBEXPORT void smb_freemsgtxt(char* buf); /* smbhash.c */ SMBEXPORT int smb_findhash(smb_t*, hash_t** compare_list, hash_t* found - ,long source_mask, BOOL mark); + ,int source_mask, BOOL mark); SMBEXPORT int smb_hashmsg(smb_t*, smbmsg_t*, const uchar* text, BOOL update); -SMBEXPORT hash_t* smb_hash(ulong msgnum, uint32_t time, unsigned source +SMBEXPORT hash_t* smb_hash(uint msgnum, uint32_t time, unsigned source ,unsigned flags, const void* data, size_t); -SMBEXPORT hash_t* smb_hashstr(ulong msgnum, uint32_t time, unsigned source +SMBEXPORT hash_t* smb_hashstr(uint msgnum, uint32_t time, unsigned source ,unsigned flags, const char* str); -SMBEXPORT hash_t** smb_msghashes(smbmsg_t*, const uchar* text, long source_mask); +SMBEXPORT hash_t** smb_msghashes(smbmsg_t*, const uchar* text, int source_mask); SMBEXPORT int smb_addhashes(smb_t*, hash_t** hash_list, BOOL skip_marked); SMBEXPORT uint16_t smb_name_crc(const char* name); SMBEXPORT uint16_t smb_subject_crc(const char *subj); SMBEXPORT void smb_freehashes(hash_t**); -SMBEXPORT long smb_getmsgidx_by_time(smb_t*, idxrec_t*, time_t); +SMBEXPORT int smb_getmsgidx_by_time(smb_t*, idxrec_t*, time_t); SMBEXPORT int smb_hashfile(const char* path, off_t, struct hash_data*); /* Fast look-up functions (using hashes) */ @@ -260,10 +260,10 @@ SMBEXPORT void smb_dump_msghdr(FILE*, smbmsg_t*); SMBEXPORT str_list_t smb_msghdr_str_list(smbmsg_t*); /* smbtxt.c */ -SMBEXPORT char* smb_getmsgtxt(smb_t*, smbmsg_t*, ulong mode); +SMBEXPORT char* smb_getmsgtxt(smb_t*, smbmsg_t*, uint mode); SMBEXPORT char* smb_getplaintext(smbmsg_t*, char* body); SMBEXPORT uint8_t* smb_getattachment(smbmsg_t*, char* body, char* filename, size_t filename_len, uint32_t* filelen, int index); -SMBEXPORT ulong smb_countattachments(smb_t*, smbmsg_t*, const char* body); +SMBEXPORT uint smb_countattachments(smb_t*, smbmsg_t*, const char* body); SMBEXPORT void smb_parse_content_type(const char* content_type, char** subtype, char** charset); /* smbfile.c */ @@ -277,7 +277,7 @@ SMBEXPORT off_t smb_ftell(FILE* fp); SMBEXPORT size_t smb_fread(smb_t*, void* buf, size_t bytes, FILE* fp); SMBEXPORT size_t smb_fwrite(smb_t*, const void* buf, size_t bytes, FILE* fp); SMBEXPORT off_t smb_fgetlength(FILE* fp); -SMBEXPORT int smb_fsetlength(FILE* fp, long length); +SMBEXPORT int smb_fsetlength(FILE* fp, off_t length); SMBEXPORT void smb_rewind(FILE* fp); SMBEXPORT void smb_clearerr(FILE* fp); SMBEXPORT int smb_open_fp(smb_t*, FILE**, int share); diff --git a/src/smblib/smbtxt.c b/src/smblib/smbtxt.c index 6bd41cb129eac9a135a83a104b1a20dcc8ffb7e8..23c8f7ff1199b1ee394b5f38bdd8b4f0cc9c2fec 100644 --- a/src/smblib/smbtxt.c +++ b/src/smblib/smbtxt.c @@ -28,7 +28,7 @@ #include "base64.h" #include "lzh.h" -char* smb_getmsgtxt(smb_t* smb, smbmsg_t* msg, ulong mode) +char* smb_getmsgtxt(smb_t* smb, smbmsg_t* msg, uint mode) { char* buf; char* preamble; @@ -38,7 +38,7 @@ char* smb_getmsgtxt(smb_t* smb, smbmsg_t* msg, ulong mode) uint16_t xlat; uint i; int lzh; /* BOOL */ - long l=0,lzhlen,length; + int l=0,lzhlen,length; if((buf=(char*)malloc(sizeof(char)))==NULL) { safe_snprintf(smb->last_error, sizeof(smb->last_error) @@ -592,12 +592,12 @@ uint8_t* smb_getattachment(smbmsg_t* msg, char* buf, char* filename, size_t file /* Return number of file attachments contained in MIME-encoded message body */ /* 'body' may be NULL if the body text is not already read/available */ -ulong smb_countattachments(smb_t* smb, smbmsg_t* msg, const char* body) +uint smb_countattachments(smb_t* smb, smbmsg_t* msg, const char* body) { if(msg->mime_version == NULL || msg->content_type == NULL) /* not MIME */ return 0; - ulong count = 0; + uint count = 0; char* buf; if(body == NULL) diff --git a/src/xpdev/filewrap.h b/src/xpdev/filewrap.h index dba8080831266829b1cd9c7fde1ee83c30559cdf..64a93ebabb4e82773ee76bc78883d3814cfdb897 100644 --- a/src/xpdev/filewrap.h +++ b/src/xpdev/filewrap.h @@ -58,6 +58,8 @@ #define SH_COMPAT 0 #endif + #define chsize(fd,size) _chsize_s(fd,size) + #if defined(_FILE_OFFSET_BITS) && (_FILE_OFFSET_BITS==64) #define lseek _lseeki64 #define tell _telli64