From 92cb0a973d31e024e0cb89b351e33e0941d077b2 Mon Sep 17 00:00:00 2001
From: deuce <>
Date: Sun, 8 Jul 2007 20:53:04 +0000
Subject: [PATCH] 64-bit

---
 src/sbbs3/filedat.c  |   9 ++--
 src/sbbs3/ftpsrvr.c  |   4 +-
 src/smblib/smbdefs.h | 121 ++++++++++++++++++++++---------------------
 3 files changed, 68 insertions(+), 66 deletions(-)

diff --git a/src/sbbs3/filedat.c b/src/sbbs3/filedat.c
index 3e0e4682a1..e7bae39b3d 100644
--- a/src/sbbs3/filedat.c
+++ b/src/sbbs3/filedat.c
@@ -224,6 +224,7 @@ BOOL DLLCALL addfiledat(scfg_t* cfg, file_t* f)
 	SAFEPRINTF2(str,"%s%s.dab",cfg->dir[f->dir]->data_dir,cfg->dir[f->dir]->code);
 	if((file=sopen(str,O_WRONLY|O_CREAT|O_BINARY,SH_DENYRW,S_IREAD|S_IWRITE))!=-1) {
 		now=time(NULL);
+		/* TODO: 32-bit *or* LE required */
 		write(file,&now,4);
 		close(file); 
 	}
@@ -293,7 +294,7 @@ BOOL DLLCALL addfiledat(scfg_t* cfg, file_t* f)
 			free((char *)ixbbuf);
 			return(FALSE); 
 		}
-		write(file,&f->dateuled,sizeof(time_t));
+		write(file,&f->dateuled,4);
 		write(file,&f->datedled,4);              /* Write 0 for datedled */
 		if(lwrite(file,&ixbbuf[l],length-l)!=length-l) { /* Write rest of IXB */
 			close(file);
@@ -310,7 +311,7 @@ BOOL DLLCALL addfiledat(scfg_t* cfg, file_t* f)
 			close(file);
 			return(FALSE); 
 		}
-		write(file,&f->dateuled,sizeof(time_t));
+		write(file,&f->dateuled,4);
 		write(file,&f->datedled,4); 
 	}
 	length=filelength(file);
@@ -416,8 +417,8 @@ BOOL DLLCALL putfileixb(scfg_t* cfg, file_t* f)
 	
 	lseek(file,l+11+3,SEEK_SET);
 
-	write(file,&f->dateuled,sizeof(f->dateuled));
-	write(file,&f->datedled,sizeof(f->datedled));
+	write(file,&f->dateuled,4);
+	write(file,&f->datedled,4);
 
 	close(file);
 
