diff --git a/golded3/geall.h b/golded3/geall.h index 5772e8d..a59ca36 100644 --- a/golded3/geall.h +++ b/golded3/geall.h @@ -326,16 +326,17 @@ const int REPLYRE_NUMERIC = 2; // ------------------------------------------------------------------ // Name typedefs -typedef char Name[36]; +typedef TCHAR Name[36]; // ------------------------------------------------------------------ // Combined name/address structure -struct Node { +struct Node +{ Name name; Addr addr; - Node& operator=(const Node& a) { strcpy(name, a.name); addr=a.addr; return *this; } + Node &operator=(const Node &a) { strxcpy(name, a.name, ARRAYSIZE(name)); addr=a.addr; return *this; } }; diff --git a/golded3/gectrl.cpp b/golded3/gectrl.cpp index c425b58..30c2025 100644 --- a/golded3/gectrl.cpp +++ b/golded3/gectrl.cpp @@ -578,12 +578,14 @@ void DoKludges(int mode, GMsg* msg, int kludges) { line->kludge = GKLUD_RFC; } - struct tm* tm = ggmtime(&msg->written); + struct tm tm; ggmtime(&tm, &msg->written); + sprintf(buf, "%sDate: %s, %02d %s %04d %02d:%02d:%02d", rfc, - __gsweekday[tm->tm_wday], - tm->tm_mday, __gsmonth[tm->tm_mon], 1900+tm->tm_year, - tm->tm_hour, tm->tm_min, tm->tm_sec - ); + __gsweekday[tm.tm_wday], + tm.tm_mday, __gsmonth[tm.tm_mon], 1900+tm.tm_year, + tm.tm_hour, tm.tm_min, tm.tm_sec + ); + if(AA->Usetzutc()) sprintf(buf + strlen(buf), " %+05d", tzoffset()); diff --git a/golded3/gehdrs.cpp b/golded3/gehdrs.cpp index 3ecb2ac..f5cb4cf 100644 --- a/golded3/gehdrs.cpp +++ b/golded3/gehdrs.cpp @@ -176,8 +176,12 @@ void DispHeader(GMsg* msg, bool prn, FILE* fp, int width) { *buf1 = NUL; strsetsz(buf1, nodewidth); - if(msg->written) - strftimei(buf2, CFG->disphdrdateset.len, LNG->DateTimeFmt, ggmtime(&msg->written)); + if (msg->written) + { + struct tm tm; ggmtime(&tm, &msg->written); + strftimei(buf2, CFG->disphdrdateset.len, LNG->DateTimeFmt, &tm); + } + strsetsz(buf2, datewidth); // write from line @@ -205,8 +209,12 @@ void DispHeader(GMsg* msg, bool prn, FILE* fp, int width) { *buf2 = NUL; strsetsz(buf2, nodewidth); - if(msg->arrived) - strftimei(buf2, CFG->disphdrdateset.len, LNG->DateTimeFmt, ggmtime(&msg->arrived)); + if (msg->arrived) + { + struct tm tm; ggmtime(&tm, &msg->arrived); + strftimei(buf2, CFG->disphdrdateset.len, LNG->DateTimeFmt, &tm); + } + strsetsz(buf2, datewidth); // write to line diff --git a/golded3/geline.cpp b/golded3/geline.cpp index c1d4d01..5d4f017 100644 --- a/golded3/geline.cpp +++ b/golded3/geline.cpp @@ -792,7 +792,8 @@ void KludgeDATE(GMsg* msg, const char* ptr) { } } - if(date_ok) { + if (date_ok) + { struct tm t; t.tm_year = (year < 80) ? (year+100) : (year > 1900) ? (year-1900) : year; t.tm_mon = month - 1; @@ -801,11 +802,11 @@ void KludgeDATE(GMsg* msg, const char* ptr) { t.tm_min = minute; t.tm_sec = second; t.tm_isdst = -1; - time32_t a = gmktime(&t); - struct tm *tp = ggmtime(&a); - tp->tm_isdst = -1; - time32_t b = gmktime(tp); - msg->written = a + a - b; + time32_t a = gmktime(&t); + struct tm tp; ggmtime(&tp, &a); + tp.tm_isdst = -1; + time32_t b = gmktime(&tp); + msg->written = a + a - b; } } diff --git a/golded3/gemlst.cpp b/golded3/gemlst.cpp index 9d9b686..364d9a3 100644 --- a/golded3/gemlst.cpp +++ b/golded3/gemlst.cpp @@ -332,8 +332,13 @@ void GMsgList::print_line(uint idx, uint pos, bool isbar) { case MSGLISTDATE_ARRIVED: dt = ml->arrived; break; case MSGLISTDATE_RECEIVED: dt = ml->received; break; } - if(dt) - strftimei(dbuf, 20, "%d %b %y", ggmtime(&dt)); + + if (dt) + { + struct tm tm; ggmtime(&tm, &dt); + strftimei(dbuf, 20, "%d %b %y", &tm); + } + if(AA->Msglistdate()) strsetsz(dbuf, 10); else @@ -934,8 +939,12 @@ void GThreadlist::print_line(uint idx, uint pos, bool isbar) { case MSGLISTDATE_RECEIVED: dt = msg.received; break; } - if(dt) - strftimei(dbuf, 20, "%d %b %y", ggmtime(&dt)); + if (dt) + { + struct tm tm; ggmtime(&tm, &dt); + strftimei(dbuf, 20, "%d %b %y", &tm); + } + strcat(buf, dbuf); } strcat(buf, " "); diff --git a/golded3/gemsgs.cpp b/golded3/gemsgs.cpp index fba5891..b617408 100644 --- a/golded3/gemsgs.cpp +++ b/golded3/gemsgs.cpp @@ -154,20 +154,20 @@ void TokenXlat(int mode, std::string &input, GMsg* msg, GMsg* oldmsg, int __orig const char *osver = ggetosstring(); time32_t t = gtime(NULL); - struct tm* written_tm = glocaltime(&t); + struct tm written_tm; glocaltime(&written_tm, &t); char cdate[80]; - strftimei(cdate, 80, LNG->DateFmt, written_tm); + strftimei(cdate, 80, LNG->DateFmt, &written_tm); char ctime[80]; - strftimei(ctime, 80, LNG->TimeFmt, written_tm); + strftimei(ctime, 80, LNG->TimeFmt, &written_tm); char cdtime[80]; - strftimei(cdtime, 80, LNG->DateTimeFmt, written_tm); - written_tm = ggmtime(&oldmsg->written); + strftimei(cdtime, 80, LNG->DateTimeFmt, &written_tm); + ggmtime(&written_tm, &oldmsg->written); char odate[80]; - strftimei(odate, 80, LNG->DateFmt, written_tm); + strftimei(odate, 80, LNG->DateFmt, &written_tm); char otime[80]; - strftimei(otime, 80, LNG->TimeFmt, written_tm); + strftimei(otime, 80, LNG->TimeFmt, &written_tm); char odtime[80]; - strftimei(odtime, 80, LNG->DateTimeFmt, written_tm); + strftimei(odtime, 80, LNG->DateTimeFmt, &written_tm); const char* origareaid = AL.AreaIdToPtr(__origarea)->echoid(); bool origareaisinet = make_bool(AL.AreaIdToPtr(__origarea)->isinternet()); diff --git a/golded3/gepost.cpp b/golded3/gepost.cpp index 9efe10e..a23f730 100644 --- a/golded3/gepost.cpp +++ b/golded3/gepost.cpp @@ -243,10 +243,10 @@ static void MakeMsg3(int& mode, GMsg* msg) { // Do Timefields if(msg->attr.fmu()) { - time32_t a = gtime(NULL); - struct tm *tp = ggmtime(&a); - tp->tm_isdst = -1; - time32_t b = gmktime(tp); + time32_t a = gtime(NULL); + struct tm tp; ggmtime(&tp, &a); + tp.tm_isdst = -1; + time32_t b = gmktime(&tp); a += a - b; if(AA->havereceivedstamp()) msg->received = a; @@ -824,10 +824,10 @@ void MakeMsg(int mode, GMsg* omsg, bool ignore_replyto) { dochgdate = false; } if(dochgdate) { - time32_t a = gtime(NULL); - struct tm *tp = ggmtime(&a); - tp->tm_isdst = -1; - time32_t b = gmktime(tp); + time32_t a = gtime(NULL); + struct tm tp; ggmtime(&tp, &a); + tp.tm_isdst = -1; + time32_t b = gmktime(&tp); a += a - b; msg->received = msg->arrived = msg->written = a; } diff --git a/golded3/geqwks.cpp b/golded3/geqwks.cpp index 602d898..739a2cc 100644 --- a/golded3/geqwks.cpp +++ b/golded3/geqwks.cpp @@ -208,15 +208,15 @@ int ImportQWK() { _tm.tm_min = _minute; _tm.tm_sec = 0; _tm.tm_isdst = -1; - time32_t a = gmktime(&_tm); - struct tm *tp = ggmtime(&a); - tp->tm_isdst = -1; - time32_t b = gmktime(tp); - msg->written = a + a - b; + time32_t a = gmktime(&_tm); + struct tm tp; ggmtime(&tp, &a); + tp.tm_isdst = -1; + time32_t b = gmktime(&tp); + msg->written = a + a - b; a = gtime(NULL); - tp = ggmtime(&a); - tp->tm_isdst = -1; - b = gmktime(tp); + ggmtime(&tp, &a); + tp.tm_isdst = -1; + b = gmktime(&tp); msg->arrived = a + a - b; // Read message text @@ -369,11 +369,11 @@ int ExportQwkMsg(GMsg* msg, gfile& fp, int confno, int& pktmsgno) { hdr.status = msg->attr.pvt() ? '*' : ' '; sprintf(buf, "%u", confno); memcpy(hdr.msgno, buf, strlen(buf)); - struct tm* _tm = ggmtime(&msg->written); - int _year = _tm->tm_year % 100; - sprintf(buf, "%02d-%02d-%02d", _tm->tm_mon+1, _tm->tm_mday, _year); + struct tm _tm; ggmtime(&_tm, &msg->written); + int _year = _tm.tm_year % 100; + sprintf(buf, "%02d-%02d-%02d", _tm.tm_mon+1, _tm.tm_mday, _year); memcpy(hdr.date, buf, 8); - sprintf(buf, "%02d:%02d", _tm->tm_hour, _tm->tm_min); + sprintf(buf, "%02d:%02d", _tm.tm_hour, _tm.tm_min); memcpy(hdr.time, buf, 5); strxcpy(buf, msg->to, tolen+1); if(not QWK->MixCaseAllowed()) diff --git a/golded3/geread.cpp b/golded3/geread.cpp index c343788..1ae6a08 100644 --- a/golded3/geread.cpp +++ b/golded3/geread.cpp @@ -1181,10 +1181,10 @@ int LoadMessage(GMsg* msg, int margin) { if(msg->attr.tou()) { reader_rcv_noise = 1; if(not msg->attr.rcv()) { // Have we seen it? - time32_t a = gtime(NULL); - struct tm *tp = ggmtime(&a); - tp->tm_isdst = -1; - time32_t b = gmktime(tp); + time32_t a = gtime(NULL); + struct tm tp; ggmtime(&tp, &a); + tp.tm_isdst = -1; + time32_t b = gmktime(&tp); msg->received = a + a - b; // Get current date msg->attr.rcv1(); // Mark as received reader_rcv_noise++; @@ -1426,7 +1426,10 @@ void GotoReplies() { sprintf(rlist[replies].addr, " (%s) ", buf); } maxaddr = MaxV(maxaddr, (uint)strlen(rlist[replies].addr)); - strftimei(rlist[replies].written, CFG->disphdrdateset.len, LNG->DateTimeFmt, ggmtime(&rmsg->written)); + + struct tm tm; ggmtime(&tm, &rmsg->written); + strftimei(rlist[replies].written, CFG->disphdrdateset.len, LNG->DateTimeFmt, &tm); + maxwritten = MaxV(maxwritten, (uint)strlen(rlist[replies].written)); rlist[replies].reln = reln; replies++; diff --git a/golded3/gesoup.cpp b/golded3/gesoup.cpp index 849dfc8..b652828 100644 --- a/golded3/gesoup.cpp +++ b/golded3/gesoup.cpp @@ -171,11 +171,11 @@ void ProcessSoupMsg(char* lbuf, GMsg* msg, int& msgs, char* areaname, int tossto msg->orig = msg->oorig = CFG->internetgate.addr.valid() ? CFG->internetgate.addr : AA->aka(); msg->dest = msg->odest = AA->aka(); - time32_t a = gtime(NULL); - struct tm *tp = ggmtime(&a); - tp->tm_isdst = -1; - time32_t b = gmktime(tp); - msg->arrived = a + a - b; + time32_t a = gtime(NULL); + struct tm tp; ggmtime(&tp, &a); + tp.tm_isdst = -1; + time32_t b = gmktime(&tp); + msg->arrived = a + a - b; Line* line = NULL; Line* fline = NULL; @@ -697,11 +697,11 @@ int ExportSoupMsg(GMsg* msg, char* msgfile, gfile& fp, int ismail) { msg->attr.snt1(); msg->attr.scn1(); msg->attr.uns0(); - time32_t a = gtime(NULL); - struct tm *tp = ggmtime(&a); - tp->tm_isdst = -1; - time32_t b = gmktime(tp); - msg->arrived = a + a - b; + time32_t a = gtime(NULL); + struct tm tp; ggmtime(&tp, &a); + tp.tm_isdst = -1; + time32_t b = gmktime(&tp); + msg->arrived = a + a - b; AA->SaveHdr(GMSG_UPDATE, msg); if(msg->attr.k_s()) AA->DeleteMsg(msg, DIR_NEXT); diff --git a/golded3/geusrbse.cpp b/golded3/geusrbse.cpp index 5e4a2b4..c4d1e11 100644 --- a/golded3/geusrbse.cpp +++ b/golded3/geusrbse.cpp @@ -343,11 +343,19 @@ bool guserbase::edit_entry(uint idx) { char dbuf[16]; time32_t dt = entry.firstdate; - if(dt) - window.prints(13, 13, wattr, strftimei(dbuf, 16, "%d %b %y", ggmtime(&dt))); + + if (dt) + { + struct tm tm; ggmtime(&tm, &dt); + window.prints(13, 13, wattr, strftimei(dbuf, 16, "%d %b %y", &tm)); + } + dt = entry.lastdate; - if(dt) - window.prints(13, 38, wattr, strftimei(dbuf, 16, "%d %b %y", ggmtime(&dt))); + if (dt) + { + struct tm tm; ggmtime(&tm, &dt); + window.prints(13, 38, wattr, strftimei(dbuf, 16, "%d %b %y", &tm)); + } sprintf(dbuf, "%8u", entry.times); window.prints(13, width-11, wattr, dbuf); @@ -427,10 +435,10 @@ bool guserbase::find_entry(char* name, bool lookup) { void guserbase::write_entry(uint idx, bool updateit) { if(updateit and not entry.is_deleted) { - time32_t a = gtime(NULL); - struct tm *tp = ggmtime(&a); - tp->tm_isdst = -1; - time32_t b = gmktime(tp); + time32_t a = gtime(NULL); + struct tm tp; ggmtime(&tp, &a); + tp.tm_isdst = -1; + time32_t b = gmktime(&tp); entry.lastdate = a + a - b; if(not entry.firstdate) entry.firstdate = entry.lastdate; diff --git a/golded3/geutil.cpp b/golded3/geutil.cpp index 23109dc..bbeb066 100644 --- a/golded3/geutil.cpp +++ b/golded3/geutil.cpp @@ -53,9 +53,11 @@ void update_statuslines() { *clkinfo = NUL; *help = NUL; - if(CFG->switches.get(statuslineclock)) { + if(CFG->switches.get(statuslineclock)) + { time32_t t = gtime(NULL); - sprintf(clkinfo, " %s", strftimei(help, 40, LNG->StatusLineTimeFmt, glocaltime(&t))); + struct tm tm; glocaltime(&tm, &t); + sprintf(clkinfo, " %s", strftimei(help, 40, LNG->StatusLineTimeFmt, &tm)); } if(CFG->statuslinehelp == -1) @@ -464,7 +466,7 @@ bool is_quote2(Line* line, const char* ptr) return true; // found begin of citation? - char *begin = strrchr(ln->txt.c_str(), '<'); + const char *begin = strrchr(ln->txt.c_str(), '<'); if (begin) { // found both '<' and '>'? diff --git a/golded3/geutil2.cpp b/golded3/geutil2.cpp index 65aaa1c..0c87b56 100644 --- a/golded3/geutil2.cpp +++ b/golded3/geutil2.cpp @@ -267,13 +267,18 @@ void ScreenBlankIdle() { char blankmsg1[80]; char blankmsg2[80]; + time32_t t = gtime(NULL); - sprintf(blankmsg1, " %s %s %s ", __gver_longpid__, __gver_ver__, strftimei(blankmsg2, 40, LNG->StatusLineTimeFmt, glocaltime(&t))); + struct tm tm; glocaltime(&tm, &t); + sprintf(blankmsg1, " %s %s %s ", __gver_longpid__, __gver_ver__, strftimei(blankmsg2, 40, LNG->StatusLineTimeFmt, &tm)); sprintf(blankmsg2, " %s ", LNG->BlankMsg); - if(strblank(blankmsg2)) { + + if (strblank(blankmsg2)) + { *blankmsg2 = NUL; windowheight--; } + int b1 = strlen(blankmsg1); int b2 = strlen(blankmsg2); int blankmsglen = MaxV(b1,b2); diff --git a/golded3/geview.cpp b/golded3/geview.cpp index c373554..5d08708 100644 --- a/golded3/geview.cpp +++ b/golded3/geview.cpp @@ -218,11 +218,16 @@ void GMsgHeaderView::Paint() { color = GetColorName(msg->By(), msg->orig, color); window.prints(2, CFG->disphdrnameset.pos, color, buf); - if(datewidth > 0) { - if(msg->written) - strftimei(buf, datewidth+1, LNG->DateTimeFmt, ggmtime(&msg->written)); + if (datewidth > 0) + { + if (msg->written) + { + struct tm tm; ggmtime(&tm, &msg->written); + strftimei(buf, datewidth+1, LNG->DateTimeFmt, &tm); + } else *buf = NUL; + strsetsz(buf, datewidth); window.prints(2, CFG->disphdrdateset.pos, from_color, buf); } @@ -262,11 +267,16 @@ void GMsgHeaderView::Paint() { } window.prints(3, CFG->disphdrnameset.pos, color, buf); - if(datewidth > 0) { - if(msg->arrived) - strftimei(buf, datewidth+1, LNG->DateTimeFmt, ggmtime(&msg->arrived)); + if (datewidth > 0) + { + if (msg->arrived) + { + struct tm tm; ggmtime(&tm, &msg->arrived); + strftimei(buf, datewidth+1, LNG->DateTimeFmt, &tm); + } else *buf = NUL; + strsetsz(buf, datewidth); window.prints(3, CFG->disphdrdateset.pos, to_color, buf); } diff --git a/golded3/gmarea.h b/golded3/gmarea.h index 0154ae7..62e1761 100644 --- a/golded3/gmarea.h +++ b/golded3/gmarea.h @@ -599,7 +599,7 @@ public: int NextMsglistdate() { adat->msglistdate++; if(adat->msglistdate > MSGLISTDATE_RECEIVED) adat->msglistdate = MSGLISTDATE_NONE; return adat->msglistdate; } const ftn_aka& SetAka(const ftn_addr& a) { adat->aka.addr = a; return adat->aka; } - const char* SetInputfile(const char* i) { return strcpy(adat->inputfile, i); } + const TCHAR *SetInputfile(const TCHAR *i) { return strxcpy(adat->inputfile, i, ARRAYSIZE(adat->inputfile)); } int SetMsglistdate(int m) { adat->msglistdate = m; return adat->msglistdate; } const char* SetOrigin(const char* o) { return strxcpy(adat->origin, o, sizeof(adat->origin)); } const char* SetOutputfile(const char* o) { return strxcpy(adat->outputfile, o, sizeof(adat->outputfile)); } @@ -608,8 +608,8 @@ public: const char* SetTpl(const char* t) { return strxcpy(adat->tpl, t, sizeof(adat->tpl)); } int SetTwitmode(int m) { adat->twitmode = m; return adat->twitmode; } const Node& SetUsername(const Node& n) { adat->username = n; return adat->username; } - const char* SetXlatexport(const char* x) { return strcpy(adat->xlatexport, x); } - const char* SetXlatimport(const char* x) { return strcpy(adat->xlatimport, x); } + const TCHAR *SetXlatexport(const TCHAR *x) { return strxcpy(adat->xlatexport, x, ARRAYSIZE(adat->xlatexport)); } + const TCHAR *SetXlatimport(const TCHAR *x) { return strxcpy(adat->xlatimport, x, ARRAYSIZE(adat->xlatimport)); } int ToggleMsglistwidesubj() { adat->msglistwidesubj = not adat->msglistwidesubj; return adat->msglistwidesubj; } int ToggleViewhidden() { adat->viewhidden = not adat->viewhidden; return adat->viewhidden; } int ToggleViewkludge() { adat->viewkludge = not adat->viewkludge; return adat->viewkludge; } diff --git a/goldlib/gall/gcrcall.h b/goldlib/gall/gcrcall.h index 9b1b71d..49e7e87 100644 --- a/goldlib/gall/gcrcall.h +++ b/goldlib/gall/gcrcall.h @@ -51,9 +51,9 @@ extern dword __crc32_table[]; // fill is guaranteed for unsigned operands, and besides we use // prototyped unsigned parameters anyway, so we have no problem here. -inline word updCrc16(byte ch, word crc) { return (word)(__crc16_table[byte(crc >> 8)] ^ (crc << 8) ^ (ch)); } -inline word updCrc16c(byte ch, word crc) { return (word)(__crc16_table[byte(crc >> 8) ^ (ch)] ^ (crc << 8)); } -inline dword updCrc32(byte ch, dword crc) { return (dword)(__crc32_table[byte(crc) ^ byte(ch)] ^ (crc >> 8)); } +inline word updCrc16(byte ch, word crc) { return (word)(__crc16_table[crc >> 8] ^ ((crc << 8) & 0xFFFF) ^ ch); } +inline word updCrc16c(byte ch, word crc) { return (word)(__crc16_table[(crc >> 8) ^ ch] ^ ((crc << 8) & 0xFFFF)); } +inline dword updCrc32(byte ch, dword crc) { return (dword)(__crc32_table[(crc & 0xFF) ^ ch] ^ (crc >> 8)); } // ------------------------------------------------------------------ diff --git a/goldlib/gall/gdefs.h b/goldlib/gall/gdefs.h index 0dbca06..7ef47dd 100644 --- a/goldlib/gall/gdefs.h +++ b/goldlib/gall/gdefs.h @@ -31,6 +31,8 @@ #define __goldall_h /* ------------------------------------------------------------------ */ +#include + #ifdef __cplusplus #include #endif @@ -43,6 +45,11 @@ #else #endif +#if !defined(ARRAYSIZE) +#define ARRAYSIZE(A) sizeof(A)/sizeof((A)[0]) +#endif + + /* ------------------------------------------------------------------ // Disable some MS Visual C warnings */ diff --git a/goldlib/gall/gfilutil.h b/goldlib/gall/gfilutil.h index ca9cc98..74d06cb 100644 --- a/goldlib/gall/gfilutil.h +++ b/goldlib/gall/gfilutil.h @@ -149,10 +149,14 @@ struct Stamp { FILE* fsopen(const char* path, const char* type, int shflag); inline FILE* fsopen(const std::string& path, const char* type, int shflag) { return fsopen(path.c_str(), type, shflag); } -int is_dir(const char* path); -inline int is_dir(const std::string& path) { return is_dir(path.c_str()); } +bool is_dir(const TCHAR *path); +inline bool 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; } +#if defined(_taccess_s) +inline bool fexist(const TCHAR *filename) { return *filename ? (0 == (_taccess_s(filename, R_OK)) && !is_dir(filename)) : false; } +#else +inline bool fexist(const TCHAR *filename) { return *filename ? (0 == (_taccess(filename, R_OK)) && !is_dir(filename)) : false; } +#endif inline bool fexist(const std::string& filename) { return fexist(filename.c_str()); } dword gfixstattime(time32_t st_time); @@ -193,8 +197,8 @@ int strschg_environ(std::string& s); char* MapPath(char* map, bool reverse = false); // gcarea.cpp inline char* ReMapPath(char* map) { return MapPath(map, true); } -inline long lseekset(int fh, long offset) { return lseek(fh, offset, SEEK_SET); } -inline long lseekset(int fh, long record, long recordsize) { return lseek(fh, record*recordsize, SEEK_SET); } +inline long lseekset(int fh, long offset) { return _lseek(fh, offset, SEEK_SET); } +inline long lseekset(int fh, long record, long recordsize) { return _lseek(fh, record*recordsize, SEEK_SET); } int gchdir(const char* dir); diff --git a/goldlib/gall/gfilutl1.cpp b/goldlib/gall/gfilutl1.cpp index d85fec8..577ac27 100644 --- a/goldlib/gall/gfilutl1.cpp +++ b/goldlib/gall/gfilutl1.cpp @@ -96,12 +96,12 @@ long GetFilesize(const char* file) { // ------------------------------------------------------------------ // Convert time returned with stat to FFTime -dword gfixstattime(time32_t st_time) { - +dword gfixstattime(time32_t st_time) +{ #if (defined(__MINGW32__) && !defined(__MSVCRT__)) || defined(__CYGWIN__) - struct tm &f = *ggmtime(&st_time); + struct tm f; ggmtime(&f, &st_time); #else - struct tm &f = *glocaltime(&st_time); + struct tm f; glocaltime(&f, &st_time); #endif FFTime t; t.ft_year = f.tm_year - 80; @@ -164,8 +164,8 @@ long fsize(FILE* fp) { // ------------------------------------------------------------------ // Check if a pathname is a directory -int is_dir(const char* path) { - +bool is_dir(const TCHAR *path) +{ // Check if it's a root path (X:\) #if defined(__HAVE_DRIVES__) if(g_isalpha(path[0]) and (path[1] == ':') and isslash(path[2]) and (path[3] == NUL)) diff --git a/goldlib/gall/gkbdbase.cpp b/goldlib/gall/gkbdbase.cpp index 257d594..54216bd 100644 --- a/goldlib/gall/gkbdbase.cpp +++ b/goldlib/gall/gkbdbase.cpp @@ -1572,7 +1572,7 @@ gkey kbxget_raw(int mode) { // TO_PORT_TAG: kbxget_raw(3) #if defined(__WIN32__) - KeyCtrlState = (gkey)inp.Event.KeyEvent.dwControlKeyState; + KeyCtrlState = (gkey)(inp.Event.KeyEvent.dwControlKeyState & 0xFFFF); #endif return k; } diff --git a/goldlib/gall/glog.cpp b/goldlib/gall/glog.cpp index 78b14f3..f724bba 100644 --- a/goldlib/gall/glog.cpp +++ b/goldlib/gall/glog.cpp @@ -34,10 +34,10 @@ // ------------------------------------------------------------------ -struct tm* glog::time_now; -int glog::count = 0; -time32_t glog::secs_now; -char glog::timebuf[20]; +struct tm glog::time_now; +int glog::count = 0; +time32_t glog::secs_now; +char glog::timebuf[20]; // ------------------------------------------------------------------ @@ -109,7 +109,7 @@ void glog::printf(const char* format, ...) { char logbuf[256]; secs_now = gtime(NULL); - time_now = glocaltime(&secs_now); + glocaltime(&time_now, &secs_now); lineswritten++; @@ -118,23 +118,23 @@ void glog::printf(const char* format, ...) { switch(logtype) { case GLOG_FD: - sprintf(logbuf, "\n---------- %s, %s\n", strftimei(timebuf, 20, "%a %d %b %y", time_now), progname); + sprintf(logbuf, "\n---------- %s, %s\n", strftimei(timebuf, 20, "%a %d %b %y", &time_now), progname); break; case GLOG_MAX: - sprintf(logbuf, "\n+ %s %4.4s Begin, %s\n", strftimei(timebuf, 20, "%d %b %H:%M:%S", time_now), shortprogname, progname); + sprintf(logbuf, "\n+ %s %4.4s Begin, %s\n", strftimei(timebuf, 20, "%d %b %H:%M:%S", &time_now), shortprogname, progname); break; case GLOG_BINK: - sprintf(logbuf, "\n> %s %4.4s %s\n", strftimei(timebuf, 20, "%d-%b %H:%M:%S", time_now), shortprogname, progname); + sprintf(logbuf, "\n> %s %4.4s %s\n", strftimei(timebuf, 20, "%d-%b %H:%M:%S", &time_now), shortprogname, progname); break; case GLOG_QBBS: - sprintf(logbuf, "\n%s **************************************************\n%s %s\n", strftimei(timebuf, 20, "%d-%b-%y %H:%M", time_now), timebuf, progname); + sprintf(logbuf, "\n%s **************************************************\n%s %s\n", strftimei(timebuf, 20, "%d-%b-%y %H:%M", &time_now), timebuf, progname); break; case GLOG_DB: - sprintf(logbuf, "\n%s %s\n", strftimei(timebuf, 20, "%m/%d/%y %H:%M", time_now), progname); + sprintf(logbuf, "\n%s %s\n", strftimei(timebuf, 20, "%m/%d/%y %H:%M", &time_now), progname); break; } @@ -153,23 +153,23 @@ void glog::printf(const char* format, ...) { switch(logtype) { case GLOG_FD: - sprintf(logbuf, "%c %s %s", *buf, strftimei(timebuf, 10, "%H:%M:%S", time_now), buf+2); + sprintf(logbuf, "%c %s %s", *buf, strftimei(timebuf, 10, "%H:%M:%S", &time_now), buf+2); break; case GLOG_MAX: - sprintf(logbuf, "%c %s %4.4s %s", *buf, strftimei(timebuf, 20, "%d %b %H:%M:%S", time_now), shortprogname, buf+2); + sprintf(logbuf, "%c %s %4.4s %s", *buf, strftimei(timebuf, 20, "%d %b %H:%M:%S", &time_now), shortprogname, buf+2); break; case GLOG_BINK: - sprintf(logbuf, "%c %s %4.4s %s", *buf, strftimei(timebuf, 20, "%d-%b %H:%M:%S", time_now), shortprogname, buf+2); + sprintf(logbuf, "%c %s %4.4s %s", *buf, strftimei(timebuf, 20, "%d-%b %H:%M:%S", &time_now), shortprogname, buf+2); break; case GLOG_QBBS: - sprintf(logbuf, "%s %s", strftimei(timebuf, 20, "%d-%b-%y %H:%M", time_now), buf+2); + sprintf(logbuf, "%s %s", strftimei(timebuf, 20, "%d-%b-%y %H:%M", &time_now), buf+2); break; case GLOG_DB: - sprintf(logbuf, "%s %s", strftimei(timebuf, 20, "%m/%d/%y %H:%M", time_now), buf+2); + sprintf(logbuf, "%s %s", strftimei(timebuf, 20, "%m/%d/%y %H:%M", &time_now), buf+2); break; } if(fp.isopen()) { diff --git a/goldlib/gall/glog.h b/goldlib/gall/glog.h index dfbb06a..9e86c86 100644 --- a/goldlib/gall/glog.h +++ b/goldlib/gall/glog.h @@ -60,7 +60,7 @@ private: gfile fp; static int count; - static struct tm* time_now; + static struct tm time_now; static time32_t secs_now; static char timebuf[20]; diff --git a/goldlib/gall/gmsgattr.h b/goldlib/gall/gmsgattr.h index d88c5f4..ac18c75 100644 --- a/goldlib/gall/gmsgattr.h +++ b/goldlib/gall/gmsgattr.h @@ -492,8 +492,8 @@ typedef ftn_attr Attr; // ------------------------------------------------------------------ inline void AttrAdd(Attr* a, Attr* b) { a->add(*b); } -inline void GetAttribstr(Attr* attr, const char* attrs) { attr->get(attrs); } -inline char* MakeAttrStr(char* str, size_t maxlen, const Attr* attr) { std::string tmp; attr->make_string(tmp); strxcpy(str, tmp.c_str(), maxlen); return str; } +inline void GetAttribstr(Attr* attr, const TCHAR *attrs) { attr->get(attrs); } +inline TCHAR *MakeAttrStr(TCHAR *str, size_t maxlen, const Attr *attr) { std::string tmp; attr->make_string(tmp); strxcpy(str, tmp.c_str(), maxlen); return str; } // ------------------------------------------------------------------ diff --git a/goldlib/gall/gstrall.h b/goldlib/gall/gstrall.h index 59e71d7..3270355 100644 --- a/goldlib/gall/gstrall.h +++ b/goldlib/gall/gstrall.h @@ -82,7 +82,7 @@ char* longdotstr(char* str, long num); // Convert a long to a char* StripQuotes(char* str); // Safe versions of strcpy, strcat, sequencial strcat... -char* strxcpy(char* d, const char* s, int n); +TCHAR *strxcpy(TCHAR *d, const TCHAR *s, size_t n); char* strxcat(char *dest, const char *src, size_t max); char* strxmerge(char *dest, size_t max, ...); @@ -105,10 +105,10 @@ char* strunrevname(char* unreversedname, const char* name); inline char* strbtrim(char* st) { return strtrim(strltrim(st)); } -inline bool streql(const char* str1, const char* str2) { return not strcmp(str1,str2); } -inline bool strieql(const char* str1, const char* str2) { return not stricmp(str1,str2); } -inline bool strneql(const char* str1, const char* str2, int n) { return not strncmp(str1,str2,n); } -inline bool strnieql(const char* str1, const char* str2, int n) { return not strnicmp(str1,str2,n); } +inline bool streql (const TCHAR *str1, const TCHAR *str2) { return (0 == _tcscmp (str1, str2)); } +inline bool strieql (const TCHAR *str1, const TCHAR *str2) { return (0 == _tcsicmp (str1, str2)); } +inline bool strneql (const TCHAR *str1, const TCHAR *str2, int n) { return (0 == _tcsncmp (str1, str2, n)); } +inline bool strnieql(const TCHAR *str1, const TCHAR *str2, int n) { return (0 == _tcsnicmp(str1, str2, n)); } inline const char* strskip_to(const char* p, char* s) { return p+strcspn(p, s); } inline char* strskip_to(char* p, char* s) { return p+strcspn(p, s); } @@ -142,20 +142,26 @@ char* strcvtc(char* s); // ------------------------------------------------------------------ // String tokenizer class -class GTok { - +class GTok +{ protected: - - const char* separator; - char* token; + const TCHAR *separator; + TCHAR *token; +#if defined(_tcstok_s) + TCHAR *next_token; +#endif public: + GTok(TCHAR *sep = NULL); - GTok(char* sep=NULL); - - char* First(char* buf) { token = strtok(buf, separator); return token; } - char* Next() { token = strtok(NULL, separator); return token; } - char* Token() { return token; } +#if defined(_tcstok_s) + TCHAR *First(TCHAR *buf) { token = _tcstok_s(buf, separator, &next_token); return token; } + TCHAR *Next() { token = _tcstok_s(NULL, separator, &next_token); return token; } +#else + TCHAR *First(TCHAR *buf) { token = _tcstok(buf, separator); return token; } + TCHAR *Next() { token = _tcstok(NULL, separator); return token; } +#endif + TCHAR *Token() { return token; } }; diff --git a/goldlib/gall/gstrarr.h b/goldlib/gall/gstrarr.h index ad90dc1..8a2d24d 100644 --- a/goldlib/gall/gstrarr.h +++ b/goldlib/gall/gstrarr.h @@ -44,16 +44,28 @@ typedef std::vector gstrarray; // ------------------------------------------------------------------ -inline void tokenize(gstrarray& array, const char* str, const char* delim = NULL) { - if(delim == NULL) - delim = ", \t"; - char* tmp = throw_xstrdup(str); - char* token = strtok(tmp, delim); - while(token) { - array.push_back(token); - token = strtok(NULL, delim); - } - throw_xfree(tmp); +inline void tokenize(gstrarray &array, const TCHAR* str, const TCHAR *delim = NULL) +{ + if (delim == NULL) delim = ", \t"; + TCHAR *tmp = throw_xstrdup(str); +#if defined(_tcstok_s) + TCHAR *next_token; + TCHAR *token = _tcstok_s(tmp, delim, &next_token); +#else + TCHAR *token = _tcstok(tmp, delim); +#endif + + while (NULL != token) + { + array.push_back(token); +#if defined(_tcstok_s) + token = _tcstok_s(NULL, delim, &next_token); +#else + token = _tcstok(NULL, delim); +#endif + } + + throw_xfree(tmp); } diff --git a/goldlib/gall/gstrutil.cpp b/goldlib/gall/gstrutil.cpp index d82fa0b..f23eaa9 100644 --- a/goldlib/gall/gstrutil.cpp +++ b/goldlib/gall/gstrutil.cpp @@ -562,14 +562,19 @@ const char* strrword(const char* str, const char *separator) { // ------------------------------------------------------------------ -char* strxcpy(char* d, const char* s, int n) { - - if(n) { - strncpy(d, s, n-1); +TCHAR *strxcpy(TCHAR *d, const TCHAR *s, size_t n) +{ +#if defined(_tcsncpy_s) + _tcsncpy_s(d, n, s, _TRUNCATE); +#else + if (n) + { + _tcsncpy(d, s, n-1); d[n-1] = NUL; } else *d = NUL; +#endif return d; } diff --git a/goldlib/gall/gtimall.h b/goldlib/gall/gtimall.h index 522041a..74a1f7e 100644 --- a/goldlib/gall/gtimall.h +++ b/goldlib/gall/gtimall.h @@ -45,7 +45,9 @@ #ifdef __WIN32__ #include #endif - +#if defined(_MSC_VER) && (_MSC_VER >= 1400) +#include +#endif // ------------------------------------------------------------------ @@ -123,39 +125,69 @@ extern const char* gmonths[]; // ------------------------------------------------------------------ // Prototypes -inline struct tm *ggmtime(const time32_t *timep) +inline void ggmtime(struct tm *_tm, const time32_t *timep) { const time_t temp(*timep); -#if defined(__WIN32__) - const time_t zero(0); +#if defined(_MSC_VER) && (_MSC_VER >= 1400) + if (0 != gmtime_s(_tm, &temp)) + { + const time_t zero(0); + gmtime_s(_tm, &zero); + } +#else struct tm *time = gmtime(&temp); - return time ? time : gmtime(&zero); -#else - return gmtime(&temp); +#if defined(__WIN32__) + if (NULL == time) + { + const time_t zero(0); + time = gmtime(&zero); + } +#endif + *_tm = *time; #endif } -inline struct tm *glocaltime(const time32_t *timep) +inline void glocaltime(struct tm *_tm, const time32_t *timep) { const time_t temp(*timep); -#if defined(__WIN32__) - const time_t zero(0); +#if defined(_MSC_VER) && (_MSC_VER >= 1400) + if (0 != localtime_s(_tm, &temp)) + { + const time_t zero(0); + localtime_s(_tm, &zero); + } +#else struct tm *time = localtime(&temp); - return time ? time : localtime(&zero); -#else - return localtime(&temp); +#if defined(__WIN32__) + if (NULL == time) + { + const time_t zero(0); + time = localtime(&zero); + } +#endif + *_tm = *time; #endif } -inline char *gctime(const time32_t *timep) +inline void gctime(TCHAR *buffer, size_t sizeInChars, const time32_t *timep) { const time_t temp(*timep); -#if defined(__WIN32__) - const time_t zero(0); - char *time = ctime(&temp); - return time ? time : ctime(&zero); +#if defined(_MSC_VER) && (_MSC_VER >= 1400) + if (0 != _tctime_s(buffer, sizeInChars, &temp)) + { + const time_t zero(0); + _tctime_s(buffer, sizeInChars, &zero); + } #else - return ctime(&temp); + const char *time = _tctime(&temp); +#if defined(__WIN32__) + if (NULL == time) + { + const time_t zero(0); + time = _tctime(&zero); + } +#endif + strxcpy(buffer, time, sizeInChars); #endif } diff --git a/goldlib/gall/gtimutil.cpp b/goldlib/gall/gtimutil.cpp index 04b2cb8..c388138 100644 --- a/goldlib/gall/gtimutil.cpp +++ b/goldlib/gall/gtimutil.cpp @@ -58,12 +58,12 @@ const char* gmonths[] = { // ------------------------------------------------------------------ // Returns current timezone offset based on TZ environment variable. -int tzoffset() { - - time32_t t1 = gtime(NULL); - struct tm *tp = ggmtime(&t1); - tp->tm_isdst = -1; - time32_t t2 = gmktime(tp); +int tzoffset() +{ + time32_t t1 = gtime(NULL); + struct tm tp; ggmtime(&tp, &t1); + tp.tm_isdst = -1; + time32_t t2 = gmktime(&tp); int dt = (int)(t1 - t2); return (dt / 3600) * 100 + (dt % 3600) / 60; } @@ -350,10 +350,10 @@ time32_t FTimeToTime(FTime* __ftime, struct tm* __tm) { __tm->tm_sec = __ftime->ft_tsec * 2; __tm->tm_isdst = -1; - time32_t a = gmktime(__tm); - struct tm *tp = ggmtime(&a); - tp->tm_isdst = -1; - time32_t b = gmktime(tp); + time32_t a = gmktime(__tm); + struct tm tp; ggmtime(&tp, &a); + tp.tm_isdst = -1; + time32_t b = gmktime(&tp); _time = a + a - b; if(_time == (uint32_t)0xFFFFFFFFL) @@ -373,15 +373,15 @@ FTime TimeToFTime(time32_t __time) { FTime _ft; memset(&_ft, 0, sizeof(FTime)); - if(__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); - _ft.ft_hour = (word)(_tmp->tm_hour); - _ft.ft_min = (word)(_tmp->tm_min); - _ft.ft_tsec = (word)(_tmp->tm_sec / 2); + if (__time) + { + struct tm _tmp; ggmtime(&_tmp, &__time); + _ft.ft_year = (word)(_tmp.tm_year - 80); + _ft.ft_month = (word)(_tmp.tm_mon + 1); + _ft.ft_day = (word)(_tmp.tm_mday); + _ft.ft_hour = (word)(_tmp.tm_hour); + _ft.ft_min = (word)(_tmp.tm_min); + _ft.ft_tsec = (word)(_tmp.tm_sec / 2); } return _ft; @@ -441,10 +441,10 @@ time32_t FidoTimeToUnix(char* ptr) { t.tm_min = minute; t.tm_sec = second; t.tm_isdst = -1; - time32_t a = gmktime(&t); - struct tm *tp = ggmtime(&a); - tp->tm_isdst = -1; - time32_t b = gmktime(tp); + time32_t a = gmktime(&t); + struct tm tp; ggmtime(&tp, &a); + tp.tm_isdst = -1; + time32_t b = gmktime(&tp); return a + a - b; } return (uint32_t)-1; @@ -453,9 +453,10 @@ time32_t FidoTimeToUnix(char* ptr) { // ------------------------------------------------------------------ -char* TimeToStr(char* buf, time32_t t) { - - return strftimei(buf, 20, "%Y-%m-%d %H:%M:%S", ggmtime(&t)); +char* TimeToStr(char* buf, time32_t t) +{ + struct tm tm; ggmtime(&tm, &t); + return strftimei(buf, 20, "%Y-%m-%d %H:%M:%S", &tm); } diff --git a/goldlib/gall/gvidall.h b/goldlib/gall/gvidall.h index bcee385..2d899a2 100644 --- a/goldlib/gall/gvidall.h +++ b/goldlib/gall/gvidall.h @@ -439,8 +439,8 @@ inline vatch vcatch (vchar chr, vattr atr) { return chr | gvid_attrcalc(atr); } inline vchar vgchar (vatch chat) { return chat.Char.AsciiChar; } inline vattr vgattr (vatch chat) { return chat.Attributes; } inline vatch vschar (vatch chat, vchar chr) { chat.Char.UnicodeChar = 0; chat.Char.AsciiChar = chr; return chat; } -inline vatch vsattr (vatch chat, vattr atr) { chat.Attributes = atr; return chat; } -inline vatch vcatch (vchar chr, vattr atr) { vatch chat; chat.Char.UnicodeChar = 0; chat.Char.AsciiChar = chr; chat.Attributes = atr; return chat; } +inline vatch vsattr (vatch chat, vattr atr) { chat.Attributes = WORD(atr); return chat; } +inline vatch vcatch (vchar chr, vattr atr) { vatch chat; chat.Char.UnicodeChar = 0; chat.Char.AsciiChar = chr; chat.Attributes = WORD(atr); return chat; } #else diff --git a/goldlib/glibc/regex.c b/goldlib/glibc/regex.c index a733b78..6165dcc 100644 --- a/goldlib/glibc/regex.c +++ b/goldlib/glibc/regex.c @@ -5762,11 +5762,7 @@ weak_alias (__regexec, regexec) from either regcomp or regexec. We don't use PREG here. */ size_t -regerror (errcode, preg, errbuf, errbuf_size) - int errcode; - const regex_t *preg; - char *errbuf; - size_t errbuf_size; +regerror (int errcode, const regex_t *preg, char *errbuf, size_t errbuf_size) { const char *msg; size_t msg_size; diff --git a/goldlib/gmb3/gmofido3.cpp b/goldlib/gmb3/gmofido3.cpp index aec6b98..4141e3a 100644 --- a/goldlib/gmb3/gmofido3.cpp +++ b/goldlib/gmb3/gmofido3.cpp @@ -96,11 +96,12 @@ int FidoArea::load_message(int __mode, gmsg* __msg, FidoHdr& __hdr) { __msg->written = __msg->written ? __msg->written : FidoTimeToUnix(__hdr.datetime); - if(__msg->arrived == 0) { - time32_t a = gtime(NULL); - struct tm *tp = ggmtime(&a); - tp->tm_isdst = -1; - time32_t b = gmktime(tp); + if (__msg->arrived == 0) + { + time32_t a = gtime(NULL); + struct tm tp; ggmtime(&tp, &a); + tp.tm_isdst = -1; + time32_t b = gmktime(&tp); __msg->arrived = a + a - b; } diff --git a/goldlib/gmb3/gmofido4.cpp b/goldlib/gmb3/gmofido4.cpp index ca30e6d..270c5ec 100644 --- a/goldlib/gmb3/gmofido4.cpp +++ b/goldlib/gmb3/gmofido4.cpp @@ -168,11 +168,12 @@ 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 = ggmtime(&__msg->written); + + struct tm _tm; ggmtime(&_tm, &__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 - ); + _tm.tm_mday, gmonths[_tm.tm_mon + 1], _tm.tm_year % 100, + _tm.tm_hour, _tm.tm_min, _tm.tm_sec + ); // Write message header write(_fh, &__hdr, sizeof(FidoHdr)); diff --git a/goldlib/gmb3/gmohuds3.cpp b/goldlib/gmb3/gmohuds3.cpp index cbd2e60..7fff3b0 100644 --- a/goldlib/gmb3/gmohuds3.cpp +++ b/goldlib/gmb3/gmohuds3.cpp @@ -134,10 +134,10 @@ int _HudsArea::load_message(in _tm.tm_min = _minute; _tm.tm_sec = 0; _tm.tm_isdst = -1; - time32_t a = gmktime(&_tm); - struct tm *tp = ggmtime(&a); - tp->tm_isdst = -1; - time32_t b = gmktime(tp); + time32_t a = gmktime(&_tm); + struct tm tp; ggmtime(&tp, &a); + tp.tm_isdst = -1; + time32_t b = gmktime(&tp); __msg->written = a + a - b; __msg->arrived = 0; diff --git a/goldlib/gmb3/gmohuds4.cpp b/goldlib/gmb3/gmohuds4.cpp index 5909f78..8586241 100644 --- a/goldlib/gmb3/gmohuds4.cpp +++ b/goldlib/gmb3/gmohuds4.cpp @@ -127,9 +127,9 @@ void _HudsArea::save_message(i __hdr.replyto = (msgn_t)__msg->link.to(); __hdr.reply1st = (msgn_t)__msg->link.first(); - struct tm* _tmp = ggmtime(&__msg->written); - strc2p(strftimei(__hdr.date, 9, "%m-%d-%y", _tmp)); - strc2p(strftimei(__hdr.time, 6, "%H:%M", _tmp)); + struct tm _tmp; ggmtime(&_tmp, &__msg->written); + strc2p(strftimei(__hdr.date, 9, "%m-%d-%y", &_tmp)); + strc2p(strftimei(__hdr.time, 6, "%H:%M", &_tmp)); strc2p(strxcpy(__hdr.to, __msg->to, sizeof(__hdr.to))); strc2p(strxcpy(__hdr.by, __msg->by, sizeof(__hdr.by))); diff --git a/goldlib/gmb3/gmojamm2.cpp b/goldlib/gmb3/gmojamm2.cpp index 92c3097..2e68609 100644 --- a/goldlib/gmb3/gmojamm2.cpp +++ b/goldlib/gmb3/gmojamm2.cpp @@ -148,14 +148,14 @@ void JamArea::open_area() { data->highwater = -1; // Is the signature invalid? - if(memcmp(data->hdrinfo.signature, JAM_SIGNATURE, 4)) { - + if (memcmp(data->hdrinfo.signature, JAM_SIGNATURE, 4)) + { // Initialize header info memcpy(data->hdrinfo.signature, JAM_SIGNATURE, 4); - time32_t a = gtime(NULL); - struct tm *tp = ggmtime(&a); - tp->tm_isdst = -1; - time32_t b = gmktime(tp); + time32_t a = gtime(NULL); + struct tm tp; ggmtime(&tp, &a); + tp.tm_isdst = -1; + time32_t b = gmktime(&tp); data->hdrinfo.datecreated = a + a - b; data->hdrinfo.passwordcrc = 0xFFFFFFFFL; data->hdrinfo.basemsgnum = 1; diff --git a/goldlib/gmb3/gmopcbd3.cpp b/goldlib/gmb3/gmopcbd3.cpp index 6540735..8534826 100644 --- a/goldlib/gmb3/gmopcbd3.cpp +++ b/goldlib/gmb3/gmopcbd3.cpp @@ -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; - time32_t a = gmktime(&_tm); - struct tm *tp = ggmtime(&a); - tp->tm_isdst = -1; - time32_t b = gmktime(tp); + time32_t a = gmktime(&_tm); + struct tm tp; ggmtime(&tp, &a); + tp.tm_isdst = -1; + time32_t b = gmktime(&tp); __msg->written = a + a - b; __msg->arrived = 0; diff --git a/goldlib/gmb3/gmopcbd4.cpp b/goldlib/gmb3/gmopcbd4.cpp index 6f71418..3c4f06a 100644 --- a/goldlib/gmb3/gmopcbd4.cpp +++ b/goldlib/gmb3/gmopcbd4.cpp @@ -158,18 +158,22 @@ void PcbArea::save_message(int __mode, gmsg* __msg, PcbHdr& __hdr) { // Convert dates and times char _dtbuf[9]; - 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()) { + struct tm _tm; ggmtime(&_tm, &__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 = 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); + ggmtime(&_tm, &__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); } - else { + else + { __hdr.hasreply = ' '; __hdr.replydate = L2B(0); memcpy(__hdr.replytime, " ", 5); diff --git a/goldlib/gmb3/gmosmb1.cpp b/goldlib/gmb3/gmosmb1.cpp index 62199d4..d237e1e 100644 --- a/goldlib/gmb3/gmosmb1.cpp +++ b/goldlib/gmb3/gmosmb1.cpp @@ -324,13 +324,14 @@ 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); - time32_t a = smsgp->hdr.when_written.time; - struct tm *tp = ggmtime(&a); - tp->tm_isdst = -1; - time32_t b = gmktime(tp); + time32_t a = smsgp->hdr.when_written.time; + struct tm tp; ggmtime(&tp, &a); + tp.tm_isdst = -1; + time32_t b = gmktime(&tp); __msg->written = a + a - b; a = smsgp->hdr.when_imported.time; - b = gmktime(ggmtime(&a)); + ggmtime(&tp, &a); + b = gmktime(&tp); __msg->arrived = a + a - b; __msg->received = 0; @@ -533,12 +534,13 @@ void SMBArea::save_hdr(int mode, gmsg* msg) smsg.hdr.netattr = 0; smsg.hdr.auxattr = 0; } - else { + else + { memcpy(smsg.hdr.id, "SHD\x1a", 4); smsg.hdr.version = smb_ver(); - struct tm *tp = ggmtime(&msg->written); - tp->tm_isdst = -1; - smsg.hdr.when_written.time = gmktime(tp); + struct tm tp; ggmtime(&tp, &msg->written); + tp.tm_isdst = -1; + smsg.hdr.when_written.time = gmktime(&tp); } smsg.hdr.when_imported.time = gtime(NULL); @@ -968,9 +970,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, gctime(&smsg.hdr.when_written.time))[-1] = NUL; + gctime(buf, ARRAYSIZE(buf), &smsg.hdr.when_written.time); line = AddLineF(line, "Written : %s", buf); - stpcpy(buf, gctime(&smsg.hdr.when_imported.time))[-1] = NUL; + gctime(buf, ARRAYSIZE(buf), &smsg.hdr.when_imported.time); 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); diff --git a/goldlib/gmb3/gmosqsh4.cpp b/goldlib/gmb3/gmosqsh4.cpp index 7d4e701..eb9b0f6 100644 --- a/goldlib/gmb3/gmosqsh4.cpp +++ b/goldlib/gmb3/gmosqsh4.cpp @@ -437,11 +437,12 @@ void SquishArea::save_message(int __mode, gmsg* __msg) { __hdr.date_written = TimeToFTime(__msg->written); __hdr.date_arrived = TimeToFTime(__msg->arrived); - struct tm* _tm = ggmtime(&__msg->written); + + struct tm _tm; ggmtime(&_tm, &__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 - ); + _tm.tm_mday, gmonths[_tm.tm_mon + 1], _tm.tm_year % 100, + _tm.tm_hour, _tm.tm_min, _tm.tm_sec + ); // Setup some local variables for speed int _fhsqd = data->fhsqd; diff --git a/goldlib/gmb3/gmowcat3.cpp b/goldlib/gmb3/gmowcat3.cpp index 8895810..fee01ca 100644 --- a/goldlib/gmb3/gmowcat3.cpp +++ b/goldlib/gmb3/gmowcat3.cpp @@ -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; - time32_t a = gmktime(&_tm); - struct tm *tp = ggmtime(&a); - tp->tm_isdst = -1; - time32_t b = gmktime(tp); + time32_t a = gmktime(&_tm); + struct tm tp; ggmtime(&tp, &a); + 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; - time32_t a = gmktime(&_tm); - struct tm *tp = ggmtime(&a); - tp->tm_isdst = -1; - time32_t b = gmktime(tp); + time32_t a = gmktime(&_tm); + struct tm tp; ggmtime(&tp, &a); + tp.tm_isdst = -1; + time32_t b = gmktime(&tp); __msg->received = a + a - b; } diff --git a/goldlib/gmb3/gmowcat4.cpp b/goldlib/gmb3/gmowcat4.cpp index 6079321..1cc8e34 100644 --- a/goldlib/gmb3/gmowcat4.cpp +++ b/goldlib/gmb3/gmowcat4.cpp @@ -118,16 +118,18 @@ void WCatArea::save_message(int __mode, gmsg* __msg, WCatHdr& __hdr) { strcpy(__msg->wildcat.network, "FTSC"); strc2p(strcpy(__hdr.network, __msg->wildcat.network)); - if(__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->written) + { + struct tm _tm; ggmtime(&_tm, &__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 = 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; + if (__msg->received) + { + struct tm _tm; ggmtime(&_tm, &__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; } __hdr.mflags |= (word)(__msg->attr.pvt() ? mfPrivate : 0); diff --git a/goldlib/gmb3/gmowcat5.cpp b/goldlib/gmb3/gmowcat5.cpp index c0b1f3e..79f3cc2 100644 --- a/goldlib/gmb3/gmowcat5.cpp +++ b/goldlib/gmb3/gmowcat5.cpp @@ -77,8 +77,10 @@ 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", 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); + struct tm _tm; ggmtime(&_tm, &msg->written); + AddLineF(line, "MsgTime : %s (%u, %i)", strftimei(buf, 100, "%d %b %y %H:%M:%S", &_tm), _hdr.msgdate, _hdr.msgtime); + ggmtime(&_tm, &msg->received); + AddLineF(line, "ReadTime : %s (%u, %i)", strftimei(buf, 100, "%d %b %y %H:%M:%S", &_tm), _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); diff --git a/goldlib/gmb3/gmoxbbs3.cpp b/goldlib/gmb3/gmoxbbs3.cpp index 3c52551..593b4f8 100644 --- a/goldlib/gmb3/gmoxbbs3.cpp +++ b/goldlib/gmb3/gmoxbbs3.cpp @@ -65,17 +65,19 @@ int XbbsArea::load_message(int __mode, gmsg* __msg, XbbsHdr& __hdr) { __msg->written = FidoTimeToUnix(__hdr.date); __msg->received = __hdr.timerecv; - if(__hdr.indate[2]) { + + if(__hdr.indate[2]) + { struct tm t; - t.tm_year = __hdr.indate[0]+89; - t.tm_mon = __hdr.indate[1]-1; - t.tm_mday = __hdr.indate[2]; - t.tm_hour = t.tm_min = t.tm_sec = 0; - t.tm_isdst = -1; - time32_t a = gmktime(&t); - struct tm *tp = ggmtime(&a); - tp->tm_isdst = -1; - time32_t b = gmktime(tp); + t.tm_year = __hdr.indate[0]+89; + t.tm_mon = __hdr.indate[1]-1; + t.tm_mday = __hdr.indate[2]; + t.tm_hour = t.tm_min = t.tm_sec = 0; + t.tm_isdst = -1; + time32_t a = gmktime(&t); + struct tm tp; ggmtime(&tp, &a); + tp.tm_isdst = -1; + time32_t b = gmktime(&tp); __msg->arrived = a + a - b; } diff --git a/goldlib/gmb3/gmoxbbs4.cpp b/goldlib/gmb3/gmoxbbs4.cpp index 7fbe130..f8da379 100644 --- a/goldlib/gmb3/gmoxbbs4.cpp +++ b/goldlib/gmb3/gmoxbbs4.cpp @@ -135,16 +135,17 @@ 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 = ggmtime(&__msg->written); + struct tm _tm; ggmtime(&_tm, &__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 = 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); + _tm.tm_mday, gmonths[_tm.tm_mon + 1], _tm.tm_year % 100, + _tm.tm_hour, _tm.tm_min, _tm.tm_sec + ); + + if (__msg->arrived) ggmtime(&_tm, &__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); __hdr.indate[3] = 0; __hdr.msgnum = __msg->msgno;