Fixing warnings and errors for MSVS 2005 compiler

This commit is contained in:
Ianos Gnatiuc 2006-04-21 19:57:30 +00:00
parent e3bbfbee86
commit df0f689816
44 changed files with 417 additions and 289 deletions

View File

@ -326,16 +326,17 @@ const int REPLYRE_NUMERIC = 2;
// ------------------------------------------------------------------ // ------------------------------------------------------------------
// Name typedefs // Name typedefs
typedef char Name[36]; typedef TCHAR Name[36];
// ------------------------------------------------------------------ // ------------------------------------------------------------------
// Combined name/address structure // Combined name/address structure
struct Node { struct Node
{
Name name; Name name;
Addr addr; 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; }
}; };

View File

@ -578,12 +578,14 @@ void DoKludges(int mode, GMsg* msg, int kludges) {
line->kludge = GKLUD_RFC; 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, sprintf(buf, "%sDate: %s, %02d %s %04d %02d:%02d:%02d", rfc,
__gsweekday[tm->tm_wday], __gsweekday[tm.tm_wday],
tm->tm_mday, __gsmonth[tm->tm_mon], 1900+tm->tm_year, tm.tm_mday, __gsmonth[tm.tm_mon], 1900+tm.tm_year,
tm->tm_hour, tm->tm_min, tm->tm_sec tm.tm_hour, tm.tm_min, tm.tm_sec
); );
if(AA->Usetzutc()) if(AA->Usetzutc())
sprintf(buf + strlen(buf), " %+05d", tzoffset()); sprintf(buf + strlen(buf), " %+05d", tzoffset());

View File

@ -176,8 +176,12 @@ void DispHeader(GMsg* msg, bool prn, FILE* fp, int width) {
*buf1 = NUL; *buf1 = NUL;
strsetsz(buf1, nodewidth); strsetsz(buf1, nodewidth);
if(msg->written) if (msg->written)
strftimei(buf2, CFG->disphdrdateset.len, LNG->DateTimeFmt, ggmtime(&msg->written)); {
struct tm tm; ggmtime(&tm, &msg->written);
strftimei(buf2, CFG->disphdrdateset.len, LNG->DateTimeFmt, &tm);
}
strsetsz(buf2, datewidth); strsetsz(buf2, datewidth);
// write from line // write from line
@ -205,8 +209,12 @@ void DispHeader(GMsg* msg, bool prn, FILE* fp, int width) {
*buf2 = NUL; *buf2 = NUL;
strsetsz(buf2, nodewidth); strsetsz(buf2, nodewidth);
if(msg->arrived) if (msg->arrived)
strftimei(buf2, CFG->disphdrdateset.len, LNG->DateTimeFmt, ggmtime(&msg->arrived)); {
struct tm tm; ggmtime(&tm, &msg->arrived);
strftimei(buf2, CFG->disphdrdateset.len, LNG->DateTimeFmt, &tm);
}
strsetsz(buf2, datewidth); strsetsz(buf2, datewidth);
// write to line // write to line

View File

@ -792,7 +792,8 @@ void KludgeDATE(GMsg* msg, const char* ptr) {
} }
} }
if(date_ok) { if (date_ok)
{
struct tm t; struct tm t;
t.tm_year = (year < 80) ? (year+100) : (year > 1900) ? (year-1900) : year; t.tm_year = (year < 80) ? (year+100) : (year > 1900) ? (year-1900) : year;
t.tm_mon = month - 1; t.tm_mon = month - 1;
@ -801,11 +802,11 @@ void KludgeDATE(GMsg* msg, const char* ptr) {
t.tm_min = minute; t.tm_min = minute;
t.tm_sec = second; t.tm_sec = second;
t.tm_isdst = -1; t.tm_isdst = -1;
time32_t a = gmktime(&t); time32_t a = gmktime(&t);
struct tm *tp = ggmtime(&a); struct tm tp; ggmtime(&tp, &a);
tp->tm_isdst = -1; tp.tm_isdst = -1;
time32_t b = gmktime(tp); time32_t b = gmktime(&tp);
msg->written = a + a - b; msg->written = a + a - b;
} }
} }

View File

@ -332,8 +332,13 @@ void GMsgList::print_line(uint idx, uint pos, bool isbar) {
case MSGLISTDATE_ARRIVED: dt = ml->arrived; break; case MSGLISTDATE_ARRIVED: dt = ml->arrived; break;
case MSGLISTDATE_RECEIVED: dt = ml->received; 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()) if(AA->Msglistdate())
strsetsz(dbuf, 10); strsetsz(dbuf, 10);
else else
@ -934,8 +939,12 @@ void GThreadlist::print_line(uint idx, uint pos, bool isbar) {
case MSGLISTDATE_RECEIVED: dt = msg.received; break; case MSGLISTDATE_RECEIVED: dt = msg.received; break;
} }
if(dt) if (dt)
strftimei(dbuf, 20, "%d %b %y", ggmtime(&dt)); {
struct tm tm; ggmtime(&tm, &dt);
strftimei(dbuf, 20, "%d %b %y", &tm);
}
strcat(buf, dbuf); strcat(buf, dbuf);
} }
strcat(buf, " "); strcat(buf, " ");

View File

