Refactoring!
This commit is contained in:
@@ -318,9 +318,8 @@ int EchoListClass::GetEcho(int n, char** echoid, char** path, char** desc) {
|
||||
// ------------------------------------------------------------------
|
||||
// Read AREAS.BBS (any flavor!) and store echoid, path and desc.
|
||||
|
||||
void gareafile::GetAreasBBS(char* name, char* origin, char* options) {
|
||||
|
||||
FILE* fp;
|
||||
void gareafile::GetAreasBBS(char* name, char* origin, char* options)
|
||||
{
|
||||
char buf[256];
|
||||
Path areafile;
|
||||
char* ptr;
|
||||
@@ -332,17 +331,18 @@ void gareafile::GetAreasBBS(char* name, char* origin, char* options) {
|
||||
strcpy(areafile, name);
|
||||
MakePathname(areafile, areapath, areafile);
|
||||
|
||||
fp = fsopen(areafile, "rt", sharemode);
|
||||
if (fp)
|
||||
gfile fp(areafile, "rt", sharemode);
|
||||
if (fp.isopen())
|
||||
{
|
||||
setvbuf(fp, NULL, _IOFBF, 8192);
|
||||
fp.SetvBuf(NULL, _IOFBF, 8192);
|
||||
|
||||
if (not quiet)
|
||||
STD_PRINTNL("* Reading " << areafile);
|
||||
|
||||
bool firstline = true;
|
||||
|
||||
while(fgets(buf, 255, fp)) {
|
||||
while (fp.Fgets(buf, 255))
|
||||
{
|
||||
ptr = strskip_wht(buf);
|
||||
if(*ptr != ';' and *ptr != '%' and *ptr != '-' and *ptr != '#' and *ptr != '@' and strnicmp(ptr, "P ", 2) and strnicmp(ptr, "PASSTHRU", 8) and *ptr) {
|
||||
|
||||
@@ -383,7 +383,6 @@ void gareafile::GetAreasBBS(char* name, char* origin, char* options) {
|
||||
}
|
||||
}
|
||||
}
|
||||
fclose(fp);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -33,28 +33,11 @@
|
||||
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <gftnall.h>
|
||||
#include <gfilutil.h>
|
||||
#include <string>
|
||||
#include <gftnall.h>
|
||||
#include <gfile.h>
|
||||
#include <gmsgattr.h>
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
const int MAX_DESC = 81; // Area descriptions
|
||||
const int MAX_ECHO = 81; // Echoids
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Echoid typedefs
|
||||
|
||||
typedef char Echo[MAX_ECHO];
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Description typedefs
|
||||
|
||||
typedef char Desc[MAX_DESC];
|
||||
#include <geall.h>
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
@@ -221,8 +204,8 @@ protected:
|
||||
void ReadDB2011(char* file, int reclen, char* tag);
|
||||
#endif
|
||||
#ifndef GCFG_NOEZY
|
||||
void ReadEzycom102(FILE* fp, char* path, char* file, char* options);
|
||||
void ReadEzycom110(FILE* fp, char* path, char* file, char* options);
|
||||
void ReadEzycom102(gfile &fp, char* path, char* file, char* options);
|
||||
void ReadEzycom110(gfile &fp, char* path, char* file, char* options);
|
||||
#endif
|
||||
#ifndef GCFG_NOFE
|
||||
void ReadFastecho11x(int fh);
|
||||
@@ -230,13 +213,13 @@ protected:
|
||||
void ReadFastecho142(int fh);
|
||||
#endif
|
||||
#ifndef GCFG_NOFMAIL
|
||||
void ReadFMail092(FILE* fp, char* path, char* file, char* options);
|
||||
void ReadFMail098(FILE* fp, char* path, char* file, char* options);
|
||||
void ReadFMail116(FILE* fp, char* path, char* file, char* options);
|
||||
void ReadFMail092(gfile &fp, char* path, char* file, char* options);
|
||||
void ReadFMail098(gfile &fp, char* path, char* file, char* options);
|
||||
void ReadFMail116(gfile &fp, char* path, char* file, char* options);
|
||||
#endif
|
||||
#ifndef GCFG_NOFIDOCONF
|
||||
AreaCfg echoareadefaults;
|
||||
bool ReadHPTLine(FILE* f, std::string* s, bool add=false, int state=0);
|
||||
bool ReadHPTLine(gfile &f, std::string* s, bool add=false, int state=0);
|
||||
void ReadHPTFile(char* path, char* file, char* origin, int group);
|
||||
#endif
|
||||
#ifndef GCFG_NOIMAIL
|
||||
@@ -270,7 +253,7 @@ protected:
|
||||
void ReadTmailFile(char* file, char* options, char* origin);
|
||||
#endif
|
||||
#ifndef GCFG_NOWATERGATE
|
||||
void ReadWtrGteFile(char* options, FILE* fp);
|
||||
void ReadWtrGteFile(char* options, gfile &fp);
|
||||
#endif
|
||||
#ifndef GCFG_NOXBBS
|
||||
void ReadAdeptXbbsFile(char* path, char* file, char* options);
|
||||
|
@@ -77,12 +77,12 @@ bool gareafile::jbstrcpy(char *dest, char *src, size_t maxlen, size_t *jbc) {
|
||||
// ------------------------------------------------------------------
|
||||
// Read areas from Crashmail II/CrashEcho (echomail processor)
|
||||
|
||||
void gareafile::ReadCrashmailCfg(const char* file) {
|
||||
|
||||
FILE* fp = fsopen(file, "rt", sharemode);
|
||||
if (fp)
|
||||
void gareafile::ReadCrashmailCfg(const char* file)
|
||||
{
|
||||
gfile fp(file, "rt", sharemode);
|
||||
if (fp.isopen())
|
||||
{
|
||||
setvbuf(fp, NULL, _IOFBF, 8192);
|
||||
fp.SetvBuf(NULL, _IOFBF, 8192);
|
||||
|
||||
if (not quiet)
|
||||
STD_PRINTNL("* Reading " << file);
|
||||
@@ -121,7 +121,8 @@ void gareafile::ReadCrashmailCfg(const char* file) {
|
||||
|
||||
word crc16;
|
||||
|
||||
while(fgets(buf, 4000, fp) != NULL) {
|
||||
while (fp.Fgets(buf, 4000))
|
||||
{
|
||||
jbcpos=0;
|
||||
jbstrcpy(key, buf, 30, &jbcpos);
|
||||
switch(crc16 = strCrc16(key)) {
|
||||
@@ -240,7 +241,6 @@ void gareafile::ReadCrashmailCfg(const char* file) {
|
||||
strxmerge(tmp, 100, address, "@", domain, NULL);
|
||||
CfgAddress(tmp);
|
||||
}
|
||||
fclose(fp);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -39,38 +39,38 @@
|
||||
// ------------------------------------------------------------------
|
||||
// Read D'Bridge 1.30
|
||||
|
||||
void gareafile::ReadDB130(char* tag, char* dbpath) {
|
||||
|
||||
void gareafile::ReadDB130(char* /*tag*/, char* dbpath)
|
||||
{
|
||||
AreaCfg aa;
|
||||
DB130_AA1 AA1;
|
||||
DB130_AA2 AA2;
|
||||
FILE *fp1, *fp2;
|
||||
Path file1, file2;
|
||||
|
||||
MakePathname(file1, dbpath, "dbridge.aa1");
|
||||
MakePathname(file2, dbpath, "dbridge.aa2");
|
||||
|
||||
fp1 = fsopen(file1, "rb", sharemode);
|
||||
if (fp1)
|
||||
gfile fp1(file1, "rb", sharemode);
|
||||
if (fp1.isopen())
|
||||
{
|
||||
setvbuf(fp1, NULL, _IOFBF, 8192);
|
||||
fp1.SetvBuf(NULL, _IOFBF, 8192);
|
||||
|
||||
if (not quiet)
|
||||
STD_PRINTNL("* Reading " << file1);
|
||||
|
||||
fp2 = fsopen(file2, "rb", sharemode);
|
||||
if (fp2)
|
||||
gfile fp2(file2, "rb", sharemode);
|
||||
if (fp2.isopen())
|
||||
{
|
||||
setvbuf(fp2, NULL, _IOFBF, 8192);
|
||||
fp2.SetvBuf(NULL, _IOFBF, 8192);
|
||||
|
||||
if (not quiet)
|
||||
STD_PRINTNL("* Reading " << file2);
|
||||
|
||||
while(fread(&AA1, sizeof(DB130_AA1), 1, fp1) == 1) {
|
||||
while (fp1.Fread(&AA1, sizeof(DB130_AA1)))
|
||||
{
|
||||
fp2.Fread(&AA2, sizeof(DB130_AA2));
|
||||
|
||||
fread(&AA2, sizeof(DB130_AA2), 1, fp2);
|
||||
|
||||
if(AA1.allocated and strchr("QFqf", AA2.msgbase)) {
|
||||
if (AA1.allocated and strchr("QFqf", AA2.msgbase))
|
||||
{
|
||||
aa.reset();
|
||||
switch(g_toupper(AA2.msgbase)) {
|
||||
case 'Q':
|
||||
@@ -105,11 +105,7 @@ void gareafile::ReadDB130(char* tag, char* dbpath) {
|
||||
AddNewArea(aa);
|
||||
}
|
||||
}
|
||||
|
||||
fclose(fp2);
|
||||
}
|
||||
|
||||
fclose(fp1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,20 +113,21 @@ void gareafile::ReadDB130(char* tag, char* dbpath) {
|
||||
// ------------------------------------------------------------------
|
||||
// Read D'Bridge B1046
|
||||
|
||||
void gareafile::ReadDB1046(char* file, char* tag) {
|
||||
|
||||
void gareafile::ReadDB1046(char* file, char* /*tag*/)
|
||||
{
|
||||
AreaCfg aa;
|
||||
DB1046_ADF* ADF = (DB1046_ADF*)throw_calloc(1, sizeof(DB1046_ADF));
|
||||
|
||||
FILE* fp = fsopen(file, "rb", sharemode);
|
||||
if (fp)
|
||||
gfile fp(file, "rb", sharemode);
|
||||
if (fp.isopen())
|
||||
{
|
||||
setvbuf(fp, NULL, _IOFBF, 8192);
|
||||
fp.SetvBuf(NULL, _IOFBF, 8192);
|
||||
|
||||
if (not quiet)
|
||||
STD_PRINTNL("* Reading " << file);
|
||||
|
||||
while(fread(ADF, sizeof(DB1046_ADF), 1, fp) == 1) {
|
||||
while (fp.Fread(ADF, sizeof(DB1046_ADF)))
|
||||
{
|
||||
if(ADF->allocated and strchr("QFqf", ADF->msgbase)) {
|
||||
aa.reset();
|
||||
switch(g_toupper(ADF->msgbase)) {
|
||||
@@ -166,8 +163,6 @@ void gareafile::ReadDB1046(char* file, char* tag) {
|
||||
AddNewArea(aa);
|
||||
}
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
throw_free(ADF);
|
||||
@@ -177,25 +172,25 @@ void gareafile::ReadDB1046(char* file, char* tag) {
|
||||
// ------------------------------------------------------------------
|
||||
// Read D'Bridge B1047.A22 and B1047.A27+
|
||||
|
||||
void gareafile::ReadDB1047A22(char* file, int reclen, char* tag) {
|
||||
|
||||
void gareafile::ReadDB1047A22(char* file, int reclen, char* /*tag*/)
|
||||
{
|
||||
AreaCfg aa;
|
||||
FILE* fp;
|
||||
DB1047A22_ADF* ADF;
|
||||
DB1047A22_ADF* ADF = (DB1047A22_ADF *)throw_malloc(reclen);
|
||||
|
||||
ADF = (DB1047A22_ADF *)throw_malloc(reclen);
|
||||
if(ADF) {
|
||||
|
||||
fp = fsopen(file, "rb", sharemode);
|
||||
if (fp)
|
||||
if (ADF)
|
||||
{
|
||||
gfile fp(file, "rb", sharemode);
|
||||
if (fp.isopen())
|
||||
{
|
||||
setvbuf(fp, NULL, _IOFBF, 8192);
|
||||
fp.SetvBuf(NULL, _IOFBF, 8192);
|
||||
|
||||
if (not quiet)
|
||||
STD_PRINTNL("* Reading " << file);
|
||||
|
||||
while(fread(ADF, reclen, 1, fp) == 1) {
|
||||
if(ADF->allocated and strchr("QFqf", ADF->msgbase)) {
|
||||
while (fp.Fread(ADF, reclen))
|
||||
{
|
||||
if (ADF->allocated and strchr("QFqf", ADF->msgbase))
|
||||
{
|
||||
aa.reset();
|
||||
switch(g_toupper(ADF->msgbase)) {
|
||||
case 'Q':
|
||||
@@ -230,8 +225,6 @@ void gareafile::ReadDB1047A22(char* file, int reclen, char* tag) {
|
||||
AddNewArea(aa);
|
||||
}
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
throw_free(ADF);
|
||||
@@ -242,25 +235,25 @@ void gareafile::ReadDB1047A22(char* file, int reclen, char* tag) {
|
||||
// ------------------------------------------------------------------
|
||||
// Read D'Bridge B2011
|
||||
|
||||
void gareafile::ReadDB2011(char* file, int reclen, char* tag) {
|
||||
|
||||
void gareafile::ReadDB2011(char* file, int reclen, char* /*tag*/)
|
||||
{
|
||||
AreaCfg aa;
|
||||
FILE* fp;
|
||||
DB2011_ADF* ADF;
|
||||
DB2011_ADF* ADF = (DB2011_ADF *)throw_malloc(reclen);
|
||||
|
||||
ADF = (DB2011_ADF *)throw_malloc(reclen);
|
||||
if(ADF) {
|
||||
|
||||
fp = fsopen(file, "rb", sharemode);
|
||||
if (fp)
|
||||
if (ADF)
|
||||
{
|
||||
gfile fp(file, "rb", sharemode);
|
||||
if (fp.isopen())
|
||||
{
|
||||
setvbuf(fp, NULL, _IOFBF, 8192);
|
||||
fp.SetvBuf(NULL, _IOFBF, 8192);
|
||||
|
||||
if (not quiet)
|
||||
STD_PRINTNL("* Reading " << file);
|
||||
|
||||
while(fread(ADF, reclen, 1, fp) == 1) {
|
||||
if(ADF->allocated and strchr("QFqf", ADF->msgbase)) {
|
||||
while (fp.Fread(ADF, reclen))
|
||||
{
|
||||
if (ADF->allocated and strchr("QFqf", ADF->msgbase))
|
||||
{
|
||||
aa.reset();
|
||||
switch(g_toupper(ADF->msgbase)) {
|
||||
case 'Q':
|
||||
@@ -297,8 +290,6 @@ void gareafile::ReadDB2011(char* file, int reclen, char* tag) {
|
||||
AddNewArea(aa);
|
||||
}
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
throw_free(ADF);
|
||||
@@ -309,10 +300,9 @@ void gareafile::ReadDB2011(char* file, int reclen, char* tag) {
|
||||
// ------------------------------------------------------------------
|
||||
// Read D'Bridge areas, various versions...
|
||||
|
||||
void gareafile::ReadDBridge(char* tag) {
|
||||
|
||||
void gareafile::ReadDBridge(char* tag)
|
||||
{
|
||||
AreaCfg aa;
|
||||
FILE* fp;
|
||||
char* ptr;
|
||||
int line;
|
||||
char buf[256], type, options[80];
|
||||
@@ -341,50 +331,50 @@ void gareafile::ReadDBridge(char* tag) {
|
||||
|
||||
MakePathname(file, dbpath, "dbridge.prm");
|
||||
|
||||
fp = fsopen(file, "rt", sharemode);
|
||||
if (fp)
|
||||
gfile fp(file, "rt", sharemode);
|
||||
if (fp.isopen())
|
||||
{
|
||||
if (not quiet)
|
||||
STD_PRINTNL("* Reading " << file);
|
||||
|
||||
// Read netmail storage method etc
|
||||
for(line=1; line <= 2; line++)
|
||||
fgets(buf, 255, fp);
|
||||
for (line = 1; line <= 2; line++)
|
||||
fp.Fgets(buf, 255);
|
||||
type = (char)g_toupper(*buf);
|
||||
|
||||
// Fido-style netmail path
|
||||
line++;
|
||||
fgets(buf, 255, fp);
|
||||
fp.Fgets(buf, 255);
|
||||
strtrim(buf);
|
||||
strcpy(netpath, buf);
|
||||
|
||||
// BADECHO area
|
||||
for(; line <= 8; line++)
|
||||
fgets(buf, 255, fp);
|
||||
fp.Fgets(buf, 255);
|
||||
strtrim(buf);
|
||||
strcpy(badecho, buf);
|
||||
|
||||
// Hudson path
|
||||
for(; line <= 11; line++)
|
||||
fgets(buf, 255, fp);
|
||||
fp.Fgets(buf, 255);
|
||||
strtrim(buf);
|
||||
CfgHudsonpath(buf);
|
||||
|
||||
// Primary address
|
||||
for(; line <= 15; line++)
|
||||
fgets(buf, 255, fp);
|
||||
fp.Fgets(buf, 255);
|
||||
strtrim(buf);
|
||||
CfgAddress(buf);
|
||||
|
||||
// Username
|
||||
for(; line <= 17; line++)
|
||||
fgets(buf, 255, fp);
|
||||
fp.Fgets(buf, 255);
|
||||
strtrim(buf);
|
||||
//CfgUsername(buf);
|
||||
|
||||
// Hudson netmail board
|
||||
for(; line <= 20; line++) // NOTE: was 17 in older versions
|
||||
fgets(buf, 255, fp);
|
||||
fp.Fgets(buf, 255);
|
||||
|
||||
// Address/misc field
|
||||
if(type == 'F' or type == 'Q') {
|
||||
@@ -417,7 +407,7 @@ void gareafile::ReadDBridge(char* tag) {
|
||||
AddNewArea(aa);
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
fp.Fclose();
|
||||
}
|
||||
|
||||
// Read the areafile from the correct version
|
||||
|
@@ -37,10 +37,9 @@
|
||||
// ------------------------------------------------------------------
|
||||
// Read Dutchie DUTCHIE.ARE
|
||||
|
||||
void gareafile::ReadDutchie(char* tag) {
|
||||
|
||||
void gareafile::ReadDutchie(char* tag)
|
||||
{
|
||||
AreaCfg aa;
|
||||
FILE* fp;
|
||||
char* ptr;
|
||||
char* ptr2;
|
||||
Path dupath, file;
|
||||
@@ -66,16 +65,16 @@ void gareafile::ReadDutchie(char* tag) {
|
||||
|
||||
MakePathname(file, dupath, "dutchie.are");
|
||||
|
||||
fp = fsopen(file, "rb", sharemode);
|
||||
if (fp)
|
||||
gfile fp(file, "rb", sharemode);
|
||||
if (fp.isopen())
|
||||
{
|
||||
setvbuf(fp, NULL, _IOFBF, 8192);
|
||||
fp.SetvBuf(NULL, _IOFBF, 8192);
|
||||
|
||||
if (not quiet)
|
||||
STD_PRINTNL("* Reading " << file);
|
||||
|
||||
while(fgets(buf, 255, fp)) {
|
||||
|
||||
while (fp.Fgets(buf, 255))
|
||||
{
|
||||
ptr = strbtrim(buf);
|
||||
if(*ptr != ';' and *ptr != '-' and strnicmp(ptr, "PASSTHRU", 8) and *ptr != '\x1A' and *ptr) {
|
||||
|
||||
@@ -96,8 +95,6 @@ void gareafile::ReadDutchie(char* tag) {
|
||||
AddNewArea(aa);
|
||||
}
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -37,8 +37,8 @@
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
void gareafile::ReadEzycom102(FILE* fp, char* path, char* file, char* options) {
|
||||
|
||||
void gareafile::ReadEzycom102(gfile &fp, char* path, char* file, char* options)
|
||||
{
|
||||
int n;
|
||||
AreaCfg aa;
|
||||
char abuf[40];
|
||||
@@ -47,18 +47,18 @@ void gareafile::ReadEzycom102(FILE* fp, char* path, char* file, char* options) {
|
||||
CONSTANTRECORD* constant = new CONSTANTRECORD; throw_new(constant);
|
||||
MESSAGERECORD* messages = new MESSAGERECORD; throw_new(messages);
|
||||
|
||||
fread(config, sizeof(CONFIGRECORD), 1, fp);
|
||||
fclose(fp);
|
||||
fp.Fread(config, sizeof(CONFIGRECORD));
|
||||
fp.Fclose();
|
||||
|
||||
MakePathname(file, path, "constant.ezy");
|
||||
fp = fsopen(file, "rb", sharemode);
|
||||
if (fp)
|
||||
fp.Fopen(file, "rb", sharemode);
|
||||
if (fp.isopen())
|
||||
{
|
||||
if (not quiet)
|
||||
STD_PRINTNL("* Reading " << file);
|
||||
|
||||
fread(constant, sizeof(CONSTANTRECORD), 1, fp);
|
||||
fclose(fp);
|
||||
fp.Fread(constant, sizeof(CONSTANTRECORD));
|
||||
fp.Fclose();
|
||||
|
||||
STRNP2C(config->defaultorigin);
|
||||
STRNP2C(config->userbasepath);
|
||||
@@ -192,16 +192,16 @@ void gareafile::ReadEzycom102(FILE* fp, char* path, char* file, char* options) {
|
||||
}
|
||||
|
||||
MakePathname(file, path, "messages.ezy");
|
||||
fp = fsopen(file, "rb", sharemode);
|
||||
if (fp)
|
||||
fp.Fopen(file, "rb", sharemode);
|
||||
if (fp.isopen())
|
||||
{
|
||||
if (not quiet)
|
||||
STD_PRINTNL("* Reading " << file);
|
||||
|
||||
int record = 1;
|
||||
|
||||
while(fread(messages, sizeof(MESSAGERECORD), 1, fp) == 1) {
|
||||
|
||||
while (fp.Fread(messages, sizeof(MESSAGERECORD)))
|
||||
{
|
||||
if(record <= constant->maxmess) {
|
||||
|
||||
if(*messages->name) {
|
||||
@@ -266,7 +266,8 @@ void gareafile::ReadEzycom102(FILE* fp, char* path, char* file, char* options) {
|
||||
|
||||
record++;
|
||||
}
|
||||
fclose(fp);
|
||||
|
||||
fp.Fclose();
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -38,8 +38,8 @@
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
void gareafile::ReadEzycom110(FILE* fp, char* path, char* file, char* options) {
|
||||
|
||||
void gareafile::ReadEzycom110(gfile &fp, char* path, char* file, char* options)
|
||||
{
|
||||
int n;
|
||||
AreaCfg aa;
|
||||
char abuf[40];
|
||||
@@ -48,18 +48,18 @@ void gareafile::ReadEzycom110(FILE* fp, char* path, char* file, char* options) {
|
||||
CONSTANTRECORD* constant = new CONSTANTRECORD; throw_new(constant);
|
||||
MESSAGERECORD* messages = new MESSAGERECORD; throw_new(messages);
|
||||
|
||||
fread(config, sizeof(CONFIGRECORD), 1, fp);
|
||||
fclose(fp);
|
||||
fp.Fread(config, sizeof(CONFIGRECORD));
|
||||
fp.Fclose();
|
||||
|
||||
MakePathname(file, path, "constant.ezy");
|
||||
fp = fsopen(file, "rb", sharemode);
|
||||
if (fp)
|
||||
fp.Fopen(file, "rb", sharemode);
|
||||
if (fp.isopen())
|
||||
{
|
||||
if (not quiet)
|
||||
STD_PRINTNL("* Reading " << file);
|
||||
|
||||
fread(constant, sizeof(CONSTANTRECORD), 1, fp);
|
||||
fclose(fp);
|
||||
fp.Fread(constant, sizeof(CONSTANTRECORD));
|
||||
fp.Fclose();
|
||||
|
||||
STRNP2C(config->defaultorigin);
|
||||
STRNP2C(config->userbasepath);
|
||||
@@ -193,22 +193,22 @@ void gareafile::ReadEzycom110(FILE* fp, char* path, char* file, char* options) {
|
||||
}
|
||||
|
||||
MakePathname(file, path, "MESSAGES.EZY");
|
||||
fp = fsopen(file, "rb", sharemode);
|
||||
if (fp)
|
||||
fp.Fopen(file, "rb", sharemode);
|
||||
if (fp.isopen())
|
||||
{
|
||||
if (not quiet)
|
||||
STD_PRINTNL("* Reading " << file);
|
||||
|
||||
int record = 1;
|
||||
|
||||
while(fread(messages, sizeof(MESSAGERECORD), 1, fp) == 1) {
|
||||
|
||||
if(record <= constant->maxmess) {
|
||||
|
||||
if(*messages->name) {
|
||||
|
||||
switch(messages->typ) {
|
||||
|
||||
while (fp.Fread(messages, sizeof(MESSAGERECORD)))
|
||||
{
|
||||
if (record <= constant->maxmess)
|
||||
{
|
||||
if (*messages->name)
|
||||
{
|
||||
switch (messages->typ)
|
||||
{
|
||||
case 0: // localmail
|
||||
case 1: // netmail
|
||||
case 2: // echomail
|
||||
@@ -266,7 +266,8 @@ void gareafile::ReadEzycom110(FILE* fp, char* path, char* file, char* options) {
|
||||
|
||||
record++;
|
||||
}
|
||||
fclose(fp);
|
||||
|
||||
fp.Fclose();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -278,9 +279,8 @@ void gareafile::ReadEzycom110(FILE* fp, char* path, char* file, char* options) {
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
void gareafile::ReadEzycom(char* tag) {
|
||||
|
||||
FILE* fp;
|
||||
void gareafile::ReadEzycom(char* tag)
|
||||
{
|
||||
char* ptr;
|
||||
Path path, file;
|
||||
char options[80], abuf[40];
|
||||
@@ -311,15 +311,16 @@ void gareafile::ReadEzycom(char* tag) {
|
||||
}
|
||||
if(not fexist(file))
|
||||
MakePathname(file, path, "config.ezy");
|
||||
fp = fsopen(file, "rb", sharemode);
|
||||
if (fp)
|
||||
|
||||
gfile fp(file, "rb", sharemode);
|
||||
if (fp.isopen())
|
||||
{
|
||||
if (not quiet)
|
||||
STD_PRINTNL("* Reading " << file);
|
||||
|
||||
char _verstr[9];
|
||||
fread(_verstr, 9, 1, fp);
|
||||
rewind(fp);
|
||||
fp.Fread(_verstr, 9);
|
||||
fp.Rewind();
|
||||
|
||||
strp2c(_verstr);
|
||||
|
||||
|
@@ -33,14 +33,14 @@
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
void gareafile::ReadFMail092(FILE* fp, char* path, char* file, char* options) {
|
||||
|
||||
void gareafile::ReadFMail092(gfile &fp, char* path, char* file, char* options)
|
||||
{
|
||||
AreaCfg aa;
|
||||
|
||||
configType* cfg = new configType; throw_new(cfg);
|
||||
|
||||
fread(cfg, sizeof(configType), 1, fp);
|
||||
fclose(fp);
|
||||
fp.Fread(cfg, sizeof(configType));
|
||||
fp.Fclose();
|
||||
|
||||
// Get Hudson msgbase path
|
||||
CfgHudsonpath(cfg->bbsPath);
|
||||
@@ -159,11 +159,11 @@ void gareafile::ReadFMail092(FILE* fp, char* path, char* file, char* options) {
|
||||
|
||||
MakePathname(file, path, "fmail.ar");
|
||||
|
||||
fp = fsopen(file, "rb", sharemode);
|
||||
if(fp) {
|
||||
|
||||
while(fread(ar, sizeof(rawEchoType), 1, fp) == 1) {
|
||||
|
||||
fp.Fopen(file, "rb", sharemode);
|
||||
if (fp.isopen())
|
||||
{
|
||||
while (fp.Fread(ar, sizeof(rawEchoType)))
|
||||
{
|
||||
if(ar->options.active and ar->board and ar->board < 201) {
|
||||
|
||||
aa.reset();
|
||||
@@ -197,7 +197,7 @@ void gareafile::ReadFMail092(FILE* fp, char* path, char* file, char* options) {
|
||||
}
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
fp.Fclose();
|
||||
}
|
||||
|
||||
throw_delete(ar);
|
||||
|
@@ -34,14 +34,14 @@
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
void gareafile::ReadFMail098(FILE* fp, char* path, char* file, char* options) {
|
||||
|
||||
void gareafile::ReadFMail098(gfile &fp, char* path, char* file, char* options)
|
||||
{
|
||||
AreaCfg aa;
|
||||
|
||||
configType* cfg = new configType; throw_new(cfg);
|
||||
|
||||
fread(cfg, sizeof(configType), 1, fp);
|
||||
fclose(fp);
|
||||
fp.Fread(cfg, sizeof(configType));
|
||||
fp.Fclose();
|
||||
|
||||
// Get Hudson msgbase path
|
||||
CfgHudsonpath(cfg->bbsPath);
|
||||
@@ -161,18 +161,17 @@ void gareafile::ReadFMail098(FILE* fp, char* path, char* file, char* options) {
|
||||
|
||||
MakePathname(file, path, "fmail.ar");
|
||||
|
||||
fp = fsopen(file, "rb", sharemode);
|
||||
if(fp) {
|
||||
|
||||
|
||||
fread(&hdr, sizeof(headerType), 1, fp);
|
||||
fseek(fp, hdr.headerSize, SEEK_SET);
|
||||
fp.Fopen(file, "rb", sharemode);
|
||||
if (fp.isopen())
|
||||
{
|
||||
fp.Fread(&hdr, sizeof(headerType));
|
||||
fp.FseekSet(hdr.headerSize);
|
||||
|
||||
ar = (rawEchoType*)throw_calloc(1, hdr.recordSize);
|
||||
if(ar) {
|
||||
|
||||
while(fread(ar, hdr.recordSize, 1, fp) == 1) {
|
||||
|
||||
if (ar)
|
||||
{
|
||||
while (fp.Fread(ar, hdr.recordSize))
|
||||
{
|
||||
if(ar->options.active) {
|
||||
|
||||
aa.reset();
|
||||
@@ -226,7 +225,7 @@ void gareafile::ReadFMail098(FILE* fp, char* path, char* file, char* options) {
|
||||
|
||||
throw_free(ar);
|
||||
|
||||
fclose(fp);
|
||||
fp.Fclose();
|
||||
}
|
||||
|
||||
throw_delete(cfg);
|
||||
|
@@ -38,14 +38,14 @@
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
void gareafile::ReadFMail116(FILE* fp, char* path, char* file, char* options) {
|
||||
|
||||
void gareafile::ReadFMail116(gfile &fp, char* path, char* file, char* options)
|
||||
{
|
||||
AreaCfg aa;
|
||||
|
||||
configType* cfg = new configType; throw_new(cfg);
|
||||
|
||||
fread(cfg, sizeof(configType), 1, fp);
|
||||
fclose(fp);
|
||||
fp.Fread(cfg, sizeof(configType));
|
||||
fp.Fclose();
|
||||
|
||||
// Get Hudson msgbase path
|
||||
CfgHudsonpath(cfg->bbsPath);
|
||||
@@ -165,22 +165,21 @@ void gareafile::ReadFMail116(FILE* fp, char* path, char* file, char* options) {
|
||||
|
||||
MakePathname(file, path, "fmail.ar");
|
||||
|
||||
fp = fsopen(file, "rb", sharemode);
|
||||
if(fp) {
|
||||
|
||||
|
||||
fread(&hdr, sizeof(headerType), 1, fp);
|
||||
fp.Fopen(file, "rb", sharemode);
|
||||
if (fp.isopen())
|
||||
{
|
||||
fp.Fread(&hdr, sizeof(headerType));
|
||||
|
||||
uint headerSize = hdr.headerSize;
|
||||
uint recordSize = hdr.recordSize;
|
||||
|
||||
fseek(fp, headerSize, SEEK_SET);
|
||||
fp.FseekSet(headerSize);
|
||||
|
||||
ar = (rawEchoType116*)throw_calloc(1, recordSize);
|
||||
if(ar) {
|
||||
|
||||
while(fread(ar, recordSize, 1, fp) == 1) {
|
||||
|
||||
if (ar)
|
||||
{
|
||||
while(fp.Fread(ar, recordSize))
|
||||
{
|
||||
if(ar->options.active) {
|
||||
|
||||
aa.reset();
|
||||
@@ -234,7 +233,7 @@ void gareafile::ReadFMail116(FILE* fp, char* path, char* file, char* options) {
|
||||
|
||||
throw_free(ar);
|
||||
|
||||
fclose(fp);
|
||||
fp.Fclose();
|
||||
}
|
||||
|
||||
throw_delete(cfg);
|
||||
@@ -243,10 +242,9 @@ void gareafile::ReadFMail116(FILE* fp, char* path, char* file, char* options) {
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
void gareafile::ReadFMail(char* tag) {
|
||||
|
||||
void gareafile::ReadFMail(char* tag)
|
||||
{
|
||||
char* ptr;
|
||||
FILE* fp;
|
||||
char options[80];
|
||||
Path path, file;
|
||||
|
||||
@@ -271,16 +269,16 @@ void gareafile::ReadFMail(char* tag) {
|
||||
|
||||
MakePathname(file, path, "fmail.cfg");
|
||||
|
||||
fp = fsopen(file, "rb", sharemode);
|
||||
if(fp) {
|
||||
|
||||
gfile fp(file, "rb", sharemode);
|
||||
if (fp.isopen())
|
||||
{
|
||||
struct {
|
||||
byte vmajor;
|
||||
byte vminor;
|
||||
} _rev;
|
||||
|
||||
fread(&_rev, sizeof(_rev), 1, fp);
|
||||
rewind(fp);
|
||||
fp.Fread(&_rev, sizeof(_rev));
|
||||
fp.Rewind();
|
||||
|
||||
uint fmver = (_rev.vmajor << 8) | _rev.vminor;
|
||||
|
||||
|
@@ -43,20 +43,21 @@ static char comment_char = '#';
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
bool gareafile::ReadHPTLine(FILE* f, std::string* s, bool add, int state) {
|
||||
|
||||
bool gareafile::ReadHPTLine(gfile &f, std::string* s, bool add, int state)
|
||||
{
|
||||
std::string str;
|
||||
char buf[81];
|
||||
|
||||
if(fgets(buf, 81, f) == NULL)
|
||||
return false; // eof
|
||||
if (!f.Fgets(buf, 81)) return false; // eof
|
||||
|
||||
str = buf;
|
||||
|
||||
if(buf[strlen(buf)-1] != '\n') {
|
||||
while(fgets(buf, 81, f) != NULL) {
|
||||
if (buf[strlen(buf)-1] != '\n')
|
||||
{
|
||||
while (f.Fgets(buf, 81))
|
||||
{
|
||||
str += buf;
|
||||
if(buf[strlen(buf)-1] == '\n')
|
||||
if (buf[strlen(buf)-1] == '\n')
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -178,10 +179,10 @@ void gareafile::ReadHPTFile(char* path, char* file, char* origin, int group) {
|
||||
AreaCfg aa;
|
||||
Path buf2;
|
||||
|
||||
FILE* fp = fsopen(file, "rb", sharemode);
|
||||
if (fp)
|
||||
gfile fp(file, "rb", sharemode);
|
||||
if (fp.isopen())
|
||||
{
|
||||
setvbuf(fp, NULL, _IOFBF, 8192);
|
||||
fp.SetvBuf(NULL, _IOFBF, 8192);
|
||||
|
||||
if (not quiet)
|
||||
STD_PRINTNL("* Reading " << file);
|
||||
@@ -192,8 +193,8 @@ void gareafile::ReadHPTFile(char* path, char* file, char* origin, int group) {
|
||||
aa.groupid = group;
|
||||
|
||||
std::string s;
|
||||
while(ReadHPTLine(fp, &s)) {
|
||||
|
||||
while (ReadHPTLine(fp, &s))
|
||||
{
|
||||
if(not s.empty()) {
|
||||
|
||||
char *alptr = throw_xstrdup(s.c_str());
|
||||
@@ -378,9 +379,10 @@ void gareafile::ReadHPTFile(char* path, char* file, char* origin, int group) {
|
||||
}
|
||||
}
|
||||
|
||||
skip_config:
|
||||
fclose(fp);
|
||||
}else{
|
||||
skip_config:;
|
||||
}
|
||||
else
|
||||
{
|
||||
STD_PRINTNL(" * AREAFILE FIDOCONFIG: Can't open file '" << path << '/' << file << ": " << strerror(errno) );
|
||||
}
|
||||
}
|
||||
|
@@ -27,7 +27,6 @@
|
||||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
#include <gmemdbg.h>
|
||||
#include <gfile.h>
|
||||
#if defined(__GOLD_GUI__)
|
||||
#include <gvidall.h>
|
||||
#include <gvidgui.h>
|
||||
|
@@ -26,7 +26,6 @@
|
||||
|
||||
#include <cstdlib>
|
||||
#include <gmemdbg.h>
|
||||
#include <gfile.h>
|
||||
#include <gstrall.h>
|
||||
#if defined(__GOLD_GUI__)
|
||||
#include <gvidall.h>
|
||||
|
@@ -26,7 +26,6 @@
|
||||
|
||||
#include <cstdlib>
|
||||
#include <gmemdbg.h>
|
||||
#include <gfile.h>
|
||||
#include <gstrall.h>
|
||||
#if defined(__GOLD_GUI__)
|
||||
#include <gvidall.h>
|
||||
|
@@ -53,12 +53,12 @@ const char *gareafile::gettype(const char *msgtype, const byte wtrtype) {
|
||||
// ------------------------------------------------------------------
|
||||
// Read WaterGate v0.93
|
||||
|
||||
void gareafile::ReadWtrGteFile(char* options, FILE* fp) {
|
||||
|
||||
void gareafile::ReadWtrGteFile(char* options, gfile &fp)
|
||||
{
|
||||
AreaCfg aa;
|
||||
ConfigRecord* _tmp = new ConfigRecord; throw_new(_tmp);
|
||||
ConfigRecord& c = *_tmp;
|
||||
fread(&c, sizeof(ConfigRecord), 1, fp);
|
||||
fp.Fread(&c, sizeof(ConfigRecord));
|
||||
|
||||
strp2c(c.systemdir);
|
||||
CfgJampath(c.systemdir);
|
||||
@@ -161,9 +161,8 @@ void gareafile::ReadWtrGteFile(char* options, FILE* fp) {
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
void gareafile::ReadWtrGte(char* tag) {
|
||||
|
||||
FILE* fp;
|
||||
void gareafile::ReadWtrGte(char* tag)
|
||||
{
|
||||
char* ptr;
|
||||
char options[80];
|
||||
Path wtrpath, file;
|
||||
@@ -188,21 +187,20 @@ void gareafile::ReadWtrGte(char* tag) {
|
||||
strcpy(wtrpath, areapath);
|
||||
|
||||
MakePathname(file, wtrpath, "wtrcfg.tdb");
|
||||
fp = fsopen(file, "rb", sharemode);
|
||||
if (fp)
|
||||
gfile fp(file, "rb", sharemode);
|
||||
if (fp.isopen())
|
||||
{
|
||||
if (not quiet)
|
||||
STD_PRINTNL("* Reading " << file);
|
||||
|
||||
char header[26];
|
||||
fread(header, 26, 1, fp); strp2c(header);
|
||||
fp.Fread(header, 26);
|
||||
strp2c(header);
|
||||
|
||||
if(streql(header, ConfigHeader))
|
||||
ReadWtrGteFile(options, fp);
|
||||
else
|
||||
STD_PRINTNL("* Error: WaterGate \"" << header << "\" is not supported - Skipping.");
|
||||
|
||||
fclose(fp);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user