Changed time_t type to time32_t

This commit is contained in:
Ianos Gnatiuc
2005-10-20 21:10:42 +00:00
parent d8a855aa42
commit 44c26c3b0a
34 changed files with 1392 additions and 1369 deletions

View File

@@ -155,7 +155,7 @@ inline int is_dir(const std::string& path) { return is_dir(path.c_str()); }
inline bool fexist(const char* filename) { return *filename ? ((access(filename, R_OK) == 0) and not is_dir(filename)) : false; }
inline bool fexist(const std::string& filename) { return fexist(filename.c_str()); }
dword gfixstattime(time_t st_time);
dword gfixstattime(time32_t st_time);
dword GetFiletime(const char* file);
inline dword GetFiletime(const std::string& file) { return GetFiletime(file.c_str()); }

View File

@@ -96,7 +96,7 @@ long GetFilesize(const char* file) {
// ------------------------------------------------------------------
// Convert time returned with stat to FFTime
dword gfixstattime(time_t st_time) {
dword gfixstattime(time32_t st_time) {
#if (defined(__MINGW32__) && !defined(__MSVCRT__)) || defined(__CYGWIN__)
struct tm &f = *ggmtime(&st_time);

View File

@@ -36,7 +36,7 @@
struct tm* glog::time_now;
int glog::count = 0;
time_t glog::secs_now;
time32_t glog::secs_now;
char glog::timebuf[20];
@@ -108,7 +108,7 @@ void glog::printf(const char* format, ...) {
char buf[256];
char logbuf[256];
secs_now = time(NULL);
secs_now = gtime(NULL);
time_now = glocaltime(&secs_now);
lineswritten++;

View File

@@ -61,7 +61,7 @@ private:
static int count;
static struct tm* time_now;
static time_t secs_now;
static time32_t secs_now;
static char timebuf[20];
protected:

View File

@@ -123,40 +123,54 @@ extern const char* gmonths[];
// ------------------------------------------------------------------
// Prototypes
inline struct tm *ggmtime(const time_t *timep)
inline struct tm *ggmtime(const time32_t *timep)
{
const time_t temp(*timep);
#if defined(__WIN32__)
const time_t zero(0);
struct tm *time = gmtime(timep);
struct tm *time = gmtime(&temp);
return time ? time : gmtime(&zero);
#else
return gmtime(&timep);
return gmtime(&temp);
#endif
}
inline struct tm* glocaltime(const time_t *timep)
inline struct tm *glocaltime(const time32_t *timep)
{
const time_t temp(*timep);
#if defined(__WIN32__)
const time_t zero(0);
struct tm *time = localtime(timep);
struct tm *time = localtime(&temp);
return time ? time : localtime(&zero);
#else
return localtime(timep);
return localtime(&temp);
#endif
}
inline struct tm* ggmtime(const time32_t *timep)
inline char *gctime(const time32_t *timep)
{
const time_t temp(*timep);
return ggmtime(&temp);
#if defined(__WIN32__)
const time_t zero(0);
char *time = ctime(&temp);
return time ? time : ctime(&zero);
#else
return ctime(&temp);
#endif
}
inline struct tm* glocaltime(const time32_t *timep)
inline time32_t gtime(time32_t *timep)
{
const time_t temp(*timep);
return glocaltime(&temp);
time32_t temp = (time32_t)time(NULL);
return timep ? *timep = temp : temp;
}
inline time32_t gmktime(struct tm *timep)
{
return (time32_t)mktime(timep);
}
#if defined(__OS2__)
inline void usleep(long duration) { DosSleep(duration); }
#elif defined(__MINGW32__) || defined(_MSC_VER)
@@ -178,13 +192,13 @@ int tzoffset();
char* strftimei(char* s, size_t maxsize, const char* fmt, const struct tm* t); // __attribute__ ((format (strftime, 3, 0)));
FTime TimeToFTime(time_t __time) __attribute__ ((const));
time_t FTimeToTime(FTime* __ftime, struct tm* __tm=NULL);
FTime TimeToFTime(time32_t __time) __attribute__ ((const));
time32_t FTimeToTime(FTime* __ftime, struct tm* __tm=NULL);
time_t FidoTimeToUnix(char* __fidotime);
time32_t FidoTimeToUnix(char* __fidotime);
char* FTimeToStr(char* buf, FTime &t);
char* TimeToStr(char* buf, time_t t);
char* TimeToStr(char* buf, time32_t t);
// ------------------------------------------------------------------

View File

@@ -60,10 +60,10 @@ const char* gmonths[] = {
int tzoffset() {
time_t t1 = time(NULL);
time32_t t1 = gtime(NULL);
struct tm *tp = ggmtime(&t1);
tp->tm_isdst=-1;
time_t t2 = mktime(tp);
tp->tm_isdst = -1;
time32_t t2 = gmktime(tp);
int dt = (int)(t1 - t2);
return (dt / 3600) * 100 + (dt % 3600) / 60;
}
@@ -329,7 +329,7 @@ int str2mon(const char* ptr) {
// ------------------------------------------------------------------
time_t FTimeToTime(FTime* __ftime, struct tm* __tm) {
time32_t FTimeToTime(FTime* __ftime, struct tm* __tm) {
struct tm _tm;
ulong _time = 0;
@@ -350,10 +350,10 @@ time_t FTimeToTime(FTime* __ftime, struct tm* __tm) {
__tm->tm_sec = __ftime->ft_tsec * 2;
__tm->tm_isdst = -1;
time_t a = mktime(__tm);
time32_t a = gmktime(__tm);
struct tm *tp = ggmtime(&a);
tp->tm_isdst = -1;
time_t b = mktime(tp);
tp->tm_isdst = -1;
time32_t b = gmktime(tp);
_time = a + a - b;
if(_time == (ulong)0xFFFFFFFFL)
@@ -368,7 +368,7 @@ time_t FTimeToTime(FTime* __ftime, struct tm* __tm) {
// ------------------------------------------------------------------
FTime TimeToFTime(time_t __time) {
FTime TimeToFTime(time32_t __time) {
FTime _ft;
memset(&_ft, 0, sizeof(FTime));
@@ -390,7 +390,7 @@ FTime TimeToFTime(time_t __time) {
// ------------------------------------------------------------------
time_t FidoTimeToUnix(char* ptr) {
time32_t FidoTimeToUnix(char* ptr) {
bool date_ok = false;
int year=0, month=0, day=0;
@@ -441,10 +441,10 @@ time_t FidoTimeToUnix(char* ptr) {
t.tm_min = minute;
t.tm_sec = second;
t.tm_isdst = -1;
time_t a = mktime(&t);
time32_t a = gmktime(&t);
struct tm *tp = ggmtime(&a);
tp->tm_isdst = -1;
time_t b = mktime(tp);
tp->tm_isdst = -1;
time32_t b = gmktime(tp);
return a + a - b;
}
return (ulong)-1;
@@ -453,7 +453,7 @@ time_t FidoTimeToUnix(char* ptr) {
// ------------------------------------------------------------------
char* TimeToStr(char* buf, time_t t) {
char* TimeToStr(char* buf, time32_t t) {
return strftimei(buf, 20, "%Y-%m-%d %H:%M:%S", ggmtime(&t));
}

View File

@@ -300,9 +300,9 @@ struct areas_record_type {
byte days; /* days to keep messages */
word msgs; /* num messages to keep */
struct im_stats stats; /* statistics */
time_t creation; /* date/time of statistic start */
time_t update; /* last update by midnight update */
time_t marked; /* used by kill dead */
time32_t creation; /* date/time of statistic start */
time32_t update; /* last update by midnight update */
time32_t marked; /* used by kill dead */
byte kill_dead; /* kill echos without traffic */
word read_sec; /* Security level for read access */
word write_sec; /* Security level for write access */

View File

@@ -229,7 +229,7 @@ struct im_config_type {
bit ulnk_hudson_passth:1; /* unlinked Hudson areas passth */
bit compr_before_unpack:1; /* compress before unpacking */
bit rsvd3:1; /* reserved */
time_t last_run; /* last maintenance run */
time32_t last_run; /* last maintenance run */
word rsvd4; /* reserved */
byte rsvd5; /* reserved */
byte rsvd6; /* reserved */
@@ -322,9 +322,9 @@ struct areas_record_type
byte days; /* days to keep messages */
word msgs; /* num messages to keep */
struct im_stats stats; /* statistics */
time_t creation; /* date/time of statistic start */
time_t update; /* last update by midnight update */
time_t marked; /* used by kill dead */
time32_t creation; /* date/time of statistic start */
time32_t update; /* last update by midnight update */
time32_t marked; /* used by kill dead */
byte kill_dead; /* kill echos without traffic */
word read_sec; /* Security level for read access */
word write_sec; /* Security level for write access */

View File

@@ -505,10 +505,10 @@ typedef struct _user_info
USHORT computer_type;
ULONG userid;
USHORT pointid;
time_t initial_logon;
time_t expires;
time_t last_logon;
time_t logon_today;
time32_t initial_logon;
time32_t expires;
time32_t last_logon;
time32_t logon_today;
USHORT birthyear;
UCHAR birthmonth;
UCHAR birthday;
@@ -551,8 +551,8 @@ typedef struct _user_info
SHORT CallsToday;
LONG TotalMinsEver;
LONG NetmailDebits;
time_t LastPWChange;
time_t LastListedNewFiles; //JM940822
time32_t LastPWChange;
time32_t LastListedNewFiles; //JM940822
ULONG FileKCredit;
CHAR UnixId[8];
CHAR Country[24];
@@ -591,7 +591,7 @@ typedef struct _xmsg
CHAR indate[4]; /* import date (YMD(null)) */
ULONG msgnum;
ULONG timesread;
time_t timerecv;
time32_t timerecv;
ULONG length; /* Length of message */
LONG start; /* Starting postition in text file */
ULONG OrigMsg;

View File

@@ -97,10 +97,10 @@ int FidoArea::load_message(int __mode, gmsg* __msg, FidoHdr& __hdr) {
__msg->written = __msg->written ? __msg->written : FidoTimeToUnix(__hdr.datetime);
if(__msg->arrived == 0) {
time_t a = time(NULL);
time32_t a = gtime(NULL);
struct tm *tp = ggmtime(&a);
tp->tm_isdst = -1;
time_t b = mktime(tp);
tp->tm_isdst = -1;
time32_t b = gmktime(tp);
__msg->arrived = a + a - b;
}

View File

@@ -134,10 +134,10 @@ int _HudsArea<msgn_t, rec_t, attr_t, board_t, last_t, __HUDSON>::load_message(in
_tm.tm_min = _minute;
_tm.tm_sec = 0;
_tm.tm_isdst = -1;
time_t a = mktime(&_tm);
time32_t a = gmktime(&_tm);
struct tm *tp = ggmtime(&a);
tp->tm_isdst = -1;
time_t b = mktime(tp);
tp->tm_isdst = -1;
time32_t b = gmktime(tp);
__msg->written = a + a - b;
__msg->arrived = 0;

View File

@@ -152,10 +152,10 @@ void JamArea::open_area() {
// Initialize header info
memcpy(data->hdrinfo.signature, JAM_SIGNATURE, 4);
time_t a = time(NULL);
time32_t a = gtime(NULL);
struct tm *tp = ggmtime(&a);
tp->tm_isdst = -1;
time_t b = mktime(tp);
tp->tm_isdst = -1;
time32_t b = gmktime(tp);
data->hdrinfo.datecreated = a + a - b;
data->hdrinfo.passwordcrc = 0xFFFFFFFFL;
data->hdrinfo.basemsgnum = 1;

View File

@@ -79,10 +79,10 @@ int PcbArea::load_message(int __mode, gmsg* __msg, PcbHdr& __hdr) {
_tm.tm_min = _minute;
_tm.tm_sec = 0;
_tm.tm_isdst = -1;
time_t a = mktime(&_tm);
time32_t a = gmktime(&_tm);
struct tm *tp = ggmtime(&a);
tp->tm_isdst = -1;
time_t b = mktime(tp);
tp->tm_isdst = -1;
time32_t b = gmktime(tp);
__msg->written = a + a - b;
__msg->arrived = 0;

View File

@@ -324,13 +324,13 @@ int SMBArea::load_hdr(gmsg* __msg, smbmsg_t *smsg)
__msg->attr.cfm(smsgp->hdr.auxattr & MSG_CONFIRMREQ);
__msg->attr.tfs(smsgp->hdr.auxattr & MSG_TRUNCFILE);
time_t a = smsgp->hdr.when_written.time;
time32_t a = smsgp->hdr.when_written.time;
struct tm *tp = ggmtime(&a);
tp->tm_isdst = -1;
time_t b = mktime(tp);
tp->tm_isdst = -1;
time32_t b = gmktime(tp);
__msg->written = a + a - b;
a = smsgp->hdr.when_imported.time;
b = mktime(ggmtime(&a));
b = gmktime(ggmtime(&a));
__msg->arrived = a + a - b;
__msg->received = 0;
@@ -538,9 +538,9 @@ void SMBArea::save_hdr(int mode, gmsg* msg)
smsg.hdr.version = smb_ver();
struct tm *tp = ggmtime(&msg->written);
tp->tm_isdst = -1;
smsg.hdr.when_written.time = mktime(tp);
smsg.hdr.when_written.time = gmktime(tp);
}
smsg.hdr.when_imported.time = time(NULL);
smsg.hdr.when_imported.time = gtime(NULL);
// Transfer attributes
if(msg->attr.pvt()) smsg.hdr.attr |= MSG_PRIVATE;
@@ -968,9 +968,9 @@ Line* SMBArea::make_dump_msg(Line*& lin, gmsg* msg, char* lng_head)
line = AddLineF(line, "Attr : %04Xh", smsg.hdr.attr);
line = AddLineF(line, "AUXAttr : %04Xh", smsg.hdr.auxattr);
line = AddLineF(line, "NetAttr : %04Xh", smsg.hdr.netattr);
stpcpy(buf, ctime((time_t *)&smsg.hdr.when_written.time))[-1] = NUL;
stpcpy(buf, gctime(&smsg.hdr.when_written.time))[-1] = NUL;
line = AddLineF(line, "Written : %s", buf);
stpcpy(buf, ctime((time_t *)&smsg.hdr.when_imported.time))[-1] = NUL;
stpcpy(buf, gctime(&smsg.hdr.when_imported.time))[-1] = NUL;
line = AddLineF(line, "Imported : %s", buf);
line = AddLineF(line, "Number : %d (%d)", smsg.hdr.number, (int32_t)(ftell(data->sid_fp)/sizeof(idxrec_t)));
line = AddLineF(line, "Thread orig : %d", smsg.hdr.thread_orig);

View File

@@ -128,7 +128,7 @@ int SquishArea::load_message(int __mode, gmsg* __msg, SqshHdr& __hdr) {
__msg->dest.point = __msg->odest.point = __hdr.dest.point;
// Convert date and time
time_t _written = FTimeToTime(&__hdr.date_written);
time32_t _written = FTimeToTime(&__hdr.date_written);
__msg->written = _written ? _written : FidoTimeToUnix(__hdr.ftsc_date);
__msg->arrived = FTimeToTime(&__hdr.date_arrived);

View File

@@ -103,10 +103,10 @@ int WCatArea::load_message(int __mode, gmsg* __msg, WCatHdr& __hdr) {
_tm.tm_min = _minute;
_tm.tm_sec = _second;
_tm.tm_isdst = -1;
time_t a = mktime(&_tm);
time32_t a = gmktime(&_tm);
struct tm *tp = ggmtime(&a);
tp->tm_isdst = -1;
time_t b = mktime(tp);
tp->tm_isdst = -1;
time32_t b = gmktime(tp);
__msg->written = a + a - b;
}
@@ -123,10 +123,10 @@ int WCatArea::load_message(int __mode, gmsg* __msg, WCatHdr& __hdr) {
_tm.tm_min = _minute;
_tm.tm_sec = _second;
_tm.tm_isdst = -1;
time_t a = mktime(&_tm);
time32_t a = gmktime(&_tm);
struct tm *tp = ggmtime(&a);
tp->tm_isdst = -1;
time_t b = mktime(tp);
tp->tm_isdst = -1;
time32_t b = gmktime(tp);
__msg->received = a + a - b;
}

View File

@@ -72,10 +72,10 @@ int XbbsArea::load_message(int __mode, gmsg* __msg, XbbsHdr& __hdr) {
t.tm_mday = __hdr.indate[2];
t.tm_hour = t.tm_min = t.tm_sec = 0;
t.tm_isdst = -1;
time_t a = mktime(&t);
time32_t a = gmktime(&t);
struct tm *tp = ggmtime(&a);
tp->tm_isdst = -1;
time_t b = mktime(tp);
tp->tm_isdst = -1;
time32_t b = gmktime(tp);
__msg->arrived = a + a - b;
}

View File

@@ -82,6 +82,7 @@ typedef int16_t sshort;
typedef uint16_t ushort;
typedef uint32_t dword;
typedef uint32_t time32_t; /* 32-bit time_t type */
#endif //#ifndef __goldall_h

File diff suppressed because it is too large Load Diff