@ -154,20 +154,20 @@ void TokenXlat(int mode, std::string &input, GMsg* msg, GMsg* oldmsg, int __orig
const char *osver = ggetosstring(); const char *osver = ggetosstring();
time32_t t = gtime(NULL); time32_t t = gtime(NULL);
struct tm* written_tm = glocaltime(&t); struct tm written_tm; glocaltime(&written_tm, &t);
char cdate[80]; char cdate[80];
strftimei(cdate, 80, LNG->DateFmt, written_tm); strftimei(cdate, 80, LNG->DateFmt, &written_tm);
char ctime[80]; char ctime[80];
strftimei(ctime, 80, LNG->TimeFmt, written_tm); strftimei(ctime, 80, LNG->TimeFmt, &written_tm);
char cdtime[80]; char cdtime[80];
strftimei(cdtime, 80, LNG->DateTimeFmt, written_tm); strftimei(cdtime, 80, LNG->DateTimeFmt, &written_tm);
written_tm = ggmtime(&oldmsg->written); ggmtime(&written_tm, &oldmsg->written);
char odate[80]; char odate[80];
strftimei(odate, 80, LNG->DateFmt, written_tm); strftimei(odate, 80, LNG->DateFmt, &written_tm);
char otime[80]; char otime[80];
strftimei(otime, 80, LNG->TimeFmt, written_tm); strftimei(otime, 80, LNG->TimeFmt, &written_tm);
char odtime[80]; char odtime[80];
strftimei(odtime, 80, LNG->DateTimeFmt, written_tm); strftimei(odtime, 80, LNG->DateTimeFmt, &written_tm);
const char* origareaid = AL.AreaIdToPtr(__origarea)->echoid(); const char* origareaid = AL.AreaIdToPtr(__origarea)->echoid();
bool origareaisinet = make_bool(AL.AreaIdToPtr(__origarea)->isinternet()); bool origareaisinet = make_bool(AL.AreaIdToPtr(__origarea)->isinternet());

View File

@ -243,10 +243,10 @@ static void MakeMsg3(int& mode, GMsg* msg) {
// Do Timefields // Do Timefields
if(msg->attr.fmu()) { if(msg->attr.fmu()) {
time32_t a = gtime(NULL); time32_t a = gtime(NULL);
struct tm *tp = ggmtime(&a); struct tm tp; ggmtime(&tp, &a);
tp->tm_isdst = -1; tp.tm_isdst = -1;
time32_t b = gmktime(tp); time32_t b = gmktime(&tp);
a += a - b; a += a - b;
if(AA->havereceivedstamp()) if(AA->havereceivedstamp())
msg->received = a; msg->received = a;
@ -824,10 +824,10 @@ void MakeMsg(int mode, GMsg* omsg, bool ignore_replyto) {
dochgdate = false; dochgdate = false;
} }
if(dochgdate) { if(dochgdate) {
time32_t a = gtime(NULL); time32_t a = gtime(NULL);
struct tm *tp = ggmtime(&a); struct tm tp; ggmtime(&tp, &a);
tp->tm_isdst = -1; tp.tm_isdst = -1;
time32_t b = gmktime(tp); time32_t b = gmktime(&tp);
a += a - b; a += a - b;
msg->received = msg->arrived = msg->written = a; msg->received = msg->arrived = msg->written = a;
} }

View File

@ -208,15 +208,15 @@ int ImportQWK() {
_tm.tm_min = _minute; _tm.tm_min = _minute;
_tm.tm_sec = 0; _tm.tm_sec = 0;
_tm.tm_isdst = -1; _tm.tm_isdst = -1;
time32_t a = gmktime(&_tm); time32_t a = gmktime(&_tm);
struct tm *tp = ggmtime(&a); struct tm tp; ggmtime(&tp, &a);
tp->tm_isdst = -1; tp.tm_isdst = -1;
time32_t b = gmktime(tp); time32_t b = gmktime(&tp);
msg->written = a + a - b; msg->written = a + a - b;
a = gtime(NULL); a = gtime(NULL);
tp = ggmtime(&a); ggmtime(&tp, &a);
tp->tm_isdst = -1; tp.tm_isdst = -1;
b = gmktime(tp); b = gmktime(&tp);
msg->arrived = a + a - b; msg->arrived = a + a - b;
// Read message text // Read message text
@ -369,11 +369,11 @@ int ExportQwkMsg(GMsg* msg, gfile& fp, int confno, int& pktmsgno) {
hdr.status = msg->attr.pvt() ? '*' : ' '; hdr.status = msg->attr.pvt() ? '*' : ' ';
sprintf(buf, "%u", confno); sprintf(buf, "%u", confno);
memcpy(hdr.msgno, buf, strlen(buf)); memcpy(hdr.msgno, buf, strlen(buf));
struct tm* _tm = ggmtime(&msg->written); struct tm _tm; ggmtime(&_tm, &msg->written);
int _year = _tm->tm_year % 100; int _year = _tm.tm_year % 100;
sprintf(buf, "%02d-%02d-%02d", _tm->tm_mon+1, _tm->tm_mday, _year); sprintf(buf, "%02d-%02d-%02d", _tm.tm_mon+1, _tm.tm_mday, _year);
memcpy(hdr.date, buf, 8); 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); memcpy(hdr.time, buf, 5);
strxcpy(buf, msg->to, tolen+1); strxcpy(buf, msg->to, tolen+1);
if(not QWK->MixCaseAllowed()) if(not QWK->MixCaseAllowed())

View File

@ -1181,10 +1181,10 @@ int LoadMessage(GMsg* msg, int margin) {
if(msg->attr.tou()) { if(msg->attr.tou()) {
reader_rcv_noise = 1; reader_rcv_noise = 1;
if(not msg->attr.rcv()) { // Have we seen it? if(not msg->attr.rcv()) { // Have we seen it?
time32_t a = gtime(NULL); time32_t a = gtime(NULL);
struct tm *tp = ggmtime(&a); struct tm tp; ggmtime(&tp, &a);
tp->tm_isdst = -1; tp.tm_isdst = -1;
time32_t b = gmktime(tp); time32_t b = gmktime(&tp);
msg->received = a + a - b; // Get current date msg->received = a + a - b; // Get current date
msg->attr.rcv1(); // Mark as received msg->attr.rcv1(); // Mark as received
reader_rcv_noise++; reader_rcv_noise++;
@ -1426,7 +1426,10 @@ void GotoReplies() {
sprintf(rlist[replies].addr, " (%s) ", buf); sprintf(rlist[replies].addr, " (%s) ", buf);
} }
maxaddr = MaxV(maxaddr, (uint)strlen(rlist[replies].addr)); 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)); maxwritten = MaxV(maxwritten, (uint)strlen(rlist[replies].written));
rlist[replies].reln = reln; rlist[replies].reln = reln;
replies++; replies++;

View File

@ -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->orig = msg->oorig = CFG->internetgate.addr.valid() ? CFG->internetgate.addr : AA->aka();
msg->dest = msg->odest = AA->aka(); msg->dest = msg->odest = AA->aka();
time32_t a = gtime(NULL); time32_t a = gtime(NULL);
struct tm *tp = ggmtime(&a); struct tm tp; ggmtime(&tp, &a);
tp->tm_isdst = -1; tp.tm_isdst = -1;
time32_t b = gmktime(tp); time32_t b = gmktime(&tp);
msg->arrived = a + a - b; msg->arrived = a + a - b;
Line* line = NULL; Line* line = NULL;
Line* fline = NULL; Line* fline = NULL;
@ -697,11 +697,11 @@ int ExportSoupMsg(GMsg* msg, char* msgfile, gfile& fp, int ismail) {
msg->attr.snt1(); msg->attr.snt1();
msg->attr.scn1(); msg->attr.scn1();
msg->attr.uns0(); msg->attr.uns0();
time32_t a = gtime(NULL); time32_t a = gtime(NULL);
struct tm *tp = ggmtime(&a); struct tm tp; ggmtime(&tp, &a);
tp->tm_isdst = -1; tp.tm_isdst = -1;
time32_t b = gmktime(tp); time32_t b = gmktime(&tp);
msg->arrived = a + a - b; msg->arrived = a + a - b;
AA->SaveHdr(GMSG_UPDATE, msg); AA->SaveHdr(GMSG_UPDATE, msg);
if(msg->attr.k_s()) if(msg->attr.k_s())
AA->DeleteMsg(msg, DIR_NEXT); AA->DeleteMsg(msg, DIR_NEXT);

View File

@ -343,11 +343,19 @@ bool guserbase::edit_entry(uint idx) {
char dbuf[16]; char dbuf[16];
time32_t dt = entry.firstdate; 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; dt = entry.lastdate;
if(dt) if (dt)
window.prints(13, 38, wattr, strftimei(dbuf, 16, "%d %b %y", ggmtime(&dt))); {
struct tm tm; ggmtime(&tm, &dt);
window.prints(13, 38, wattr, strftimei(dbuf, 16, "%d %b %y", &tm));
}
sprintf(dbuf, "%8u", entry.times); sprintf(dbuf, "%8u", entry.times);
window.prints(13, width-11, wattr, dbuf); 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) { void guserbase::write_entry(uint idx, bool updateit) {
if(updateit and not entry.is_deleted) { if(updateit and not entry.is_deleted) {
time32_t a = gtime(NULL); time32_t a = gtime(NULL);
struct tm *tp = ggmtime(&a); struct tm tp; ggmtime(&tp, &a);
tp->tm_isdst = -1; tp.tm_isdst = -1;
time32_t b = gmktime(tp); time32_t b = gmktime(&tp);
entry.lastdate = a + a - b; entry.lastdate = a + a - b;
if(not entry.firstdate) if(not entry.firstdate)
entry.firstdate = entry.lastdate; entry.firstdate = entry.lastdate;

View File

@ -53,9 +53,11 @@ void update_statuslines() {
*clkinfo = NUL; *clkinfo = NUL;
*help = NUL; *help = NUL;
if(CFG->switches.get(statuslineclock)) { if(CFG->switches.get(statuslineclock))
{
time32_t t = gtime(NULL); 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) if(CFG->statuslinehelp == -1)
@ -464,7 +466,7 @@ bool is_quote2(Line* line, const char* ptr)
return true; return true;
// found begin of citation? // found begin of citation?
char *begin = strrchr(ln->txt.c_str(), '<'); const char *begin = strrchr(ln->txt.c_str(), '<');
if (begin) if (begin)
{ {
// found both '<' and '>'? // found both '<' and '>'?

View File

@ -267,13 +267,18 @@ void ScreenBlankIdle() {
char blankmsg1[80]; char blankmsg1[80];
char blankmsg2[80]; char blankmsg2[80];
time32_t t = gtime(NULL); 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); sprintf(blankmsg2, " %s ", LNG->BlankMsg);
if(strblank(blankmsg2)) {
if (strblank(blankmsg2))
{
*blankmsg2 = NUL; *blankmsg2 = NUL;
windowheight--; windowheight--;
} }
int b1 = strlen(blankmsg1); int b1 = strlen(blankmsg1);
int b2 = strlen(blankmsg2); int b2 = strlen(blankmsg2);
int blankmsglen = MaxV(b1,b2); int blankmsglen = MaxV(b1,b2);

View File

@ -218,11 +218,16 @@ void GMsgHeaderView::Paint() {
color = GetColorName(msg->By(), msg->orig, color); color = GetColorName(msg->By(), msg->orig, color);
window.prints(2, CFG->disphdrnameset.pos, color, buf); window.prints(2, CFG->disphdrnameset.pos, color, buf);
if(datewidth > 0) { if (datewidth > 0)
if(msg->written) {
strftimei(buf, datewidth+1, LNG->DateTimeFmt, ggmtime(&msg->written)); if (msg->written)
{
struct tm tm; ggmtime(&tm, &msg->written);
strftimei(buf, datewidth+1, LNG->DateTimeFmt, &tm);
}
else else
*buf = NUL; *buf = NUL;
strsetsz(buf, datewidth); strsetsz(buf, datewidth);
window.prints(2, CFG->disphdrdateset.pos, from_color, buf); window.prints(2, CFG->disphdrdateset.pos, from_color, buf);
} }
@ -262,11 +267,16 @@ void GMsgHeaderView::Paint() {
} }
window.prints(3, CFG->disphdrnameset.pos, color, buf); window.prints(3, CFG->disphdrnameset.pos, color, buf);
if(datewidth > 0) { if (datewidth > 0)
if(msg->arrived) {
strftimei(buf, datewidth+1, LNG->DateTimeFmt, ggmtime(&msg->arrived)); if (msg->arrived)
{
struct tm tm; ggmtime(&tm, &msg->arrived);
strftimei(buf, datewidth+1, LNG->DateTimeFmt, &tm);
}
else else
*buf = NUL; *buf = NUL;
strsetsz(buf, datewidth); strsetsz(buf, datewidth);
window.prints(3, CFG->disphdrdateset.pos, to_color, buf); window.prints(3, CFG->disphdrdateset.pos, to_color, buf);
} }

View File

@ -599,7 +599,7 @@ public:
int NextMsglistdate() { adat->msglistdate++; if(adat->msglistdate > MSGLISTDATE_RECEIVED) adat->msglistdate = MSGLISTDATE_NONE; return adat->msglistdate; } 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 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; } 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* 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)); } 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)); } const char* SetTpl(const char* t) { return strxcpy(adat->tpl, t, sizeof(adat->tpl)); }
int SetTwitmode(int m) { adat->twitmode = m; return adat->twitmode; } int SetTwitmode(int m) { adat->twitmode = m; return adat->twitmode; }
const Node& SetUsername(const Node& n) { adat->username = n; return adat->username; } const Node& SetUsername(const Node& n) { adat->username = n; return adat->username; }
const char* SetXlatexport(const char* x) { return strcpy(adat->xlatexport, x); } const TCHAR *SetXlatexport(const TCHAR *x) { return strxcpy(adat->xlatexport, x, ARRAYSIZE(adat->xlatexport)); }
const char* SetXlatimport(const char* x) { return strcpy(adat->xlatimport, x); } 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 ToggleMsglistwidesubj() { adat->msglistwidesubj = not adat->msglistwidesubj; return adat->msglistwidesubj; }
int ToggleViewhidden() { adat->viewhidden = not adat->viewhidden; return adat->viewhidden; } int ToggleViewhidden() { adat->viewhidden = not adat->viewhidden; return adat->viewhidden; }
int ToggleViewkludge() { adat->viewkludge = not adat->viewkludge; return adat->viewkludge; } int ToggleViewkludge() { adat->viewkludge = not adat->viewkludge; return adat->viewkludge; }

View File

@ -51,9 +51,9 @@ extern dword __crc32_table[];
// fill is guaranteed for unsigned operands, and besides we use // fill is guaranteed for unsigned operands, and besides we use
// prototyped unsigned parameters anyway, so we have no problem here. // 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 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[byte(crc >> 8) ^ (ch)] ^ (crc << 8)); } 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[byte(crc) ^ byte(ch)] ^ (crc >> 8)); } inline dword updCrc32(byte ch, dword crc) { return (dword)(__crc32_table[(crc & 0xFF) ^ ch] ^ (crc >> 8)); }
// ------------------------------------------------------------------ // ------------------------------------------------------------------

View File

@ -31,6 +31,8 @@
#define __goldall_h #define __goldall_h
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
#include <tchar.h>
#ifdef __cplusplus #ifdef __cplusplus
#include <cstddef> #include <cstddef>
#endif #endif
@ -43,6 +45,11 @@
#else #else
#endif #endif
#if !defined(ARRAYSIZE)
#define ARRAYSIZE(A) sizeof(A)/sizeof((A)[0])
#endif
/* ------------------------------------------------------------------ /* ------------------------------------------------------------------
// Disable some MS Visual C warnings */ // Disable some MS Visual C warnings */

View File

@ -149,10 +149,14 @@ struct Stamp {
FILE* fsopen(const char* path, const char* type, int shflag); 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); } 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); bool is_dir(const TCHAR *path);
inline int is_dir(const std::string& path) { return is_dir(path.c_str()); } 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()); } inline bool fexist(const std::string& filename) { return fexist(filename.c_str()); }
dword gfixstattime(time32_t st_time); 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 char* MapPath(char* map, bool reverse = false); // gcarea.cpp
inline char* ReMapPath(char* map) { return MapPath(map, true); } 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 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 record, long recordsize) { return _lseek(fh, record*recordsize, SEEK_SET); }
int gchdir(const char* dir); int gchdir(const char* dir);

View File

@ -96,12 +96,12 @@ long GetFilesize(const char* file) {
// ------------------------------------------------------------------ // ------------------------------------------------------------------
// Convert time returned with stat to FFTime // 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__) #if (defined(__MINGW32__) && !defined(__MSVCRT__)) || defined(__CYGWIN__)
struct tm &f = *ggmtime(&st_time); struct tm f; ggmtime(&f, &st_time);
#else #else
struct tm &f = *glocaltime(&st_time); struct tm f; glocaltime(&f, &st_time);
#endif #endif
FFTime t; FFTime t;
t.ft_year = f.tm_year - 80; t.ft_year = f.tm_year - 80;
@ -164,8 +164,8 @@ long fsize(FILE* fp) {
// ------------------------------------------------------------------ // ------------------------------------------------------------------
// Check if a pathname is a directory // 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:\) // Check if it's a root path (X:\)
#if defined(__HAVE_DRIVES__) #if defined(__HAVE_DRIVES__)
if(g_isalpha(path[0]) and (path[1] == ':') and isslash(path[2]) and (path[3] == NUL)) if(g_isalpha(path[0]) and (path[1] == ':') and isslash(path[2]) and (path[3] == NUL))

View File

@ -1572,7 +1572,7 @@ gkey kbxget_raw(int mode) {
// TO_PORT_TAG: kbxget_raw(3) // TO_PORT_TAG: kbxget_raw(3)
#if defined(__WIN32__) #if defined(__WIN32__)
KeyCtrlState = (gkey)inp.Event.KeyEvent.dwControlKeyState; KeyCtrlState = (gkey)(inp.Event.KeyEvent.dwControlKeyState & 0xFFFF);
#endif #endif
return k; return k;
} }

View File

@ -34,10 +34,10 @@
// ------------------------------------------------------------------ // ------------------------------------------------------------------
struct tm* glog::time_now; struct tm glog::time_now;
int glog::count = 0; int glog::count = 0;
time32_t glog::secs_now; time32_t glog::secs_now;
char glog::timebuf[20]; char glog::timebuf[20];
// ------------------------------------------------------------------ // ------------------------------------------------------------------
@ -109,7 +109,7 @@ void glog::printf(const char* format, ...) {
char logbuf[256]; char logbuf[256];
secs_now = gtime(NULL); secs_now = gtime(NULL);
time_now = glocaltime(&secs_now); glocaltime(&time_now, &secs_now);
lineswritten++; lineswritten++;
@ -118,23 +118,23 @@ void glog::printf(const char* format, ...) {
switch(logtype) { switch(logtype) {
case GLOG_FD: 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; break;
case GLOG_MAX: 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; break;
case GLOG_BINK: 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; break;
case GLOG_QBBS: 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; break;
case GLOG_DB: 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; break;
} }
@ -153,23 +153,23 @@ void glog::printf(const char* format, ...) {
switch(logtype) { switch(logtype) {
case GLOG_FD: 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; break;
case GLOG_MAX: 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; break;
case GLOG_BINK: 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; break;
case GLOG_QBBS: 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; break;
case GLOG_DB: 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; break;
} }
if(fp.isopen()) { if(fp.isopen()) {

View File

@ -60,7 +60,7 @@ private:
gfile fp; gfile fp;
static int count; static int count;
static struct tm* time_now; static struct tm time_now;
static time32_t secs_now; static time32_t secs_now;
static char timebuf[20]; static char timebuf[20];

View File

@ -492,8 +492,8 @@ typedef ftn_attr Attr;
// ------------------------------------------------------------------ // ------------------------------------------------------------------
inline void AttrAdd(Attr* a, Attr* b) { a->add(*b); } inline void AttrAdd(Attr* a, Attr* b) { a->add(*b); }
inline void GetAttribstr(Attr* attr, const char* attrs) { attr->get(attrs); } inline void GetAttribstr(Attr* attr, const TCHAR *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 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; }
// ------------------------------------------------------------------ // ------------------------------------------------------------------

View File

@ -82,7 +82,7 @@ char* longdotstr(char* str, long num); // Convert a long to a
char* StripQuotes(char* str); char* StripQuotes(char* str);
// Safe versions of strcpy, strcat, sequencial strcat... // 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* strxcat(char *dest, const char *src, size_t max);
char* strxmerge(char *dest, 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 char* strbtrim(char* st) { return strtrim(strltrim(st)); }
inline bool streql(const char* str1, const char* str2) { return not strcmp(str1,str2); } inline bool streql (const TCHAR *str1, const TCHAR *str2) { return (0 == _tcscmp (str1, str2)); }
inline bool strieql(const char* str1, const char* str2) { return not stricmp(str1,str2); } inline bool strieql (const TCHAR *str1, const TCHAR *str2) { return (0 == _tcsicmp (str1, str2)); }
inline bool strneql(const char* str1, const char* str2, int n) { return not strncmp(str1,str2,n); } inline bool strneql (const TCHAR *str1, const TCHAR *str2, int n) { return (0 == _tcsncmp (str1, str2, n)); }
inline bool strnieql(const char* str1, const char* str2, int n) { return not strnicmp(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 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); } inline char* strskip_to(char* p, char* s) { return p+strcspn(p, s); }
@ -142,20 +142,26 @@ char* strcvtc(char* s);
// ------------------------------------------------------------------ // ------------------------------------------------------------------
// String tokenizer class // String tokenizer class
class GTok { class GTok
{
protected: protected:
const TCHAR *separator;
const char* separator; TCHAR *token;
char* token; #if defined(_tcstok_s)
TCHAR *next_token;
#endif
public: public:
GTok(TCHAR *sep = NULL);
GTok(char* sep=NULL); #if defined(_tcstok_s)
TCHAR *First(TCHAR *buf) { token = _tcstok_s(buf, separator, &next_token); return token; }
char* First(char* buf) { token = strtok(buf, separator); return token; } TCHAR *Next() { token = _tcstok_s(NULL, separator, &next_token); return token; }
char* Next() { token = strtok(NULL, separator); return token; } #else
char* Token() { return token; } TCHAR *First(TCHAR *buf) { token = _tcstok(buf, separator); return token; }
TCHAR *Next() { token = _tcstok(NULL, separator); return token; }
#endif
TCHAR *Token() { return token; }
}; };

View File

@ -44,16 +44,28 @@ typedef std::vector<std::string> gstrarray;
// ------------------------------------------------------------------ // ------------------------------------------------------------------
inline void tokenize(gstrarray& array, const char* str, const char* delim = NULL) { inline void tokenize(gstrarray &array, const TCHAR* str, const TCHAR *delim = NULL)
if(delim == NULL) {
delim = ", \t"; if (delim == NULL) delim = ", \t";
char* tmp = throw_xstrdup(str); TCHAR *tmp = throw_xstrdup(str);
char* token = strtok(tmp, delim); #if defined(_tcstok_s)
while(token) { TCHAR *next_token;
array.push_back(token); TCHAR *token = _tcstok_s(tmp, delim, &next_token);
token = strtok(NULL, delim); #else
} TCHAR *token = _tcstok(tmp, delim);
throw_xfree(tmp); #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);
} }

View File

@ -562,14 +562,19 @@ const char* strrword(const char* str, const char *separator) {
// ------------------------------------------------------------------ // ------------------------------------------------------------------
char* strxcpy(char* d, const char* s, int n) { TCHAR *strxcpy(TCHAR *d, const TCHAR *s, size_t n)
{
if(n) { #if defined(_tcsncpy_s)
strncpy(d, s, n-1); _tcsncpy_s(d, n, s, _TRUNCATE);
#else
if (n)
{
_tcsncpy(d, s, n-1);
d[n-1] = NUL; d[n-1] = NUL;
} }
else else
*d = NUL; *d = NUL;
#endif
return d; return d;
} }

View File

@ -45,7 +45,9 @@
#ifdef __WIN32__ #ifdef __WIN32__
#include <windows.h> #include <windows.h>
#endif #endif
#if defined(_MSC_VER) && (_MSC_VER >= 1400)
#include <time.h>
#endif
// ------------------------------------------------------------------ // ------------------------------------------------------------------
@ -123,39 +125,69 @@ extern const char* gmonths[];
// ------------------------------------------------------------------ // ------------------------------------------------------------------
// Prototypes // Prototypes
inline struct tm *ggmtime(const time32_t *timep) inline void ggmtime(struct tm *_tm, const time32_t *timep)
{ {
const time_t temp(*timep); const time_t temp(*timep);
#if defined(__WIN32__) #if defined(_MSC_VER) && (_MSC_VER >= 1400)
const time_t zero(0); if (0 != gmtime_s(_tm, &temp))
{
const time_t zero(0);
gmtime_s(_tm, &zero);
}
#else
struct tm *time = gmtime(&temp); struct tm *time = gmtime(&temp);
return time ? time : gmtime(&zero); #if defined(__WIN32__)
#else if (NULL == time)
return gmtime(&temp); {
const time_t zero(0);
time = gmtime(&zero);
}
#endif
*_tm = *time;
#endif #endif
} }
inline struct tm *glocaltime(const time32_t *timep) inline void glocaltime(struct tm *_tm, const time32_t *timep)
{ {
const time_t temp(*timep); const time_t temp(*timep);
#if defined(__WIN32__) #if defined(_MSC_VER) && (_MSC_VER >= 1400)
const time_t zero(0); if (0 != localtime_s(_tm, &temp))
{
const time_t zero(0);
localtime_s(_tm, &zero);
}
#else
struct tm *time = localtime(&temp); struct tm *time = localtime(&temp);
return time ? time : localtime(&zero); #if defined(__WIN32__)
#else if (NULL == time)
return localtime(&temp); {
const time_t zero(0);
time = localtime(&zero);
}
#endif
*_tm = *time;
#endif #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); const time_t temp(*timep);
#if defined(__WIN32__) #if defined(_MSC_VER) && (_MSC_VER >= 1400)
const time_t zero(0); if (0 != _tctime_s(buffer, sizeInChars, &temp))
char *time = ctime(&temp); {
return time ? time : ctime(&zero); const time_t zero(0);
_tctime_s(buffer, sizeInChars, &zero);
}
#else #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 #endif
} }

View File

@ -58,12 +58,12 @@ const char* gmonths[] = {
// ------------------------------------------------------------------ // ------------------------------------------------------------------
// Returns current timezone offset based on TZ environment variable. // Returns current timezone offset based on TZ environment variable.
int tzoffset() { int tzoffset()
{
time32_t t1 = gtime(NULL); time32_t t1 = gtime(NULL);
struct tm *tp = ggmtime(&t1); struct tm tp; ggmtime(&tp, &t1);
tp->tm_isdst = -1; tp.tm_isdst = -1;
time32_t t2 = gmktime(tp); time32_t t2 = gmktime(&tp);
int dt = (int)(t1 - t2); int dt = (int)(t1 - t2);
return (dt / 3600) * 100 + (dt % 3600) / 60; 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_sec = __ftime->ft_tsec * 2;
__tm->tm_isdst = -1; __tm->tm_isdst = -1;
time32_t a = gmktime(__tm); time32_t a = gmktime(__tm);
struct tm *tp = ggmtime(&a); struct tm tp; ggmtime(&tp, &a);
tp->tm_isdst = -1; tp.tm_isdst = -1;
time32_t b = gmktime(tp); time32_t b = gmktime(&tp);
_time = a + a - b; _time = a + a - b;
if(_time == (uint32_t)0xFFFFFFFFL) if(_time == (uint32_t)0xFFFFFFFFL)
@ -373,15 +373,15 @@ FTime TimeToFTime(time32_t __time) {
FTime _ft; FTime _ft;
memset(&_ft, 0, sizeof(FTime)); memset(&_ft, 0, sizeof(FTime));
if(__time) { if (__time)
{
struct tm* _tmp = ggmtime(&__time); struct tm _tmp; ggmtime(&_tmp, &__time);
_ft.ft_year = (word)(_tmp->tm_year - 80); _ft.ft_year = (word)(_tmp.tm_year - 80);
_ft.ft_month = (word)(_tmp->tm_mon + 1); _ft.ft_month = (word)(_tmp.tm_mon + 1);
_ft.ft_day = (word)(_tmp->tm_mday); _ft.ft_day = (word)(_tmp.tm_mday);
_ft.ft_hour = (word)(_tmp->tm_hour); _ft.ft_hour = (word)(_tmp.tm_hour);
_ft.ft_min = (word)(_tmp->tm_min); _ft.ft_min = (word)(_tmp.tm_min);
_ft.ft_tsec = (word)(_tmp->tm_sec / 2); _ft.ft_tsec = (word)(_tmp.tm_sec / 2);
} }
return _ft; return _ft;
@ -441,10 +441,10 @@ time32_t FidoTimeToUnix(char* ptr) {
t.tm_min = minute; t.tm_min = minute;
t.tm_sec = second; t.tm_sec = second;
t.tm_isdst = -1; t.tm_isdst = -1;
time32_t a = gmktime(&t); time32_t a = gmktime(&t);
struct tm *tp = ggmtime(&a); struct tm tp; ggmtime(&tp, &a);
tp->tm_isdst = -1; tp.tm_isdst = -1;
time32_t b = gmktime(tp); time32_t b = gmktime(&tp);
return a + a - b; return a + a - b;
} }
return (uint32_t)-1; return (uint32_t)-1;
@ -453,9 +453,10 @@ time32_t FidoTimeToUnix(char* ptr) {
// ------------------------------------------------------------------ // ------------------------------------------------------------------
char* TimeToStr(char* buf, time32_t t) { char* TimeToStr(char* buf, time32_t t)
{
return strftimei(buf, 20, "%Y-%m-%d %H:%M:%S", ggmtime(&t)); struct tm tm; ggmtime(&tm, &t);
return strftimei(buf, 20, "%Y-%m-%d %H:%M:%S", &tm);
} }

View File

@ -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 vchar vgchar (vatch chat) { return chat.Char.AsciiChar; }
inline vattr vgattr (vatch chat) { return chat.Attributes; } 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 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 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 = 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 #else

View File

@ -5762,11 +5762,7 @@ weak_alias (__regexec, regexec)
from either regcomp or regexec. We don't use PREG here. */ from either regcomp or regexec. We don't use PREG here. */
size_t size_t
regerror (errcode, preg, errbuf, errbuf_size) regerror (int errcode, const regex_t *preg, char *errbuf, size_t errbuf_size)
int errcode;
const regex_t *preg;
char *errbuf;
size_t errbuf_size;
{ {
const char *msg; const char *msg;
size_t msg_size; size_t msg_size;

View File

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

View File

@ -168,11 +168,12 @@ void FidoArea::save_message(int __mode, gmsg* __msg, FidoHdr& __hdr) {
__hdr.opus.written = TimeToFTime(__msg->written); __hdr.opus.written = TimeToFTime(__msg->written);
__hdr.opus.arrived = TimeToFTime(__msg->arrived); __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", sprintf(__hdr.datetime, "%02d %3s %02d %02d:%02d:%02d",
_tm->tm_mday, gmonths[_tm->tm_mon+1], _tm->tm_year % 100, _tm.tm_mday, gmonths[_tm.tm_mon + 1], _tm.tm_year % 100,
_tm->tm_hour, _tm->tm_min, _tm->tm_sec _tm.tm_hour, _tm.tm_min, _tm.tm_sec
); );
// Write message header // Write message header
write(_fh, &__hdr, sizeof(FidoHdr)); write(_fh, &__hdr, sizeof(FidoHdr));

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_min = _minute;
_tm.tm_sec = 0; _tm.tm_sec = 0;
_tm.tm_isdst = -1; _tm.tm_isdst = -1;
time32_t a = gmktime(&_tm); time32_t a = gmktime(&_tm);
struct tm *tp = ggmtime(&a); struct tm tp; ggmtime(&tp, &a);
tp->tm_isdst = -1; tp.tm_isdst = -1;
time32_t b = gmktime(tp); time32_t b = gmktime(&tp);
__msg->written = a + a - b; __msg->written = a + a - b;
__msg->arrived = 0; __msg->arrived = 0;

View File

@ -127,9 +127,9 @@ void _HudsArea<msgn_t, rec_t, attr_t, board_t, last_t, __HUDSON>::save_message(i
__hdr.replyto = (msgn_t)__msg->link.to(); __hdr.replyto = (msgn_t)__msg->link.to();
__hdr.reply1st = (msgn_t)__msg->link.first(); __hdr.reply1st = (msgn_t)__msg->link.first();
struct tm* _tmp = ggmtime(&__msg->written); struct tm _tmp; ggmtime(&_tmp, &__msg->written);
strc2p(strftimei(__hdr.date, 9, "%m-%d-%y", _tmp)); strc2p(strftimei(__hdr.date, 9, "%m-%d-%y", &_tmp));
strc2p(strftimei(__hdr.time, 6, "%H:%M", _tmp)); strc2p(strftimei(__hdr.time, 6, "%H:%M", &_tmp));
strc2p(strxcpy(__hdr.to, __msg->to, sizeof(__hdr.to))); strc2p(strxcpy(__hdr.to, __msg->to, sizeof(__hdr.to)));
strc2p(strxcpy(__hdr.by, __msg->by, sizeof(__hdr.by))); strc2p(strxcpy(__hdr.by, __msg->by, sizeof(__hdr.by)));

View File

@ -148,14 +148,14 @@ void JamArea::open_area() {
data->highwater = -1; data->highwater = -1;
// Is the signature invalid? // Is the signature invalid?
if(memcmp(data->hdrinfo.signature, JAM_SIGNATURE, 4)) { if (memcmp(data->hdrinfo.signature, JAM_SIGNATURE, 4))
{
// Initialize header info // Initialize header info
memcpy(data->hdrinfo.signature, JAM_SIGNATURE, 4); memcpy(data->hdrinfo.signature, JAM_SIGNATURE, 4);
time32_t a = gtime(NULL); time32_t a = gtime(NULL);
struct tm *tp = ggmtime(&a); struct tm tp; ggmtime(&tp, &a);
tp->tm_isdst = -1; tp.tm_isdst = -1;
time32_t b = gmktime(tp); time32_t b = gmktime(&tp);
data->hdrinfo.datecreated = a + a - b; data->hdrinfo.datecreated = a + a - b;
data->hdrinfo.passwordcrc = 0xFFFFFFFFL; data->hdrinfo.passwordcrc = 0xFFFFFFFFL;
data->hdrinfo.basemsgnum = 1; 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_min = _minute;
_tm.tm_sec = 0; _tm.tm_sec = 0;
_tm.tm_isdst = -1; _tm.tm_isdst = -1;
time32_t a = gmktime(&_tm); time32_t a = gmktime(&_tm);
struct tm *tp = ggmtime(&a); struct tm tp; ggmtime(&tp, &a);
tp->tm_isdst = -1; tp.tm_isdst = -1;
time32_t b = gmktime(tp); time32_t b = gmktime(&tp);
__msg->written = a + a - b; __msg->written = a + a - b;
__msg->arrived = 0; __msg->arrived = 0;

View File

@ -158,18 +158,22 @@ void PcbArea::save_message(int __mode, gmsg* __msg, PcbHdr& __hdr) {
// Convert dates and times // Convert dates and times
char _dtbuf[9]; char _dtbuf[9];
struct tm* _tm = ggmtime(&__msg->written); 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.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); 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()) { _idx.date = (word)YMD2JDN(1900+_tm.tm_year, _tm.tm_mon+1, _tm.tm_mday);
if (__msg->link.first())
{
__hdr.hasreply = 'R'; __hdr.hasreply = 'R';
_tm = ggmtime(&__msg->pcboard.reply_written); ggmtime(&_tm, &__msg->pcboard.reply_written);
int _year = _tm->tm_year % 100; int _year = _tm.tm_year % 100;
__hdr.replydate = L2B((10000L*_year) + (100L*(_tm->tm_mon+1)) + _tm->tm_mday); __hdr.replydate = L2B((10000L*_year) + (100L*(_tm.tm_mon+1)) + _tm.tm_mday);
memcpy(__hdr.replytime, strftimei(_dtbuf, 6, "%H:%M", _tm), 5); memcpy(__hdr.replytime, strftimei(_dtbuf, 6, "%H:%M", &_tm), 5);
} }
else { else
{
__hdr.hasreply = ' '; __hdr.hasreply = ' ';
__hdr.replydate = L2B(0); __hdr.replydate = L2B(0);
memcpy(__hdr.replytime, " ", 5); memcpy(__hdr.replytime, " ", 5);

View File

@ -324,13 +324,14 @@ int SMBArea::load_hdr(gmsg* __msg, smbmsg_t *smsg)
__msg->attr.cfm(smsgp->hdr.auxattr & MSG_CONFIRMREQ); __msg->attr.cfm(smsgp->hdr.auxattr & MSG_CONFIRMREQ);
__msg->attr.tfs(smsgp->hdr.auxattr & MSG_TRUNCFILE); __msg->attr.tfs(smsgp->hdr.auxattr & MSG_TRUNCFILE);
time32_t a = smsgp->hdr.when_written.time; time32_t a = smsgp->hdr.when_written.time;
struct tm *tp = ggmtime(&a); struct tm tp; ggmtime(&tp, &a);
tp->tm_isdst = -1; tp.tm_isdst = -1;
time32_t b = gmktime(tp); time32_t b = gmktime(&tp);
__msg->written = a + a - b; __msg->written = a + a - b;
a = smsgp->hdr.when_imported.time; a = smsgp->hdr.when_imported.time;
b = gmktime(ggmtime(&a)); ggmtime(&tp, &a);
b = gmktime(&tp);
__msg->arrived = a + a - b; __msg->arrived = a + a - b;
__msg->received = 0; __msg->received = 0;
@ -533,12 +534,13 @@ void SMBArea::save_hdr(int mode, gmsg* msg)
smsg.hdr.netattr = 0; smsg.hdr.netattr = 0;
smsg.hdr.auxattr = 0; smsg.hdr.auxattr = 0;
} }
else { else
{
memcpy(smsg.hdr.id, "SHD\x1a", 4); memcpy(smsg.hdr.id, "SHD\x1a", 4);
smsg.hdr.version = smb_ver(); smsg.hdr.version = smb_ver();
struct tm *tp = ggmtime(&msg->written); struct tm tp; ggmtime(&tp, &msg->written);
tp->tm_isdst = -1; tp.tm_isdst = -1;
smsg.hdr.when_written.time = gmktime(tp); smsg.hdr.when_written.time = gmktime(&tp);
} }
smsg.hdr.when_imported.time = gtime(NULL); 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, "Attr : %04Xh", smsg.hdr.attr);
line = AddLineF(line, "AUXAttr : %04Xh", smsg.hdr.auxattr); line = AddLineF(line, "AUXAttr : %04Xh", smsg.hdr.auxattr);
line = AddLineF(line, "NetAttr : %04Xh", smsg.hdr.netattr); 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); 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, "Imported : %s", buf);
line = AddLineF(line, "Number : %d (%d)", smsg.hdr.number, (int32_t)(ftell(data->sid_fp)/sizeof(idxrec_t))); 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); line = AddLineF(line, "Thread orig : %d", smsg.hdr.thread_orig);

View File

@ -437,11 +437,12 @@ void SquishArea::save_message(int __mode, gmsg* __msg) {
__hdr.date_written = TimeToFTime(__msg->written); __hdr.date_written = TimeToFTime(__msg->written);
__hdr.date_arrived = TimeToFTime(__msg->arrived); __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", sprintf(__hdr.ftsc_date, "%02d %3s %02d %02d:%02d:%02d",
_tm->tm_mday, gmonths[_tm->tm_mon+1], _tm->tm_year % 100, _tm.tm_mday, gmonths[_tm.tm_mon + 1], _tm.tm_year % 100,
_tm->tm_hour, _tm->tm_min, _tm->tm_sec _tm.tm_hour, _tm.tm_min, _tm.tm_sec
); );
// Setup some local variables for speed // Setup some local variables for speed
int _fhsqd = data->fhsqd; int _fhsqd = data->fhsqd;

View File

@ -103,10 +103,10 @@ int WCatArea::load_message(int __mode, gmsg* __msg, WCatHdr& __hdr) {
_tm.tm_min = _minute; _tm.tm_min = _minute;
_tm.tm_sec = _second; _tm.tm_sec = _second;
_tm.tm_isdst = -1; _tm.tm_isdst = -1;
time32_t a = gmktime(&_tm); time32_t a = gmktime(&_tm);
struct tm *tp = ggmtime(&a); struct tm tp; ggmtime(&tp, &a);
tp->tm_isdst = -1; tp.tm_isdst = -1;
time32_t b = gmktime(tp); time32_t b = gmktime(&tp);
__msg->written = a + a - b; __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_min = _minute;
_tm.tm_sec = _second; _tm.tm_sec = _second;
_tm.tm_isdst = -1; _tm.tm_isdst = -1;
time32_t a = gmktime(&_tm); time32_t a = gmktime(&_tm);
struct tm *tp = ggmtime(&a); struct tm tp; ggmtime(&tp, &a);
tp->tm_isdst = -1; tp.tm_isdst = -1;
time32_t b = gmktime(tp); time32_t b = gmktime(&tp);
__msg->received = a + a - b; __msg->received = a + a - b;
} }

View File

@ -118,16 +118,18 @@ void WCatArea::save_message(int __mode, gmsg* __msg, WCatHdr& __hdr) {
strcpy(__msg->wildcat.network, "FTSC"); strcpy(__msg->wildcat.network, "FTSC");
strc2p(strcpy(__hdr.network, __msg->wildcat.network)); strc2p(strcpy(__hdr.network, __msg->wildcat.network));
if(__msg->written) { 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); struct tm _tm; ggmtime(&_tm, &__msg->written);
__hdr.msgtime = ((_tm->tm_hour*3600L)+(_tm->tm_min*60L)+_tm->tm_sec)+1; __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) { if (__msg->received)
struct tm* _tm = ggmtime(&__msg->received); {
__hdr.readdate = (word)YMD2JDN(1900+_tm->tm_year, _tm->tm_mon+1, _tm->tm_mday); struct tm _tm; ggmtime(&_tm, &__msg->received);
__hdr.readtime = ((_tm->tm_hour*3600L)+(_tm->tm_min*60L)+_tm->tm_sec)+1; __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); __hdr.mflags |= (word)(__msg->attr.pvt() ? mfPrivate : 0);

View File

@ -77,8 +77,10 @@ Line* WCatArea::make_dump_msg(Line*& lin, gmsg* msg, char* lng_head) {
AddLineF(line, "DestUserID : %i", _hdr.touserid); AddLineF(line, "DestUserID : %i", _hdr.touserid);
AddLineF(line, "Subject : %s", STRNP2C(_hdr.subject)); AddLineF(line, "Subject : %s", STRNP2C(_hdr.subject));
AddLineF(line, "Network : %s", STRNP2C(_hdr.network)); 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); struct tm _tm; ggmtime(&_tm, &msg->written);
AddLineF(line, "ReadTime : %s (%u, %i)", strftimei(buf, 100, "%d %b %y %H:%M:%S", ggmtime(&msg->received)), _hdr.readdate, _hdr.readtime); 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, "mFlags : %u (%04Xh)", _hdr.mflags, _hdr.mflags);
AddLineF(line, "Reference : %u", _hdr.reference); 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); AddLineF(line, "FidoFrom : %u:%u/%u.%u", _hdr.origaddr.zone, _hdr.origaddr.net, _hdr.origaddr.node, _hdr.origaddr.point);

View File

@ -65,17 +65,19 @@ int XbbsArea::load_message(int __mode, gmsg* __msg, XbbsHdr& __hdr) {
__msg->written = FidoTimeToUnix(__hdr.date); __msg->written = FidoTimeToUnix(__hdr.date);
__msg->received = __hdr.timerecv; __msg->received = __hdr.timerecv;
if(__hdr.indate[2]) {
if(__hdr.indate[2])
{
struct tm t; struct tm t;
t.tm_year = __hdr.indate[0]+89; t.tm_year = __hdr.indate[0]+89;
t.tm_mon = __hdr.indate[1]-1; t.tm_mon = __hdr.indate[1]-1;
t.tm_mday = __hdr.indate[2]; t.tm_mday = __hdr.indate[2];
t.tm_hour = t.tm_min = t.tm_sec = 0; t.tm_hour = t.tm_min = t.tm_sec = 0;
t.tm_isdst = -1; t.tm_isdst = -1;
time32_t a = gmktime(&t); time32_t a = gmktime(&t);
struct tm *tp = ggmtime(&a); struct tm tp; ggmtime(&tp, &a);
tp->tm_isdst = -1; tp.tm_isdst = -1;
time32_t b = gmktime(tp); time32_t b = gmktime(&tp);
__msg->arrived = a + a - b; __msg->arrived = a + a - b;
} }

View File

@ -135,16 +135,17 @@ void XbbsArea::save_message(int __mode, gmsg* __msg, XbbsHdr& __hdr) {
strxcpy(__hdr.to, __msg->to, sizeof(__hdr.to)); strxcpy(__hdr.to, __msg->to, sizeof(__hdr.to));
strxcpy(__hdr.subj, __msg->re, sizeof(__hdr.subj)); 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", sprintf(__hdr.date, "%02d %3s %02d %02d:%02d:%02d",
_tm->tm_mday, gmonths[_tm->tm_mon+1], _tm->tm_year % 100, _tm.tm_mday, gmonths[_tm.tm_mon + 1], _tm.tm_year % 100,
_tm->tm_hour, _tm->tm_min, _tm->tm_sec _tm.tm_hour, _tm.tm_min, _tm.tm_sec
); );
if(__msg->arrived)
_tm = ggmtime(&__msg->arrived); 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[0] = (byte)(_tm.tm_year - 89);
__hdr.indate[2] = (byte)(_tm->tm_mday); __hdr.indate[1] = (byte)(_tm.tm_mon + 1);
__hdr.indate[2] = (byte)(_tm.tm_mday);
__hdr.indate[3] = 0; __hdr.indate[3] = 0;
__hdr.msgnum = __msg->msgno; __hdr.msgnum = __msg->msgno;