diff --git a/src/sbbs3/ftpsrvr.c b/src/sbbs3/ftpsrvr.c
index 1e3ba13f6f..6589815919 100644
--- a/src/sbbs3/ftpsrvr.c
+++ b/src/sbbs3/ftpsrvr.c
@@ -1040,7 +1040,7 @@ BOOL upload_stats(ulong bytes)
 {
 	char	str[MAX_PATH+1];
 	int		file;
-	ulong	val;
+	uint32_t	val;
 
 	sprintf(str,"%sdsts.dab",scfg.ctrl_dir);
 	if((file=nopen(str,O_RDWR))==-1) 
@@ -1063,7 +1063,7 @@ BOOL download_stats(ulong bytes)
 {
 	char	str[MAX_PATH+1];
 	int		file;
-	ulong	val;
+	uint32_t	val;
 
 	sprintf(str,"%sdsts.dab",scfg.ctrl_dir);
 	if((file=nopen(str,O_RDWR))==-1) 
diff --git a/src/smblib/smbdefs.h b/src/smblib/smbdefs.h
index 894c26abf5..01e553d386 100644
--- a/src/smblib/smbdefs.h
+++ b/src/smblib/smbdefs.h
@@ -416,20 +416,20 @@ enum {
 
 typedef struct _PACK {		/* Time with time-zone */
 
-	ulong	time;			/* Local time (unix format) */
-	short	zone;			/* Time zone */
+	uint32_t	time;			/* Local time (unix format) */
+	int16_t		zone;			/* Time zone */
 
 } when_t;
 
 typedef struct _PACK {		/* Index record */
 
-	ushort	to; 			/* 16-bit CRC of recipient name (lower case) */
-	ushort	from;			/* 16-bit CRC of sender name (lower case) */
-	ushort	subj;			/* 16-bit CRC of subject (lower case, w/o RE:) */
-	ushort	attr;			/* attributes (read, permanent, etc.) */
-	ulong	offset; 		/* offset into header file */
-	ulong	number; 		/* number of message (1 based) */
-	ulong	time;			/* time/date message was imported/posted */
+	uint16_t	to; 			/* 16-bit CRC of recipient name (lower case) */
+	uint16_t	from;			/* 16-bit CRC of sender name (lower case) */
+	uint16_t	subj;			/* 16-bit CRC of subject (lower case, w/o RE:) */
+	uint16_t	attr;			/* attributes (read, permanent, etc.) */
+	uint32_t	offset; 		/* offset into header file */
+	uint32_t	number; 		/* number of message (1 based) */
+	uint32_t	time;			/* time/date message was imported/posted */
 
 } idxrec_t;
 
@@ -461,13 +461,13 @@ enum {
 
 typedef struct _PACK {
 
-	ulong	number;					/* Message number */
-	ulong	time;					/* Local time of fingerprinting */
-	ulong	length;					/* Length (in bytes) of source */
+	uint32_t	number;					/* Message number */
+	uint32_t	time;					/* Local time of fingerprinting */
+	uint32_t	length;					/* Length (in bytes) of source */
 	uchar	source;					/* SMB_HASH_SOURCE* (in low 5-bits) */
 	uchar	flags;					/* indications of valid hashes and pre-processing */
-	ushort	crc16;					/* CRC-16 of source */
-	ulong	crc32;					/* CRC-32 of source */
+	uint16_t	crc16;					/* CRC-16 of source */
+	uint32_t	crc32;					/* CRC-32 of source */
 	uchar	md5[MD5_DIGEST_SIZE];	/* MD5 digest of source */
 	uchar	reserved[28];			/* sizeof(hash_t) = 64 */
 
@@ -476,44 +476,44 @@ typedef struct _PACK {
 typedef struct _PACK {		/* Message base header (fixed portion) */
 
     uchar   id[LEN_HEADER_ID];	/* SMB<^Z> */
-    ushort  version;        /* version number (initially 100h for 1.00) */
-    ushort  length;         /* length including this struct */
+    uint16_t  version;        /* version number (initially 100h for 1.00) */
+    uint16_t  length;         /* length including this struct */
 
 } smbhdr_t;
 
 typedef struct _PACK {		/* Message base status header */
 
-	ulong	last_msg;		/* last message number */
-	ulong	total_msgs; 	/* total messages */
-	ulong	header_offset;	/* byte offset to first header record */
-	ulong	max_crcs;		/* Maximum number of CRCs to keep in history */
-    ulong   max_msgs;       /* Maximum number of message to keep in sub */
-    ushort  max_age;        /* Maximum age of message to keep in sub (in days) */
-	ushort	attr;			/* Attributes for this message base (SMB_HYPER,etc) */
+	uint32_t	last_msg;		/* last message number */
+	uint32_t	total_msgs; 	/* total messages */
+	uint32_t	header_offset;	/* byte offset to first header record */
+	uint32_t	max_crcs;		/* Maximum number of CRCs to keep in history */
+    uint32_t   max_msgs;       /* Maximum number of message to keep in sub */
+    uint16_t  max_age;        /* Maximum age of message to keep in sub (in days) */
+	uint16_t	attr;			/* Attributes for this message base (SMB_HYPER,etc) */
 
 } smbstatus_t;
 
 typedef struct _PACK {		/* Message header */
 
 	/* 00 */ uchar	id[LEN_HEADER_ID];	/* SHD<^Z> */
-    /* 04 */ ushort	type;				/* Message type (normally 0) */
-    /* 06 */ ushort	version;			/* Version of type (initially 100h for 1.00) */
-    /* 08 */ ushort	length;				/* Total length of fixed record + all fields */
-	/* 0a */ ushort	attr;				/* Attributes (bit field) (duped in SID) */
-	/* 0c */ ulong	auxattr;			/* Auxillary attributes (bit field) */
-    /* 10 */ ulong	netattr;			/* Network attributes */
+    /* 04 */ uint16_t	type;				/* Message type (normally 0) */
+    /* 06 */ uint16_t	version;			/* Version of type (initially 100h for 1.00) */
+    /* 08 */ uint16_t	length;				/* Total length of fixed record + all fields */
+	/* 0a */ uint16_t	attr;				/* Attributes (bit field) (duped in SID) */
+	/* 0c */ uint32_t	auxattr;			/* Auxillary attributes (bit field) */
+    /* 10 */ uint32_t	netattr;			/* Network attributes */
 	/* 14 */ when_t	when_written;		/* Date/time/zone message was written */
 	/* 1a */ when_t	when_imported;		/* Date/time/zone message was imported */
-    /* 20 */ ulong	number;				/* Message number */
-    /* 24 */ ulong	thread_back;		/* Message number for backwards threading (aka thread_orig) */
-    /* 28 */ ulong	thread_next;		/* Next message in thread */
-    /* 2c */ ulong	thread_first;		/* First reply to this message */
-	/* 30 */ ushort	delivery_attempts;	/* Delivery attempt counter */
-	/* 32 */ ulong	times_downloaded;	/* Total number of times downloaded */
-	/* 36 */ ulong	last_downloaded;	/* Date/time of last download */
+    /* 20 */ uint32_t	number;				/* Message number */
+    /* 24 */ uint32_t	thread_back;		/* Message number for backwards threading (aka thread_orig) */
+    /* 28 */ uint32_t	thread_next;		/* Next message in thread */
+    /* 2c */ uint32_t	thread_first;		/* First reply to this message */
+	/* 30 */ uint16_t	delivery_attempts;	/* Delivery attempt counter */
+	/* 32 */ uint32_t	times_downloaded;	/* Total number of times downloaded */
+	/* 36 */ uint32_t	last_downloaded;	/* Date/time of last download */
 	/* 3a */ uchar	reserved[6];		/* Reserved for future use */
-    /* 40 */ ulong	offset;				/* Offset for buffer into data file (0 or mod 256) */
-	/* 44 */ ushort	total_dfields;		/* Total number of data fields */
+    /* 40 */ uint32_t	offset;				/* Offset for buffer into data file (0 or mod 256) */
+	/* 44 */ uint16_t	total_dfields;		/* Total number of data fields */
 
 } msghdr_t;
 
@@ -521,25 +521,25 @@ typedef struct _PACK {		/* Message header */
 
 typedef struct _PACK {		/* Data field */
 
-	ushort	type;			/* Type of data field */
-    ulong   offset;         /* Offset into buffer */ 
-    ulong   length;         /* Length of data field */
+	uint16_t	type;			/* Type of data field */
+    uint32_t   offset;         /* Offset into buffer */ 
+    uint32_t   length;         /* Length of data field */
 
 } dfield_t;
 
 typedef struct _PACK {		/* Header field */
 
-	ushort	type;
-	ushort	length; 		/* Length of buffer */
+	uint16_t	type;
+	uint16_t	length; 		/* Length of buffer */
 
 } hfield_t;
 
 typedef struct _PACK {		/* FidoNet address (zone:net/node.point) */
 
-	ushort	zone;
-	ushort	net;
-	ushort	node;
-	ushort	point;
+	uint16_t	zone;
+	uint16_t	net;
+	uint16_t	node;
+	uint16_t	point;
 
 } fidoaddr_t;
 
@@ -549,7 +549,7 @@ typedef struct _PACK {		/* FidoNet address (zone:net/node.point) */
 
 typedef struct {		/* Network (type and address) */
 
-    ushort  type;
+    uint16_t  type;
 	void	*addr;
 
 } net_t;
@@ -582,22 +582,23 @@ typedef struct {				/* Message */
 				*ftn_reply;		/* FTN REPLY */
 	char*		summary;		/* Summary  */
 	char*		subj;			/* Subject  */
-	ushort		to_agent,		/* Type of agent message is to */
+	uint16_t		to_agent,		/* Type of agent message is to */
 				from_agent, 	/* Type of agent message is from */
 				replyto_agent;	/* Type of agent replies should be sent to */
 	net_t		to_net, 		/* Destination network type and address */
                 from_net,       /* Origin network address */
                 replyto_net;    /* Network type and address for replies */
-	ushort		total_hfields;	/* Total number of header fields */
+	uint16_t		total_hfields;	/* Total number of header fields */
 	hfield_t	*hfield;		/* Header fields (fixed length portion) */
 	void		**hfield_dat;	/* Header fields (variable length portion) */
 	dfield_t	*dfield;		/* Data fields (fixed length portion) */
-	long		offset; 		/* Offset (number of records) into index */
+	int32_t		offset; 		/* Offset (number of records) into index */
+	/* TODO: Should this be a BOOL? */
 	int			forwarded;		/* Forwarded from agent to another */
-	ulong		expiration; 	/* Message will expire on this day (if >0) */
-	ulong		priority;		/* Message priority (0 is lowest) */
-	ulong		cost;			/* Cost to download/read */
-	ulong		flags;			/* Various smblib run-time flags (see MSG_FLAG_*) */
+	uint32_t		expiration; 	/* Message will expire on this day (if >0) */
+	uint32_t		priority;		/* Message priority (0 is lowest) */
+	uint32_t		cost;			/* Cost to download/read */
+	uint32_t		flags;			/* Various smblib run-time flags (see MSG_FLAG_*) */
 
 } smbmsg_t;
 
@@ -610,16 +611,16 @@ typedef struct {			/* Message base */
     FILE*	sda_fp;			/* File pointer for data allocation (.sda) file */
     FILE*	sha_fp;			/* File pointer for header allocation (.sha) file */
 	FILE*	hash_fp;		/* File pointer for hash (.hash) file */
-	ulong	retry_time; 	/* Maximum number of seconds to retry opens/locks */
-	ulong	retry_delay;	/* Time-slice yield (milliseconds) while retrying */
+	uint32_t	retry_time; 	/* Maximum number of seconds to retry opens/locks */
+	uint32_t	retry_delay;	/* Time-slice yield (milliseconds) while retrying */
 	smbstatus_t status; 	/* Status header record */
 	BOOL	locked;			/* SMB header is locked */
 	char	last_error[MAX_PATH*2];		/* Last error message */
 
 	/* Private member variables (not initialized by or used by smblib) */
-	uint	subnum;			/* Sub-board number */
-	long	msgs;			/* Number of messages loaded (for user) */
-	long	curmsg;			/* Current message number (for user) */
+	uint32_t	subnum;			/* Sub-board number */
+	int32_t	msgs;			/* Number of messages loaded (for user) */
+	int32_t	curmsg;			/* Current message number (for user) */
 
 } smb_t;
 
-- 
GitLab