Sorry, refactoring!
This commit is contained in:
parent
bcf5ac98c1
commit
6cac338f3e
@ -144,21 +144,20 @@ Area* AreaList::NewArea(const char *basetype) {
|
|||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
// Write lastreads for the next session
|
// Write lastreads for the next session
|
||||||
|
|
||||||
void AreaList::WriteGoldLast() {
|
void AreaList::WriteGoldLast()
|
||||||
|
{
|
||||||
word GOLDLAST_VER = CUR_GOLDLAST_VER;
|
word GOLDLAST_VER = CUR_GOLDLAST_VER;
|
||||||
gfile fp;
|
|
||||||
ggoldlast entry;
|
ggoldlast entry;
|
||||||
Path lst;
|
Path lst;
|
||||||
|
|
||||||
strcpy(lst, AddPath(CFG->goldpath, CFG->goldlast));
|
strcpy(lst, AddPath(CFG->goldpath, CFG->goldlast));
|
||||||
|
|
||||||
fp.fopen(lst, "wb", CFG->sharemode);
|
gfile fp(lst, "wb", CFG->sharemode);
|
||||||
if(fp.isopen()) {
|
if (fp.isopen())
|
||||||
|
{
|
||||||
fp.setvbuf(NULL, _IOFBF, 8192);
|
fp.SetvBuf(NULL, _IOFBF, 8192);
|
||||||
fp.fwrite(&GOLDLAST_VER, sizeof(word));
|
fp.Fwrite(&GOLDLAST_VER, sizeof(word));
|
||||||
fp.fwrite(AL.alistselections, sizeof(AL.alistselections));
|
fp.Fwrite(AL.alistselections, sizeof(AL.alistselections));
|
||||||
|
|
||||||
for(area_iterator ap = idx.begin(); ap != idx.end(); ap++) {
|
for(area_iterator ap = idx.begin(); ap != idx.end(); ap++) {
|
||||||
|
|
||||||
@ -178,7 +177,7 @@ void AreaList::WriteGoldLast() {
|
|||||||
if((*ap)->isunreadchg)
|
if((*ap)->isunreadchg)
|
||||||
entry.flags |= 4;
|
entry.flags |= 4;
|
||||||
|
|
||||||
fp.fwrite(&entry, sizeof(entry));
|
fp.Fwrite(&entry, sizeof(entry));
|
||||||
|
|
||||||
// Write variable length extensions
|
// Write variable length extensions
|
||||||
(*ap)->Mark.Save(fp);
|
(*ap)->Mark.Save(fp);
|
||||||
@ -186,7 +185,7 @@ void AreaList::WriteGoldLast() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fp.fclose();
|
fp.Fclose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -194,27 +193,27 @@ void AreaList::WriteGoldLast() {
|
|||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
// Read the lastreads from the last session
|
// Read the lastreads from the last session
|
||||||
|
|
||||||
void AreaList::ReadGoldLast() {
|
void AreaList::ReadGoldLast()
|
||||||
|
{
|
||||||
word GOLDLAST_VER;
|
word GOLDLAST_VER;
|
||||||
gfile fp;
|
|
||||||
ggoldlast entry;
|
ggoldlast entry;
|
||||||
|
|
||||||
fp.fopen(AddPath(CFG->goldpath, CFG->goldlast), "rb", CFG->sharemode);
|
gfile fp(AddPath(CFG->goldpath, CFG->goldlast), "rb", CFG->sharemode);
|
||||||
if(fp.isopen()) {
|
if (fp.isopen())
|
||||||
|
{
|
||||||
|
fp.SetvBuf(NULL, _IOFBF, 8192);
|
||||||
|
fp.Fread(&GOLDLAST_VER, sizeof(word));
|
||||||
|
|
||||||
fp.setvbuf(NULL, _IOFBF, 8192);
|
if (GOLDLAST_VER != CUR_GOLDLAST_VER)
|
||||||
fp.fread(&GOLDLAST_VER, sizeof(word));
|
{
|
||||||
|
fp.Fclose();
|
||||||
if(GOLDLAST_VER != CUR_GOLDLAST_VER) {
|
|
||||||
fp.close();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fp.fread(AL.alistselections, sizeof(AL.alistselections));
|
fp.Fread(AL.alistselections, sizeof(AL.alistselections));
|
||||||
|
|
||||||
while(fp.fread(&entry, sizeof(entry))) {
|
|
||||||
|
|
||||||
|
while (fp.Fread(&entry, sizeof(entry)))
|
||||||
|
{
|
||||||
bool found = false;
|
bool found = false;
|
||||||
|
|
||||||
for(area_iterator ap = idx.begin(); ap != idx.end(); ap++) {
|
for(area_iterator ap = idx.begin(); ap != idx.end(); ap++) {
|
||||||
@ -237,17 +236,18 @@ void AreaList::ReadGoldLast() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(not found) {
|
if (not found)
|
||||||
|
{
|
||||||
// skip stored message marks
|
// skip stored message marks
|
||||||
dword dw;
|
dword dw;
|
||||||
fp.fread(&dw, sizeof(dword));
|
fp.Fread(&dw, sizeof(dword));
|
||||||
fp.fseek(dw*sizeof(dword), SEEK_CUR);
|
fp.Fseek(dw*sizeof(dword), SEEK_CUR);
|
||||||
fp.fread(&dw, sizeof(dword));
|
fp.Fread(&dw, sizeof(dword));
|
||||||
fp.fseek(dw*sizeof(dword), SEEK_CUR);
|
fp.Fseek(dw*sizeof(dword), SEEK_CUR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fp.fclose();
|
fp.Fclose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -886,14 +886,15 @@ int ReadCfg(const char* cfgfile, int ignoreunknown) {
|
|||||||
inuse--;
|
inuse--;
|
||||||
|
|
||||||
// When the final cfg is compiled
|
// When the final cfg is compiled
|
||||||
if(inuse == 0) {
|
if (inuse == 0)
|
||||||
|
{
|
||||||
// Mark all areas listed in the NEWSRC file as newsgroups
|
// Mark all areas listed in the NEWSRC file as newsgroups
|
||||||
gfile gfp;
|
gfile gfp(CFG->soupnewsrcfile, "rt");
|
||||||
gfp.fopen(CFG->soupnewsrcfile, "rt");
|
if (gfp.isopen())
|
||||||
if(gfp.isopen()) {
|
{
|
||||||
char buf2[512];
|
char buf2[512];
|
||||||
while(gfp.fgets(buf2, sizeof(buf2))) {
|
while (gfp.Fgets(buf2, sizeof(buf2)))
|
||||||
|
{
|
||||||
char* ptr = strpbrk(buf2, ":! ");
|
char* ptr = strpbrk(buf2, ":! ");
|
||||||
if(ptr) {
|
if(ptr) {
|
||||||
*ptr = NUL;
|
*ptr = NUL;
|
||||||
@ -902,7 +903,7 @@ int ReadCfg(const char* cfgfile, int ignoreunknown) {
|
|||||||
ap->set_type(ap->isnet() ? GMB_SOUP|GMB_EMAIL|GMB_NET : GMB_SOUP|GMB_NEWSGROUP|GMB_ECHO);
|
ap->set_type(ap->isnet() ? GMB_SOUP|GMB_EMAIL|GMB_NET : GMB_SOUP|GMB_NEWSGROUP|GMB_ECHO);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
gfp.fclose();
|
gfp.Fclose();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(*CFG->soupemail) {
|
if(*CFG->soupemail) {
|
||||||
|
@ -244,20 +244,20 @@ static void WriteMsgs(GMsg* msg) {
|
|||||||
AA->SetOutputfile(ofname);
|
AA->SetOutputfile(ofname);
|
||||||
|
|
||||||
gclipbrd clipbrd;
|
gclipbrd clipbrd;
|
||||||
gfile fp;
|
gfile fp(fname, "rb");
|
||||||
|
|
||||||
if(fp.fopen(fname, "rb")) {
|
if (fp.isopen())
|
||||||
|
{
|
||||||
long len = fp.filelength();
|
long len = fp.FileLength();
|
||||||
char* buf = (char*) throw_malloc(len+1);
|
char* buf = (char*) throw_malloc(len+1);
|
||||||
buf[len] = NUL;
|
buf[len] = NUL;
|
||||||
fp.fread(buf, 1, len);
|
fp.Fread(buf, len);
|
||||||
|
|
||||||
clipbrd.writeclipbrd(buf);
|
clipbrd.writeclipbrd(buf);
|
||||||
|
|
||||||
throw_free(buf);
|
throw_free(buf);
|
||||||
|
|
||||||
fp.close();
|
fp.Fclose();
|
||||||
}
|
}
|
||||||
|
|
||||||
remove(fname);
|
remove(fname);
|
||||||
@ -316,20 +316,20 @@ static void WriteMsgs(GMsg* msg) {
|
|||||||
SaveLines(MODE_WRITE, fname, msg, prnmargin, true);
|
SaveLines(MODE_WRITE, fname, msg, prnmargin, true);
|
||||||
|
|
||||||
gclipbrd clipbrd;
|
gclipbrd clipbrd;
|
||||||
gfile fp;
|
gfile fp(fname, "rb");
|
||||||
|
|
||||||
if(fp.fopen(fname, "rb")) {
|
if (fp.isopen())
|
||||||
|
{
|
||||||
long len = fp.filelength();
|
long len = fp.FileLength();
|
||||||
char* buf = (char*) throw_malloc(len+1);
|
char* buf = (char*) throw_malloc(len+1);
|
||||||
buf[len] = NUL;
|
buf[len] = NUL;
|
||||||
fp.fread(buf, 1, len);
|
fp.Fread(buf, len);
|
||||||
|
|
||||||
clipbrd.writeclipbrd(buf);
|
clipbrd.writeclipbrd(buf);
|
||||||
|
|
||||||
throw_free(buf);
|
throw_free(buf);
|
||||||
|
|
||||||
fp.close();
|
fp.Fclose();
|
||||||
}
|
}
|
||||||
|
|
||||||
remove(fname);
|
remove(fname);
|
||||||
|
@ -3272,7 +3272,7 @@ char* ParseInternetAddr(char* __string, char* __name, char* __addr, bool detect_
|
|||||||
char* begaddr = endchar;
|
char* begaddr = endchar;
|
||||||
if(*endchar == '<') {
|
if(*endchar == '<') {
|
||||||
begaddr++;
|
begaddr++;
|
||||||
endchar--;
|
if (endchar > __string) endchar--;
|
||||||
}
|
}
|
||||||
__string = strskip_wht(__string);
|
__string = strskip_wht(__string);
|
||||||
strbtrim(strxcpy(__name, __string, MinV((size_t)(endchar-__string)+1, (size_t)sizeof(INam))));
|
strbtrim(strxcpy(__name, __string, MinV((size_t)(endchar-__string)+1, (size_t)sizeof(INam))));
|
||||||
|
@ -34,25 +34,27 @@ static void ReadGldFile() {
|
|||||||
|
|
||||||
if(QWK->FoundBBS()) {
|
if(QWK->FoundBBS()) {
|
||||||
|
|
||||||
gfile fp;
|
|
||||||
Path gldfile;
|
Path gldfile;
|
||||||
|
|
||||||
QWK->ResetConfNo();
|
QWK->ResetConfNo();
|
||||||
|
|
||||||
sprintf(gldfile, "%s%s.GLD", CFG->goldpath, QWK->BbsID());
|
sprintf(gldfile, "%s%s.GLD", CFG->goldpath, QWK->BbsID());
|
||||||
fp.fopen(gldfile, "rt");
|
gfile fp(gldfile, "rt");
|
||||||
if(fp.isopen()) {
|
|
||||||
|
if (fp.isopen())
|
||||||
|
{
|
||||||
char* key;
|
char* key;
|
||||||
char* val;
|
char* val;
|
||||||
char buf[256];
|
char buf[256];
|
||||||
while(fp.fgets(buf, sizeof(buf))) {
|
while (fp.Fgets(buf, sizeof(buf)))
|
||||||
|
{
|
||||||
val = strtrim(buf);
|
val = strtrim(buf);
|
||||||
getkeyval(&key, &val);
|
getkeyval(&key, &val);
|
||||||
strtrim(StripQuotes(val));
|
strtrim(StripQuotes(val));
|
||||||
if(QWK->FindEcho(val))
|
if(QWK->FindEcho(val))
|
||||||
QWK->ConfNo(atoi(key));
|
QWK->ConfNo(atoi(key));
|
||||||
}
|
}
|
||||||
fp.fclose();
|
fp.Fclose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -65,7 +67,6 @@ int ImportQWK() {
|
|||||||
if(not *QWK->ImportPath())
|
if(not *QWK->ImportPath())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
gfile fp;
|
|
||||||
gfile fpb; // For BBSID.GLD
|
gfile fpb; // For BBSID.GLD
|
||||||
Path file;
|
Path file;
|
||||||
Path gldfile;
|
Path gldfile;
|
||||||
@ -73,22 +74,24 @@ int ImportQWK() {
|
|||||||
|
|
||||||
// Parse the control file
|
// Parse the control file
|
||||||
strcpy(file, AddPath(QWK->ImportPath(), "CONTROL.DAT"));
|
strcpy(file, AddPath(QWK->ImportPath(), "CONTROL.DAT"));
|
||||||
fp.fopen(file, "rt");
|
gfile fp(file, "rt");
|
||||||
if(fp.isopen()) {
|
if (fp.isopen())
|
||||||
|
{
|
||||||
char buf[256];
|
char buf[256];
|
||||||
int line = 0;
|
int line = 0;
|
||||||
int confno = 0;
|
int confno = 0;
|
||||||
int confcnt = 0;
|
int confcnt = 0;
|
||||||
int confnos = 0;
|
int confnos = 0;
|
||||||
while(fp.fgets(buf, sizeof(buf))) {
|
while (fp.Fgets(buf, sizeof(buf)))
|
||||||
|
{
|
||||||
line++;
|
line++;
|
||||||
strtrim(buf);
|
strtrim(buf);
|
||||||
|
|
||||||
if((line >= 12) and (confcnt < confnos)) {
|
if((line >= 12) and (confcnt < confnos)) {
|
||||||
if(line % 2) {
|
if(line % 2)
|
||||||
if(fpb.isopen())
|
{
|
||||||
fpb.printf("%u \"%s\"\n", confno, buf);
|
if (fpb.isopen())
|
||||||
|
fpb.Printf("%u \"%s\"\n", confno, buf);
|
||||||
confcnt++;
|
confcnt++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -99,15 +102,15 @@ int ImportQWK() {
|
|||||||
if(ptr) {
|
if(ptr) {
|
||||||
strxcpy(bbsid, strskip_wht(ptr+1), 9);
|
strxcpy(bbsid, strskip_wht(ptr+1), 9);
|
||||||
sprintf(gldfile, "%s%s.GLD", CFG->goldpath, bbsid);
|
sprintf(gldfile, "%s%s.GLD", CFG->goldpath, bbsid);
|
||||||
fpb.fopen(gldfile, "wt");
|
fpb.Fopen(gldfile, "wt");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(line == 11)
|
else if(line == 11)
|
||||||
confnos = atoi(buf) + 1;
|
confnos = atoi(buf) + 1;
|
||||||
}
|
}
|
||||||
if(fpb.isopen())
|
|
||||||
fpb.fclose();
|
fpb.Fclose();
|
||||||
fp.fclose();
|
fp.Fclose();
|
||||||
remove(file);
|
remove(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,11 +125,11 @@ int ImportQWK() {
|
|||||||
OrigArea = CurrArea = -1;
|
OrigArea = CurrArea = -1;
|
||||||
|
|
||||||
strcpy(file, AddPath(QWK->ImportPath(), "MESSAGES.DAT"));
|
strcpy(file, AddPath(QWK->ImportPath(), "MESSAGES.DAT"));
|
||||||
fp.fopen(file, "rb");
|
fp.Fopen(file, "rb");
|
||||||
if(fp.isopen()) {
|
if (fp.isopen())
|
||||||
|
{
|
||||||
// Skip past product info header
|
// Skip past product info header
|
||||||
fp.fseekset(sizeof(QWKHdr));
|
fp.FseekSet(sizeof(QWKHdr));
|
||||||
|
|
||||||
QWKHdr hdr;
|
QWKHdr hdr;
|
||||||
|
|
||||||
@ -141,7 +144,7 @@ int ImportQWK() {
|
|||||||
ResetMsg(msg);
|
ResetMsg(msg);
|
||||||
|
|
||||||
memset(&hdr, 0, sizeof(QWKHdr));
|
memset(&hdr, 0, sizeof(QWKHdr));
|
||||||
more = 1 == fp.fread(&hdr, sizeof(QWKHdr));
|
more = 1 == fp.Fread(&hdr, sizeof(QWKHdr));
|
||||||
if(more) {
|
if(more) {
|
||||||
|
|
||||||
char blocks[7];
|
char blocks[7];
|
||||||
@ -167,9 +170,10 @@ int ImportQWK() {
|
|||||||
CurrArea = AL.AreaNoToId(areano);
|
CurrArea = AL.AreaNoToId(areano);
|
||||||
tosstobadmsgs = true;
|
tosstobadmsgs = true;
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
tosstobadmsgs = -1;
|
tosstobadmsgs = -1;
|
||||||
fp.fseek(msglen, SEEK_CUR);
|
fp.Fseek(msglen, SEEK_CUR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -225,7 +229,7 @@ int ImportQWK() {
|
|||||||
sprintf(msg->txt, "AREA:%s_%u\r", bbsid, hdr.confno);
|
sprintf(msg->txt, "AREA:%s_%u\r", bbsid, hdr.confno);
|
||||||
txtptr += strlen(msg->txt);
|
txtptr += strlen(msg->txt);
|
||||||
}
|
}
|
||||||
fp.fread(txtptr, msglen);
|
fp.Fread(txtptr, msglen);
|
||||||
strtrim(txtptr);
|
strtrim(txtptr);
|
||||||
strchg(txtptr, 0xE3, 0x0D);
|
strchg(txtptr, 0xE3, 0x0D);
|
||||||
|
|
||||||
@ -315,22 +319,24 @@ int ImportQWK() {
|
|||||||
ResetMsg(msg);
|
ResetMsg(msg);
|
||||||
throw_free(msg);
|
throw_free(msg);
|
||||||
|
|
||||||
fp.fclose();
|
fp.Fclose();
|
||||||
remove(file);
|
remove(file);
|
||||||
|
|
||||||
if(*QWK->TossLog()) {
|
if (*QWK->TossLog())
|
||||||
fp.fopen(QWK->TossLog(), "at");
|
{
|
||||||
if(fp.isopen()) {
|
fp.Fopen(QWK->TossLog(), "at");
|
||||||
|
if (fp.isopen())
|
||||||
|
{
|
||||||
uint na = 0;
|
uint na = 0;
|
||||||
while(na < AL.size()) {
|
while(na < AL.size()) {
|
||||||
if(AL[na]->istossed) {
|
if(AL[na]->istossed) {
|
||||||
AL[na]->istossed = false;
|
AL[na]->istossed = false;
|
||||||
AL[na]->isunreadchg = true;
|
AL[na]->isunreadchg = true;
|
||||||
fp.printf("%s\n", AL[na]->echoid());
|
fp.Printf("%s\n", AL[na]->echoid());
|
||||||
}
|
}
|
||||||
na++;
|
na++;
|
||||||
}
|
}
|
||||||
fp.fclose();
|
fp.Fclose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -389,7 +395,7 @@ int ExportQwkMsg(GMsg* msg, gfile& fp, int confno, int& pktmsgno) {
|
|||||||
hdr.pktmsgno = (word)++pktmsgno;
|
hdr.pktmsgno = (word)++pktmsgno;
|
||||||
|
|
||||||
// Write preliminary header
|
// Write preliminary header
|
||||||
fp.fwrite(&hdr, sizeof(QWKHdr));
|
fp.Fwrite(&hdr, sizeof(QWKHdr));
|
||||||
|
|
||||||
// Write body
|
// Write body
|
||||||
int level = 0;
|
int level = 0;
|
||||||
@ -418,9 +424,10 @@ int ExportQwkMsg(GMsg* msg, gfile& fp, int confno, int& pktmsgno) {
|
|||||||
while(line) {
|
while(line) {
|
||||||
if(line->type & GLINE_KLUDGE) {
|
if(line->type & GLINE_KLUDGE) {
|
||||||
if(AA->isinternet()) {
|
if(AA->isinternet()) {
|
||||||
if((line->kludge == GKLUD_RFC) or (line->kludge == 0)) {
|
if ((line->kludge == GKLUD_RFC) or (line->kludge == 0))
|
||||||
|
{
|
||||||
XlatStr(mbuf, line->txt.c_str(), level, CharTable);
|
XlatStr(mbuf, line->txt.c_str(), level, CharTable);
|
||||||
msglen += fp.printf("%s%c", mbuf, qwkterm);
|
msglen += fp.Printf("%s%c", mbuf, qwkterm);
|
||||||
}
|
}
|
||||||
else if(line->type & GLINE_WRAP) {
|
else if(line->type & GLINE_WRAP) {
|
||||||
while(line->next and (line->type & GLINE_WRAP))
|
while(line->next and (line->type & GLINE_WRAP))
|
||||||
@ -428,9 +435,10 @@ int ExportQwkMsg(GMsg* msg, gfile& fp, int confno, int& pktmsgno) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if((line->type & GLINE_KLUDGE) and QWK->KludgesAllowed()) {
|
if ((line->type & GLINE_KLUDGE) and QWK->KludgesAllowed())
|
||||||
|
{
|
||||||
XlatStr(mbuf, line->txt.c_str(), level, CharTable);
|
XlatStr(mbuf, line->txt.c_str(), level, CharTable);
|
||||||
msglen += fp.printf("%s%c", mbuf, qwkterm);
|
msglen += fp.Printf("%s%c", mbuf, qwkterm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -438,16 +446,16 @@ int ExportQwkMsg(GMsg* msg, gfile& fp, int confno, int& pktmsgno) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Write blank line after header lines
|
// Write blank line after header lines
|
||||||
if(AA->Internetrfcbody()) {
|
if (AA->Internetrfcbody())
|
||||||
msglen += fp.printf("%c", qwkterm);
|
msglen += fp.Printf("%c", qwkterm);
|
||||||
}
|
|
||||||
|
|
||||||
// Write all message lines
|
// Write all message lines
|
||||||
line = msg->lin;
|
line = msg->lin;
|
||||||
while(line) {
|
while(line) {
|
||||||
if(not (line->type & GLINE_KLUDGE)) {
|
if (not (line->type & GLINE_KLUDGE))
|
||||||
|
{
|
||||||
XlatStr(mbuf, line->txt.c_str(), level, CharTable);
|
XlatStr(mbuf, line->txt.c_str(), level, CharTable);
|
||||||
msglen += fp.printf("%s%c", mbuf, qwkterm);
|
msglen += fp.Printf("%s%c", mbuf, qwkterm);
|
||||||
}
|
}
|
||||||
line = line->next;
|
line = line->next;
|
||||||
}
|
}
|
||||||
@ -459,16 +467,17 @@ int ExportQwkMsg(GMsg* msg, gfile& fp, int confno, int& pktmsgno) {
|
|||||||
memcpy(hdr.blocks, buf, strlen(buf));
|
memcpy(hdr.blocks, buf, strlen(buf));
|
||||||
|
|
||||||
// Write padding spaces at the end if necessary
|
// Write padding spaces at the end if necessary
|
||||||
if(endlen) {
|
if (endlen)
|
||||||
|
{
|
||||||
char padding[128];
|
char padding[128];
|
||||||
memset(padding, ' ', 128);
|
memset(padding, ' ', 128);
|
||||||
fp.fwrite(padding, 128-endlen);
|
fp.Fwrite(padding, 128-endlen);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Re-write the header
|
// Re-write the header
|
||||||
fp.fseek(-(blocks*128), SEEK_CUR);
|
fp.Fseek(-(blocks*128), SEEK_CUR);
|
||||||
fp.fwrite(&hdr, sizeof(QWKHdr));
|
fp.Fwrite(&hdr, sizeof(QWKHdr));
|
||||||
fp.fseek((blocks-1)*128, SEEK_CUR);
|
fp.Fseek((blocks-1)*128, SEEK_CUR);
|
||||||
|
|
||||||
// Mark msg as sent
|
// Mark msg as sent
|
||||||
msg->attr.snt1();
|
msg->attr.snt1();
|
||||||
@ -529,10 +538,12 @@ int ExportQWK() {
|
|||||||
|
|
||||||
// Get the scan list
|
// Get the scan list
|
||||||
strcpy(scanfile, AddPath(CFG->goldpath, "GOLDQWK.LST"));
|
strcpy(scanfile, AddPath(CFG->goldpath, "GOLDQWK.LST"));
|
||||||
fp.fopen(scanfile, "rt");
|
fp.Fopen(scanfile, "rt");
|
||||||
if(fp.isopen()) {
|
if (fp.isopen())
|
||||||
|
{
|
||||||
char buf[256];
|
char buf[256];
|
||||||
while(fp.fgets(buf, sizeof(buf))) {
|
while (fp.Fgets(buf, sizeof(buf)))
|
||||||
|
{
|
||||||
char* ptr = strchr(buf, ' ');
|
char* ptr = strchr(buf, ' ');
|
||||||
if(ptr) {
|
if(ptr) {
|
||||||
*ptr++ = NUL;
|
*ptr++ = NUL;
|
||||||
@ -541,7 +552,7 @@ int ExportQWK() {
|
|||||||
AL[a]->Expo.Add(atol(ptr));
|
AL[a]->Expo.Add(atol(ptr));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fp.fclose();
|
fp.Fclose();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Export from the QWK areas
|
// Export from the QWK areas
|
||||||
@ -550,14 +561,16 @@ int ExportQWK() {
|
|||||||
ReadGldFile();
|
ReadGldFile();
|
||||||
Path replyfile;
|
Path replyfile;
|
||||||
int pktmsgno = 0;
|
int pktmsgno = 0;
|
||||||
if(QWK->FirstConf()) {
|
if (QWK->FirstConf())
|
||||||
|
{
|
||||||
sprintf(replyfile, "%s%s.MSG", QWK->ExportPath(), QWK->BbsID());
|
sprintf(replyfile, "%s%s.MSG", QWK->ExportPath(), QWK->BbsID());
|
||||||
fp.fopen(replyfile, "wb");
|
fp.Fopen(replyfile, "wb");
|
||||||
if(fp.isopen()) {
|
if (fp.isopen())
|
||||||
|
{
|
||||||
char firstrec[128];
|
char firstrec[128];
|
||||||
memset(firstrec, ' ', 128);
|
memset(firstrec, ' ', 128);
|
||||||
memcpy(firstrec, QWK->BbsID(), strlen(QWK->BbsID()));
|
memcpy(firstrec, QWK->BbsID(), strlen(QWK->BbsID()));
|
||||||
fp.fwrite(firstrec, 128);
|
fp.Fwrite(firstrec, 128);
|
||||||
pktmsgno = 0;
|
pktmsgno = 0;
|
||||||
}
|
}
|
||||||
do {
|
do {
|
||||||
@ -568,8 +581,9 @@ int ExportQWK() {
|
|||||||
}
|
}
|
||||||
} while(QWK->NextConf());
|
} while(QWK->NextConf());
|
||||||
}
|
}
|
||||||
if(fp.isopen()) {
|
if (fp.isopen())
|
||||||
fp.fclose();
|
{
|
||||||
|
fp.Fclose();
|
||||||
if(pktmsgno == 0)
|
if(pktmsgno == 0)
|
||||||
remove(replyfile);
|
remove(replyfile);
|
||||||
}
|
}
|
||||||
|
@ -575,15 +575,16 @@ int ExternUtil(GMsg *msg, ExtUtil *extutil) {
|
|||||||
if(extutil->options & EXTUTIL_RELOAD) {
|
if(extutil->options & EXTUTIL_RELOAD) {
|
||||||
|
|
||||||
if(not (extutil->options & EXTUTIL_KEEPCTRL)) {
|
if(not (extutil->options & EXTUTIL_KEEPCTRL)) {
|
||||||
if(*msg->tearline or *msg->origin) {
|
if (*msg->tearline or *msg->origin)
|
||||||
gfile fp;
|
{
|
||||||
fp.fopen(editorfile, "at");
|
gfile fp(editorfile, "at");
|
||||||
if(fp.isopen()) {
|
if (fp.isopen())
|
||||||
if(*msg->tearline)
|
{
|
||||||
fp.printf("--- %s\n", msg->tearline);
|
if (*msg->tearline)
|
||||||
if(*msg->origin)
|
fp.Printf("--- %s\n", msg->tearline);
|
||||||
fp.printf(" * Origin: %s\n", msg->origin);
|
if (*msg->origin)
|
||||||
fp.fclose();
|
fp.Printf(" * Origin: %s\n", msg->origin);
|
||||||
|
fp.Fclose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -938,11 +939,11 @@ void TouchSemaphore() {
|
|||||||
|
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
|
|
||||||
void make_pathreport(const char* reportfile) {
|
void make_pathreport(const char* reportfile)
|
||||||
|
{
|
||||||
gfile fp;
|
gfile fp(reportfile, "wt");
|
||||||
fp.fopen(reportfile, "wt");
|
if (fp.isopen())
|
||||||
if(fp) {
|
{
|
||||||
std::string path;
|
std::string path;
|
||||||
ftn_addr address;
|
ftn_addr address;
|
||||||
std::vector<ftn_addr> alist;
|
std::vector<ftn_addr> alist;
|
||||||
@ -964,7 +965,7 @@ void make_pathreport(const char* reportfile) {
|
|||||||
strcpy(buf, msg->By());
|
strcpy(buf, msg->By());
|
||||||
strchg(buf, ' ', '_');
|
strchg(buf, ' ', '_');
|
||||||
std::string temp;
|
std::string temp;
|
||||||
fp.printf("%s %s ", buf, address.make_string(temp).c_str());
|
fp.Printf("%s %s ", buf, address.make_string(temp).c_str());
|
||||||
path = "";
|
path = "";
|
||||||
Line* line = msg->lin;
|
Line* line = msg->lin;
|
||||||
while(line) {
|
while(line) {
|
||||||
@ -978,11 +979,11 @@ void make_pathreport(const char* reportfile) {
|
|||||||
for(int i=0; i<links.size(); i++)
|
for(int i=0; i<links.size(); i++)
|
||||||
address = links[i];
|
address = links[i];
|
||||||
}
|
}
|
||||||
fp.printf("%s\n", path.c_str());
|
fp.Printf("%s\n", path.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
w_progress(MODE_QUIT, BLACK_|_BLACK, 0, 0, NULL);
|
w_progress(MODE_QUIT, BLACK_|_BLACK, 0, 0, NULL);
|
||||||
fp.fclose();
|
fp.Fclose();
|
||||||
ResetMsg(msg);
|
ResetMsg(msg);
|
||||||
throw_free(msg);
|
throw_free(msg);
|
||||||
}
|
}
|
||||||
|
@ -115,17 +115,20 @@ int AreaList::AreaScan(int mode, uint currno, int pmscan, int& pmails, int& pmar
|
|||||||
int groupid = -1;
|
int groupid = -1;
|
||||||
|
|
||||||
// Load scan list into a string bag
|
// Load scan list into a string bag
|
||||||
if(mode == SCAN_LIST) {
|
if (mode == SCAN_LIST)
|
||||||
gfile fp;
|
{
|
||||||
Path tmp;
|
Path tmp;
|
||||||
strcpy(tmp, file ? file : ListScan.File());
|
strcpy(tmp, file ? file : ListScan.File());
|
||||||
char* listfile;
|
char* listfile;
|
||||||
char* option=tmp;
|
char* option=tmp;
|
||||||
getkeyval(&listfile, &option);
|
getkeyval(&listfile, &option);
|
||||||
fp.fopen(AddPath(CFG->goldpath, listfile), "rt");
|
gfile fp(AddPath(CFG->goldpath, listfile), "rt");
|
||||||
if(fp.isopen()) {
|
|
||||||
|
if (fp.isopen())
|
||||||
|
{
|
||||||
char buf[512];
|
char buf[512];
|
||||||
while(fp.fgets(buf, sizeof(buf))) {
|
while (fp.Fgets(buf, sizeof(buf)))
|
||||||
|
{
|
||||||
strbtrim(buf);
|
strbtrim(buf);
|
||||||
char* val = strtok(buf, ", \t");
|
char* val = strtok(buf, ", \t");
|
||||||
while(val) {
|
while(val) {
|
||||||
@ -133,8 +136,8 @@ int AreaList::AreaScan(int mode, uint currno, int pmscan, int& pmails, int& pmar
|
|||||||
val = strtok(NULL, ", \t");
|
val = strtok(NULL, ", \t");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fp.fclose();
|
fp.Fclose();
|
||||||
if(((*option == '-') or (*option == '/')) and strieql(option+1, "delete"))
|
if (((*option == '-') or (*option == '/')) and strieql(option+1, "delete"))
|
||||||
remove(listfile);
|
remove(listfile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -384,16 +384,16 @@ int ImportSOUP() {
|
|||||||
const int MBUF_SIZE = 65535;
|
const int MBUF_SIZE = 65535;
|
||||||
const int LBUF_SIZE = 65535;
|
const int LBUF_SIZE = 65535;
|
||||||
|
|
||||||
gfile fpa; // For AREAS file
|
|
||||||
gfile fpm; // For *.MSG files
|
gfile fpm; // For *.MSG files
|
||||||
|
|
||||||
int importedmsgs = 0;
|
int importedmsgs = 0;
|
||||||
|
|
||||||
Path areasfile;
|
Path areasfile;
|
||||||
strcpy(areasfile, AddPath(CFG->soupimportpath, "AREAS"));
|
strcpy(areasfile, AddPath(CFG->soupimportpath, "AREAS"));
|
||||||
fpa.fopen(areasfile, "rt");
|
gfile fpa(areasfile, "rt");
|
||||||
if(fpa.isopen()) {
|
|
||||||
|
|
||||||
|
if (fpa.isopen())
|
||||||
|
{
|
||||||
char buf[2048];
|
char buf[2048];
|
||||||
|
|
||||||
LoadCharset("N/A", "N/A");
|
LoadCharset("N/A", "N/A");
|
||||||
@ -403,8 +403,8 @@ int ImportSOUP() {
|
|||||||
|
|
||||||
GMsg* msg = (GMsg*)throw_calloc(1, sizeof(GMsg));
|
GMsg* msg = (GMsg*)throw_calloc(1, sizeof(GMsg));
|
||||||
|
|
||||||
while(fpa.fgets(buf, sizeof(buf))) {
|
while (fpa.Fgets(buf, sizeof(buf)))
|
||||||
|
{
|
||||||
char* delim = "\t\n";
|
char* delim = "\t\n";
|
||||||
char* prefix = strtok(buf, delim);
|
char* prefix = strtok(buf, delim);
|
||||||
char* areaname = strtok(NULL, delim);
|
char* areaname = strtok(NULL, delim);
|
||||||
@ -457,9 +457,9 @@ int ImportSOUP() {
|
|||||||
AL.SetActiveAreaNo(areano);
|
AL.SetActiveAreaNo(areano);
|
||||||
OrigArea = CurrArea;
|
OrigArea = CurrArea;
|
||||||
|
|
||||||
fpm.fopen(msgfile, "rb");
|
fpm.Fopen(msgfile, "rb");
|
||||||
if(fpm.isopen()) {
|
if (fpm.isopen())
|
||||||
|
{
|
||||||
imported++;
|
imported++;
|
||||||
|
|
||||||
int msgs = 0;
|
int msgs = 0;
|
||||||
@ -477,16 +477,16 @@ int ImportSOUP() {
|
|||||||
// Get binary formats
|
// Get binary formats
|
||||||
|
|
||||||
dword msglen = 0;
|
dword msglen = 0;
|
||||||
while(fpm.fread(&msglen, 4) == 1) {
|
while (fpm.Fread(&msglen, 4) == 1)
|
||||||
|
{
|
||||||
msglen = swapendian(msglen);
|
msglen = swapendian(msglen);
|
||||||
uint msglensz = (uint)msglen;
|
uint msglensz = (uint)msglen;
|
||||||
if(msglen != msglensz)
|
if(msglen != msglensz)
|
||||||
msglensz--;
|
msglensz--;
|
||||||
msg->txt = (char*)throw_calloc(1, msglensz+1);
|
msg->txt = (char*)throw_calloc(1, msglensz+1);
|
||||||
fpm.fread(msg->txt, msglensz);
|
fpm.Fread(msg->txt, msglensz);
|
||||||
if(msglen != msglensz)
|
if (msglen != msglensz)
|
||||||
fpm.fseek(msglen-msglensz, SEEK_CUR);
|
fpm.Fseek(msglen-msglensz, SEEK_CUR);
|
||||||
ProcessSoupMsg(lbuf, msg, msgs, areaname, tosstobadmsgs);
|
ProcessSoupMsg(lbuf, msg, msgs, areaname, tosstobadmsgs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -494,8 +494,8 @@ int ImportSOUP() {
|
|||||||
|
|
||||||
// Get non-binary formats
|
// Get non-binary formats
|
||||||
|
|
||||||
while(fpm.fgets(mbuf, MBUF_SIZE)) {
|
while (fpm.Fgets(mbuf, MBUF_SIZE))
|
||||||
|
{
|
||||||
if(msgfmt == 'u') {
|
if(msgfmt == 'u') {
|
||||||
if(strneql(mbuf, "#! rnews ", 9)) {
|
if(strneql(mbuf, "#! rnews ", 9)) {
|
||||||
dword msglen = atol(mbuf+9);
|
dword msglen = atol(mbuf+9);
|
||||||
@ -503,9 +503,9 @@ int ImportSOUP() {
|
|||||||
if(msglen != msglensz)
|
if(msglen != msglensz)
|
||||||
msglensz--;
|
msglensz--;
|
||||||
msg->txt = (char*)throw_calloc(1, msglensz+1);
|
msg->txt = (char*)throw_calloc(1, msglensz+1);
|
||||||
fpm.fread(msg->txt, msglensz);
|
fpm.Fread(msg->txt, msglensz);
|
||||||
if(msglen != msglensz)
|
if (msglen != msglensz)
|
||||||
fpm.fseek(msglen-msglensz, SEEK_CUR);
|
fpm.Fseek(msglen-msglensz, SEEK_CUR);
|
||||||
ProcessSoupMsg(lbuf, msg, msgs, areaname, tosstobadmsgs);
|
ProcessSoupMsg(lbuf, msg, msgs, areaname, tosstobadmsgs);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -553,10 +553,9 @@ int ImportSOUP() {
|
|||||||
AA->Unlock();
|
AA->Unlock();
|
||||||
AA->Close();
|
AA->Close();
|
||||||
|
|
||||||
if(msgs)
|
if (msgs) importedmsgs += msgs;
|
||||||
importedmsgs += msgs;
|
|
||||||
|
|
||||||
fpm.fclose();
|
fpm.Fclose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -571,23 +570,22 @@ int ImportSOUP() {
|
|||||||
throw_free(lbuf);
|
throw_free(lbuf);
|
||||||
throw_free(mbuf);
|
throw_free(mbuf);
|
||||||
|
|
||||||
fpa.fclose();
|
fpa.Fclose();
|
||||||
remove(areasfile);
|
remove(areasfile);
|
||||||
|
|
||||||
if(*CFG->souptosslog)
|
if (*CFG->souptosslog)
|
||||||
fpa.fopen(CFG->souptosslog, "at");
|
fpa.Fopen(CFG->souptosslog, "at");
|
||||||
|
|
||||||
for(uint na = 0; na < AL.size(); na++) {
|
for(uint na = 0; na < AL.size(); na++) {
|
||||||
if(AL[na]->istossed) {
|
if(AL[na]->istossed) {
|
||||||
AL[na]->istossed = false;
|
AL[na]->istossed = false;
|
||||||
AL[na]->isunreadchg = true;
|
AL[na]->isunreadchg = true;
|
||||||
if(fpa.isopen())
|
if (fpa.isopen())
|
||||||
fpa.printf("%s\n", AL[na]->echoid());
|
fpa.Printf("%s\n", AL[na]->echoid());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(fpa.isopen())
|
fpa.Fclose();
|
||||||
fpa.fclose();
|
|
||||||
|
|
||||||
if(importedmsgs and *CFG->soupreplylinker) {
|
if(importedmsgs and *CFG->soupreplylinker) {
|
||||||
sprintf(buf, LNG->Replylinker, CFG->soupreplylinker);
|
sprintf(buf, LNG->Replylinker, CFG->soupreplylinker);
|
||||||
@ -609,14 +607,15 @@ int ExportSoupMsg(GMsg* msg, char* msgfile, gfile& fp, int ismail) {
|
|||||||
|
|
||||||
NW(ismail);
|
NW(ismail);
|
||||||
|
|
||||||
if(not fp.isopen()) {
|
if (not fp.isopen())
|
||||||
fp.open(AddPath(CFG->soupexportpath, msgfile), O_RDWR|O_CREAT|O_BINARY, "rb+");
|
{
|
||||||
if(fp.isopen())
|
fp.Open(AddPath(CFG->soupexportpath, msgfile), O_RDWR|O_CREAT|O_BINARY, "rb+");
|
||||||
fp.fseek(0, SEEK_END);
|
if (fp.isopen())
|
||||||
|
fp.Fseek(0, SEEK_END);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(fp.isopen()) {
|
if (fp.isopen())
|
||||||
|
{
|
||||||
int level = 0;
|
int level = 0;
|
||||||
if(CharTable)
|
if(CharTable)
|
||||||
level = CharTable->level ? CharTable->level : 2;
|
level = CharTable->level ? CharTable->level : 2;
|
||||||
@ -625,7 +624,7 @@ int ExportSoupMsg(GMsg* msg, char* msgfile, gfile& fp, int ismail) {
|
|||||||
|
|
||||||
// Write placeholder for message length
|
// Write placeholder for message length
|
||||||
dword msglen = 0xFFFFFFFFL;
|
dword msglen = 0xFFFFFFFFL;
|
||||||
fp.fwrite(&msglen, 4);
|
fp.Fwrite(&msglen, 4);
|
||||||
msglen = 0;
|
msglen = 0;
|
||||||
|
|
||||||
bool qp = false;
|
bool qp = false;
|
||||||
@ -648,7 +647,7 @@ int ExportSoupMsg(GMsg* msg, char* msgfile, gfile& fp, int ismail) {
|
|||||||
if((line->kludge == GKLUD_RFC) or (line->kludge == 0)) {
|
if((line->kludge == GKLUD_RFC) or (line->kludge == 0)) {
|
||||||
const char *ltxt = line->txt.c_str();
|
const char *ltxt = line->txt.c_str();
|
||||||
XlatStr(mbuf, (*ltxt == CTRL_A) ? (ltxt + 1) : ltxt, level, CharTable);
|
XlatStr(mbuf, (*ltxt == CTRL_A) ? (ltxt + 1) : ltxt, level, CharTable);
|
||||||
msglen += fp.printf("%s%s", mbuf, (line->type & GLINE_WRAP) ? "" : "\n");
|
msglen += fp.Printf("%s%s", mbuf, (line->type & GLINE_WRAP) ? "" : "\n");
|
||||||
}
|
}
|
||||||
else if(line->type & GLINE_WRAP) {
|
else if(line->type & GLINE_WRAP) {
|
||||||
while(line->next and (line->type & GLINE_WRAP))
|
while(line->next and (line->type & GLINE_WRAP))
|
||||||
@ -659,7 +658,7 @@ int ExportSoupMsg(GMsg* msg, char* msgfile, gfile& fp, int ismail) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Write blank line after header lines
|
// Write blank line after header lines
|
||||||
msglen += fp.printf("\n");
|
msglen += fp.Printf("\n");
|
||||||
|
|
||||||
// Write all message lines
|
// Write all message lines
|
||||||
line = msg->lin;
|
line = msg->lin;
|
||||||
@ -680,19 +679,19 @@ int ExportSoupMsg(GMsg* msg, char* msgfile, gfile& fp, int ismail) {
|
|||||||
else if(*(mptr-1) == '=')
|
else if(*(mptr-1) == '=')
|
||||||
mptr--;
|
mptr--;
|
||||||
int mlen = (int)(mptr - mbeg);
|
int mlen = (int)(mptr - mbeg);
|
||||||
msglen += fp.printf("%*.*s=\n", mlen, mlen, mbeg);
|
msglen += fp.Printf("%*.*s=\n", mlen, mlen, mbeg);
|
||||||
} while(strlen(mptr) > 76);
|
} while(strlen(mptr) > 76);
|
||||||
}
|
}
|
||||||
msglen += fp.printf("%s\n", mptr);
|
msglen += fp.Printf("%s\n", mptr);
|
||||||
}
|
}
|
||||||
line = line->next;
|
line = line->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Re-write the correct message length
|
// Re-write the correct message length
|
||||||
fp.fseek(-(msglen+4), SEEK_CUR);
|
fp.Fseek(-(msglen+4), SEEK_CUR);
|
||||||
dword be_msglen = swapendian(msglen);
|
dword be_msglen = swapendian(msglen);
|
||||||
fp.fwrite(&be_msglen, 4);
|
fp.Fwrite(&be_msglen, 4);
|
||||||
fp.fseek(msglen, SEEK_CUR);
|
fp.Fseek(msglen, SEEK_CUR);
|
||||||
|
|
||||||
msg->attr.snt1();
|
msg->attr.snt1();
|
||||||
msg->attr.scn1();
|
msg->attr.scn1();
|
||||||
@ -762,10 +761,12 @@ int ExportSOUP() {
|
|||||||
|
|
||||||
// Get the scan list
|
// Get the scan list
|
||||||
strcpy(scanfile, AddPath(CFG->goldpath, "goldsoup.lst"));
|
strcpy(scanfile, AddPath(CFG->goldpath, "goldsoup.lst"));
|
||||||
fp.fopen(scanfile, "rt");
|
fp.Fopen(scanfile, "rt");
|
||||||
if(fp.isopen()) {
|
if (fp.isopen())
|
||||||
|
{
|
||||||
char buf[256];
|
char buf[256];
|
||||||
while(fp.fgets(buf, sizeof(buf))) {
|
while (fp.Fgets(buf, sizeof(buf)))
|
||||||
|
{
|
||||||
char* ptr = strchr(buf, ' ');
|
char* ptr = strchr(buf, ' ');
|
||||||
if(ptr) {
|
if(ptr) {
|
||||||
*ptr++ = NUL;
|
*ptr++ = NUL;
|
||||||
@ -774,7 +775,7 @@ int ExportSOUP() {
|
|||||||
AL[a]->Expo.Add(atol(ptr));
|
AL[a]->Expo.Add(atol(ptr));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fp.fclose();
|
fp.Fclose();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Export from the e-mail and newsgroup areas
|
// Export from the e-mail and newsgroup areas
|
||||||
@ -787,29 +788,29 @@ int ExportSOUP() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Close any open SOUP files
|
// Close any open SOUP files
|
||||||
if(mfp.isopen())
|
mfp.Fclose();
|
||||||
mfp.fclose();
|
nfp.Fclose();
|
||||||
if(nfp.isopen())
|
|
||||||
nfp.fclose();
|
|
||||||
|
|
||||||
// Update the REPLIES file
|
// Update the REPLIES file
|
||||||
fp.open(AddPath(CFG->soupexportpath, "REPLIES"), O_RDWR|O_CREAT|O_BINARY, "rb+");
|
fp.Open(AddPath(CFG->soupexportpath, "REPLIES"), O_RDWR|O_CREAT|O_BINARY, "rb+");
|
||||||
if(fp.isopen()) {
|
if (fp.isopen())
|
||||||
|
{
|
||||||
char buf[512];
|
char buf[512];
|
||||||
int hasmail = false;
|
int hasmail = false;
|
||||||
int hasnews = false;
|
int hasnews = false;
|
||||||
while(fp.fgets(buf, sizeof(buf))) {
|
while (fp.Fgets(buf, sizeof(buf)))
|
||||||
|
{
|
||||||
strtok(buf, "\t\n");
|
strtok(buf, "\t\n");
|
||||||
if(strieql(buf, "GOLDMAIL"))
|
if(strieql(buf, "GOLDMAIL"))
|
||||||
hasmail = true;
|
hasmail = true;
|
||||||
else if(strieql(buf, "GOLDNEWS"))
|
else if(strieql(buf, "GOLDNEWS"))
|
||||||
hasnews = true;
|
hasnews = true;
|
||||||
}
|
}
|
||||||
if(mailexported and not hasmail)
|
if (mailexported and not hasmail)
|
||||||
fp.printf("GOLDMAIL\tmail\tbn\n");
|
fp.Printf("GOLDMAIL\tmail\tbn\n");
|
||||||
if(newsexported and not hasnews)
|
if (newsexported and not hasnews)
|
||||||
fp.printf("GOLDNEWS\tnews\tBn\n");
|
fp.Printf("GOLDNEWS\tnews\tBn\n");
|
||||||
fp.fclose();
|
fp.Fclose();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete the scanfile
|
// Delete the scanfile
|
||||||
|
@ -39,9 +39,11 @@ guserbase::guserbase() {
|
|||||||
|
|
||||||
strcpy(fname, AddPath(CFG->goldpath, CFG->golduser));
|
strcpy(fname, AddPath(CFG->goldpath, CFG->golduser));
|
||||||
|
|
||||||
do {
|
do
|
||||||
usrbase.open(fname, O_RDWR|O_CREAT|O_BINARY, SH_DENYNO, S_STDRW);
|
{
|
||||||
if(not usrbase) {
|
usrbase.Open(fname, O_RDWR|O_CREAT|O_BINARY, SH_DENYNO, S_STDRW);
|
||||||
|
if (!usrbase.isopen())
|
||||||
|
{
|
||||||
if((errno != EACCES) or (not PopupLocked(++tries, false, fname))) {
|
if((errno != EACCES) or (not PopupLocked(++tries, false, fname))) {
|
||||||
WideLog->ErrOpen();
|
WideLog->ErrOpen();
|
||||||
WideLog->printf("! Addressbook cannot be opened.");
|
WideLog->printf("! Addressbook cannot be opened.");
|
||||||
@ -50,13 +52,14 @@ guserbase::guserbase() {
|
|||||||
OpenErrorExit();
|
OpenErrorExit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while(not usrbase);
|
}
|
||||||
|
while(!usrbase.isopen());
|
||||||
|
|
||||||
if(tries)
|
if(tries)
|
||||||
PopupLocked(0, 0, NULL);
|
PopupLocked(0, 0, NULL);
|
||||||
|
|
||||||
if((uint) usrbase.filelength() < sizeof(gusrbaseheader) + sizeof(gusrbaseentry)) {
|
if (uint(usrbase.FileLength()) < sizeof(gusrbaseheader) + sizeof(gusrbaseentry))
|
||||||
|
{
|
||||||
header.version = 0;
|
header.version = 0;
|
||||||
|
|
||||||
strcpy(entry.macro, "_asa_");
|
strcpy(entry.macro, "_asa_");
|
||||||
@ -84,8 +87,8 @@ guserbase::guserbase() {
|
|||||||
entry.comment2[0] = NUL;
|
entry.comment2[0] = NUL;
|
||||||
entry.comment3[0] = NUL;
|
entry.comment3[0] = NUL;
|
||||||
|
|
||||||
usrbase.lseek(0, SEEK_SET);
|
usrbase.LseekSet(0);
|
||||||
usrbase.write(&header.version, sizeof(header.version));
|
usrbase.Write(&header.version, sizeof(header.version));
|
||||||
write_entry(0);
|
write_entry(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,7 +103,7 @@ guserbase::guserbase() {
|
|||||||
|
|
||||||
guserbase::~guserbase() {
|
guserbase::~guserbase() {
|
||||||
|
|
||||||
usrbase.close();
|
usrbase.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -109,21 +112,25 @@ guserbase::~guserbase() {
|
|||||||
void guserbase::refresh_maximum_index() {
|
void guserbase::refresh_maximum_index() {
|
||||||
|
|
||||||
// Are we doing it for the first time?
|
// Are we doing it for the first time?
|
||||||
if(not read_time) {
|
if (not read_time)
|
||||||
usrbase.getftime(&read_time);
|
{
|
||||||
|
usrbase.GetFTime(&read_time);
|
||||||
need_update = true;
|
need_update = true;
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
dword tmp;
|
dword tmp;
|
||||||
usrbase.getftime(&tmp);
|
usrbase.GetFTime(&tmp);
|
||||||
if(read_time != tmp) {
|
if (read_time != tmp)
|
||||||
|
{
|
||||||
read_time = tmp;
|
read_time = tmp;
|
||||||
need_update = true;
|
need_update = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(need_update)
|
if (need_update)
|
||||||
maximum_index = (usrbase.filelength()-sizeof(gusrbaseheader)) / sizeof(gusrbaseentry) - 1;
|
maximum_index = (uint(usrbase.FileLength()) - sizeof(gusrbaseheader)) / sizeof(gusrbaseentry) - 1;
|
||||||
if(index > maximum_index)
|
|
||||||
|
if (index > maximum_index)
|
||||||
index = maximum_index;
|
index = maximum_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -136,9 +143,11 @@ void guserbase::lock() {
|
|||||||
|
|
||||||
long tries = 0;
|
long tries = 0;
|
||||||
|
|
||||||
do {
|
do
|
||||||
usrbase.lock(0, 1);
|
{
|
||||||
if(not usrbase.okay()) {
|
usrbase.Lock(0, 1);
|
||||||
|
if (!usrbase.okay())
|
||||||
|
{
|
||||||
if(not PopupLocked(++tries, false, fname)) {
|
if(not PopupLocked(++tries, false, fname)) {
|
||||||
WideLog->ErrLock();
|
WideLog->ErrLock();
|
||||||
WideLog->printf("! GoldED's Addressbook could not be locked.");
|
WideLog->printf("! GoldED's Addressbook could not be locked.");
|
||||||
@ -147,7 +156,9 @@ void guserbase::lock() {
|
|||||||
LockErrorExit();
|
LockErrorExit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while(not usrbase.okay());
|
}
|
||||||
|
while(!usrbase.okay());
|
||||||
|
|
||||||
if(tries)
|
if(tries)
|
||||||
PopupLocked(0, 0, NULL);
|
PopupLocked(0, 0, NULL);
|
||||||
}
|
}
|
||||||
@ -156,10 +167,10 @@ void guserbase::lock() {
|
|||||||
|
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
|
|
||||||
void guserbase::unlock() {
|
void guserbase::unlock()
|
||||||
|
{
|
||||||
if(WideCanLock)
|
if (WideCanLock)
|
||||||
usrbase.unlock(0, 1);
|
usrbase.Unlock(0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -405,8 +416,9 @@ bool guserbase::find_entry(char* name, bool lookup) {
|
|||||||
uint old_index = index;
|
uint old_index = index;
|
||||||
|
|
||||||
refresh_maximum_index();
|
refresh_maximum_index();
|
||||||
usrbase.lseek(sizeof(gusrbaseheader), SEEK_SET);
|
usrbase.LseekSet(sizeof(gusrbaseheader));
|
||||||
for(index=0; index<=maximum_index; index++) {
|
for (index=0; index<=maximum_index; index++)
|
||||||
|
{
|
||||||
read_entry(index, &entry);
|
read_entry(index, &entry);
|
||||||
|
|
||||||
if(strieql(name, entry.name))
|
if(strieql(name, entry.name))
|
||||||
@ -446,35 +458,33 @@ void guserbase::write_entry(uint idx, bool updateit) {
|
|||||||
entry.times++;
|
entry.times++;
|
||||||
}
|
}
|
||||||
|
|
||||||
usrbase.lseek(sizeof(gusrbaseheader) + sizeof(gusrbaseentry)*(idx+1)-1, SEEK_SET);
|
usrbase.LseekSet(sizeof(gusrbaseheader) + sizeof(gusrbaseentry)*(idx+1)-1);
|
||||||
char z = 0;
|
char z = 0;
|
||||||
usrbase.write(&z, 1); // adjust entry size first...
|
usrbase.Write(&z, 1); // adjust entry size first...
|
||||||
usrbase.lseek(sizeof(gusrbaseheader) + sizeof(gusrbaseentry)*idx, SEEK_SET);
|
usrbase.LseekSet(sizeof(gusrbaseheader) + sizeof(gusrbaseentry)*idx);
|
||||||
usrbase.write(entry.macro, sizeof(entry.macro));
|
usrbase.Write(entry.macro, sizeof(entry.macro));
|
||||||
usrbase.write(entry.name, sizeof(entry.name));
|
usrbase.Write(entry.name, sizeof(entry.name));
|
||||||
usrbase.write(&entry.fidoaddr.zone, sizeof(entry.fidoaddr.zone));
|
usrbase.Write(&entry.fidoaddr.zone, sizeof(entry.fidoaddr.zone));
|
||||||
usrbase.write(&entry.fidoaddr.net, sizeof(entry.fidoaddr.net));
|
usrbase.Write(&entry.fidoaddr.net, sizeof(entry.fidoaddr.net));
|
||||||
usrbase.write(&entry.fidoaddr.node, sizeof(entry.fidoaddr.node));
|
usrbase.Write(&entry.fidoaddr.node, sizeof(entry.fidoaddr.node));
|
||||||
usrbase.write(&entry.fidoaddr.point, sizeof(entry.fidoaddr.point));
|
usrbase.Write(&entry.fidoaddr.point, sizeof(entry.fidoaddr.point));
|
||||||
usrbase.write(entry.iaddr, sizeof(entry.iaddr));
|
usrbase.Write(entry.iaddr, sizeof(entry.iaddr));
|
||||||
usrbase.write(&entry.prefer_internet, sizeof(entry.prefer_internet));
|
usrbase.Write(&entry.prefer_internet, sizeof(entry.prefer_internet));
|
||||||
usrbase.write(&entry.is_deleted, sizeof(entry.is_deleted));
|
usrbase.Write(&entry.is_deleted, sizeof(entry.is_deleted));
|
||||||
usrbase.write(entry.pseudo, sizeof(entry.pseudo));
|
usrbase.Write(entry.organisation, sizeof(entry.organisation));
|
||||||
usrbase.write(entry.organisation, sizeof(entry.organisation));
|
usrbase.Write(entry.snail1, sizeof(entry.snail1));
|
||||||
usrbase.write(entry.snail1, sizeof(entry.snail1));
|
usrbase.Write(entry.snail2, sizeof(entry.snail2));
|
||||||
usrbase.write(entry.snail2, sizeof(entry.snail2));
|
usrbase.Write(entry.snail3, sizeof(entry.snail3));
|
||||||
usrbase.write(entry.snail3, sizeof(entry.snail3));
|
usrbase.Write(entry.voicephone, sizeof(entry.voicephone));
|
||||||
usrbase.write(entry.dataphone, sizeof(entry.dataphone));
|
usrbase.Write(entry.faxphone, sizeof(entry.faxphone));
|
||||||
usrbase.write(entry.voicephone, sizeof(entry.voicephone));
|
usrbase.Write(&entry.firstdate, sizeof(entry.firstdate));
|
||||||
usrbase.write(entry.faxphone, sizeof(entry.faxphone));
|
usrbase.Write(&entry.lastdate, sizeof(entry.lastdate));
|
||||||
usrbase.write(&entry.firstdate, sizeof(entry.firstdate));
|
usrbase.Write(&entry.times, sizeof(entry.times));
|
||||||
usrbase.write(&entry.lastdate, sizeof(entry.lastdate));
|
usrbase.Write(entry.homepage, sizeof(entry.homepage));
|
||||||
usrbase.write(&entry.times, sizeof(entry.times));
|
usrbase.Write(&entry.group, sizeof(entry.group));
|
||||||
usrbase.write(entry.homepage, sizeof(entry.homepage));
|
usrbase.Write(entry.comment1, sizeof(entry.comment1));
|
||||||
usrbase.write(&entry.group, sizeof(entry.group));
|
usrbase.Write(entry.comment2, sizeof(entry.comment1));
|
||||||
usrbase.write(entry.comment1, sizeof(entry.comment1));
|
usrbase.Write(entry.comment3, sizeof(entry.comment1));
|
||||||
usrbase.write(entry.comment2, sizeof(entry.comment1));
|
|
||||||
usrbase.write(entry.comment3, sizeof(entry.comment1));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
@ -514,33 +524,34 @@ bool guserbase::read_entry(uint idx, gusrbaseentry *ent) {
|
|||||||
clear_entry(ent);
|
clear_entry(ent);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
usrbase.lseek(idx*sizeof(gusrbaseentry)+sizeof(gusrbaseheader), SEEK_SET);
|
{
|
||||||
usrbase.read(ent->macro, sizeof(ent->macro));
|
usrbase.LseekSet(idx*sizeof(gusrbaseentry)+sizeof(gusrbaseheader));
|
||||||
usrbase.read(ent->name, sizeof(ent->name));
|
usrbase.Read(ent->macro, sizeof(ent->macro));
|
||||||
usrbase.read(&ent->fidoaddr.zone, sizeof(ent->fidoaddr.zone));
|
usrbase.Read(ent->name, sizeof(ent->name));
|
||||||
usrbase.read(&ent->fidoaddr.net, sizeof(ent->fidoaddr.net));
|
usrbase.Read(&ent->fidoaddr.zone, sizeof(ent->fidoaddr.zone));
|
||||||
usrbase.read(&ent->fidoaddr.node, sizeof(ent->fidoaddr.node));
|
usrbase.Read(&ent->fidoaddr.net, sizeof(ent->fidoaddr.net));
|
||||||
usrbase.read(&ent->fidoaddr.point, sizeof(ent->fidoaddr.point));
|
usrbase.Read(&ent->fidoaddr.node, sizeof(ent->fidoaddr.node));
|
||||||
usrbase.read(ent->iaddr, sizeof(ent->iaddr));
|
usrbase.Read(&ent->fidoaddr.point, sizeof(ent->fidoaddr.point));
|
||||||
usrbase.read(&ent->prefer_internet, sizeof(ent->prefer_internet));
|
usrbase.Read(ent->iaddr, sizeof(ent->iaddr));
|
||||||
usrbase.read(&ent->is_deleted, sizeof(ent->is_deleted));
|
usrbase.Read(&ent->prefer_internet, sizeof(ent->prefer_internet));
|
||||||
usrbase.read(ent->pseudo, sizeof(ent->pseudo));
|
usrbase.Read(&ent->is_deleted, sizeof(ent->is_deleted));
|
||||||
usrbase.read(ent->organisation, sizeof(ent->organisation));
|
usrbase.Read(ent->pseudo, sizeof(ent->pseudo));
|
||||||
usrbase.read(ent->snail1, sizeof(ent->snail1));
|
usrbase.Read(ent->organisation, sizeof(ent->organisation));
|
||||||
usrbase.read(ent->snail2, sizeof(ent->snail2));
|
usrbase.Read(ent->snail1, sizeof(ent->snail1));
|
||||||
usrbase.read(ent->snail3, sizeof(ent->snail3));
|
usrbase.Read(ent->snail2, sizeof(ent->snail2));
|
||||||
usrbase.read(ent->dataphone, sizeof(ent->dataphone));
|
usrbase.Read(ent->snail3, sizeof(ent->snail3));
|
||||||
usrbase.read(ent->voicephone, sizeof(ent->voicephone));
|
usrbase.Read(ent->dataphone, sizeof(ent->dataphone));
|
||||||
usrbase.read(ent->faxphone, sizeof(ent->faxphone));
|
usrbase.Read(ent->voicephone, sizeof(ent->voicephone));
|
||||||
usrbase.read(&ent->firstdate, sizeof(ent->firstdate));
|
usrbase.Read(ent->faxphone, sizeof(ent->faxphone));
|
||||||
usrbase.read(&ent->lastdate, sizeof(ent->lastdate));
|
usrbase.Read(&ent->firstdate, sizeof(ent->firstdate));
|
||||||
usrbase.read(&ent->times, sizeof(ent->times));
|
usrbase.Read(&ent->lastdate, sizeof(ent->lastdate));
|
||||||
usrbase.read(ent->homepage, sizeof(ent->homepage));
|
usrbase.Read(&ent->times, sizeof(ent->times));
|
||||||
usrbase.read(&ent->group, sizeof(ent->group));
|
usrbase.Read(ent->homepage, sizeof(ent->homepage));
|
||||||
usrbase.read(ent->comment1, sizeof(ent->comment1));
|
usrbase.Read(&ent->group, sizeof(ent->group));
|
||||||
usrbase.read(ent->comment2, sizeof(ent->comment1));
|
usrbase.Read(ent->comment1, sizeof(ent->comment1));
|
||||||
usrbase.read(ent->comment3, sizeof(ent->comment1));
|
usrbase.Read(ent->comment2, sizeof(ent->comment1));
|
||||||
|
usrbase.Read(ent->comment3, sizeof(ent->comment1));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -570,14 +581,15 @@ void guserbase::pack_addressbook() {
|
|||||||
// zap
|
// zap
|
||||||
maximum_index = nidx;
|
maximum_index = nidx;
|
||||||
// At least one record should present
|
// At least one record should present
|
||||||
if(maximum_index)
|
if (maximum_index) --maximum_index;
|
||||||
--maximum_index;
|
usrbase.ChSize((maximum_index + 1) * sizeof(gusrbaseentry) + sizeof(gusrbaseheader));
|
||||||
usrbase.chsize((maximum_index + 1) * sizeof(gusrbaseentry) + sizeof(gusrbaseheader));
|
usrbase.Close();
|
||||||
usrbase.close();
|
|
||||||
|
|
||||||
do {
|
do
|
||||||
usrbase.open(fname, O_RDWR|O_CREAT|O_BINARY, SH_DENYNO, S_STDRW);
|
{
|
||||||
if(not usrbase) {
|
usrbase.Open(fname, O_RDWR|O_CREAT|O_BINARY, SH_DENYNO, S_STDRW);
|
||||||
|
if (!usrbase.isopen())
|
||||||
|
{
|
||||||
if((errno != EACCES) or (not PopupLocked(++tries, false, fname))) {
|
if((errno != EACCES) or (not PopupLocked(++tries, false, fname))) {
|
||||||
WideLog->ErrOpen();
|
WideLog->ErrOpen();
|
||||||
WideLog->printf("! GoldED's Addressbook cannot be opened.");
|
WideLog->printf("! GoldED's Addressbook cannot be opened.");
|
||||||
@ -586,7 +598,8 @@ void guserbase::pack_addressbook() {
|
|||||||
OpenErrorExit();
|
OpenErrorExit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while(not usrbase);
|
}
|
||||||
|
while(!usrbase.isopen());
|
||||||
|
|
||||||
if(tries)
|
if(tries)
|
||||||
PopupLocked(0, 0, NULL);
|
PopupLocked(0, 0, NULL);
|
||||||
|
@ -54,9 +54,10 @@ void WriteNoDupes(const char* file, const char* line) {
|
|||||||
long tries = 0;
|
long tries = 0;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
fp.fopen(file, "at+", SH_DENYRW);
|
fp.Fopen(file, "at+", SH_DENYRW);
|
||||||
|
|
||||||
if(not fp.isopen()) {
|
if (!fp.isopen())
|
||||||
|
{
|
||||||
if((errno != EACCES) or (PopupLocked(++tries, false, file) == false)) {
|
if((errno != EACCES) or (PopupLocked(++tries, false, file) == false)) {
|
||||||
LOG.ErrOpen();
|
LOG.ErrOpen();
|
||||||
LOG.printf("! A semaphore file could not be opened.");
|
LOG.printf("! A semaphore file could not be opened.");
|
||||||
@ -65,24 +66,27 @@ void WriteNoDupes(const char* file, const char* line) {
|
|||||||
OpenErrorExit();
|
OpenErrorExit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while(not fp.isopen());
|
}
|
||||||
|
while(!fp.isopen());
|
||||||
|
|
||||||
if(tries)
|
if (tries)
|
||||||
PopupLocked(0, 0, NULL);
|
PopupLocked(0, 0, NULL);
|
||||||
|
|
||||||
fp.fseek(0, SEEK_SET);
|
fp.FseekSet(0);
|
||||||
while(fp.fgets(buf, sizeof(buf))) {
|
while (fp.Fgets(buf, sizeof(buf)))
|
||||||
|
{
|
||||||
if(strieql(strtrim(buf), line)) {
|
if(strieql(strtrim(buf), line)) {
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(not found) {
|
if (not found)
|
||||||
fp.fseek(0, SEEK_END);
|
{
|
||||||
fp.printf("%s\n", line);
|
fp.Fseek(0, SEEK_END);
|
||||||
|
fp.Printf("%s\n", line);
|
||||||
}
|
}
|
||||||
fp.fclose();
|
fp.Fclose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -29,11 +29,56 @@
|
|||||||
#include <cstdarg>
|
#include <cstdarg>
|
||||||
#include <gfile.h>
|
#include <gfile.h>
|
||||||
|
|
||||||
|
#if defined(_MSC_VER) /*&& (_MSC_VER >= 1400)*/
|
||||||
|
|
||||||
|
#define g_sopen(fn, of, sh, pm) _tsopen(fn, of, sh, pm)
|
||||||
|
#define g_close(fh) _close(fh)
|
||||||
|
#define g_read(fh, buf, cnt) _read(fh, buf, cnt)
|
||||||
|
#define g_write(fh, buf, cnt) _write(fh, buf, cnt)
|
||||||
|
#define g_tell(fh) _tell(fh)
|
||||||
|
#define g_lseek(fh, off, org) _lseek(fh, off, org)
|
||||||
|
#define g_filelength(fh) _filelength(fh)
|
||||||
|
#define g_chsize(fh, size) _chsize(fh, size)
|
||||||
|
|
||||||
|
#define g_fsopen(fn, of, sh) _tfsopen(fn, of, sh)
|
||||||
|
#define g_fdopen(fp, of) _tfdopen(fp, of)
|
||||||
|
#define g_fileno(fp) _fileno(fp)
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#define g_sopen(fn, of, sh, pm) sopen(fn, of, sh, pm)
|
||||||
|
#define g_close(fh) close(fh)
|
||||||
|
#define g_read(fh, buf, cnt) read(fh, buf, cnt)
|
||||||
|
#define g_write(fh, buf, cnt) write(fh, buf, cnt)
|
||||||
|
#define g_tell(fh) tell(fh)
|
||||||
|
#define g_lseek(fh, off, org) lseek(fh, off, org)
|
||||||
|
#define g_filelength(fh) filelength(fh)
|
||||||
|
#define g_chsize(fh, size) chsize(fh, size)
|
||||||
|
|
||||||
|
#define g_fsopen(fn, of, sh) fsopen(fn, of, sh)
|
||||||
|
#define g_fdopen(fp, of) fdopen(fp, of)
|
||||||
|
#define g_fileno(fp) fileno(fp)
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define g_lock(fh, off, len) lock(fh, off, len)
|
||||||
|
#define g_unlock(fh, off, len) unlock(fh, off, len)
|
||||||
|
|
||||||
|
#define g_fclose(fp) fclose(fp)
|
||||||
|
#define g_fread(buf, rsz, cnt, fp) fread(buf, rsz, cnt, fp)
|
||||||
|
#define g_fwrite(buf, rsz, cnt, fp) fwrite(buf, rsz, cnt, fp)
|
||||||
|
#define g_fgetc(fp) fgetc(fp)
|
||||||
|
#define g_fputc(c, fp) fputc(c, fp)
|
||||||
|
#define g_fgets(str, cnt, fp) fgets(str, cnt, fp)
|
||||||
|
#define g_fputs(str, fp) fputs(str, fp)
|
||||||
|
#define g_fflush(fp) fflush(fp)
|
||||||
|
#define g_ftell(fp) ftell(fp)
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
|
|
||||||
gfile::gfile() {
|
gfile::gfile()
|
||||||
|
{
|
||||||
fh = -1;
|
fh = -1;
|
||||||
fp = NULL;
|
fp = NULL;
|
||||||
status = EBADF;
|
status = EBADF;
|
||||||
@ -42,8 +87,8 @@ gfile::gfile() {
|
|||||||
|
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
|
|
||||||
gfile::gfile(int __fh) {
|
gfile::gfile(int __fh)
|
||||||
|
{
|
||||||
fh = __fh;
|
fh = __fh;
|
||||||
fp = NULL;
|
fp = NULL;
|
||||||
status = 0;
|
status = 0;
|
||||||
@ -52,8 +97,8 @@ gfile::gfile(int __fh) {
|
|||||||
|
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
|
|
||||||
gfile::gfile(FILE* __fp) {
|
gfile::gfile(FILE* __fp)
|
||||||
|
{
|
||||||
fh = -1;
|
fh = -1;
|
||||||
fp = __fp;
|
fp = __fp;
|
||||||
status = 0;
|
status = 0;
|
||||||
@ -62,51 +107,42 @@ gfile::gfile(FILE* __fp) {
|
|||||||
|
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
|
|
||||||
gfile::gfile(const char* __path, int __access, int __shflag, int __mode) {
|
gfile::gfile(const char* __path, int __access, int __shflag, int __mode)
|
||||||
|
{
|
||||||
open(__path, __access, __shflag, __mode);
|
fh = -1;
|
||||||
}
|
fp = NULL;
|
||||||
|
Open(__path, __access, __shflag, __mode);
|
||||||
|
|
||||||
// ------------------------------------------------------------------
|
|
||||||
|
|
||||||
gfile::gfile(const char* __path, const char* __mode, int __shflag) {
|
|
||||||
|
|
||||||
fopen(__path, __mode, __shflag);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------
|
|
||||||
|
|
||||||
gfile::~gfile() {
|
|
||||||
|
|
||||||
if(fp != NULL)
|
|
||||||
fclose();
|
|
||||||
if(fh != -1)
|
|
||||||
close();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------
|
|
||||||
|
|
||||||
int gfile::okay() {
|
|
||||||
|
|
||||||
return !status;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
|
|
||||||
bool gfile::isopen() {
|
gfile::gfile(const char* __path, const char* __mode, int __shflag)
|
||||||
|
{
|
||||||
|
fh = -1;
|
||||||
|
fp = NULL;
|
||||||
|
Fopen(__path, __mode, __shflag);
|
||||||
|
}
|
||||||
|
|
||||||
if((fh != -1) or (fp != NULL))
|
// ------------------------------------------------------------------
|
||||||
return true;
|
|
||||||
|
gfile::~gfile()
|
||||||
|
{
|
||||||
|
if (fp != NULL) Fclose();
|
||||||
|
if (fh != -1) Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------
|
||||||
|
|
||||||
|
bool gfile::isopen()
|
||||||
|
{
|
||||||
|
if ((fh != -1) or (fp != NULL)) return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
|
|
||||||
int gfile::setfh(int __fh) {
|
int gfile::setfh(int __fh)
|
||||||
|
{
|
||||||
fh = __fh;
|
fh = __fh;
|
||||||
status = 0;
|
status = 0;
|
||||||
return fh;
|
return fh;
|
||||||
@ -114,8 +150,8 @@ int gfile::setfh(int __fh) {
|
|||||||
|
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
|
|
||||||
FILE* gfile::setfp(FILE* __fp) {
|
FILE* gfile::setfp(FILE* __fp)
|
||||||
|
{
|
||||||
fp = __fp;
|
fp = __fp;
|
||||||
status = 0;
|
status = 0;
|
||||||
return fp;
|
return fp;
|
||||||
@ -123,31 +159,35 @@ FILE* gfile::setfp(FILE* __fp) {
|
|||||||
|
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
|
|
||||||
int gfile::open(const char* __path, int __access, int __shflag, int __mode) {
|
int gfile::Open(const char* __path, int __access, int __shflag, int __mode)
|
||||||
|
{
|
||||||
fh = ::sopen(__path, __access, __shflag, __mode);
|
#if defined(_tsopen_s)
|
||||||
|
status = _tsopen_s(&fh, __path, __access, __shflag, __mode);
|
||||||
|
return fh;
|
||||||
|
#else
|
||||||
|
fh = g_sopen(__path, __access, __shflag, __mode);
|
||||||
status = (fh == -1) ? errno : 0;
|
status = (fh == -1) ? errno : 0;
|
||||||
return fh;
|
return fh;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
|
|
||||||
int gfile::open(const char* __path, int __access, char* __fmode, int __shflag, int __mode) {
|
int gfile::Open(const char* __path, int __access, const char* __fmode, int __shflag, int __mode)
|
||||||
|
{
|
||||||
open(__path, __access, __shflag, __mode);
|
Open(__path, __access, __shflag, __mode);
|
||||||
fdopen(__fmode);
|
Fdopen(__fmode);
|
||||||
return fh;
|
return fh;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
|
|
||||||
int gfile::close() {
|
int gfile::Close()
|
||||||
|
{
|
||||||
|
if (fp) return Fclose();
|
||||||
|
|
||||||
if(fp)
|
int _ret = g_close(fh);
|
||||||
return fclose();
|
|
||||||
|
|
||||||
int _ret = ::close(fh);
|
|
||||||
status = _ret ? errno : 0;
|
status = _ret ? errno : 0;
|
||||||
fh = -1;
|
fh = -1;
|
||||||
return _ret;
|
return _ret;
|
||||||
@ -155,223 +195,214 @@ int gfile::close() {
|
|||||||
|
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
|
|
||||||
int gfile::read(void* __ptr, size_t __len) {
|
int gfile::Read(void* __ptr, size_t __len)
|
||||||
|
{
|
||||||
int _ret = ::read(fh, __ptr, (unsigned)__len);
|
int _ret = g_read(fh, __ptr, unsigned(__len));
|
||||||
status = (_ret == -1) ? errno : 0;
|
status = (_ret == -1) ? errno : 0;
|
||||||
return _ret;
|
return _ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
|
|
||||||
int gfile::write(void* __ptr, size_t __len) {
|
int gfile::Write(void* __ptr, size_t __len)
|
||||||
|
{
|
||||||
int _ret = ::write(fh, __ptr, (unsigned)__len);
|
int _ret = g_write(fh, __ptr, unsigned(__len));
|
||||||
status = (_ret == -1) ? errno : 0;
|
status = (_ret == -1) ? errno : 0;
|
||||||
return _ret;
|
return _ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
|
|
||||||
long gfile::tell() {
|
long gfile::Tell()
|
||||||
|
{
|
||||||
long _ret = ::tell(fh);
|
long _ret = g_tell(fh);
|
||||||
status = (_ret == -1) ? errno : 0;
|
status = (_ret == -1) ? errno : 0;
|
||||||
return _ret;
|
return _ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
|
|
||||||
long gfile::lseek(long __offset, int __direction) {
|
long gfile::Lseek(long __offset, int __direction)
|
||||||
|
{
|
||||||
long _ret = ::lseek(fh, __offset, __direction);
|
long _ret = g_lseek(fh, __offset, __direction);
|
||||||
status = (_ret == -1) ? errno : 0;
|
status = (_ret == -1) ? errno : 0;
|
||||||
return _ret;
|
return _ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
|
|
||||||
long gfile::filelength() {
|
long gfile::FileLength()
|
||||||
|
{
|
||||||
long _ret = ::filelength(fh);
|
long _ret = g_filelength(fh);
|
||||||
status = (_ret == -1) ? errno : 0;
|
status = (_ret == -1) ? errno : 0;
|
||||||
return _ret;
|
return _ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
|
|
||||||
int gfile::chsize(long __size) {
|
int gfile::ChSize(long __size)
|
||||||
|
{
|
||||||
int _ret = ::chsize(fh, __size);
|
int _ret = g_chsize(fh, __size);
|
||||||
status = _ret ? errno : 0;
|
status = _ret ? errno : 0;
|
||||||
return _ret;
|
return _ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
|
|
||||||
int gfile::lock(long __offset, long __len) {
|
int gfile::Lock(long __offset, long __len)
|
||||||
|
{
|
||||||
int _ret = ::lock(fh, __offset, __len);
|
int _ret = g_lock(fh, __offset, __len);
|
||||||
status = _ret ? errno : 0;
|
status = _ret ? errno : 0;
|
||||||
return _ret;
|
return _ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
|
|
||||||
int gfile::unlock(long __offset, long __len) {
|
int gfile::Unlock(long __offset, long __len)
|
||||||
|
{
|
||||||
int _ret = ::unlock(fh, __offset, __len);
|
int _ret = g_unlock(fh, __offset, __len);
|
||||||
status = _ret ? errno : 0;
|
status = _ret ? errno : 0;
|
||||||
return _ret;
|
return _ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
|
|
||||||
int gfile::getftime(dword* __ftime) {
|
int gfile::GetFTime(time32_t *__ftime)
|
||||||
|
{
|
||||||
struct stat s;
|
struct stat s;
|
||||||
if(fp)
|
if (fp) Fflush();
|
||||||
fflush();
|
int rv = fstat(fh, &s);
|
||||||
int rv = fstat (fh, &s);
|
|
||||||
status = (rv) ? errno : 0;
|
status = (rv) ? errno : 0;
|
||||||
if(rv == 0)
|
if (rv == 0) *__ftime = gfixstattime(time32_t(s.st_mtime));
|
||||||
*__ftime = gfixstattime(s.st_mtime);
|
else __ftime = 0;
|
||||||
else
|
|
||||||
__ftime = 0;
|
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
|
|
||||||
FILE* gfile::fopen(const std::string& __path, const char* __mode, int __shflag) {
|
FILE* gfile::Fopen(const char* __path, const char* __mode, int __shflag)
|
||||||
|
{
|
||||||
return fopen(__path.c_str(), __mode, __shflag);
|
fp = g_fsopen(__path, __mode, __shflag);
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------
|
|
||||||
|
|
||||||
FILE* gfile::fopen(const char* __path, const char* __mode, int __shflag) {
|
|
||||||
|
|
||||||
fp = ::fsopen(__path, __mode, __shflag);
|
|
||||||
status = (fp == NULL) ? errno : 0;
|
status = (fp == NULL) ? errno : 0;
|
||||||
if(fp)
|
if (fp) fh = g_fileno(fp);
|
||||||
fh = fileno(fp);
|
|
||||||
return fp;
|
return fp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
|
|
||||||
FILE* gfile::fdopen(char* __mode) {
|
FILE* gfile::Fdopen(const char* __mode)
|
||||||
|
{
|
||||||
fp = ::fdopen(fh, __mode);
|
fp = g_fdopen(fh, __mode);
|
||||||
status = fp ? 0 : errno;
|
status = fp ? 0 : errno;
|
||||||
if(fp)
|
if (fp) fh = g_fileno(fp);
|
||||||
fh = fileno(fp);
|
|
||||||
return fp;
|
return fp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
|
|
||||||
int gfile::fclose() {
|
int gfile::Fclose()
|
||||||
|
{
|
||||||
int _ret = 0;
|
int _ret = 0;
|
||||||
if(fp)
|
if (fp) _ret = g_fclose(fp);
|
||||||
_ret = ::fclose(fp);
|
|
||||||
status = _ret ? errno : 0;
|
status = _ret ? errno : 0;
|
||||||
fp = NULL;
|
fp = NULL; fh = -1;
|
||||||
fh = -1;
|
|
||||||
return _ret;
|
return _ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
|
|
||||||
size_t gfile::fread(void* __ptr, size_t __size, size_t __items) {
|
size_t gfile::Fread(void* __ptr, size_t __size, size_t __items)
|
||||||
|
{
|
||||||
size_t _ret = ::fread(__ptr, __size, __items, fp);
|
size_t _ret = g_fread(__ptr, __size, __items, fp);
|
||||||
status = ferror_() ? errno : 0;
|
status = ferror_() ? errno : 0;
|
||||||
return _ret;
|
return _ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
|
|
||||||
size_t gfile::fwrite(const void* __ptr, size_t __size, size_t __items) {
|
size_t gfile::Fwrite(const void* __ptr, size_t __size, size_t __items)
|
||||||
|
{
|
||||||
size_t _ret = ::fwrite(__ptr, __size, __items, fp);
|
size_t _ret = g_fwrite(__ptr, __size, __items, fp);
|
||||||
status = (_ret < __items) ? errno : 0;
|
status = (_ret < __items) ? errno : 0;
|
||||||
return _ret;
|
return _ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
|
|
||||||
int gfile::fgetc() {
|
int gfile::Fgetc()
|
||||||
|
{
|
||||||
|
int _ret = g_fgetc(fp);
|
||||||
|
status = ferror_() ? errno : 0;
|
||||||
|
return _ret;
|
||||||
|
}
|
||||||
|
|
||||||
int _ret = ::fgetc(fp);
|
|
||||||
|
// ------------------------------------------------------------------
|
||||||
|
|
||||||
|
int gfile::Fputc(int __ch)
|
||||||
|
{
|
||||||
|
int _ret = g_fputc(__ch, fp);
|
||||||
status = ferror_() ? errno : 0;
|
status = ferror_() ? errno : 0;
|
||||||
return _ret;
|
return _ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
|
|
||||||
int gfile::fputc(int __ch) {
|
char* gfile::Fgets(char* __str, size_t __len)
|
||||||
|
{
|
||||||
int _ret = ::fputc(__ch, fp);
|
char* _ret = g_fgets(__str, int(__len), fp);
|
||||||
status = ferror_() ? errno : 0;
|
|
||||||
return _ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------
|
|
||||||
|
|
||||||
char* gfile::fgets(char* __str, size_t __len) {
|
|
||||||
|
|
||||||
char* _ret = ::fgets(__str, __len, fp);
|
|
||||||
status = (_ret == NULL) ? errno : 0;
|
status = (_ret == NULL) ? errno : 0;
|
||||||
return _ret;
|
return _ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
|
|
||||||
int gfile::fputs(const char* __str) {
|
int gfile::Fputs(const char* __str)
|
||||||
|
{
|
||||||
int _ret = ::fputs(__str, fp);
|
int _ret = g_fputs(__str, fp);
|
||||||
status = (_ret == EOF) ? errno : 0;
|
status = (_ret == EOF) ? errno : 0;
|
||||||
return _ret;
|
return _ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
|
|
||||||
int gfile::printf(const char* __format, ...) {
|
int gfile::Printf(const char* __format, ...)
|
||||||
|
{
|
||||||
va_list _argptr;
|
va_list _argptr;
|
||||||
va_start(_argptr, __format);
|
va_start(_argptr, __format);
|
||||||
int _outcount = ::vfprintf(fp, __format, _argptr);
|
int _outcount = vfprintf(fp, __format, _argptr);
|
||||||
va_end(_argptr);
|
va_end(_argptr);
|
||||||
return _outcount;
|
return _outcount;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
|
|
||||||
int gfile::fflush() {
|
int gfile::Fflush()
|
||||||
|
{
|
||||||
int _ret = ::fflush(fp);
|
int _ret = g_fflush(fp);
|
||||||
status = _ret ? errno : 0;
|
status = _ret ? errno : 0;
|
||||||
return _ret;
|
return _ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
|
|
||||||
long gfile::ftell() {
|
long gfile::Ftell()
|
||||||
|
{
|
||||||
long _ret = ::ftell(fp);
|
long _ret = g_ftell(fp);
|
||||||
status = (_ret == -1) ? errno : 0;
|
status = (_ret == -1) ? errno : 0;
|
||||||
return _ret;
|
return _ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
|
|
||||||
int gfile::fseek(long __offset, int __direction) {
|
int gfile::Fseek(long __offset, int __direction)
|
||||||
|
{
|
||||||
int _ret = ::fseek(fp, __offset, __direction);
|
int _ret = ::fseek(fp, __offset, __direction);
|
||||||
status = _ret ? errno : 0;
|
status = _ret ? errno : 0;
|
||||||
return _ret;
|
return _ret;
|
||||||
@ -379,31 +410,12 @@ int gfile::fseek(long __offset, int __direction) {
|
|||||||
|
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
|
|
||||||
int gfile::setvbuf(char* __buf, int __type, size_t __size) {
|
int gfile::SetvBuf(char* __buf, int __type, size_t __size)
|
||||||
|
{
|
||||||
int _ret = ::setvbuf(fp, __buf, __type, __size);
|
int _ret = ::setvbuf(fp, __buf, __type, __size);
|
||||||
status = _ret ? errno : 0;
|
status = _ret ? errno : 0;
|
||||||
return _ret;
|
return _ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------
|
|
||||||
|
|
||||||
#ifdef __GOLDWARE_HAS_BOOL
|
|
||||||
gfile& gfile::operator>> (bool& i) { fread(&i, sizeof(bool)); return *this; }
|
|
||||||
#endif
|
|
||||||
gfile& gfile::operator>> (uint8_t& i) { fread(&i, sizeof(uint8_t)); return *this; }
|
|
||||||
gfile& gfile::operator>> (uint16_t& i) { fread(&i, sizeof(uint16_t)); return *this; }
|
|
||||||
gfile& gfile::operator>> (uint32_t& i) { fread(&i, sizeof(uint32_t)); return *this; }
|
|
||||||
gfile& gfile::operator>> (unsigned long& i) { fread(&i, sizeof(unsigned long)); return *this; }
|
|
||||||
|
|
||||||
#ifdef __GOLDWARE_HAS_BOOL
|
|
||||||
gfile& gfile::operator<< (bool o) { fwrite(&o, sizeof(o)); return *this; }
|
|
||||||
#endif
|
|
||||||
gfile& gfile::operator<< (uint8_t o) { fwrite(&o, sizeof(o)); return *this; }
|
|
||||||
gfile& gfile::operator<< (uint16_t o) { fwrite(&o, sizeof(o)); return *this; }
|
|
||||||
gfile& gfile::operator<< (uint32_t o) { fwrite(&o, sizeof(o)); return *this; }
|
|
||||||
gfile& gfile::operator<< (unsigned long o) { fwrite(&o, sizeof(o)); return *this; }
|
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
|
@ -43,8 +43,8 @@
|
|||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
// Stream/Unix-style file I/O class
|
// Stream/Unix-style file I/O class
|
||||||
|
|
||||||
class gfile {
|
class gfile
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// ----------------------------------------------------------------
|
// ----------------------------------------------------------------
|
||||||
@ -63,8 +63,9 @@ public:
|
|||||||
// --------------------------------------------------------------
|
// --------------------------------------------------------------
|
||||||
// Handy utility functions
|
// Handy utility functions
|
||||||
|
|
||||||
int okay(); // Returns non-zero if no errors were detected
|
int okay() { return (0 == status); }
|
||||||
bool isopen(); // true if the file is open
|
bool isopen(); // true if the file is open
|
||||||
|
operator bool() { return isopen(); }
|
||||||
|
|
||||||
|
|
||||||
// --------------------------------------------------------------
|
// --------------------------------------------------------------
|
||||||
@ -78,8 +79,6 @@ public:
|
|||||||
|
|
||||||
~gfile(); // Destructor (closes file)
|
~gfile(); // Destructor (closes file)
|
||||||
|
|
||||||
operator bool() { return isopen(); }
|
|
||||||
|
|
||||||
|
|
||||||
// --------------------------------------------------------------
|
// --------------------------------------------------------------
|
||||||
// Set file handle or stream pointer
|
// Set file handle or stream pointer
|
||||||
@ -91,73 +90,73 @@ public:
|
|||||||
// --------------------------------------------------------------
|
// --------------------------------------------------------------
|
||||||
// UNIX-style raw I/O
|
// UNIX-style raw I/O
|
||||||
|
|
||||||
int open (const char* __path, int __access, int __shflag=SH_DENYNO, int __mode=S_IREAD|S_IWRITE);
|
int Open (const char* __path, int __access, int __shflag=SH_DENYNO, int __mode=S_IREAD|S_IWRITE);
|
||||||
int open (const char* __path, int __access, char* __fmode, int __shflag=SH_DENYNO, int __mode=S_IREAD|S_IWRITE);
|
int Open (const char* __path, int __access, const char* __fmode, int __shflag=SH_DENYNO, int __mode=S_IREAD|S_IWRITE);
|
||||||
int close ();
|
int Close ();
|
||||||
|
|
||||||
int read (void* __ptr, size_t __len);
|
int Read (void* __ptr, size_t __len);
|
||||||
int write (void* __ptr, size_t __len);
|
int Write (void* __ptr, size_t __len);
|
||||||
|
|
||||||
long tell ();
|
long Tell ();
|
||||||
long lseek (long __offset, int __direction);
|
long Lseek (long __offset, int __direction);
|
||||||
long lseek (long __record, long __recordsize, int __direction);
|
long Lseek (long __record, long __recordsize, int __direction) { return Lseek(__record*__recordsize, __direction); }
|
||||||
long lseekset (long __record, long __recordsize=1);
|
long LseekSet (long __record, long __recordsize = 1) { return Lseek(__record*__recordsize, SEEK_SET); }
|
||||||
|
|
||||||
long filelength ();
|
long FileLength ();
|
||||||
|
|
||||||
int chsize (long __size);
|
int ChSize (long __size);
|
||||||
|
|
||||||
int lock (long __offset, long __len);
|
int Lock (long __offset, long __len);
|
||||||
int unlock (long __offset, long __len);
|
int Unlock (long __offset, long __len);
|
||||||
|
|
||||||
int getftime (dword* __ftime);
|
int GetFTime (dword* __ftime);
|
||||||
|
|
||||||
|
|
||||||
// --------------------------------------------------------------
|
// --------------------------------------------------------------
|
||||||
// ANSI-style streaming buffered I/O
|
// ANSI-style streaming buffered I/O
|
||||||
|
|
||||||
FILE* fopen (const char* __path, const char* __mode, int __shflag=SH_DENYNO);
|
FILE* Fopen (const char* __path, const char* __mode, int __shflag=SH_DENYNO);
|
||||||
FILE* fopen (const std::string& __path, const char* __mode, int __shflag=SH_DENYNO);
|
FILE* Fopen (const std::string& __path, const char* __mode, int __shflag=SH_DENYNO) { return Fopen(__path.c_str(), __mode, __shflag); }
|
||||||
FILE* fdopen (char* __mode);
|
FILE* Fdopen (const char* __mode);
|
||||||
int fclose ();
|
int Fclose ();
|
||||||
|
|
||||||
size_t fread (void* __ptr, size_t __size, size_t __items=1);
|
size_t Fread (void* __ptr, size_t __size, size_t __items=1);
|
||||||
size_t fwrite (const void* __ptr, size_t __size, size_t __items=1);
|
size_t Fwrite (const void* __ptr, size_t __size, size_t __items=1);
|
||||||
|
|
||||||
int fgetc ();
|
int Fgetc ();
|
||||||
int fputc (int __ch);
|
int Fputc (int __ch);
|
||||||
|
|
||||||
char* fgets (char* __str, size_t __len);
|
char* Fgets (char* __str, size_t __len);
|
||||||
int fputs (const char* __str);
|
int Fputs (const char* __str);
|
||||||
|
|
||||||
int printf (const char* __format, ...) __attribute__ ((format (printf, 2, 3)));
|
int Printf (const char* __format, ...) __attribute__ ((format (printf, 2, 3)));
|
||||||
|
|
||||||
int fflush ();
|
int Fflush ();
|
||||||
|
|
||||||
long ftell ();
|
long Ftell ();
|
||||||
int fseek (long __offset, int __direction);
|
int Fseek (long __offset, int __direction);
|
||||||
int fseek (long __record, long __recordsize, int __direction);
|
int Fseek (long __record, long __recordsize, int __direction) { return Fseek(__record*__recordsize, __direction); }
|
||||||
int fseekset(long __record, long __recordsize=1);
|
int FseekSet(long __record, long __recordsize = 1) { return Fseek(__record*__recordsize, SEEK_SET); }
|
||||||
|
|
||||||
void rewind ();
|
void Rewind () { rewind(fp); }
|
||||||
|
|
||||||
int setvbuf (char* __buf=NULL, int __type=_IOFBF, size_t __size=8192);
|
int SetvBuf (char* __buf=NULL, int __type=_IOFBF, size_t __size=8192);
|
||||||
int setvbuf (size_t __size) { return setvbuf(NULL, _IOFBF, __size); }
|
int SetvBuf (size_t __size) { return SetvBuf(NULL, _IOFBF, __size); }
|
||||||
|
|
||||||
int feof_ ();
|
int feof_ () { return feof(fp); }
|
||||||
int ferror_ ();
|
int ferror_ () { return ferror(fp); }
|
||||||
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------
|
// ----------------------------------------------------------------
|
||||||
|
|
||||||
#ifdef __GOLDWARE_HAS_BOOL
|
#ifdef __GOLDWARE_HAS_BOOL
|
||||||
gfile& operator>> (bool& i);
|
gfile& operator>> (bool& i) { Fread(&i, sizeof(bool)); return *this; }
|
||||||
#endif
|
#endif
|
||||||
gfile& operator>> (uint8_t& i);
|
gfile& operator>> (uint8_t& i) { Fread(&i, sizeof(uint8_t)); return *this; }
|
||||||
gfile& operator>> (uint16_t& i);
|
gfile& operator>> (uint16_t& i) { Fread(&i, sizeof(uint16_t)); return *this; }
|
||||||
gfile& operator>> (uint32_t& i);
|
gfile& operator>> (uint32_t& i) { Fread(&i, sizeof(uint32_t)); return *this; }
|
||||||
#if !defined(__CYGWIN__)
|
#if !defined(__CYGWIN__)
|
||||||
gfile& operator>> (unsigned long& i);
|
gfile& operator>> (unsigned long& i) { Fread(&i, sizeof(unsigned long)); return *this; }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
gfile& operator>> (char& i) { return operator>>((uint8_t&)i); }
|
gfile& operator>> (char& i) { return operator>>((uint8_t&)i); }
|
||||||
@ -171,13 +170,13 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __GOLDWARE_HAS_BOOL
|
#ifdef __GOLDWARE_HAS_BOOL
|
||||||
gfile& operator<< (bool o);
|
gfile& operator<< (bool o) { Fwrite(&o, sizeof(o)); return *this; }
|
||||||
#endif
|
#endif
|
||||||
gfile& operator<< (uint8_t o);
|
gfile& operator<< (uint8_t o) { Fwrite(&o, sizeof(o)); return *this; }
|
||||||
gfile& operator<< (uint16_t o);
|
gfile& operator<< (uint16_t o) { Fwrite(&o, sizeof(o)); return *this; }
|
||||||
gfile& operator<< (uint32_t o);
|
gfile& operator<< (uint32_t o) { Fwrite(&o, sizeof(o)); return *this; }
|
||||||
#if !defined(__CYGWIN__)
|
#if !defined(__CYGWIN__)
|
||||||
gfile& operator<< (unsigned long o);
|
gfile& operator<< (unsigned long o) { Fwrite(&o, sizeof(o)); return *this; }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
gfile& operator<< (char o) { return operator<<((uint8_t )o); }
|
gfile& operator<< (char o) { return operator<<((uint8_t )o); }
|
||||||
@ -189,70 +188,9 @@ public:
|
|||||||
#if !defined(__CYGWIN__)
|
#if !defined(__CYGWIN__)
|
||||||
gfile& operator<< (long o) { return operator<<((unsigned long)o); }
|
gfile& operator<< (long o) { return operator<<((unsigned long)o); }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------
|
|
||||||
// Inline implementations
|
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------
|
|
||||||
|
|
||||||
inline long gfile::lseek(long __record, long __recordsize, int __direction) {
|
|
||||||
|
|
||||||
return lseek(__record*__recordsize, __direction);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------
|
|
||||||
|
|
||||||
inline long gfile::lseekset(long __record, long __recordsize) {
|
|
||||||
|
|
||||||
return lseek(__record*__recordsize, SEEK_SET);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------
|
|
||||||
|
|
||||||
inline int gfile::ferror_() {
|
|
||||||
|
|
||||||
return ferror(fp);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------
|
|
||||||
|
|
||||||
inline int gfile::fseek(long __record, long __recordsize, int __direction) {
|
|
||||||
|
|
||||||
return fseek(__record*__recordsize, __direction);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------
|
|
||||||
|
|
||||||
inline int gfile::fseekset(long __record, long __recordsize) {
|
|
||||||
|
|
||||||
return fseek(__record*__recordsize, SEEK_SET);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------
|
|
||||||
|
|
||||||
inline void gfile::rewind() {
|
|
||||||
|
|
||||||
::rewind(fp);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------
|
|
||||||
|
|
||||||
inline int gfile::feof_() {
|
|
||||||
|
|
||||||
return feof(fp);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -159,10 +159,10 @@ inline bool fexist(const TCHAR *filename) { return *filename ? (0 == (_taccess(f
|
|||||||
#endif
|
#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);
|
time32_t gfixstattime(time32_t st_time);
|
||||||
|
|
||||||
dword GetFiletime(const char* file);
|
time32_t GetFiletime(const char* file);
|
||||||
inline dword GetFiletime(const std::string& file) { return GetFiletime(file.c_str()); }
|
inline time32_t GetFiletime(const std::string& file) { return GetFiletime(file.c_str()); }
|
||||||
|
|
||||||
inline long FiletimeCmp(const char* file1, const char* file2) { return long(GetFiletime(file1) - GetFiletime(file2)); }
|
inline long FiletimeCmp(const char* file1, const char* file2) { return long(GetFiletime(file1) - GetFiletime(file2)); }
|
||||||
inline long FiletimeCmp(const std::string& file1, const std::string& file2) { return FiletimeCmp(file1.c_str(), file2.c_str()); }
|
inline long FiletimeCmp(const std::string& file1, const std::string& file2) { return FiletimeCmp(file1.c_str(), file2.c_str()); }
|
||||||
@ -184,7 +184,7 @@ char* StripBackslash(char* p);
|
|||||||
char* PathCopy(char* dst, const char* src);
|
char* PathCopy(char* dst, const char* src);
|
||||||
void PathCopy(std::string& dst, const char* src);
|
void PathCopy(std::string& dst, const char* src);
|
||||||
|
|
||||||
void TouchFile(const char* __filename);
|
void TouchFile(const TCHAR *filename);
|
||||||
|
|
||||||
int TestLockPath(const char* __path);
|
int TestLockPath(const char* __path);
|
||||||
void WipeFile(const char* file, int options);
|
void WipeFile(const char* file, int options);
|
||||||
|
@ -28,6 +28,8 @@
|
|||||||
#include <gtimall.h>
|
#include <gtimall.h>
|
||||||
#include <gstrall.h>
|
#include <gstrall.h>
|
||||||
#include <gfilutil.h>
|
#include <gfilutil.h>
|
||||||
|
#include <gfile.h>
|
||||||
|
|
||||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
#include <sys/utime.h>
|
#include <sys/utime.h>
|
||||||
#else
|
#else
|
||||||
@ -96,7 +98,7 @@ 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)
|
time32_t gfixstattime(time32_t st_time)
|
||||||
{
|
{
|
||||||
#if (defined(__MINGW32__) && !defined(__MSVCRT__)) || defined(__CYGWIN__)
|
#if (defined(__MINGW32__) && !defined(__MSVCRT__)) || defined(__CYGWIN__)
|
||||||
struct tm f; ggmtime(&f, &st_time);
|
struct tm f; ggmtime(&f, &st_time);
|
||||||
@ -138,7 +140,7 @@ dword gfixstattime(time32_t st_time)
|
|||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
// Get timestamp of file
|
// Get timestamp of file
|
||||||
|
|
||||||
dword GetFiletime(const char* file) {
|
time32_t GetFiletime(const char* file) {
|
||||||
|
|
||||||
struct stat st;
|
struct stat st;
|
||||||
if(stat(file, &st) == 0) {
|
if(stat(file, &st) == 0) {
|
||||||
@ -301,11 +303,14 @@ FILE *fsopen(const char *path, const char *type, int shflag) {
|
|||||||
|
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
|
|
||||||
void TouchFile(const char* filename) {
|
void TouchFile(const TCHAR *filename)
|
||||||
|
{
|
||||||
if(not fexist(filename))
|
if (not fexist(filename))
|
||||||
close(open(filename, O_WRONLY|O_CREAT|O_TRUNC, S_STDRW));
|
{
|
||||||
else {
|
gfile fh(filename, O_WRONLY|O_CREAT|O_TRUNC);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
struct utimbuf ut;
|
struct utimbuf ut;
|
||||||
ut.actime = ut.modtime = time(NULL);
|
ut.actime = ut.modtime = time(NULL);
|
||||||
utime(filename, &ut);
|
utime(filename, &ut);
|
||||||
|
@ -62,17 +62,18 @@ glog::~glog() {
|
|||||||
|
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
|
|
||||||
int glog::open(const char* filename, const char* name, const char* shortname, int type, uint bufsz, int shflag) {
|
int glog::open(const char* filename, const char* name, const char* shortname, int type, uint bufsz, int shflag)
|
||||||
|
{
|
||||||
fp.fopen(filename, "at", shflag);
|
fp.Fopen(filename, "at", shflag);
|
||||||
if(fp.status) {
|
if (fp.status)
|
||||||
|
{
|
||||||
status = fp.status;
|
status = fp.status;
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
count++;
|
count++;
|
||||||
bufsize = bufsz;
|
bufsize = bufsz;
|
||||||
fp.setvbuf(NULL, bufsize ? _IOFBF : _IONBF, bufsize);
|
fp.SetvBuf(NULL, bufsize ? _IOFBF : _IONBF, bufsize);
|
||||||
|
|
||||||
init(name, shortname, type);
|
init(name, shortname, type);
|
||||||
|
|
||||||
@ -82,9 +83,9 @@ int glog::open(const char* filename, const char* name, const char* shortname, in
|
|||||||
|
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
|
|
||||||
void glog::close() {
|
void glog::close()
|
||||||
|
{
|
||||||
fp.fclose();
|
fp.Fclose();
|
||||||
count--;
|
count--;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,8 +139,8 @@ void glog::printf(const char* format, ...) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(fp.isopen())
|
if (fp.isopen())
|
||||||
fp.printf("%s", logbuf);
|
fp.Printf("%s", logbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
*buf = NUL;
|
*buf = NUL;
|
||||||
@ -172,9 +173,10 @@ void glog::printf(const char* format, ...) {
|
|||||||
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())
|
||||||
fp.printf("%s\n", logbuf);
|
{
|
||||||
fp.fflush();
|
fp.Printf("%s\n", logbuf);
|
||||||
|
fp.Fflush();
|
||||||
}
|
}
|
||||||
if(storelines != -1) {
|
if(storelines != -1) {
|
||||||
if(storelines < GLOG_STORELINES)
|
if(storelines < GLOG_STORELINES)
|
||||||
|
@ -293,30 +293,29 @@ uint GTag::ToReln(uint32_t __tagn) {
|
|||||||
|
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
|
|
||||||
void GTag::Load(gfile& fp) {
|
void GTag::Load(gfile& fp)
|
||||||
|
{
|
||||||
dword val;
|
dword val;
|
||||||
|
|
||||||
fp.fread(&val, sizeof(dword));
|
fp.Fread(&val, sizeof(dword));
|
||||||
count = (uint) val;
|
count = (uint) val;
|
||||||
if(count) {
|
if (count)
|
||||||
|
{
|
||||||
Resize(count);
|
Resize(count);
|
||||||
fp.fread(tag, sizeof(uint32_t), count);
|
fp.Fread(tag, sizeof(uint32_t), count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
|
|
||||||
void GTag::Save(gfile& fp) {
|
void GTag::Save(gfile& fp)
|
||||||
|
{
|
||||||
|
dword val = (dword) count;
|
||||||
|
fp.Fwrite(&val, sizeof(dword));
|
||||||
|
|
||||||
dword val;
|
if (tag and count)
|
||||||
|
fp.Fwrite(tag, sizeof(uint32_t), count);
|
||||||
val = (dword) count;
|
|
||||||
fp.fwrite(&val, sizeof(dword));
|
|
||||||
|
|
||||||
if(tag and count)
|
|
||||||
fp.fwrite(tag, sizeof(uint32_t), count);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -131,20 +131,22 @@ static int find_cat_name(const char* cat) {
|
|||||||
int found=NO;
|
int found=NO;
|
||||||
|
|
||||||
// Reset file pointer.
|
// Reset file pointer.
|
||||||
whelp.fp->fseekset(whelp.offset);
|
whelp.fp->FseekSet(whelp.offset);
|
||||||
|
|
||||||
// Check for "*I" marker.
|
// Check for "*I" marker.
|
||||||
whelp.fp->fgets(buf, BUFSIZE);
|
whelp.fp->Fgets(buf, BUFSIZE);
|
||||||
if(strnieql(buf,"*I",2)) {
|
if (strnieql(buf,"*I",2))
|
||||||
|
{
|
||||||
// Search index for help category entry. If found,
|
// Search index for help category entry. If found,
|
||||||
// then advance file pointer to specified position.
|
// then advance file pointer to specified position.
|
||||||
for(;;) {
|
for(;;)
|
||||||
whelp.fp->fread(&recd,sizeof(Hlpr));
|
{
|
||||||
|
whelp.fp->Fread(&recd,sizeof(Hlpr));
|
||||||
if(recd.offset==-1L)
|
if(recd.offset==-1L)
|
||||||
break;
|
break;
|
||||||
if(strieql(recd.category,cat)) {
|
if (strieql(recd.category,cat))
|
||||||
whelp.fp->fseekset(whelp.offset + recd.offset);
|
{
|
||||||
|
whelp.fp->FseekSet(whelp.offset + recd.offset);
|
||||||
found=YES;
|
found=YES;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -166,20 +168,22 @@ static int find_cat_number(int cat) {
|
|||||||
int found=NO;
|
int found=NO;
|
||||||
|
|
||||||
// Reset file pointer.
|
// Reset file pointer.
|
||||||
whelp.fp->fseekset(whelp.offset);
|
whelp.fp->FseekSet(whelp.offset);
|
||||||
|
|
||||||
// Check for "*I" marker.
|
// Check for "*I" marker.
|
||||||
whelp.fp->fgets(buf, BUFSIZE);
|
whelp.fp->Fgets(buf, BUFSIZE);
|
||||||
if(strnieql(buf,"*I",2)) {
|
if (strnieql(buf,"*I",2))
|
||||||
|
{
|
||||||
// Search index for help category entry. If found,
|
// Search index for help category entry. If found,
|
||||||
// then advance file pointer to specified position.
|
// then advance file pointer to specified position.
|
||||||
for(;;) {
|
for (;;)
|
||||||
whelp.fp->fread(&recd,sizeof(Hlpr));
|
{
|
||||||
if(recd.offset==-1L)
|
whelp.fp->Fread(&recd,sizeof(Hlpr));
|
||||||
|
if (recd.offset==-1L)
|
||||||
break;
|
break;
|
||||||
if(recd.help==cat) {
|
if (recd.help==cat)
|
||||||
whelp.fp->fseekset(whelp.offset + recd.offset);
|
{
|
||||||
|
whelp.fp->FseekSet(whelp.offset + recd.offset);
|
||||||
found=YES;
|
found=YES;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -205,18 +209,21 @@ static int find_page(long startpos, int pageofs) {
|
|||||||
int lines = whelp.srow;
|
int lines = whelp.srow;
|
||||||
|
|
||||||
lastpagepos = currpos = startpos;
|
lastpagepos = currpos = startpos;
|
||||||
whelp.fp->fseekset(startpos);
|
whelp.fp->FseekSet(startpos);
|
||||||
|
|
||||||
while(currpage < pageofs) {
|
while (currpage < pageofs)
|
||||||
whelp.fp->fgets(buf, BUFSIZE);
|
{
|
||||||
if(not whelp.fp->okay()) {
|
whelp.fp->Fgets(buf, BUFSIZE);
|
||||||
whelp.fp->fseekset(lastpagepos);
|
if (not whelp.fp->okay())
|
||||||
|
{
|
||||||
|
whelp.fp->FseekSet(lastpagepos);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
lines++;
|
lines++;
|
||||||
currpos=whelp.fp->ftell();
|
currpos=whelp.fp->Ftell();
|
||||||
if(strnieql(buf, "*E", 2)) {
|
if (strnieql(buf, "*E", 2))
|
||||||
whelp.fp->fseekset(lastpagepos);
|
{
|
||||||
|
whelp.fp->FseekSet(lastpagepos);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(strnieql(buf, "*P", 2)) {
|
if(strnieql(buf, "*P", 2)) {
|
||||||
@ -252,7 +259,7 @@ static void disp_cat() {
|
|||||||
page = wrow = wcol = end = menuopen = itemopen = 0;
|
page = wrow = wcol = end = menuopen = itemopen = 0;
|
||||||
|
|
||||||
// save current info
|
// save current info
|
||||||
startpos = whelp.fp->ftell();
|
startpos = whelp.fp->Ftell();
|
||||||
curr = gwin.cmenu;
|
curr = gwin.cmenu;
|
||||||
|
|
||||||
// set text attribute
|
// set text attribute
|
||||||
@ -261,7 +268,7 @@ static void disp_cat() {
|
|||||||
for(;;) {
|
for(;;) {
|
||||||
|
|
||||||
// read next line from help file into buffer
|
// read next line from help file into buffer
|
||||||
whelp.fp->fgets(buf,BUFSIZE);
|
whelp.fp->Fgets(buf,BUFSIZE);
|
||||||
strtrim(buf);
|
strtrim(buf);
|
||||||
|
|
||||||
// if end-of-file or "*E" was found, assume end-of-category
|
// if end-of-file or "*E" was found, assume end-of-category
|
||||||
@ -326,10 +333,10 @@ static void disp_cat() {
|
|||||||
// try to find selected category, if found set
|
// try to find selected category, if found set
|
||||||
// file pointer to it, otherwise reset file
|
// file pointer to it, otherwise reset file
|
||||||
// pointer back to previous help category
|
// pointer back to previous help category
|
||||||
if(find_cat_name(catarray[i]))
|
if (find_cat_name(catarray[i]))
|
||||||
startpos=whelp.fp->ftell();
|
startpos = whelp.fp->Ftell();
|
||||||
else
|
else
|
||||||
whelp.fp->fseekset(startpos);
|
whelp.fp->FseekSet(startpos);
|
||||||
|
|
||||||
// clear help window and set
|
// clear help window and set
|
||||||
// position to upper left corner
|
// position to upper left corner
|
||||||
@ -501,11 +508,13 @@ static void help_handler() {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
if(not whelp.fp) {
|
if (not whelp.fp)
|
||||||
|
{
|
||||||
whelpclosefile = true;
|
whelpclosefile = true;
|
||||||
whelp.fp = new gfile; throw_new(whelp.fp);
|
whelp.fp = new gfile; throw_new(whelp.fp);
|
||||||
whelp.fp->fopen(whelp.file,"rb");
|
whelp.fp->Fopen(whelp.file,"rb");
|
||||||
if(not whelp.fp->isopen()) {
|
if (!whelp.fp->isopen())
|
||||||
|
{
|
||||||
wtextattr(whelp.textattr);
|
wtextattr(whelp.textattr);
|
||||||
wputs("\nHelp file not found: ");
|
wputs("\nHelp file not found: ");
|
||||||
wputs(whelp.file);
|
wputs(whelp.file);
|
||||||
@ -514,9 +523,9 @@ static void help_handler() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(whelp.fp->isopen()) {
|
if (whelp.fp->isopen())
|
||||||
|
{
|
||||||
whelp.fp->fseekset(whelp.offset);
|
whelp.fp->FseekSet(whelp.offset);
|
||||||
|
|
||||||
// find help category in help file
|
// find help category in help file
|
||||||
found=find_cat_number(cat);
|
found=find_cat_number(cat);
|
||||||
@ -526,8 +535,9 @@ static void help_handler() {
|
|||||||
disp_cat();
|
disp_cat();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(whelpclosefile) {
|
if (whelpclosefile)
|
||||||
whelp.fp->fclose();
|
{
|
||||||
|
whelp.fp->Fclose();
|
||||||
delete whelp.fp;
|
delete whelp.fp;
|
||||||
whelp.fp = NULL;
|
whelp.fp = NULL;
|
||||||
}
|
}
|
||||||
|
@ -42,30 +42,32 @@ extern _help_t whelp;
|
|||||||
void whelpcompile(const char* helpfile, long& offset) {
|
void whelpcompile(const char* helpfile, long& offset) {
|
||||||
|
|
||||||
gfile ifp(helpfile, "rb");
|
gfile ifp(helpfile, "rb");
|
||||||
if(ifp) {
|
if (ifp.isopen())
|
||||||
|
{
|
||||||
ifp.setvbuf();
|
ifp.SetvBuf();
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
while(ifp.fgets(buf, sizeof(buf))) {
|
while (ifp.Fgets(buf, sizeof(buf)))
|
||||||
|
{
|
||||||
if(strnieql(buf, "*B ", 3))
|
if(strnieql(buf, "*B ", 3))
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
ifp.rewind();
|
ifp.Rewind();
|
||||||
|
|
||||||
Hlpr* helpindex = (Hlpr*)throw_xcalloc(count+2, sizeof(Hlpr));
|
Hlpr* helpindex = (Hlpr*)throw_xcalloc(count+2, sizeof(Hlpr));
|
||||||
|
|
||||||
long relative_offset = 0;
|
long relative_offset = 0;
|
||||||
|
|
||||||
whelp.fp->fputs("*I\r\n");
|
whelp.fp->Fputs("*I\r\n");
|
||||||
whelp.fp->fwrite(helpindex, count+1, sizeof(Hlpr));
|
whelp.fp->Fwrite(helpindex, count+1, sizeof(Hlpr));
|
||||||
whelp.fp->fputs("\r\n\r\n");
|
whelp.fp->Fputs("\r\n\r\n");
|
||||||
relative_offset += 4 + ((count+1)*sizeof(Hlpr)) + 4;
|
relative_offset += 4 + ((count+1)*sizeof(Hlpr)) + 4;
|
||||||
|
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
bool comment = true;
|
bool comment = true;
|
||||||
while(ifp.fgets(buf, sizeof(buf))) {
|
while (ifp.Fgets(buf, sizeof(buf)))
|
||||||
|
{
|
||||||
if(strnieql(buf, "*B ", 3)) {
|
if(strnieql(buf, "*B ", 3)) {
|
||||||
comment = false;
|
comment = false;
|
||||||
helpindex[counter].help = atow(buf+3);
|
helpindex[counter].help = atow(buf+3);
|
||||||
@ -74,8 +76,9 @@ void whelpcompile(const char* helpfile, long& offset) {
|
|||||||
helpindex[counter].offset = relative_offset + strlen(buf);
|
helpindex[counter].offset = relative_offset + strlen(buf);
|
||||||
counter++;
|
counter++;
|
||||||
}
|
}
|
||||||
if(not comment) {
|
if (not comment)
|
||||||
whelp.fp->fputs(buf);
|
{
|
||||||
|
whelp.fp->Fputs(buf);
|
||||||
relative_offset += strlen(buf);
|
relative_offset += strlen(buf);
|
||||||
}
|
}
|
||||||
if(strnieql(buf, "*E", 2))
|
if(strnieql(buf, "*E", 2))
|
||||||
@ -83,15 +86,15 @@ void whelpcompile(const char* helpfile, long& offset) {
|
|||||||
}
|
}
|
||||||
helpindex[counter].offset = -1L;
|
helpindex[counter].offset = -1L;
|
||||||
|
|
||||||
whelp.fp->fseekset(offset);
|
whelp.fp->FseekSet(offset);
|
||||||
whelp.fp->fputs("*I\r\n");
|
whelp.fp->Fputs("*I\r\n");
|
||||||
whelp.fp->fwrite(helpindex, count+1, sizeof(Hlpr));
|
whelp.fp->Fwrite(helpindex, count+1, sizeof(Hlpr));
|
||||||
offset += relative_offset;
|
offset += relative_offset;
|
||||||
whelp.fp->fseekset(offset);
|
whelp.fp->FseekSet(offset);
|
||||||
|
|
||||||
throw_xfree(helpindex);
|
throw_xfree(helpindex);
|
||||||
|
|
||||||
ifp.fclose();
|
ifp.Fclose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1231,8 +1231,9 @@ int wmenuget() {
|
|||||||
|
|
||||||
// separate ASCII code from keypress code, if ASCII
|
// separate ASCII code from keypress code, if ASCII
|
||||||
// code is zero, then it must be an extended key
|
// code is zero, then it must be an extended key
|
||||||
ch=(char)xch;
|
ch = char(xch & 0xFF);
|
||||||
if(!ch and gmnudropthrough) {
|
if (!ch and gmnudropthrough)
|
||||||
|
{
|
||||||
if((xch != Key_PgDn) and (xch != Key_PgUp))
|
if((xch != Key_PgDn) and (xch != Key_PgUp))
|
||||||
kbput(xch);
|
kbput(xch);
|
||||||
goto ESCAPE_KEY;
|
goto ESCAPE_KEY;
|
||||||
|
@ -678,7 +678,7 @@ int wpickstr(int srow, int scol, int erow, int ecol, int btype, vattr bordattr,
|
|||||||
// position for the item that begins with the same ASCII
|
// position for the item that begins with the same ASCII
|
||||||
// character as the keypress. If not found after current
|
// character as the keypress. If not found after current
|
||||||
// position, search from the beginning for a match
|
// position, search from the beginning for a match
|
||||||
ch = (char)g_toupper((char)xch);
|
ch = (char)g_toupper(char(xch & 0xFF));
|
||||||
if(!ch)
|
if(!ch)
|
||||||
break;
|
break;
|
||||||
for(i=r.curr+1; i<r.numelems; i++)
|
for(i=r.curr+1; i<r.numelems; i++)
|
||||||
|
@ -66,8 +66,7 @@ void gareafile::ReadInterMail(char* tag) {
|
|||||||
|
|
||||||
const char* _file = AddPath(_path, "fd.sys");
|
const char* _file = AddPath(_path, "fd.sys");
|
||||||
|
|
||||||
gfile fp;
|
gfile fp(_file, "rb");
|
||||||
fp.fopen(_file, "rb");
|
|
||||||
if (fp.isopen())
|
if (fp.isopen())
|
||||||
{
|
{
|
||||||
_ctl* ctl = (_ctl*)throw_calloc(1, sizeof(_ctl));
|
_ctl* ctl = (_ctl*)throw_calloc(1, sizeof(_ctl));
|
||||||
@ -75,11 +74,11 @@ void gareafile::ReadInterMail(char* tag) {
|
|||||||
if (not quiet)
|
if (not quiet)
|
||||||
STD_PRINTNL("* Reading " << _file);
|
STD_PRINTNL("* Reading " << _file);
|
||||||
|
|
||||||
fp.fread(ctl, sizeof(_ctl));
|
fp.Fread(ctl, sizeof(_ctl));
|
||||||
|
|
||||||
if(not memcmp(ctl->fingerprint, "JoHo", 5) and (ctl->sysrev == IM_THISREV)) {
|
if (not memcmp(ctl->fingerprint, "JoHo", 5) and (ctl->sysrev == IM_THISREV))
|
||||||
|
{
|
||||||
fp.fclose();
|
fp.Fclose();
|
||||||
|
|
||||||
CfgHudsonpath(ctl->e.qbase);
|
CfgHudsonpath(ctl->e.qbase);
|
||||||
|
|
||||||
@ -136,7 +135,7 @@ void gareafile::ReadInterMail(char* tag) {
|
|||||||
if(fexist(_file)) {
|
if(fexist(_file)) {
|
||||||
|
|
||||||
_file = AddPath(ctl->s.systempath, "imfolder.cfg");
|
_file = AddPath(ctl->s.systempath, "imfolder.cfg");
|
||||||
fp.fopen(_file, "rb");
|
fp.Fopen(_file, "rb");
|
||||||
if (fp.isopen())
|
if (fp.isopen())
|
||||||
{
|
{
|
||||||
if (not quiet)
|
if (not quiet)
|
||||||
@ -144,8 +143,8 @@ void gareafile::ReadInterMail(char* tag) {
|
|||||||
|
|
||||||
FOLDER* _folder = (FOLDER*)throw_calloc(1, sizeof(FOLDER));
|
FOLDER* _folder = (FOLDER*)throw_calloc(1, sizeof(FOLDER));
|
||||||
|
|
||||||
while(fp.fread(_folder, sizeof(FOLDER)) == 1) {
|
while (fp.Fread(_folder, sizeof(FOLDER)) == 1)
|
||||||
|
{
|
||||||
aa.reset();
|
aa.reset();
|
||||||
switch(_folder->ftype) {
|
switch(_folder->ftype) {
|
||||||
case F_MSG: aa.basetype = "OPUS"; break;
|
case F_MSG: aa.basetype = "OPUS"; break;
|
||||||
@ -174,13 +173,13 @@ void gareafile::ReadInterMail(char* tag) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw_free(_folder);
|
throw_free(_folder);
|
||||||
fp.fclose();
|
fp.Fclose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
_file = AddPath(ctl->s.systempath, "folder.cfg");
|
_file = AddPath(ctl->s.systempath, "folder.cfg");
|
||||||
fp.fopen(_file, "rb");
|
fp.Fopen(_file, "rb");
|
||||||
if (fp.isopen())
|
if (fp.isopen())
|
||||||
{
|
{
|
||||||
if (not quiet)
|
if (not quiet)
|
||||||
@ -188,7 +187,8 @@ void gareafile::ReadInterMail(char* tag) {
|
|||||||
|
|
||||||
OLDFOLDER* _folder = (OLDFOLDER*)throw_calloc(1, sizeof(OLDFOLDER));
|
OLDFOLDER* _folder = (OLDFOLDER*)throw_calloc(1, sizeof(OLDFOLDER));
|
||||||
|
|
||||||
while(fp.fread(_folder, sizeof(OLDFOLDER)) == 1) {
|
while (fp.Fread(_folder, sizeof(OLDFOLDER)) == 1)
|
||||||
|
{
|
||||||
long _behave = _folder->behave;
|
long _behave = _folder->behave;
|
||||||
if(not (DELETED & _behave)) {
|
if(not (DELETED & _behave)) {
|
||||||
|
|
||||||
@ -216,7 +216,7 @@ void gareafile::ReadInterMail(char* tag) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw_free(_folder);
|
throw_free(_folder);
|
||||||
fp.fclose();
|
fp.Fclose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -66,17 +66,16 @@ void gareafile::ReadLoraBBS(char* tag) {
|
|||||||
if(*_path == NUL)
|
if(*_path == NUL)
|
||||||
strcpy(_path, areapath);
|
strcpy(_path, areapath);
|
||||||
|
|
||||||
gfile fp;
|
|
||||||
const char* _file = AddPath(_path, "config.dat");
|
const char* _file = AddPath(_path, "config.dat");
|
||||||
fp.fopen(_file, "rb");
|
gfile fp(_file, "rb");
|
||||||
if (fp.isopen())
|
if (fp.isopen())
|
||||||
{
|
{
|
||||||
if (not quiet)
|
if (not quiet)
|
||||||
STD_PRINTNL("* Reading " << _file);
|
STD_PRINTNL("* Reading " << _file);
|
||||||
|
|
||||||
_configuration* cfg = (_configuration*)throw_calloc(1, sizeof(_configuration));
|
_configuration* cfg = (_configuration*)throw_calloc(1, sizeof(_configuration));
|
||||||
fp.fread(cfg, sizeof(_configuration));
|
fp.Fread(cfg, sizeof(_configuration));
|
||||||
fp.fclose();
|
fp.Fclose();
|
||||||
|
|
||||||
//CfgUsername(cfg->sysop);
|
//CfgUsername(cfg->sysop);
|
||||||
|
|
||||||
@ -134,18 +133,18 @@ void gareafile::ReadLoraBBS(char* tag) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_file = AddPath(_path, "sysmsg.dat");
|
_file = AddPath(_path, "sysmsg.dat");
|
||||||
fp.fopen(_file, "rb");
|
fp.Fopen(_file, "rb");
|
||||||
if (fp.isopen())
|
if (fp.isopen())
|
||||||
{
|
{
|
||||||
fp.setvbuf(NULL, _IOFBF, 8192);
|
fp.SetvBuf(NULL, _IOFBF, 8192);
|
||||||
|
|
||||||
if (not quiet)
|
if (not quiet)
|
||||||
STD_PRINTNL("* Reading " << _file);
|
STD_PRINTNL("* Reading " << _file);
|
||||||
|
|
||||||
_sysmsg* sysmsg = (_sysmsg*)throw_calloc(1, sizeof(_sysmsg));
|
_sysmsg* sysmsg = (_sysmsg*)throw_calloc(1, sizeof(_sysmsg));
|
||||||
|
|
||||||
while(fp.fread(sysmsg, sizeof(_sysmsg)) == 1) {
|
while (fp.Fread(sysmsg, sizeof(_sysmsg)) == 1)
|
||||||
|
{
|
||||||
if(sysmsg->passthrough)
|
if(sysmsg->passthrough)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -196,7 +195,7 @@ void gareafile::ReadLoraBBS(char* tag) {
|
|||||||
AddNewArea(aa);
|
AddNewArea(aa);
|
||||||
}
|
}
|
||||||
throw_free(sysmsg);
|
throw_free(sysmsg);
|
||||||
fp.fclose();
|
fp.Fclose();
|
||||||
}
|
}
|
||||||
throw_free(cfg);
|
throw_free(cfg);
|
||||||
}
|
}
|
||||||
|
@ -84,9 +84,8 @@ void gareafile::ReadPCBoard(char* tag) {
|
|||||||
|
|
||||||
CfgPcboardpath(_path);
|
CfgPcboardpath(_path);
|
||||||
|
|
||||||
gfile fp;
|
|
||||||
const char* _file = AddPath(_path, "pcboard.dat");
|
const char* _file = AddPath(_path, "pcboard.dat");
|
||||||
fp.fopen(_file, "rt");
|
gfile fp(_file, "rt");
|
||||||
if (fp.isopen())
|
if (fp.isopen())
|
||||||
{
|
{
|
||||||
if (not quiet)
|
if (not quiet)
|
||||||
@ -95,7 +94,8 @@ void gareafile::ReadPCBoard(char* tag) {
|
|||||||
int _line = 0;
|
int _line = 0;
|
||||||
|
|
||||||
char _buf[256];
|
char _buf[256];
|
||||||
while(fp.fgets(_buf, sizeof(_buf))) {
|
while (fp.Fgets(_buf, sizeof(_buf)))
|
||||||
|
{
|
||||||
_line++;
|
_line++;
|
||||||
switch(_line) {
|
switch(_line) {
|
||||||
case 28: // Location of User INDEX Files
|
case 28: // Location of User INDEX Files
|
||||||
@ -113,44 +113,45 @@ void gareafile::ReadPCBoard(char* tag) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fp.fclose();
|
fp.Fclose();
|
||||||
|
|
||||||
if(*_fidopath) {
|
if (*_fidopath)
|
||||||
|
{
|
||||||
const char* _file = AddPath(_fidopath, "pcbfido.cfg");
|
const char* _file = AddPath(_fidopath, "pcbfido.cfg");
|
||||||
fp.fopen(_file, "rb");
|
fp.Fopen(_file, "rb");
|
||||||
if (fp.isopen())
|
if (fp.isopen())
|
||||||
{
|
{
|
||||||
if (not quiet)
|
if (not quiet)
|
||||||
STD_PRINTNL("* Reading " << _file);
|
STD_PRINTNL("* Reading " << _file);
|
||||||
|
|
||||||
// Get configuration file version
|
// Get configuration file version
|
||||||
fp.fread(&fido_version, 2);
|
fp.Fread(&fido_version, 2);
|
||||||
|
|
||||||
if(fido_version == 2) {
|
if(fido_version == 2) {
|
||||||
|
|
||||||
word numrecs = 0;
|
word numrecs = 0;
|
||||||
|
|
||||||
// Get areas
|
// Get areas
|
||||||
fp.fread(&numrecs, 2);
|
fp.Fread(&numrecs, 2);
|
||||||
numareas = numrecs;
|
numareas = numrecs;
|
||||||
areap = (PcbFidoArea*)throw_calloc(1+numrecs, sizeof(PcbFidoArea));
|
areap = (PcbFidoArea*)throw_calloc(1+numrecs, sizeof(PcbFidoArea));
|
||||||
fp.fread(areap, sizeof(PcbFidoArea), numrecs);
|
fp.Fread(areap, sizeof(PcbFidoArea), numrecs);
|
||||||
|
|
||||||
// Skip archivers
|
// Skip archivers
|
||||||
fp.fseek(sizeof(PcbFidoArchivers), SEEK_CUR);
|
fp.Fseek(sizeof(PcbFidoArchivers), SEEK_CUR);
|
||||||
|
|
||||||
// Get directories
|
// Get directories
|
||||||
dirp = (PcbFidoDirectories*)throw_calloc(1, sizeof(PcbFidoDirectories));
|
dirp = (PcbFidoDirectories*)throw_calloc(1, sizeof(PcbFidoDirectories));
|
||||||
fp.fread(dirp, sizeof(PcbFidoDirectories));
|
fp.Fread(dirp, sizeof(PcbFidoDirectories));
|
||||||
|
|
||||||
// Skip EMSI profile
|
// Skip EMSI profile
|
||||||
fp.fseek(sizeof(PcbFidoEmsiData), SEEK_CUR);
|
fp.Fseek(sizeof(PcbFidoEmsiData), SEEK_CUR);
|
||||||
|
|
||||||
// Get akas
|
// Get akas
|
||||||
fp.fread(&numrecs, 2);
|
fp.Fread(&numrecs, 2);
|
||||||
akanumrecs = numrecs;
|
akanumrecs = numrecs;
|
||||||
akap = (PcbFidoAddress*)throw_calloc(1+numrecs, sizeof(PcbFidoAddress));
|
akap = (PcbFidoAddress*)throw_calloc(1+numrecs, sizeof(PcbFidoAddress));
|
||||||
fp.fread(akap, sizeof(PcbFidoAddress), numrecs);
|
fp.Fread(akap, sizeof(PcbFidoAddress), numrecs);
|
||||||
int akano = 0;
|
int akano = 0;
|
||||||
while(akano < numrecs) {
|
while(akano < numrecs) {
|
||||||
CfgAddress(akap[akano].nodestr);
|
CfgAddress(akap[akano].nodestr);
|
||||||
@ -160,41 +161,43 @@ void gareafile::ReadPCBoard(char* tag) {
|
|||||||
else if(fido_version == 3) {
|
else if(fido_version == 3) {
|
||||||
|
|
||||||
dir3 = (PcbDirectories*)throw_calloc(1, sizeof(PcbDirectories));
|
dir3 = (PcbDirectories*)throw_calloc(1, sizeof(PcbDirectories));
|
||||||
fp.fread(dir3, sizeof(PcbDirectories));
|
fp.Fread(dir3, sizeof(PcbDirectories));
|
||||||
fp.fclose();
|
fp.Fclose();
|
||||||
|
|
||||||
_file = AddPath(_fidopath, "areas.dat");
|
_file = AddPath(_fidopath, "areas.dat");
|
||||||
fp.fopen(_file, "rb");
|
fp.Fopen(_file, "rb");
|
||||||
if (fp.isopen())
|
if (fp.isopen())
|
||||||
{
|
{
|
||||||
if (not quiet)
|
if (not quiet)
|
||||||
STD_PRINTNL("* Reading " << _file);
|
STD_PRINTNL("* Reading " << _file);
|
||||||
|
|
||||||
word cfgver = 0;
|
word cfgver = 0;
|
||||||
fp.fread(&cfgver, 2);
|
fp.Fread(&cfgver, 2);
|
||||||
if(cfgver == 3) {
|
if (cfgver == 3)
|
||||||
word numrecs = (word)(fp.filelength() / sizeof(PcbAreasDat));
|
{
|
||||||
|
word numrecs = (word)(fp.FileLength() / sizeof(PcbAreasDat));
|
||||||
area3 = (PcbAreasDat*)throw_calloc(1+numrecs, sizeof(PcbAreasDat));
|
area3 = (PcbAreasDat*)throw_calloc(1+numrecs, sizeof(PcbAreasDat));
|
||||||
fp.fread(area3, sizeof(PcbAreasDat), numrecs);
|
fp.Fread(area3, sizeof(PcbAreasDat), numrecs);
|
||||||
numareas = numrecs;
|
numareas = numrecs;
|
||||||
}
|
}
|
||||||
fp.fclose();
|
fp.Fclose();
|
||||||
}
|
}
|
||||||
|
|
||||||
_file = AddPath(_fidopath, "akas.dat");
|
_file = AddPath(_fidopath, "akas.dat");
|
||||||
fp.fopen(_file, "rb");
|
fp.Fopen(_file, "rb");
|
||||||
if (fp.isopen())
|
if (fp.isopen())
|
||||||
{
|
{
|
||||||
if (not quiet)
|
if (not quiet)
|
||||||
STD_PRINTNL("* Reading " << _file);
|
STD_PRINTNL("* Reading " << _file);
|
||||||
|
|
||||||
word cfgver = 0;
|
word cfgver = 0;
|
||||||
fp.fread(&cfgver, 2);
|
fp.Fread(&cfgver, 2);
|
||||||
if(cfgver == 3) {
|
if (cfgver == 3)
|
||||||
word numrecs = (word)(fp.filelength() / sizeof(PcbAkasDat));
|
{
|
||||||
|
word numrecs = (word)(fp.FileLength() / sizeof(PcbAkasDat));
|
||||||
akanumrecs = numrecs;
|
akanumrecs = numrecs;
|
||||||
aka3 = (PcbAkasDat*)throw_calloc(1+numrecs, sizeof(PcbAkasDat));
|
aka3 = (PcbAkasDat*)throw_calloc(1+numrecs, sizeof(PcbAkasDat));
|
||||||
fp.fread(aka3, sizeof(PcbAkasDat), numrecs);
|
fp.Fread(aka3, sizeof(PcbAkasDat), numrecs);
|
||||||
int akano = 0;
|
int akano = 0;
|
||||||
while(akano < numrecs) {
|
while(akano < numrecs) {
|
||||||
char abuf[40];
|
char abuf[40];
|
||||||
@ -202,28 +205,29 @@ void gareafile::ReadPCBoard(char* tag) {
|
|||||||
akano++;
|
akano++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fp.fclose();
|
fp.Fclose();
|
||||||
}
|
}
|
||||||
|
|
||||||
_file = AddPath(_fidopath, "origins.dat");
|
_file = AddPath(_fidopath, "origins.dat");
|
||||||
fp.fopen(_file, "rb");
|
fp.Fopen(_file, "rb");
|
||||||
if (fp.isopen())
|
if (fp.isopen())
|
||||||
{
|
{
|
||||||
if (not quiet)
|
if (not quiet)
|
||||||
STD_PRINTNL("* Reading " << _file);
|
STD_PRINTNL("* Reading " << _file);
|
||||||
|
|
||||||
word cfgver = 0;
|
word cfgver = 0;
|
||||||
fp.fread(&cfgver, 2);
|
fp.Fread(&cfgver, 2);
|
||||||
if(cfgver == 3) {
|
if (cfgver == 3)
|
||||||
word numrecs = (word)(fp.filelength() / sizeof(PcbOriginsDat));
|
{
|
||||||
|
word numrecs = (word)(fp.FileLength() / sizeof(PcbOriginsDat));
|
||||||
origin3 = (PcbOriginsDat*)throw_calloc(1+numrecs, sizeof(PcbOriginsDat));
|
origin3 = (PcbOriginsDat*)throw_calloc(1+numrecs, sizeof(PcbOriginsDat));
|
||||||
fp.fread(origin3, sizeof(PcbOriginsDat), numrecs);
|
fp.Fread(origin3, sizeof(PcbOriginsDat), numrecs);
|
||||||
}
|
}
|
||||||
fp.fclose();
|
fp.Fclose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fp.fclose();
|
fp.Fclose();
|
||||||
}
|
}
|
||||||
|
|
||||||
Path netmailpath;
|
Path netmailpath;
|
||||||
@ -255,7 +259,7 @@ void gareafile::ReadPCBoard(char* tag) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_file = AddPath(_cnamespath, ".@@@");
|
_file = AddPath(_cnamespath, ".@@@");
|
||||||
fp.fopen(_file, "rb");
|
fp.Fopen(_file, "rb");
|
||||||
if (fp.isopen())
|
if (fp.isopen())
|
||||||
{
|
{
|
||||||
if (not quiet)
|
if (not quiet)
|
||||||
@ -263,21 +267,23 @@ void gareafile::ReadPCBoard(char* tag) {
|
|||||||
|
|
||||||
gfile fp2;
|
gfile fp2;
|
||||||
_file = AddPath(_cnamespath, ".add");
|
_file = AddPath(_cnamespath, ".add");
|
||||||
fp2.fopen(_file, "rb");
|
fp2.Fopen(_file, "rb");
|
||||||
if (fp2.isopen())
|
if (fp2.isopen())
|
||||||
{
|
{
|
||||||
if (not quiet)
|
if (not quiet)
|
||||||
STD_PRINTNL("* Reading " << _file);
|
STD_PRINTNL("* Reading " << _file);
|
||||||
|
|
||||||
word _recsize = 0;
|
word _recsize = 0;
|
||||||
fp.fread(&_recsize, 2);
|
fp.Fread(&_recsize, 2);
|
||||||
|
|
||||||
int confno = 0;
|
int confno = 0;
|
||||||
PcbConf* _cnames = (PcbConf*)throw_calloc(1, _recsize);
|
PcbConf* _cnames = (PcbConf*)throw_calloc(1, _recsize);
|
||||||
PcbAddConf* _cnamesadd = (PcbAddConf*)throw_calloc(1, sizeof(PcbAddConf));
|
PcbAddConf* _cnamesadd = (PcbAddConf*)throw_calloc(1, sizeof(PcbAddConf));
|
||||||
while(fp.fread(_cnames, _recsize) == 1) {
|
while (fp.Fread(_cnames, _recsize) == 1)
|
||||||
fp2.fread(_cnamesadd, sizeof(PcbAddConf));
|
{
|
||||||
if(*_cnames->name and *_cnames->msgfile) {
|
fp2.Fread(_cnamesadd, sizeof(PcbAddConf));
|
||||||
|
if (*_cnames->name and *_cnames->msgfile)
|
||||||
|
{
|
||||||
aa.reset();
|
aa.reset();
|
||||||
aa.basetype = "PCBOARD";
|
aa.basetype = "PCBOARD";
|
||||||
switch(_cnamesadd->conftype) {
|
switch(_cnamesadd->conftype) {
|
||||||
@ -351,10 +357,10 @@ void gareafile::ReadPCBoard(char* tag) {
|
|||||||
throw_free(_cnamesadd);
|
throw_free(_cnamesadd);
|
||||||
throw_free(_cnames);
|
throw_free(_cnames);
|
||||||
|
|
||||||
fp2.fclose();
|
fp2.Fclose();
|
||||||
}
|
}
|
||||||
|
|
||||||
fp.fclose();
|
fp.Fclose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,16 +80,16 @@ void PcbInit(const char* path, int userno) {
|
|||||||
*_cnamespath = NUL;
|
*_cnamespath = NUL;
|
||||||
|
|
||||||
// Open PCBOARD.DAT
|
// Open PCBOARD.DAT
|
||||||
gfile fp;
|
|
||||||
const char* _file = AddPath(_path, "PCBOARD.DAT");
|
const char* _file = AddPath(_path, "PCBOARD.DAT");
|
||||||
fp.fopen(_file, "rt", WideSharemode);
|
gfile fp(_file, "rt", WideSharemode);
|
||||||
if(fp.isopen()) {
|
if (fp.isopen())
|
||||||
|
{
|
||||||
// Get some paths/filenames
|
// Get some paths/filenames
|
||||||
int _line = 0;
|
int _line = 0;
|
||||||
char _buf[256];
|
char _buf[256];
|
||||||
fp.setvbuf(NULL, _IOFBF, 8192);
|
fp.SetvBuf(NULL, _IOFBF, 8192);
|
||||||
while(fp.fgets(_buf, sizeof(_buf))) {
|
while (fp.Fgets(_buf, sizeof(_buf)))
|
||||||
|
{
|
||||||
_line++;
|
_line++;
|
||||||
if(_line == 28)
|
if(_line == 28)
|
||||||
strxcpy(pcbwide->usersidxpath, strbtrim(_buf), sizeof(Path));
|
strxcpy(pcbwide->usersidxpath, strbtrim(_buf), sizeof(Path));
|
||||||
@ -102,32 +102,34 @@ void PcbInit(const char* path, int userno) {
|
|||||||
else if(_line == 208)
|
else if(_line == 208)
|
||||||
pcbwide->foreign = atoi(_buf);
|
pcbwide->foreign = atoi(_buf);
|
||||||
}
|
}
|
||||||
fp.fclose();
|
fp.Fclose();
|
||||||
|
|
||||||
// Open CNAMES.@@@
|
// Open CNAMES.@@@
|
||||||
_file = AddPath(_cnamespath, ".@@@");
|
_file = AddPath(_cnamespath, ".@@@");
|
||||||
fp.fopen(_file, "rb", WideSharemode);
|
fp.Fopen(_file, "rb", WideSharemode);
|
||||||
|
|
||||||
// Get board numbers for lastread indexing in the userfiles
|
// Get board numbers for lastread indexing in the userfiles
|
||||||
word _recsize = 0;
|
word _recsize = 0;
|
||||||
fp.setvbuf(NULL, _IOFBF, 8192);
|
fp.SetvBuf(NULL, _IOFBF, 8192);
|
||||||
fp.fread(&_recsize, 2);
|
fp.Fread(&_recsize, 2);
|
||||||
if(_recsize) {
|
if (_recsize)
|
||||||
|
{
|
||||||
PcbConf* _cnames = (PcbConf*)throw_calloc(1, _recsize);
|
PcbConf* _cnames = (PcbConf*)throw_calloc(1, _recsize);
|
||||||
int _rec = 0;
|
int _rec = 0;
|
||||||
pcbwide->numareas = (int)((fp.filelength()-2)/_recsize);
|
pcbwide->numareas = (int)((fp.FileLength()-2)/_recsize);
|
||||||
pcbwide->confbytelen = (pcbwide->numareas/8) + ((pcbwide->numareas%8) != 0 ? 1 : 0);
|
pcbwide->confbytelen = (pcbwide->numareas/8) + ((pcbwide->numareas%8) != 0 ? 1 : 0);
|
||||||
if(pcbwide->confbytelen < 5)
|
if(pcbwide->confbytelen < 5)
|
||||||
pcbwide->confbytelen = 5;
|
pcbwide->confbytelen = 5;
|
||||||
pcbwide->extconflen = pcbwide->confbytelen - 5;
|
pcbwide->extconflen = pcbwide->confbytelen - 5;
|
||||||
pcbwide->lastread = (int32_t*)throw_calloc(pcbwide->numareas, sizeof(int32_t));
|
pcbwide->lastread = (int32_t*)throw_calloc(pcbwide->numareas, sizeof(int32_t));
|
||||||
while(fp.fread(_cnames, _recsize) == 1) {
|
while (fp.Fread(_cnames, _recsize) == 1)
|
||||||
|
{
|
||||||
PcbAdjustArea((uint)_rec, _cnames->msgfile);
|
PcbAdjustArea((uint)_rec, _cnames->msgfile);
|
||||||
_rec++;
|
_rec++;
|
||||||
}
|
}
|
||||||
throw_free(_cnames);
|
throw_free(_cnames);
|
||||||
}
|
}
|
||||||
fp.fclose();
|
fp.Fclose();
|
||||||
|
|
||||||
const char* _username = WideUsername[0];
|
const char* _username = WideUsername[0];
|
||||||
pcbwide->user->fh = ::sopen(AddPath(_path, pcbwide->users), O_RDONLY|O_BINARY, WideSharemode, S_STDRD);
|
pcbwide->user->fh = ::sopen(AddPath(_path, pcbwide->users), O_RDONLY|O_BINARY, WideSharemode, S_STDRD);
|
||||||
|
Reference in New Issue
Block a user