All gmtime and localtime calls was rewritten to internal defined functions
This commit is contained in:
@@ -99,9 +99,9 @@ long GetFilesize(const char* file) {
|
||||
dword gfixstattime(time_t st_time) {
|
||||
|
||||
#if (defined(__MINGW32__) && !defined(__MSVCRT__)) || defined(__CYGWIN__)
|
||||
struct tm &f = *gmtime(&st_time);
|
||||
struct tm &f = *ggmtime(&st_time);
|
||||
#else
|
||||
struct tm &f = *localtime(&st_time);
|
||||
struct tm &f = *glocaltime(&st_time);
|
||||
#endif
|
||||
FFTime t;
|
||||
t.ft_year = f.tm_year - 80;
|
||||
|
@@ -109,7 +109,7 @@ void glog::printf(const char* format, ...) {
|
||||
char logbuf[256];
|
||||
|
||||
secs_now = time(NULL);
|
||||
time_now = localtime(&secs_now);
|
||||
time_now = glocaltime(&secs_now);
|
||||
|
||||
lineswritten++;
|
||||
|
||||
|
@@ -123,19 +123,39 @@ extern const char* gmonths[];
|
||||
// ------------------------------------------------------------------
|
||||
// Prototypes
|
||||
|
||||
#if defined(__WIN32__) && MAXINT > 0x0FFFFFFF // 64-bit
|
||||
extern struct tm dummy_struct_tm;
|
||||
inline struct tm* ggmtime(time_t* arg) {
|
||||
struct tm* a = gmtime(arg);
|
||||
return (a != NULL) ? a : &dummy_struct_tm;
|
||||
}
|
||||
inline struct tm* glocaltime(time_t* arg) {
|
||||
struct tm* a = localtime(arg);
|
||||
return (a != NULL) ? a : &dummy_struct_tm;
|
||||
}
|
||||
#define gmtime(arg) ggmtime(arg)
|
||||
#define localtime(arg) glocaltime(arg)
|
||||
inline struct tm *ggmtime(const time_t *timep)
|
||||
{
|
||||
#if defined(__WIN32__)
|
||||
const time_t zero(0);
|
||||
struct tm *time = gmtime(timep);
|
||||
return time ? time : gmtime(&zero);
|
||||
#else
|
||||
return gmtime(&timep);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline struct tm* glocaltime(const time_t *timep)
|
||||
{
|
||||
#if defined(__WIN32__)
|
||||
const time_t zero(0);
|
||||
struct tm *time = localtime(timep);
|
||||
return time ? time : localtime(&zero);
|
||||
#else
|
||||
return localtime(timep);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline struct tm* ggmtime(const time32_t *timep)
|
||||
{
|
||||
const time_t temp(*timep);
|
||||
return glocaltime(&temp);
|
||||
}
|
||||
|
||||
inline struct tm* glocaltime(const time32_t *timep)
|
||||
{
|
||||
const time_t temp(*timep);
|
||||
return glocaltime(&temp);
|
||||
}
|
||||
|
||||
#if defined(__OS2__)
|
||||
inline void usleep(long duration) { DosSleep(duration); }
|
||||
@@ -172,13 +192,6 @@ char* TimeToStr(char* buf, time_t t);
|
||||
long YMD2JDN(unsigned yr, unsigned mo, unsigned day) __attribute__ ((const));
|
||||
void JDN2YMD(long scalar, unsigned *yr, unsigned *mo, unsigned *day);
|
||||
|
||||
inline struct tm *gmtime(const time32_t *timep)
|
||||
{
|
||||
const time_t zero(0);
|
||||
const time_t temp(*timep);
|
||||
struct tm *time = gmtime(&temp);
|
||||
return time ? time : gmtime(&zero);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
|
@@ -43,13 +43,6 @@
|
||||
#endif
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
#ifdef __WIN32__
|
||||
struct tm dummy_struct_tm = { 0, 0, 0, 1, 0, 70, 0, 0, -1 };
|
||||
#endif
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
const char* gmonths[] = {
|
||||
@@ -68,7 +61,7 @@ const char* gmonths[] = {
|
||||
int tzoffset() {
|
||||
|
||||
time_t t1 = time(NULL);
|
||||
struct tm *tp = gmtime(&t1);
|
||||
struct tm *tp = ggmtime(&t1);
|
||||
tp->tm_isdst=-1;
|
||||
time_t t2 = mktime(tp);
|
||||
int dt = (int)(t1 - t2);
|
||||
@@ -358,7 +351,7 @@ time_t FTimeToTime(FTime* __ftime, struct tm* __tm) {
|
||||
__tm->tm_isdst = -1;
|
||||
|
||||
time_t a = mktime(__tm);
|
||||
struct tm *tp = gmtime(&a);
|
||||
struct tm *tp = ggmtime(&a);
|
||||
tp->tm_isdst = -1;
|
||||
time_t b = mktime(tp);
|
||||
_time = a + a - b;
|
||||
@@ -382,7 +375,7 @@ FTime TimeToFTime(time_t __time) {
|
||||
|
||||
if(__time) {
|
||||
|
||||
struct tm* _tmp = gmtime(&__time);
|
||||
struct tm* _tmp = ggmtime(&__time);
|
||||
_ft.ft_year = (word)(_tmp->tm_year - 80);
|
||||
_ft.ft_month = (word)(_tmp->tm_mon + 1);
|
||||
_ft.ft_day = (word)(_tmp->tm_mday);
|
||||
@@ -449,7 +442,7 @@ time_t FidoTimeToUnix(char* ptr) {
|
||||
t.tm_sec = second;
|
||||
t.tm_isdst = -1;
|
||||
time_t a = mktime(&t);
|
||||
struct tm *tp = gmtime(&a);
|
||||
struct tm *tp = ggmtime(&a);
|
||||
tp->tm_isdst = -1;
|
||||
time_t b = mktime(tp);
|
||||
return a + a - b;
|
||||
@@ -462,7 +455,7 @@ time_t FidoTimeToUnix(char* ptr) {
|
||||
|
||||
char* TimeToStr(char* buf, time_t t) {
|
||||
|
||||
return strftimei(buf, 20, "%Y-%m-%d %H:%M:%S", gmtime(&t));
|
||||
return strftimei(buf, 20, "%Y-%m-%d %H:%M:%S", ggmtime(&t));
|
||||
}
|
||||
|
||||
|
||||
|
@@ -98,7 +98,7 @@ int FidoArea::load_message(int __mode, gmsg* __msg, FidoHdr& __hdr) {
|
||||
|
||||
if(__msg->arrived == 0) {
|
||||
time_t a = time(NULL);
|
||||
struct tm *tp = gmtime(&a);
|
||||
struct tm *tp = ggmtime(&a);
|
||||
tp->tm_isdst = -1;
|
||||
time_t b = mktime(tp);
|
||||
__msg->arrived = a + a - b;
|
||||
|
@@ -168,7 +168,7 @@ void FidoArea::save_message(int __mode, gmsg* __msg, FidoHdr& __hdr) {
|
||||
__hdr.opus.written = TimeToFTime(__msg->written);
|
||||
__hdr.opus.arrived = TimeToFTime(__msg->arrived);
|
||||
}
|
||||
struct tm* _tm = gmtime(&__msg->written);
|
||||
struct tm* _tm = ggmtime(&__msg->written);
|
||||
sprintf(__hdr.datetime, "%02d %3s %02d %02d:%02d:%02d",
|
||||
_tm->tm_mday, gmonths[_tm->tm_mon+1], _tm->tm_year % 100,
|
||||
_tm->tm_hour, _tm->tm_min, _tm->tm_sec
|
||||
|
@@ -135,7 +135,7 @@ int _HudsArea<msgn_t, rec_t, attr_t, board_t, last_t, __HUDSON>::load_message(in
|
||||
_tm.tm_sec = 0;
|
||||
_tm.tm_isdst = -1;
|
||||
time_t a = mktime(&_tm);
|
||||
struct tm *tp = gmtime(&a);
|
||||
struct tm *tp = ggmtime(&a);
|
||||
tp->tm_isdst = -1;
|
||||
time_t b = mktime(tp);
|
||||
__msg->written = a + a - b;
|
||||
|
@@ -127,7 +127,7 @@ void _HudsArea<msgn_t, rec_t, attr_t, board_t, last_t, __HUDSON>::save_message(i
|
||||
__hdr.replyto = (msgn_t)__msg->link.to();
|
||||
__hdr.reply1st = (msgn_t)__msg->link.first();
|
||||
|
||||
struct tm* _tmp = gmtime(&__msg->written);
|
||||
struct tm* _tmp = ggmtime(&__msg->written);
|
||||
strc2p(strftimei(__hdr.date, 9, "%m-%d-%y", _tmp));
|
||||
strc2p(strftimei(__hdr.time, 6, "%H:%M", _tmp));
|
||||
|
||||
|
@@ -153,7 +153,7 @@ void JamArea::open_area() {
|
||||
// Initialize header info
|
||||
memcpy(data->hdrinfo.signature, JAM_SIGNATURE, 4);
|
||||
time_t a = time(NULL);
|
||||
struct tm *tp = gmtime(&a);
|
||||
struct tm *tp = ggmtime(&a);
|
||||
tp->tm_isdst = -1;
|
||||
time_t b = mktime(tp);
|
||||
data->hdrinfo.datecreated = a + a - b;
|
||||
|
@@ -80,7 +80,7 @@ int PcbArea::load_message(int __mode, gmsg* __msg, PcbHdr& __hdr) {
|
||||
_tm.tm_sec = 0;
|
||||
_tm.tm_isdst = -1;
|
||||
time_t a = mktime(&_tm);
|
||||
struct tm *tp = gmtime(&a);
|
||||
struct tm *tp = ggmtime(&a);
|
||||
tp->tm_isdst = -1;
|
||||
time_t b = mktime(tp);
|
||||
__msg->written = a + a - b;
|
||||
|
@@ -158,13 +158,13 @@ void PcbArea::save_message(int __mode, gmsg* __msg, PcbHdr& __hdr) {
|
||||
|
||||
// Convert dates and times
|
||||
char _dtbuf[9];
|
||||
struct tm* _tm = gmtime(&__msg->written);
|
||||
struct tm* _tm = ggmtime(&__msg->written);
|
||||
memcpy(__hdr.date, strftimei(_dtbuf, 9, __msg->attr.uns() ? "%d-%m-%y" : "%d-%m\xC4%y", _tm), 8);
|
||||
memcpy(__hdr.time, strftimei(_dtbuf, 6, "%H:%M", _tm), 5);
|
||||
_idx.date = (word)YMD2JDN(1900+_tm->tm_year, _tm->tm_mon+1, _tm->tm_mday);
|
||||
if(__msg->link.first()) {
|
||||
__hdr.hasreply = 'R';
|
||||
_tm = gmtime(&__msg->pcboard.reply_written);
|
||||
_tm = ggmtime(&__msg->pcboard.reply_written);
|
||||
int _year = _tm->tm_year % 100;
|
||||
__hdr.replydate = L2B((10000L*_year) + (100L*(_tm->tm_mon+1)) + _tm->tm_mday);
|
||||
memcpy(__hdr.replytime, strftimei(_dtbuf, 6, "%H:%M", _tm), 5);
|
||||
|
@@ -325,12 +325,12 @@ int SMBArea::load_hdr(gmsg* __msg, smbmsg_t *smsg)
|
||||
__msg->attr.tfs(smsgp->hdr.auxattr & MSG_TRUNCFILE);
|
||||
|
||||
time_t a = smsgp->hdr.when_written.time;
|
||||
struct tm *tp = gmtime(&a);
|
||||
struct tm *tp = ggmtime(&a);
|
||||
tp->tm_isdst = -1;
|
||||
time_t b = mktime(tp);
|
||||
__msg->written = a + a - b;
|
||||
a = smsgp->hdr.when_imported.time;
|
||||
b = mktime(gmtime(&a));
|
||||
b = mktime(ggmtime(&a));
|
||||
__msg->arrived = a + a - b;
|
||||
__msg->received = 0;
|
||||
|
||||
@@ -536,7 +536,7 @@ void SMBArea::save_hdr(int mode, gmsg* msg)
|
||||
else {
|
||||
memcpy(smsg.hdr.id, "SHD\x1a", 4);
|
||||
smsg.hdr.version = smb_ver();
|
||||
struct tm *tp = gmtime(&msg->written);
|
||||
struct tm *tp = ggmtime(&msg->written);
|
||||
tp->tm_isdst = -1;
|
||||
smsg.hdr.when_written.time = mktime(tp);
|
||||
}
|
||||
|
@@ -437,7 +437,7 @@ void SquishArea::save_message(int __mode, gmsg* __msg) {
|
||||
|
||||
__hdr.date_written = TimeToFTime(__msg->written);
|
||||
__hdr.date_arrived = TimeToFTime(__msg->arrived);
|
||||
struct tm* _tm = gmtime(&__msg->written);
|
||||
struct tm* _tm = ggmtime(&__msg->written);
|
||||
sprintf(__hdr.ftsc_date, "%02d %3s %02d %02d:%02d:%02d",
|
||||
_tm->tm_mday, gmonths[_tm->tm_mon+1], _tm->tm_year % 100,
|
||||
_tm->tm_hour, _tm->tm_min, _tm->tm_sec
|
||||
|
@@ -104,7 +104,7 @@ int WCatArea::load_message(int __mode, gmsg* __msg, WCatHdr& __hdr) {
|
||||
_tm.tm_sec = _second;
|
||||
_tm.tm_isdst = -1;
|
||||
time_t a = mktime(&_tm);
|
||||
struct tm *tp = gmtime(&a);
|
||||
struct tm *tp = ggmtime(&a);
|
||||
tp->tm_isdst = -1;
|
||||
time_t b = mktime(tp);
|
||||
__msg->written = a + a - b;
|
||||
@@ -124,7 +124,7 @@ int WCatArea::load_message(int __mode, gmsg* __msg, WCatHdr& __hdr) {
|
||||
_tm.tm_sec = _second;
|
||||
_tm.tm_isdst = -1;
|
||||
time_t a = mktime(&_tm);
|
||||
struct tm *tp = gmtime(&a);
|
||||
struct tm *tp = ggmtime(&a);
|
||||
tp->tm_isdst = -1;
|
||||
time_t b = mktime(tp);
|
||||
__msg->received = a + a - b;
|
||||
|
@@ -119,13 +119,13 @@ void WCatArea::save_message(int __mode, gmsg* __msg, WCatHdr& __hdr) {
|
||||
strc2p(strcpy(__hdr.network, __msg->wildcat.network));
|
||||
|
||||
if(__msg->written) {
|
||||
struct tm* _tm = gmtime(&__msg->written);
|
||||
struct tm* _tm = ggmtime(&__msg->written);
|
||||
__hdr.msgdate = (word)(YMD2JDN(1900+_tm->tm_year, _tm->tm_mon+1, _tm->tm_mday)-1);
|
||||
__hdr.msgtime = ((_tm->tm_hour*3600L)+(_tm->tm_min*60L)+_tm->tm_sec)+1;
|
||||
}
|
||||
|
||||
if(__msg->received) {
|
||||
struct tm* _tm = gmtime(&__msg->received);
|
||||
struct tm* _tm = ggmtime(&__msg->received);
|
||||
__hdr.readdate = (word)YMD2JDN(1900+_tm->tm_year, _tm->tm_mon+1, _tm->tm_mday);
|
||||
__hdr.readtime = ((_tm->tm_hour*3600L)+(_tm->tm_min*60L)+_tm->tm_sec)+1;
|
||||
}
|
||||
|
@@ -77,8 +77,8 @@ Line* WCatArea::make_dump_msg(Line*& lin, gmsg* msg, char* lng_head) {
|
||||
AddLineF(line, "DestUserID : %i", _hdr.touserid);
|
||||
AddLineF(line, "Subject : %s", STRNP2C(_hdr.subject));
|
||||
AddLineF(line, "Network : %s", STRNP2C(_hdr.network));
|
||||
AddLineF(line, "MsgTime : %s (%u, %i)", strftimei(buf, 100, "%d %b %y %H:%M:%S", gmtime(&msg->written)), _hdr.msgdate, _hdr.msgtime);
|
||||
AddLineF(line, "ReadTime : %s (%u, %i)", strftimei(buf, 100, "%d %b %y %H:%M:%S", gmtime(&msg->received)), _hdr.readdate, _hdr.readtime);
|
||||
AddLineF(line, "MsgTime : %s (%u, %i)", strftimei(buf, 100, "%d %b %y %H:%M:%S", ggmtime(&msg->written)), _hdr.msgdate, _hdr.msgtime);
|
||||
AddLineF(line, "ReadTime : %s (%u, %i)", strftimei(buf, 100, "%d %b %y %H:%M:%S", ggmtime(&msg->received)), _hdr.readdate, _hdr.readtime);
|
||||
AddLineF(line, "mFlags : %u (%04Xh)", _hdr.mflags, _hdr.mflags);
|
||||
AddLineF(line, "Reference : %u", _hdr.reference);
|
||||
AddLineF(line, "FidoFrom : %u:%u/%u.%u", _hdr.origaddr.zone, _hdr.origaddr.net, _hdr.origaddr.node, _hdr.origaddr.point);
|
||||
|
@@ -73,7 +73,7 @@ int XbbsArea::load_message(int __mode, gmsg* __msg, XbbsHdr& __hdr) {
|
||||
t.tm_hour = t.tm_min = t.tm_sec = 0;
|
||||
t.tm_isdst = -1;
|
||||
time_t a = mktime(&t);
|
||||
struct tm *tp = gmtime(&a);
|
||||
struct tm *tp = ggmtime(&a);
|
||||
tp->tm_isdst = -1;
|
||||
time_t b = mktime(tp);
|
||||
__msg->arrived = a + a - b;
|
||||
|
@@ -135,13 +135,13 @@ void XbbsArea::save_message(int __mode, gmsg* __msg, XbbsHdr& __hdr) {
|
||||
strxcpy(__hdr.to, __msg->to, sizeof(__hdr.to));
|
||||
strxcpy(__hdr.subj, __msg->re, sizeof(__hdr.subj));
|
||||
|
||||
struct tm* _tm = gmtime(&__msg->written);
|
||||
struct tm* _tm = ggmtime(&__msg->written);
|
||||
sprintf(__hdr.date, "%02d %3s %02d %02d:%02d:%02d",
|
||||
_tm->tm_mday, gmonths[_tm->tm_mon+1], _tm->tm_year % 100,
|
||||
_tm->tm_hour, _tm->tm_min, _tm->tm_sec
|
||||
);
|
||||
if(__msg->arrived)
|
||||
_tm = gmtime(&__msg->arrived);
|
||||
_tm = ggmtime(&__msg->arrived);
|
||||
__hdr.indate[0] = (byte)(_tm->tm_year - 89);
|
||||
__hdr.indate[1] = (byte)(_tm->tm_mon + 1);
|
||||
__hdr.indate[2] = (byte)(_tm->tm_mday);
|
||||
|
Reference in New Issue
Block a user