Sorry, refactoring!
This commit is contained in:
parent
6cac338f3e
commit
f2ece5007e
@ -184,8 +184,6 @@ void AreaList::WriteGoldLast()
|
|||||||
(*ap)->PMrk.Save(fp);
|
(*ap)->PMrk.Save(fp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fp.Fclose();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -205,10 +203,7 @@ void AreaList::ReadGoldLast()
|
|||||||
fp.Fread(&GOLDLAST_VER, sizeof(word));
|
fp.Fread(&GOLDLAST_VER, sizeof(word));
|
||||||
|
|
||||||
if (GOLDLAST_VER != CUR_GOLDLAST_VER)
|
if (GOLDLAST_VER != CUR_GOLDLAST_VER)
|
||||||
{
|
|
||||||
fp.Fclose();
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
fp.Fread(AL.alistselections, sizeof(AL.alistselections));
|
fp.Fread(AL.alistselections, sizeof(AL.alistselections));
|
||||||
|
|
||||||
@ -246,8 +241,6 @@ void AreaList::ReadGoldLast()
|
|||||||
fp.Fseek(dw*sizeof(dword), SEEK_CUR);
|
fp.Fseek(dw*sizeof(dword), SEEK_CUR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fp.Fclose();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -255,18 +248,17 @@ void AreaList::ReadGoldLast()
|
|||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
// Write all areas to GOLDAREA.INC in AREADEF format
|
// Write all areas to GOLDAREA.INC in AREADEF format
|
||||||
|
|
||||||
void AreaList::WriteAreaDef(const char* file) {
|
void AreaList::WriteAreaDef(const char* file)
|
||||||
|
{
|
||||||
int tmp;
|
int tmp;
|
||||||
FILE* fp;
|
|
||||||
Path path;
|
Path path;
|
||||||
char groupid[10], echoid[sizeof(Echo)+2];
|
char groupid[10], echoid[sizeof(Echo)+2];
|
||||||
int maxechoid=0, maxdesc=0, maxgroupid=0, maxpath=0, maxaddr=0, maxattr=0;
|
int maxechoid=0, maxdesc=0, maxgroupid=0, maxpath=0, maxaddr=0, maxattr=0;
|
||||||
char desc[sizeof(Desc)+2], type[6], msgbase[9], addr[40], attr[150], origin[163];
|
char desc[sizeof(Desc)+2], type[6], msgbase[9], addr[40], attr[150], origin[163];
|
||||||
|
|
||||||
fp = fsopen(file, "wt", CFG->sharemode);
|
gfile fp(file, "wt", CFG->sharemode);
|
||||||
if(fp) {
|
if (fp.isopen())
|
||||||
|
{
|
||||||
area_iterator aa;
|
area_iterator aa;
|
||||||
for(aa = idx.begin(); aa != idx.end(); aa++) {
|
for(aa = idx.begin(); aa != idx.end(); aa++) {
|
||||||
tmp = strlen((*aa)->echoid());
|
tmp = strlen((*aa)->echoid());
|
||||||
@ -325,8 +317,9 @@ void AreaList::WriteAreaDef(const char* file) {
|
|||||||
sprintf(echoid, "\"%s\"", (*aa)->echoid());
|
sprintf(echoid, "\"%s\"", (*aa)->echoid());
|
||||||
else
|
else
|
||||||
strcpy(echoid, (*aa)->echoid());
|
strcpy(echoid, (*aa)->echoid());
|
||||||
if((*aa)->isseparator()) {
|
if ((*aa)->isseparator())
|
||||||
fprintf(fp, "AREASEP %-*s %-*s %*s %s\n",
|
{
|
||||||
|
fp.Printf("AREASEP %-*s %-*s %*s %s\n",
|
||||||
maxechoid, echoid,
|
maxechoid, echoid,
|
||||||
maxdesc, desc,
|
maxdesc, desc,
|
||||||
maxgroupid, groupid,
|
maxgroupid, groupid,
|
||||||
@ -349,7 +342,7 @@ void AreaList::WriteAreaDef(const char* file) {
|
|||||||
sprintf(origin, " \"%.*s\"", (int)sizeof(origin)-4, CFG->origin[(*aa)->originno()].c_str());
|
sprintf(origin, " \"%.*s\"", (int)sizeof(origin)-4, CFG->origin[(*aa)->originno()].c_str());
|
||||||
else
|
else
|
||||||
*origin = NUL;
|
*origin = NUL;
|
||||||
fprintf(fp, "AREADEF %-*s %-*s %*s %s %s %-*s %-*s %-*s%s\n",
|
fp.Printf("AREADEF %-*s %-*s %*s %s %s %-*s %-*s %-*s%s\n",
|
||||||
maxechoid, echoid,
|
maxechoid, echoid,
|
||||||
maxdesc, desc,
|
maxdesc, desc,
|
||||||
maxgroupid, groupid,
|
maxgroupid, groupid,
|
||||||
@ -362,8 +355,6 @@ void AreaList::WriteAreaDef(const char* file) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(fp);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -807,9 +807,8 @@ void getdztoken(char** key, char** val) {
|
|||||||
|
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
|
|
||||||
void AreaList::ReadEcholist(char* val) {
|
void AreaList::ReadEcholist(char* val)
|
||||||
|
{
|
||||||
FILE* fp;
|
|
||||||
char* key;
|
char* key;
|
||||||
Path file;
|
Path file;
|
||||||
char buf[256], options[80];
|
char buf[256], options[80];
|
||||||
@ -836,11 +835,11 @@ void AreaList::ReadEcholist(char* val) {
|
|||||||
strcpy(file, key);
|
strcpy(file, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(*file) {
|
if (*file)
|
||||||
|
{
|
||||||
fp = fsopen(file, "rt", CFG->sharemode);
|
gfile fp(file, "rt", CFG->sharemode);
|
||||||
if(fp) {
|
if (fp.isopen())
|
||||||
|
{
|
||||||
void (*tok)(char**, char**);
|
void (*tok)(char**, char**);
|
||||||
|
|
||||||
if(is_dz)
|
if(is_dz)
|
||||||
@ -851,8 +850,8 @@ void AreaList::ReadEcholist(char* val) {
|
|||||||
if (not quiet)
|
if (not quiet)
|
||||||
STD_PRINTNL("* Reading " << file);
|
STD_PRINTNL("* Reading " << file);
|
||||||
|
|
||||||
while(fgets((val=buf), sizeof(buf), fp)) {
|
while (fp.Fgets((val=buf), sizeof(buf)))
|
||||||
|
{
|
||||||
// Get echoid
|
// Get echoid
|
||||||
if(is_sqafix) {
|
if(is_sqafix) {
|
||||||
tok(&key, &val);
|
tok(&key, &val);
|
||||||
@ -900,8 +899,6 @@ void AreaList::ReadEcholist(char* val) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(fp);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -323,8 +323,8 @@ struct AF_entry idetect[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
void InstallDetect(char* path) {
|
void InstallDetect(char* path)
|
||||||
|
{
|
||||||
// Create GOLDED.BAK file if there is an existing GOLDED.CFG
|
// Create GOLDED.BAK file if there is an existing GOLDED.CFG
|
||||||
if(fexist(CFG->goldcfg)) {
|
if(fexist(CFG->goldcfg)) {
|
||||||
Path cmdlinecfgbak;
|
Path cmdlinecfgbak;
|
||||||
@ -337,12 +337,13 @@ void InstallDetect(char* path) {
|
|||||||
|
|
||||||
STD_PRINTNL("Please wait while GoldED+ is detecting your software.");
|
STD_PRINTNL("Please wait while GoldED+ is detecting your software.");
|
||||||
|
|
||||||
FILE* fp = fopen(CFG->goldcfg, "wt");
|
gfile fp(CFG->goldcfg, "wt");
|
||||||
if(fp) {
|
if (fp.isopen())
|
||||||
|
{
|
||||||
if(*path) {
|
if (*path)
|
||||||
|
{
|
||||||
MapPath(PathCopy(CFG->areapath, path));
|
MapPath(PathCopy(CFG->areapath, path));
|
||||||
fprintf(fp, "AREAPATH %s\n", path);
|
fp.Printf("AREAPATH %s\n", path);
|
||||||
}
|
}
|
||||||
|
|
||||||
Path pth;
|
Path pth;
|
||||||
@ -362,8 +363,9 @@ void InstallDetect(char* path) {
|
|||||||
if(ptr)
|
if(ptr)
|
||||||
*ptr = NUL;
|
*ptr = NUL;
|
||||||
}
|
}
|
||||||
if(fexist(AddPath(pth, idetect[i].configname))) {
|
if (fexist(AddPath(pth, idetect[i].configname)))
|
||||||
fprintf(fp, "AREAFILE %s %s\n", idetect[i].name, pth);
|
{
|
||||||
|
fp.Printf("AREAFILE %s %s\n", idetect[i].name, pth);
|
||||||
STD_PRINTNL("Found " << idetect[i].name << (ptr ? "." : " (unreliable)."));
|
STD_PRINTNL("Found " << idetect[i].name << (ptr ? "." : " (unreliable)."));
|
||||||
if(streql(idetect[i].name, "Squish"))
|
if(streql(idetect[i].name, "Squish"))
|
||||||
gotsquish = true;
|
gotsquish = true;
|
||||||
@ -376,8 +378,9 @@ void InstallDetect(char* path) {
|
|||||||
ptr = getenv("IM");
|
ptr = getenv("IM");
|
||||||
if(ptr)
|
if(ptr)
|
||||||
PathCopy(pth, ptr);
|
PathCopy(pth, ptr);
|
||||||
if(fexist(AddPath(pth, "im.exe")) or fexist(AddPath(pth, "intrecho.exe"))) {
|
if (fexist(AddPath(pth, "im.exe")) or fexist(AddPath(pth, "intrecho.exe")))
|
||||||
fprintf(fp, "AREAFILE InterMail %s\n", pth);
|
{
|
||||||
|
fp.Printf("AREAFILE InterMail %s\n", pth);
|
||||||
STD_PRINTNL("Found InterMail and/or InterEcho.");
|
STD_PRINTNL("Found InterMail and/or InterEcho.");
|
||||||
detected = true;
|
detected = true;
|
||||||
}
|
}
|
||||||
@ -391,21 +394,24 @@ void InstallDetect(char* path) {
|
|||||||
else
|
else
|
||||||
extractdirname(pth, pth);
|
extractdirname(pth, pth);
|
||||||
}
|
}
|
||||||
if(fexist(AddPath(pth, "max.prm"))) {
|
if (fexist(AddPath(pth, "max.prm")))
|
||||||
fprintf(fp, "AREAFILE Maximus %s\n", pth);
|
{
|
||||||
|
fp.Printf("AREAFILE Maximus %s\n", pth);
|
||||||
STD_PRINTNL("Found Maximus.");
|
STD_PRINTNL("Found Maximus.");
|
||||||
detected = true;
|
detected = true;
|
||||||
}
|
}
|
||||||
if(not gotsquish and fexist(AddPath(pth, "squish.cfg"))) {
|
if (not gotsquish and fexist(AddPath(pth, "squish.cfg")))
|
||||||
fprintf(fp, "AREAFILE Squish %s\n", pth);
|
{
|
||||||
|
fp.Printf("AREAFILE Squish %s\n", pth);
|
||||||
STD_PRINTNL("Found Squish.");
|
STD_PRINTNL("Found Squish.");
|
||||||
detected = true;
|
detected = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Detect ME2
|
// Detect ME2
|
||||||
strcpy(pth, CFG->areapath);
|
strcpy(pth, CFG->areapath);
|
||||||
if(fexist(AddPath(pth, "areadesc.me2"))) {
|
if (fexist(AddPath(pth, "areadesc.me2")))
|
||||||
fprintf(fp, "AREAFILE ME2 %sareadesc.me2 %sareas.bbs\n", pth, pth);
|
{
|
||||||
|
fp.Printf("AREAFILE ME2 %sareadesc.me2 %sareas.bbs\n", pth, pth);
|
||||||
STD_PRINTNL("Found ME2.");
|
STD_PRINTNL("Found ME2.");
|
||||||
gotareasbbs = true;
|
gotareasbbs = true;
|
||||||
detected = true;
|
detected = true;
|
||||||
@ -414,8 +420,9 @@ void InstallDetect(char* path) {
|
|||||||
// Detect AREAS.BBS
|
// Detect AREAS.BBS
|
||||||
if(not gotareasbbs) {
|
if(not gotareasbbs) {
|
||||||
strcpy(pth, CFG->areapath);
|
strcpy(pth, CFG->areapath);
|
||||||
if(fexist(AddPath(pth, "areas.bbs"))) {
|
if (fexist(AddPath(pth, "areas.bbs")))
|
||||||
fprintf(fp, "AREAFILE AreasBBS %sareas.bbs\n", pth);
|
{
|
||||||
|
fp.Printf("AREAFILE AreasBBS %sareas.bbs\n", pth);
|
||||||
STD_PRINTNL("Found AREAS.BBS.");
|
STD_PRINTNL("Found AREAS.BBS.");
|
||||||
detected = true;
|
detected = true;
|
||||||
}
|
}
|
||||||
@ -423,36 +430,36 @@ void InstallDetect(char* path) {
|
|||||||
|
|
||||||
if(not detected)
|
if(not detected)
|
||||||
STD_PRINTNL("Sorry, could not find any supported software. Try another path.");
|
STD_PRINTNL("Sorry, could not find any supported software. Try another path.");
|
||||||
|
|
||||||
fclose(fp);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
|
|
||||||
int InstallFinish() {
|
int InstallFinish()
|
||||||
|
{
|
||||||
FILE* fp = fopen(CFG->goldcfg, "at");
|
gfile fp(CFG->goldcfg, "at");
|
||||||
if(fp) {
|
if (fp.isopen())
|
||||||
|
{
|
||||||
char buf[77];
|
char buf[77];
|
||||||
|
|
||||||
// Check what we have
|
// Check what we have
|
||||||
|
if (CFG->username.empty())
|
||||||
if(CFG->username.empty()) {
|
{
|
||||||
if (EnterString("Please enter your name:", buf, sizeof(buf)))
|
if (EnterString("Please enter your name:", buf, sizeof(buf)))
|
||||||
goto install_terminated;
|
return -1;
|
||||||
fprintf(fp, "USERNAME %s\n", buf);
|
fp.Printf("USERNAME %s\n", buf);
|
||||||
CfgUsername(buf);
|
CfgUsername(buf);
|
||||||
}
|
}
|
||||||
if(CFG->aka.empty()) {
|
if (CFG->aka.empty())
|
||||||
|
{
|
||||||
if (EnterString("Please enter your FidoNet address:", buf, sizeof(buf)))
|
if (EnterString("Please enter your FidoNet address:", buf, sizeof(buf)))
|
||||||
goto install_terminated;
|
return -1;
|
||||||
fprintf(fp, "ADDRESS %s\n", buf);
|
fp.Printf("ADDRESS %s\n", buf);
|
||||||
CfgAddress(buf);
|
CfgAddress(buf);
|
||||||
}
|
}
|
||||||
if(AL.basetypes.empty()) {
|
if (AL.basetypes.empty())
|
||||||
|
{
|
||||||
if (EnterString("Please enter the path to your *.msg netmail area:", buf, sizeof(buf)))
|
if (EnterString("Please enter the path to your *.msg netmail area:", buf, sizeof(buf)))
|
||||||
return -1;
|
return -1;
|
||||||
AreaCfg aa;
|
AreaCfg aa;
|
||||||
@ -464,54 +471,53 @@ int InstallFinish() {
|
|||||||
aa.setpath(buf);
|
aa.setpath(buf);
|
||||||
aa.attr = CFG->attribsnet;
|
aa.attr = CFG->attribsnet;
|
||||||
AL.AddNewArea(&aa);
|
AL.AddNewArea(&aa);
|
||||||
fprintf(fp, "AREADEF %s \"%s\" 0 Net %s %s\n", aa.desc, aa.echoid, aa.basetype, buf);
|
fp.Printf("AREADEF %s \"%s\" 0 Net %s %s\n", aa.desc, aa.echoid, aa.basetype, buf);
|
||||||
if (EnterString("Please enter the path *and* filename of your areas.bbs file:", buf, sizeof(buf)))
|
if (EnterString("Please enter the path *and* filename of your areas.bbs file:", buf, sizeof(buf)))
|
||||||
goto install_terminated;
|
return -1;
|
||||||
fprintf(fp, "AREAFILE AreasBBS %s\n", buf);
|
fp.Printf("AREAFILE AreasBBS %s\n", buf);
|
||||||
char buf2[200]="AreasBBS ";
|
char buf2[200]="AreasBBS ";
|
||||||
strcat(buf2, buf);
|
strcat(buf2, buf);
|
||||||
AL.GetAreafile(buf2);
|
AL.GetAreafile(buf2);
|
||||||
}
|
}
|
||||||
#ifndef GMB_NOHUDS
|
#ifndef GMB_NOHUDS
|
||||||
if(find(AL.basetypes, "HUDSON") and (*CFG->hudsonpath == NUL)) {
|
if (find(AL.basetypes, "HUDSON") and (*CFG->hudsonpath == NUL))
|
||||||
|
{
|
||||||
if (EnterString("Please enter the path to your Hudson msgbase files:", buf, sizeof(buf)))
|
if (EnterString("Please enter the path to your Hudson msgbase files:", buf, sizeof(buf)))
|
||||||
goto install_terminated;
|
return -1;
|
||||||
fprintf(fp, "HUDSONPATH %s\n", buf);
|
fp.Printf("HUDSONPATH %s\n", buf);
|
||||||
PathCopy(CFG->hudsonpath, buf);
|
PathCopy(CFG->hudsonpath, buf);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifndef GMB_NOGOLD
|
#ifndef GMB_NOGOLD
|
||||||
if(find(AL.basetypes, "GOLDBASE") and (*CFG->goldbasepath == NUL)) {
|
if (find(AL.basetypes, "GOLDBASE") and (*CFG->goldbasepath == NUL))
|
||||||
|
{
|
||||||
if (EnterString("Please enter the path to your Goldbase msgbase files:", buf, sizeof(buf)))
|
if (EnterString("Please enter the path to your Goldbase msgbase files:", buf, sizeof(buf)))
|
||||||
goto install_terminated;
|
return -1;
|
||||||
fprintf(fp, "GOLDBASEPATH %s\n", buf);
|
fp.Printf("GOLDBASEPATH %s\n", buf);
|
||||||
PathCopy(CFG->goldbasepath, buf);
|
PathCopy(CFG->goldbasepath, buf);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifndef GMB_NOJAM
|
#ifndef GMB_NOJAM
|
||||||
if(find(AL.basetypes, "JAM") and (*CFG->jampath == NUL)) {
|
if (find(AL.basetypes, "JAM") and (*CFG->jampath == NUL))
|
||||||
|
{
|
||||||
if (EnterString("Please enter the path where net/echomail.jam can be placed:", buf, sizeof(buf)))
|
if (EnterString("Please enter the path where net/echomail.jam can be placed:", buf, sizeof(buf)))
|
||||||
goto install_terminated;
|
return -1;
|
||||||
fprintf(fp, "JAMPATH %s\n", buf);
|
fp.Printf("JAMPATH %s\n", buf);
|
||||||
PathCopy(CFG->jampath, buf);
|
PathCopy(CFG->jampath, buf);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifndef GMB_NOPCB
|
#ifndef GMB_NOPCB
|
||||||
if(find(AL.basetypes, "PCBOARD") and (*CFG->pcboardpath == NUL)) {
|
if (find(AL.basetypes, "PCBOARD") and (*CFG->pcboardpath == NUL))
|
||||||
|
{
|
||||||
if (EnterString("Please enter the path to PCBoard:", buf, sizeof(buf)))
|
if (EnterString("Please enter the path to PCBoard:", buf, sizeof(buf)))
|
||||||
goto install_terminated;
|
return -1;
|
||||||
fprintf(fp, "PCBOARDPATH %s\n", buf);
|
fp.Printf("PCBOARDPATH %s\n", buf);
|
||||||
PathCopy(CFG->pcboardpath, buf);
|
PathCopy(CFG->pcboardpath, buf);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
fclose(fp);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
install_terminated:
|
|
||||||
fclose(fp);
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -720,11 +720,10 @@ static int do_if(char* val) {
|
|||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
// Compile a GoldED text config file
|
// Compile a GoldED text config file
|
||||||
|
|
||||||
int ReadCfg(const char* cfgfile, int ignoreunknown) {
|
int ReadCfg(const char* cfgfile, int ignoreunknown)
|
||||||
|
{
|
||||||
const word CRC_APP = 0x08B5;
|
const word CRC_APP = 0x08B5;
|
||||||
|
|
||||||
FILE* fp;
|
|
||||||
Path cfg;
|
Path cfg;
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
static int inuse = 0;
|
static int inuse = 0;
|
||||||
@ -741,8 +740,8 @@ int ReadCfg(const char* cfgfile, int ignoreunknown) {
|
|||||||
strcpy(cfg, cfgfile);
|
strcpy(cfg, cfgfile);
|
||||||
MakePathname(cfg, CFG->goldpath, cfg);
|
MakePathname(cfg, CFG->goldpath, cfg);
|
||||||
|
|
||||||
fp = fsopen(cfg, "rt", CFG->sharemode);
|
gfile fp(cfg, "rt", CFG->sharemode);
|
||||||
if (fp)
|
if (fp.isopen())
|
||||||
{
|
{
|
||||||
cfgname = strrchr(cfg, '\\');
|
cfgname = strrchr(cfg, '\\');
|
||||||
cfgname = cfgname ? cfgname+1 : cfg;
|
cfgname = cfgname ? cfgname+1 : cfg;
|
||||||
@ -752,11 +751,11 @@ int ReadCfg(const char* cfgfile, int ignoreunknown) {
|
|||||||
STD_PRINTNL("* Reading " << cfg);
|
STD_PRINTNL("* Reading " << cfg);
|
||||||
|
|
||||||
// Assign file buffer
|
// Assign file buffer
|
||||||
setvbuf(fp, NULL, _IOFBF, 8192);
|
fp.SetvBuf(NULL, _IOFBF, 8192);
|
||||||
|
|
||||||
// Read each line
|
// Read each line
|
||||||
while(fgets((val=buf), sizeof(buf), fp)) {
|
while (fp.Fgets((val=buf), sizeof(buf)))
|
||||||
|
{
|
||||||
line++;
|
line++;
|
||||||
|
|
||||||
// Replace TABs with SPACEs
|
// Replace TABs with SPACEs
|
||||||
@ -882,7 +881,7 @@ int ReadCfg(const char* cfgfile, int ignoreunknown) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Close and return all OK
|
// Close and return all OK
|
||||||
fclose(fp);
|
fp.Fclose();
|
||||||
inuse--;
|
inuse--;
|
||||||
|
|
||||||
// When the final cfg is compiled
|
// When the final cfg is compiled
|
||||||
|
@ -646,18 +646,19 @@ void AssignDateNames() {
|
|||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
// Load a GoldED language file
|
// Load a GoldED language file
|
||||||
|
|
||||||
void LoadLanguage(const char* file) {
|
void LoadLanguage(const char* file)
|
||||||
|
{
|
||||||
FILE* fp;
|
|
||||||
char* ptr;
|
char* ptr;
|
||||||
char* str;
|
char* str;
|
||||||
int line = 0;
|
int line = 0;
|
||||||
char buf[256];
|
char buf[256];
|
||||||
|
|
||||||
fp = fsopen(AddPath(CFG->goldpath, file), "rt", CFG->sharemode);
|
gfile fp(AddPath(CFG->goldpath, file), "rt", CFG->sharemode);
|
||||||
if(fp) {
|
if (fp.isopen())
|
||||||
setvbuf(fp, NULL, _IOFBF, 8192);
|
{
|
||||||
while(fgets((ptr=buf), sizeof(buf), fp)) {
|
fp.SetvBuf(NULL, _IOFBF, 8192);
|
||||||
|
while (fp.Fgets((ptr=buf), sizeof(buf)))
|
||||||
|
{
|
||||||
line++;
|
line++;
|
||||||
ptr = strskip_wht(ptr);
|
ptr = strskip_wht(ptr);
|
||||||
if(g_isalpha(*ptr)) {
|
if(g_isalpha(*ptr)) {
|
||||||
@ -682,7 +683,6 @@ void LoadLanguage(const char* file) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fclose(fp);
|
|
||||||
|
|
||||||
// Assign weekday/month names
|
// Assign weekday/month names
|
||||||
AssignDateNames();
|
AssignDateNames();
|
||||||
@ -693,9 +693,8 @@ void LoadLanguage(const char* file) {
|
|||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
// Read the main language definition file
|
// Read the main language definition file
|
||||||
|
|
||||||
bool ReadLangCfg(int force) {
|
bool ReadLangCfg(int force)
|
||||||
|
{
|
||||||
FILE *fpi;
|
|
||||||
char* ptr;
|
char* ptr;
|
||||||
char* str;
|
char* str;
|
||||||
long size;
|
long size;
|
||||||
@ -705,17 +704,19 @@ bool ReadLangCfg(int force) {
|
|||||||
|
|
||||||
// Read the GOLDLANG.CFG if there is one
|
// Read the GOLDLANG.CFG if there is one
|
||||||
const char* cfgname = AddPath(CFG->goldpath, CFG->langcfg);
|
const char* cfgname = AddPath(CFG->goldpath, CFG->langcfg);
|
||||||
fpi = fsopen(cfgname, "rt", CFG->sharemode);
|
|
||||||
if (fpi)
|
gfile fpi(cfgname, "rt", CFG->sharemode);
|
||||||
|
if (fpi.isopen())
|
||||||
{
|
{
|
||||||
setvbuf(fpi, NULL, _IOFBF, 8192);
|
fpi.SetvBuf(NULL, _IOFBF, 8192);
|
||||||
|
|
||||||
if (not quiet)
|
if (not quiet)
|
||||||
STD_PRINTNL("* Reading " << cfgname);
|
STD_PRINTNL("* Reading " << cfgname);
|
||||||
|
|
||||||
cfgname = CleanFilename(cfgname);
|
cfgname = CleanFilename(cfgname);
|
||||||
|
|
||||||
while(fgets((ptr=buf), sizeof(buf), fpi)) {
|
while (fpi.Fgets((ptr=buf), sizeof(buf)))
|
||||||
|
{
|
||||||
line++;
|
line++;
|
||||||
ptr = strskip_wht(ptr);
|
ptr = strskip_wht(ptr);
|
||||||
if(g_isalpha(*ptr)) {
|
if(g_isalpha(*ptr)) {
|
||||||
@ -741,7 +742,6 @@ bool ReadLangCfg(int force) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fclose(fpi);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fill in the defaults if there are "holes"
|
// Fill in the defaults if there are "holes"
|
||||||
|
@ -34,20 +34,19 @@ int ReadHelpCfg(int force) {
|
|||||||
char* ptr;
|
char* ptr;
|
||||||
long offset;
|
long offset;
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
FILE* ifp;
|
|
||||||
FILE* ofp;
|
|
||||||
Hlpr* HlpL;
|
Hlpr* HlpL;
|
||||||
int count;
|
int count;
|
||||||
int counter;
|
int counter;
|
||||||
int comment;
|
int comment;
|
||||||
|
|
||||||
if((force > 1) or (FiletimeCmp(CFG->helpcfg.fn, CFG->helpged) > 0)) {
|
if ((force > 1) or (FiletimeCmp(CFG->helpcfg.fn, CFG->helpged) > 0))
|
||||||
|
{
|
||||||
ifp = fsopen(AddPath(CFG->goldpath, CFG->helpcfg.fn), "rb", CFG->sharemode);
|
gfile ifp(AddPath(CFG->goldpath, CFG->helpcfg.fn), "rb", CFG->sharemode);
|
||||||
if(ifp) {
|
if (ifp.isopen())
|
||||||
setvbuf(ifp, NULL, _IOFBF, 8192);
|
{
|
||||||
ofp = fsopen(AddPath(CFG->goldpath, CFG->helpged), "wb", CFG->sharemode);
|
ifp.SetvBuf(NULL, _IOFBF, 8192);
|
||||||
if (ofp)
|
gfile ofp(AddPath(CFG->goldpath, CFG->helpged), "wb", CFG->sharemode);
|
||||||
|
if (ofp.isopen())
|
||||||
{
|
{
|
||||||
offset = 0L;
|
offset = 0L;
|
||||||
CFG->helpcfg.ft = GetFiletime(AddPath(CFG->goldpath, CFG->helpcfg.fn));
|
CFG->helpcfg.ft = GetFiletime(AddPath(CFG->goldpath, CFG->helpcfg.fn));
|
||||||
@ -55,27 +54,29 @@ int ReadHelpCfg(int force) {
|
|||||||
if (not quiet)
|
if (not quiet)
|
||||||
STD_PRINTNL("* Reading " << AddPath(CFG->goldpath, CFG->helpcfg.fn));
|
STD_PRINTNL("* Reading " << AddPath(CFG->goldpath, CFG->helpcfg.fn));
|
||||||
|
|
||||||
setvbuf(ofp, NULL, _IOFBF, 8192);
|
ofp.SetvBuf(NULL, _IOFBF, 8192);
|
||||||
|
|
||||||
count = 0;
|
count = 0;
|
||||||
rewind(ifp);
|
ifp.Rewind();
|
||||||
|
|
||||||
while(fgets(buf, sizeof(buf), ifp)) {
|
while (ifp.Fgets(buf, sizeof(buf)))
|
||||||
|
{
|
||||||
if(strnieql(buf, "*B ", 3))
|
if(strnieql(buf, "*B ", 3))
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
HlpL = (Hlpr*)throw_calloc(count+2, sizeof(Hlpr));
|
HlpL = (Hlpr*)throw_calloc(count+2, sizeof(Hlpr));
|
||||||
|
|
||||||
rewind(ifp);
|
ifp.Rewind();
|
||||||
fputs("*I\r\n", ofp);
|
ofp.Fputs("*I\r\n");
|
||||||
fwrite(HlpL, count+1, sizeof(Hlpr), ofp);
|
ofp.Fwrite(HlpL, count+1, sizeof(Hlpr));
|
||||||
fputs("\r\n\r\n", ofp);
|
ofp.Fputs("\r\n\r\n");
|
||||||
offset += 4 + ((count+1)*sizeof(Hlpr)) + 4;
|
offset += 4 + ((count+1)*sizeof(Hlpr)) + 4;
|
||||||
|
|
||||||
counter = 0;
|
counter = 0;
|
||||||
comment = YES;
|
comment = YES;
|
||||||
while(fgets(buf, sizeof(buf), ifp)) {
|
while (ifp.Fgets(buf, sizeof(buf)))
|
||||||
|
{
|
||||||
if(strnieql(buf, "*B ", 3)) {
|
if(strnieql(buf, "*B ", 3)) {
|
||||||
comment = NO;
|
comment = NO;
|
||||||
HlpL[counter].help = atow(buf+3);
|
HlpL[counter].help = atow(buf+3);
|
||||||
@ -84,8 +85,9 @@ int ReadHelpCfg(int force) {
|
|||||||
HlpL[counter].offset = offset + strlen(buf);
|
HlpL[counter].offset = offset + strlen(buf);
|
||||||
counter++;
|
counter++;
|
||||||
}
|
}
|
||||||
if(not comment) {
|
if (not comment)
|
||||||
fputs(buf, ofp);
|
{
|
||||||
|
ofp.Fputs(buf);
|
||||||
offset += strlen(buf);
|
offset += strlen(buf);
|
||||||
}
|
}
|
||||||
if(strnieql(buf, "*E", 2))
|
if(strnieql(buf, "*E", 2))
|
||||||
@ -93,15 +95,12 @@ int ReadHelpCfg(int force) {
|
|||||||
}
|
}
|
||||||
HlpL[counter].offset = -1L;
|
HlpL[counter].offset = -1L;
|
||||||
|
|
||||||
fseek(ofp, 0L, SEEK_SET);
|
ofp.FseekSet(0);
|
||||||
fputs("*I\r\n", ofp);
|
ofp.Fputs("*I\r\n");
|
||||||
fwrite(HlpL, count+1, sizeof(Hlpr), ofp);
|
ofp.Fwrite(HlpL, count+1, sizeof(Hlpr));
|
||||||
|
|
||||||
throw_free(HlpL);
|
throw_free(HlpL);
|
||||||
fclose(ofp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(ifp);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -818,21 +817,25 @@ void ReadXlatTables() {
|
|||||||
|
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
|
|
||||||
void CookieIndex(char* textfile, char* indexfile) {
|
void CookieIndex(char* textfile, char* indexfile)
|
||||||
|
{
|
||||||
FILE* ifp = fsopen(textfile, "rb", CFG->sharemode);
|
gfile ifp(textfile, "rb", CFG->sharemode);
|
||||||
if(ifp) {
|
if (ifp.isopen())
|
||||||
setvbuf(ifp, NULL, _IOFBF, 32000);
|
{
|
||||||
FILE* ofp = fsopen(indexfile, "wb", CFG->sharemode);
|
ifp.SetvBuf(NULL, _IOFBF, 32000);
|
||||||
if(ofp) {
|
gfile ofp(indexfile, "wb", CFG->sharemode);
|
||||||
setvbuf(ofp, NULL, _IOFBF, 16000);
|
if (ofp)
|
||||||
|
{
|
||||||
|
ofp.SetvBuf(NULL, _IOFBF, 16000);
|
||||||
char buf[256];
|
char buf[256];
|
||||||
long fpos = 0;
|
long fpos = 0;
|
||||||
long tpos = 0;
|
long tpos = 0;
|
||||||
bool was_blank = false;
|
bool was_blank = false;
|
||||||
while(fgets(buf, sizeof(buf), ifp)) {
|
while (ifp.Fgets(buf, sizeof(buf)))
|
||||||
if(strblank(buf)) {
|
{
|
||||||
fwrite(&fpos, sizeof(long), 1, ofp);
|
if (strblank(buf))
|
||||||
|
{
|
||||||
|
ofp.Fwrite(&fpos, sizeof(long));
|
||||||
fpos = tpos + strlen(buf);
|
fpos = tpos + strlen(buf);
|
||||||
was_blank = true;
|
was_blank = true;
|
||||||
}
|
}
|
||||||
@ -842,10 +845,8 @@ void CookieIndex(char* textfile, char* indexfile) {
|
|||||||
tpos += strlen(buf);
|
tpos += strlen(buf);
|
||||||
}
|
}
|
||||||
if (not was_blank)
|
if (not was_blank)
|
||||||
fwrite(&fpos, sizeof(long), 1, ofp);
|
ofp.Fwrite(&fpos, sizeof(long));
|
||||||
fclose(ofp);
|
|
||||||
}
|
}
|
||||||
fclose(ifp);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,16 +167,16 @@ int DoCarboncopy(GMsg* msg, GMsg** carbon) {
|
|||||||
else
|
else
|
||||||
cchide = false;
|
cchide = false;
|
||||||
|
|
||||||
if(*ptr == '@') {
|
if (*ptr == '@')
|
||||||
FILE* fp = fsopen(AddPath(CFG->goldpath, ++ptr), "rt", CFG->sharemode);
|
{
|
||||||
if(fp) {
|
gfile fp(AddPath(CFG->goldpath, ++ptr), "rt", CFG->sharemode);
|
||||||
|
if (fp.isopen())
|
||||||
|
{
|
||||||
gstrarray fc;
|
gstrarray fc;
|
||||||
|
|
||||||
while(fgets(buf, sizeof(buf), fp))
|
while (fp.Fgets(buf, sizeof(buf)))
|
||||||
tokenize(fc, buf, ",\n");
|
tokenize(fc, buf, ",\n");
|
||||||
|
|
||||||
fclose(fp);
|
|
||||||
|
|
||||||
for(int j = 0; j < fc.size(); j++)
|
for(int j = 0; j < fc.size(); j++)
|
||||||
if(fc[j][0] != '@') // we don't like nesting!
|
if(fc[j][0] != '@') // we don't like nesting!
|
||||||
AddCCList(fc[j].c_str(), cchide, msg, carbon, cc, A, AA, xc2to);
|
AddCCList(fc[j].c_str(), cchide, msg, carbon, cc, A, AA, xc2to);
|
||||||
@ -386,16 +386,16 @@ void DoCrosspost(GMsg* msg, std::vector<int> &postareas) {
|
|||||||
else
|
else
|
||||||
xphide = false;
|
xphide = false;
|
||||||
|
|
||||||
if(*ptr == '@') {
|
if (*ptr == '@')
|
||||||
FILE* fp = fsopen(AddPath(CFG->goldpath, ++ptr), "rt", CFG->sharemode);
|
{
|
||||||
if(fp) {
|
gfile fp(AddPath(CFG->goldpath, ++ptr), "rt", CFG->sharemode);
|
||||||
|
if (fp.isopen())
|
||||||
|
{
|
||||||
gstrarray fc;
|
gstrarray fc;
|
||||||
|
|
||||||
while(fgets(buf, sizeof(buf), fp))
|
while (fp.Fgets(buf, sizeof(buf)))
|
||||||
tokenize(fc, buf, ", \n");
|
tokenize(fc, buf, ", \n");
|
||||||
|
|
||||||
fclose(fp);
|
|
||||||
|
|
||||||
for(int j = 0; j < fc.size(); j++)
|
for(int j = 0; j < fc.size(); j++)
|
||||||
if(fc[j][0] != '@') // we don't like nesting!
|
if(fc[j][0] != '@') // we don't like nesting!
|
||||||
hideoriginal = AddXCAreas(fc[j].c_str(), xphide, postareas, postareas_attrs, local_xps) or hideoriginal;
|
hideoriginal = AddXCAreas(fc[j].c_str(), xphide, postareas, postareas_attrs, local_xps) or hideoriginal;
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
|
|
||||||
static FILE* prnfp;
|
static gfile prnfp;
|
||||||
static int prnheader;
|
static int prnheader;
|
||||||
|
|
||||||
|
|
||||||
@ -51,13 +51,15 @@ void SaveLines(int mode, const char* savefile, GMsg* msg, int margin, bool clip)
|
|||||||
strcpy(fnam, "PRN");
|
strcpy(fnam, "PRN");
|
||||||
if(mode == MODE_WRITE and streql(savefile, "\001PRN"))
|
if(mode == MODE_WRITE and streql(savefile, "\001PRN"))
|
||||||
prn = YES;
|
prn = YES;
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
strcpy(fnam, savefile);
|
strcpy(fnam, savefile);
|
||||||
strschg_environ(fnam);
|
strschg_environ(fnam);
|
||||||
prnfp = fsopen(fnam, prnacc, CFG->sharemode);
|
prnfp.Fopen(fnam, prnacc, CFG->sharemode);
|
||||||
}
|
}
|
||||||
int lines=0;
|
int lines=0;
|
||||||
if(prnfp) {
|
if (prnfp.isopen())
|
||||||
|
{
|
||||||
char *old_msg_txt = throw_strdup(msg->txt);
|
char *old_msg_txt = throw_strdup(msg->txt);
|
||||||
#ifdef OLD_STYLE_HEADER
|
#ifdef OLD_STYLE_HEADER
|
||||||
if(mode == MODE_WRITE) {
|
if(mode == MODE_WRITE) {
|
||||||
@ -99,40 +101,42 @@ void SaveLines(int mode, const char* savefile, GMsg* msg, int margin, bool clip)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
const char *ptr = line->txt.c_str();
|
const char *ptr = line->txt.c_str();
|
||||||
fwrite(ptr, strlen(ptr), 1, prnfp);
|
prnfp.Fwrite(ptr, strlen(ptr));
|
||||||
if(mode == MODE_NEW) {
|
if (mode == MODE_NEW)
|
||||||
|
{
|
||||||
if(EDIT->HardLines()) {
|
if(EDIT->HardLines()) {
|
||||||
if(line->type & GLINE_HARD) {
|
if(line->type & GLINE_HARD) {
|
||||||
if(not ((line->type & (GLINE_TEAR|GLINE_ORIG|GLINE_KLUDGE|GLINE_QUOT)) or strblank(ptr))) {
|
if (not ((line->type & (GLINE_TEAR|GLINE_ORIG|GLINE_KLUDGE|GLINE_QUOT)) or strblank(ptr)))
|
||||||
fwrite(EDIT->HardLine(), strlen(EDIT->HardLine()), 1, prnfp);
|
{
|
||||||
|
prnfp.Fwrite(EDIT->HardLine(), strlen(EDIT->HardLine()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fwrite(prn ? NL : "\n", prn ? sizeof(NL) : 1, 1, prnfp);
|
prnfp.Fwrite(prn ? NL : "\n", prn ? sizeof(NL) : 1);
|
||||||
if(prn) {
|
if (prn)
|
||||||
|
{
|
||||||
lines++;
|
lines++;
|
||||||
if(lines%CFG->printlength == 0 and CFG->switches.get(printformfeed)) {
|
if (lines%CFG->printlength == 0 and CFG->switches.get(printformfeed))
|
||||||
fwrite("\f", 1, 1, prnfp);
|
prnfp.Fwrite("\f", 1);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
line = lin[++n];
|
line = lin[++n];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Add an empty line and formfeed at the bottom
|
// Add an empty line and formfeed at the bottom
|
||||||
if(mode == MODE_WRITE) {
|
if (mode == MODE_WRITE)
|
||||||
fwrite(prn ? NL : "\n", prn ? sizeof(NL) : 1, 1, prnfp);
|
prnfp.Fwrite(prn ? NL : "\n", prn ? sizeof(NL) : 1);
|
||||||
}
|
|
||||||
// Add formfeed if requested
|
// Add formfeed if requested
|
||||||
if ((prn and CFG->switches.get(printformfeed)) or
|
if ((prn and CFG->switches.get(printformfeed)) or
|
||||||
(not prn and not clip and CFG->switches.get(formfeedseparator))) {
|
(not prn and not clip and CFG->switches.get(formfeedseparator)))
|
||||||
fwrite("\f", 1, 1, prnfp);
|
{
|
||||||
}
|
prnfp.Fwrite("\f", 1);
|
||||||
if(not prn) {
|
|
||||||
fclose(prnfp);
|
|
||||||
prnfp = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
prnfp.Fclose();
|
||||||
|
|
||||||
throw_release(msg->txt);
|
throw_release(msg->txt);
|
||||||
msg->txt = old_msg_txt;
|
msg->txt = old_msg_txt;
|
||||||
}
|
}
|
||||||
@ -162,8 +166,6 @@ static void WriteMsgs(GMsg* msg) {
|
|||||||
|
|
||||||
int overwrite = NO;
|
int overwrite = NO;
|
||||||
|
|
||||||
prnfp = NULL;
|
|
||||||
|
|
||||||
GMenuDomarks MenuDomarks;
|
GMenuDomarks MenuDomarks;
|
||||||
int source = AA->Mark.Count() ? MenuDomarks.Run(LNG->Write) : WRITE_CURRENT;
|
int source = AA->Mark.Count() ? MenuDomarks.Run(LNG->Write) : WRITE_CURRENT;
|
||||||
|
|
||||||
@ -203,12 +205,12 @@ static void WriteMsgs(GMsg* msg) {
|
|||||||
}
|
}
|
||||||
else if(target & WRITE_PRINTER) {
|
else if(target & WRITE_PRINTER) {
|
||||||
#ifdef __UNIX__
|
#ifdef __UNIX__
|
||||||
prnfp = popen(CFG->printdevice, "w");
|
prnfp.Popen(CFG->printdevice, "w");
|
||||||
#else
|
#else
|
||||||
prnfp = fsopen(CFG->printdevice, "wt", CFG->sharemode);
|
prnfp.Fopen(CFG->printdevice, "wt", CFG->sharemode);
|
||||||
#endif
|
#endif
|
||||||
if(prnfp)
|
if (prnfp.isopen())
|
||||||
fwrite(CFG->printinit+1, CFG->printinit[0], 1, prnfp);
|
prnfp.Fwrite(CFG->printinit+1, CFG->printinit[0]);
|
||||||
}
|
}
|
||||||
else if(target & WRITE_CLIPBRD) {
|
else if(target & WRITE_CLIPBRD) {
|
||||||
overwrite = YES;
|
overwrite = YES;
|
||||||
@ -238,9 +240,10 @@ static void WriteMsgs(GMsg* msg) {
|
|||||||
SaveLines(overwrite ? MODE_WRITE : MODE_APPEND, AA->Outputfile(), msg, prnmargin, make_bool(target & WRITE_CLIPBRD));
|
SaveLines(overwrite ? MODE_WRITE : MODE_APPEND, AA->Outputfile(), msg, prnmargin, make_bool(target & WRITE_CLIPBRD));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(prnfp)
|
if (prnfp.isopen())
|
||||||
fwrite(CFG->printreset+1, CFG->printreset[0], 1, prnfp);
|
prnfp.Fwrite(CFG->printreset+1, CFG->printreset[0]);
|
||||||
if(target & WRITE_CLIPBRD) {
|
if (target & WRITE_CLIPBRD)
|
||||||
|
{
|
||||||
AA->SetOutputfile(ofname);
|
AA->SetOutputfile(ofname);
|
||||||
|
|
||||||
gclipbrd clipbrd;
|
gclipbrd clipbrd;
|
||||||
@ -296,14 +299,15 @@ static void WriteMsgs(GMsg* msg) {
|
|||||||
w_info(LNG->WritingPRN);
|
w_info(LNG->WritingPRN);
|
||||||
AA->LoadMsg(msg, msg->msgno, prnmargin);
|
AA->LoadMsg(msg, msg->msgno, prnmargin);
|
||||||
#ifdef __UNIX__
|
#ifdef __UNIX__
|
||||||
prnfp = popen(CFG->printdevice, "w");
|
prnfp.Popen(CFG->printdevice, "w");
|
||||||
#else
|
#else
|
||||||
prnfp = fsopen(CFG->printdevice, "wt", CFG->sharemode);
|
prnfp.Fopen(CFG->printdevice, "wt", CFG->sharemode);
|
||||||
#endif
|
#endif
|
||||||
if(prnfp) {
|
if (prnfp.isopen())
|
||||||
fwrite(CFG->printinit+1, CFG->printinit[0], 1, prnfp);
|
{
|
||||||
|
prnfp.Fwrite(CFG->printinit+1, CFG->printinit[0]);
|
||||||
SaveLines(MODE_WRITE, "\001PRN", msg, prnmargin);
|
SaveLines(MODE_WRITE, "\001PRN", msg, prnmargin);
|
||||||
fwrite(CFG->printreset+1, CFG->printreset[0], 1, prnfp);
|
prnfp.Fwrite(CFG->printreset+1, CFG->printreset[0]);
|
||||||
}
|
}
|
||||||
w_info(NULL);
|
w_info(NULL);
|
||||||
}
|
}
|
||||||
@ -343,14 +347,11 @@ Finish:
|
|||||||
|
|
||||||
w_info(NULL);
|
w_info(NULL);
|
||||||
|
|
||||||
if(prnfp) {
|
|
||||||
#ifdef __UNIX__
|
#ifdef __UNIX__
|
||||||
pclose(prnfp);
|
prnfp.Pclose();
|
||||||
#else
|
#else
|
||||||
fclose(prnfp);
|
prnfp.Fclose();
|
||||||
#endif
|
#endif
|
||||||
prnfp = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
GFTRK(NULL);
|
GFTRK(NULL);
|
||||||
}
|
}
|
||||||
@ -439,13 +440,13 @@ void QuoteBuf(GMsg* msg) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(*openmode) {
|
if (*openmode)
|
||||||
|
{
|
||||||
FILE* fp = fsopen(quotebuf, openmode, CFG->sharemode);
|
gfile fp(quotebuf, openmode, CFG->sharemode);
|
||||||
if(fp) {
|
if (fp.isopen())
|
||||||
|
{
|
||||||
strchg(msg->txt, 0x0D, 0x0A);
|
strchg(msg->txt, 0x0D, 0x0A);
|
||||||
fputs(msg->txt, fp);
|
fp.Fputs(msg->txt);
|
||||||
fclose(fp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
HandleGEvent(EVTT_JOBDONE);
|
HandleGEvent(EVTT_JOBDONE);
|
||||||
|
@ -2012,16 +2012,17 @@ void IEclass::savefile(int __status) {
|
|||||||
// Open the save file
|
// Open the save file
|
||||||
const char* editorfile = AddPath(CFG->goldpath, EDIT->File());
|
const char* editorfile = AddPath(CFG->goldpath, EDIT->File());
|
||||||
remove(editorfile);
|
remove(editorfile);
|
||||||
FILE* _fp = fsopen(editorfile, "wb", CFG->sharemode);
|
gfile _fp(editorfile, "wb", CFG->sharemode);
|
||||||
if(_fp) {
|
if (_fp)
|
||||||
|
{
|
||||||
// Find the first line
|
// Find the first line
|
||||||
Line* _saveline = findfirstline();
|
Line* _saveline = findfirstline();
|
||||||
|
|
||||||
// First save the "unfinished" identifier
|
// First save the "unfinished" identifier
|
||||||
if(__status == MODE_UPDATE) {
|
if (__status == MODE_UPDATE)
|
||||||
fputs(unfinished, _fp);
|
{
|
||||||
fputs("\r\n", _fp);
|
_fp.Fputs(unfinished);
|
||||||
|
_fp.Fputs("\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save as whole paragraphs
|
// Save as whole paragraphs
|
||||||
@ -2037,14 +2038,11 @@ void IEclass::savefile(int __status) {
|
|||||||
strcpy(_lfptr, "\r\n");
|
strcpy(_lfptr, "\r\n");
|
||||||
|
|
||||||
// Save the line
|
// Save the line
|
||||||
fputs(_buf, _fp);
|
_fp.Fputs(_buf);
|
||||||
|
|
||||||
// Continue with the next line
|
// Continue with the next line
|
||||||
_saveline = _saveline->next;
|
_saveline = _saveline->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close save file and remove wait window
|
|
||||||
fclose(_fp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
update_statusline(statbak);
|
update_statusline(statbak);
|
||||||
@ -2864,12 +2862,15 @@ int IEclass::Start(int __mode, uint* __position, GMsg* __msg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check if there is an unfinished backup message
|
// Check if there is an unfinished backup message
|
||||||
FILE* _fp = fsopen(AddPath(CFG->goldpath, EDIT->File()), "rt", CFG->sharemode);
|
gfile _fp(AddPath(CFG->goldpath, EDIT->File()), "rt", CFG->sharemode);
|
||||||
if(_fp) {
|
if (_fp)
|
||||||
|
{
|
||||||
char _buf[EDIT_BUFLEN];
|
char _buf[EDIT_BUFLEN];
|
||||||
fgets(_buf, sizeof(_buf), _fp);
|
_fp.Fgets(_buf, sizeof(_buf));
|
||||||
fclose(_fp);
|
_fp.Fclose();
|
||||||
if(striinc(unfinished, _buf)) {
|
|
||||||
|
if (striinc(unfinished, _buf))
|
||||||
|
{
|
||||||
w_info(LNG->UnfinishedMsg);
|
w_info(LNG->UnfinishedMsg);
|
||||||
update_statusline(LNG->LoadUnfinished);
|
update_statusline(LNG->LoadUnfinished);
|
||||||
HandleGEvent(EVTT_ATTENTION);
|
HandleGEvent(EVTT_ATTENTION);
|
||||||
|
@ -798,9 +798,9 @@ void IEclass::LoadFile() {
|
|||||||
GFTRK("EditLoadFile");
|
GFTRK("EditLoadFile");
|
||||||
|
|
||||||
// Open the file to load
|
// Open the file to load
|
||||||
FILE* _fp = fsopen(AddPath(CFG->goldpath, EDIT->File()), "rb", CFG->sharemode);
|
gfile _fp(AddPath(CFG->goldpath, EDIT->File()), "rb", CFG->sharemode);
|
||||||
if(_fp) {
|
if (_fp)
|
||||||
|
{
|
||||||
XlatName __oldxlatimport;
|
XlatName __oldxlatimport;
|
||||||
|
|
||||||
// Pop up a wait window
|
// Pop up a wait window
|
||||||
@ -824,17 +824,17 @@ void IEclass::LoadFile() {
|
|||||||
currline = msgptr->lin = NULL;
|
currline = msgptr->lin = NULL;
|
||||||
|
|
||||||
// Allocate space for new message text
|
// Allocate space for new message text
|
||||||
msgptr->txt = (char*)throw_calloc(1, (uint)(fsize(_fp)+256));
|
msgptr->txt = (char*)throw_calloc(1, (uint)(_fp.FileLength()+256));
|
||||||
|
|
||||||
// Eat the backup marking line
|
// Eat the backup marking line
|
||||||
char _buf[EDIT_BUFLEN];
|
char _buf[EDIT_BUFLEN];
|
||||||
fgets(_buf, sizeof(_buf), _fp);
|
_fp.Fgets(_buf, sizeof(_buf));
|
||||||
if (not striinc(unfinished, _buf))
|
if (not striinc(unfinished, _buf))
|
||||||
rewind(_fp);
|
_fp.Rewind();
|
||||||
|
|
||||||
// Load the file and close it
|
// Load the file and close it
|
||||||
fread(msgptr->txt, 1, (uint)fsize(_fp), _fp);
|
_fp.Fread(msgptr->txt, (uint)_fp.FileLength());
|
||||||
fclose(_fp);
|
_fp.Fclose();
|
||||||
|
|
||||||
// Save current charset
|
// Save current charset
|
||||||
strcpy(__oldxlatimport, AA->Xlatimport());
|
strcpy(__oldxlatimport, AA->Xlatimport());
|
||||||
@ -981,18 +981,18 @@ void IEclass::editimport(Line* __line, char* __filename, bool imptxt) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(fileselected or getclip) {
|
if (fileselected or getclip)
|
||||||
|
{
|
||||||
// Open the file/clipboard
|
// Open the file/clipboard
|
||||||
FILE* fp = NULL;
|
gfile fp;
|
||||||
gclipbrd clipbrd;
|
gclipbrd clipbrd;
|
||||||
|
|
||||||
if(getclip)
|
if(getclip)
|
||||||
filenamebuf = CLIP_NAME;
|
filenamebuf = CLIP_NAME;
|
||||||
|
|
||||||
if(getclip ? clipbrd.openread() :
|
if(getclip ? clipbrd.openread() :
|
||||||
(fp = fsopen(filenamebuf.c_str(), binary ? "rb" : "rt", CFG->sharemode))!=NULL) {
|
(fp.Fopen(filenamebuf.c_str(), binary ? "rb" : "rt", CFG->sharemode))!=NULL)
|
||||||
|
{
|
||||||
if (isPipe)
|
if (isPipe)
|
||||||
filenamebuf = AA->Inputfile();
|
filenamebuf = AA->Inputfile();
|
||||||
|
|
||||||
@ -1037,14 +1037,15 @@ void IEclass::editimport(Line* __line, char* __filename, bool imptxt) {
|
|||||||
__line = insertlinebelow(__line, _parabuf);
|
__line = insertlinebelow(__line, _parabuf);
|
||||||
setlinetype(__line);
|
setlinetype(__line);
|
||||||
|
|
||||||
while(1) {
|
while (true)
|
||||||
|
{
|
||||||
char ibuf[80];
|
char ibuf[80];
|
||||||
char* iptr = ibuf;
|
char* iptr = ibuf;
|
||||||
char* optr = _parabuf;
|
char* optr = _parabuf;
|
||||||
int n = fread(ibuf, 1, 45, fp);
|
int n = fp.Fread(ibuf, 45);
|
||||||
if(n < 45)
|
if (n < 45) memset(ibuf+n, 0, 45-n);
|
||||||
memset(ibuf+n, 0, 45-n);
|
|
||||||
*optr++ = uuencode_enc(n);
|
*optr++ = uuencode_enc(n);
|
||||||
|
|
||||||
for(int i=0; i<n; i+=3,iptr+=3) {
|
for(int i=0; i<n; i+=3,iptr+=3) {
|
||||||
*optr++ = uuencode_enc(*iptr >> 2);
|
*optr++ = uuencode_enc(*iptr >> 2);
|
||||||
*optr++ = uuencode_enc(((*iptr << 4) & 060) | ((iptr[1] >> 4) & 017));
|
*optr++ = uuencode_enc(((*iptr << 4) & 060) | ((iptr[1] >> 4) & 017));
|
||||||
@ -1079,10 +1080,11 @@ void IEclass::editimport(Line* __line, char* __filename, bool imptxt) {
|
|||||||
__line = insertlinebelow(__line, _parabuf);
|
__line = insertlinebelow(__line, _parabuf);
|
||||||
setlinetype(__line);
|
setlinetype(__line);
|
||||||
|
|
||||||
for(;;) {
|
while (true)
|
||||||
|
{
|
||||||
char ibuf[80];
|
char ibuf[80];
|
||||||
char* optr = _parabuf;
|
char* optr = _parabuf;
|
||||||
int n = fread(ibuf, 1, 54, fp);
|
int n = fp.Fread(ibuf, 54);
|
||||||
optr = b64.encode(optr, ibuf, n);
|
optr = b64.encode(optr, ibuf, n);
|
||||||
*optr++ = '\n';
|
*optr++ = '\n';
|
||||||
*optr = NUL;
|
*optr = NUL;
|
||||||
@ -1109,8 +1111,8 @@ void IEclass::editimport(Line* __line, char* __filename, bool imptxt) {
|
|||||||
__line->next = NULL;
|
__line->next = NULL;
|
||||||
|
|
||||||
// Read paragraphs
|
// Read paragraphs
|
||||||
while(getclip ? clipbrd.read(_parabuf, EDIT_PARABUFLEN-7) : fgets(_parabuf, EDIT_PARABUFLEN-7, fp)) {
|
while (getclip ? clipbrd.read(_parabuf, EDIT_PARABUFLEN-7) : fp.Fgets(_parabuf, EDIT_PARABUFLEN-7))
|
||||||
|
{
|
||||||
XlatStr(buf, _parabuf, level, CharTable);
|
XlatStr(buf, _parabuf, level, CharTable);
|
||||||
|
|
||||||
// Insert a quotestring if asked
|
// Insert a quotestring if asked
|
||||||
@ -1211,7 +1213,7 @@ void IEclass::editimport(Line* __line, char* __filename, bool imptxt) {
|
|||||||
if (getclip)
|
if (getclip)
|
||||||
clipbrd.close();
|
clipbrd.close();
|
||||||
else
|
else
|
||||||
fclose(fp);
|
fp.Fclose();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
w_infof(LNG->CouldNotOpen, filenamebuf.c_str());
|
w_infof(LNG->CouldNotOpen, filenamebuf.c_str());
|
||||||
@ -1279,8 +1281,8 @@ void IEclass::editexport(Line* __exportline, int __endat) {
|
|||||||
|
|
||||||
update_statusline(LNG->ExportFile);
|
update_statusline(LNG->ExportFile);
|
||||||
|
|
||||||
if(edit_string(Edit__exportfilename, sizeof(Path), LNG->ExportWhatFile, H_ExportFile)) {
|
if (edit_string(Edit__exportfilename, sizeof(Path), LNG->ExportWhatFile, H_ExportFile))
|
||||||
|
{
|
||||||
// Pointer to export filename
|
// Pointer to export filename
|
||||||
char* _filenameptr = Edit__exportfilename;
|
char* _filenameptr = Edit__exportfilename;
|
||||||
|
|
||||||
@ -1288,20 +1290,19 @@ void IEclass::editexport(Line* __exportline, int __endat) {
|
|||||||
if(*_filenameptr == '+')
|
if(*_filenameptr == '+')
|
||||||
_filenameptr++;
|
_filenameptr++;
|
||||||
|
|
||||||
FILE* _fp = fsopen(_filenameptr, (*Edit__exportfilename == '+') ? "at" : "wt", CFG->sharemode);
|
gfile _fp(_filenameptr, (*Edit__exportfilename == '+') ? "at" : "wt", CFG->sharemode);
|
||||||
if(_fp) {
|
if (_fp.isopen())
|
||||||
|
{
|
||||||
update_statuslinef(LNG->ExportStatus, "ST_EXPORTSTATUS", Edit__exportfilename);
|
update_statuslinef(LNG->ExportStatus, "ST_EXPORTSTATUS", Edit__exportfilename);
|
||||||
fputc('\n', _fp);
|
_fp.Fputc('\n');
|
||||||
|
|
||||||
while((__endat ? __exportline != currline : 1) and __exportline) {
|
while ((__endat ? __exportline != currline : 1) and __exportline)
|
||||||
fwrite(__exportline->txt.c_str(), 1, __exportline->txt.length(), _fp);
|
{
|
||||||
|
_fp.Fwrite(__exportline->txt.c_str(), __exportline->txt.length());
|
||||||
if (__exportline->txt.find('\n') == __exportline->txt.npos)
|
if (__exportline->txt.find('\n') == __exportline->txt.npos)
|
||||||
fputc('\n', _fp);
|
_fp.Fputc('\n');
|
||||||
__exportline = __exportline->next;
|
__exportline = __exportline->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(_fp);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,25 +173,27 @@ static void ReadEcholists() {
|
|||||||
Echo* echoin = (Echo*)throw_calloc(1, sizeof(Echo));
|
Echo* echoin = (Echo*)throw_calloc(1, sizeof(Echo));
|
||||||
|
|
||||||
// Read the import taglist
|
// Read the import taglist
|
||||||
FILE* fp = fsopen(AddPath(CFG->areapath, CFG->semaphore.importlist), "rt", CFG->sharemode);
|
gfile fp(AddPath(CFG->areapath, CFG->semaphore.importlist), "rt", CFG->sharemode);
|
||||||
|
if (fp.isopen())
|
||||||
if(fp) {
|
{
|
||||||
char buf[256];
|
char buf[256];
|
||||||
int echonums = 0;
|
int echonums = 0;
|
||||||
update_statusline(LNG->ReadingEcholist);
|
update_statusline(LNG->ReadingEcholist);
|
||||||
while(fgets(buf, sizeof(buf), fp)) {
|
while (fp.Fgets(buf, sizeof(buf)))
|
||||||
|
{
|
||||||
if(not strblank(buf)) {
|
if(not strblank(buf)) {
|
||||||
echonums++;
|
echonums++;
|
||||||
echoin = (Echo*)throw_realloc(echoin, (echonums+2)*sizeof(Echo));
|
echoin = (Echo*)throw_realloc(echoin, (echonums+2)*sizeof(Echo));
|
||||||
strcpy(echoin[echonums-1], strtrim(strsetsz(buf, sizeof(Echo)-1)));
|
strcpy(echoin[echonums-1], strtrim(strsetsz(buf, sizeof(Echo)-1)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*echoin[echonums] = 0; // Mark end
|
*echoin[echonums] = 0; // Mark end
|
||||||
fclose(fp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mark the areas from the import taglist
|
// Mark the areas from the import taglist
|
||||||
for(uint n=0; n<AL.size(); n++) {
|
for (uint n = 0; n < AL.size(); n++)
|
||||||
|
{
|
||||||
char buf[256];
|
char buf[256];
|
||||||
strcpy(buf, AL[n]->echoid());
|
strcpy(buf, AL[n]->echoid());
|
||||||
int x = SearchTaglist(echoin, buf);
|
int x = SearchTaglist(echoin, buf);
|
||||||
@ -205,41 +207,33 @@ static void ReadEcholists() {
|
|||||||
|
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
|
|
||||||
static void ReadEscsets() {
|
static void ReadEscsets()
|
||||||
|
{
|
||||||
|
std::vector<Map>::iterator x = CFG->xlatescset.begin();
|
||||||
|
for (int n = 0; x != CFG->xlatescset.end(); x++, n++)
|
||||||
|
{
|
||||||
|
gfile fp(AddPath(CFG->goldpath, CFG->xlatged), "rb", CFG->sharemode);
|
||||||
|
if (fp.isopen())
|
||||||
|
{
|
||||||
|
fp.FseekSet(((long)CFG->xlatcharset.size()*(long)sizeof(Chs)) + ((long)n*(long)sizeof(Esc)));
|
||||||
|
|
||||||
FILE* fp;
|
if (strieql(x->imp, "Composed"))
|
||||||
|
{
|
||||||
std::vector<Map>::iterator x;
|
|
||||||
int n;
|
|
||||||
for(n = 0, x = CFG->xlatescset.begin(); x != CFG->xlatescset.end(); x++, n++) {
|
|
||||||
if(strieql(x->imp, "Composed")) {
|
|
||||||
fp = fsopen(AddPath(CFG->goldpath, CFG->xlatged), "rb", CFG->sharemode);
|
|
||||||
if(fp) {
|
|
||||||
CompTable = (Esc*)throw_realloc(CompTable, sizeof(Esc));
|
CompTable = (Esc*)throw_realloc(CompTable, sizeof(Esc));
|
||||||
fseek(fp, ((long)CFG->xlatcharset.size()*(long)sizeof(Chs)) + ((long)n*(long)sizeof(Esc)), SEEK_SET);
|
fp.Fread(CompTable, sizeof(Esc));
|
||||||
fread(CompTable, sizeof(Esc), 1, fp);
|
|
||||||
CompTP = CompTable->t;
|
CompTP = CompTable->t;
|
||||||
fclose(fp);
|
|
||||||
}
|
}
|
||||||
}
|
else if (strieql(x->imp, "I51"))
|
||||||
else if(strieql(x->imp, "I51")) {
|
{
|
||||||
fp = fsopen(AddPath(CFG->goldpath, CFG->xlatged), "rb", CFG->sharemode);
|
|
||||||
if(fp) {
|
|
||||||
I51Table = (Esc*)throw_realloc(I51Table, sizeof(Esc));
|
I51Table = (Esc*)throw_realloc(I51Table, sizeof(Esc));
|
||||||
fseek(fp, ((long)CFG->xlatcharset.size()*(long)sizeof(Chs)) + ((long)n*(long)sizeof(Esc)), SEEK_SET);
|
fp.Fread(I51Table, sizeof(Esc));
|
||||||
fread(I51Table, sizeof(Esc), 1, fp);
|
|
||||||
I51TP = I51Table->t;
|
I51TP = I51Table->t;
|
||||||
fclose(fp);
|
|
||||||
}
|
}
|
||||||
}
|
else if (strieql(x->imp, "MNEMONIC"))
|
||||||
else if(strieql(x->imp, "MNEMONIC")) {
|
{
|
||||||
fp = fsopen(AddPath(CFG->goldpath, CFG->xlatged), "rb", CFG->sharemode);
|
|
||||||
if(fp) {
|
|
||||||
MNETable = (Esc*)throw_realloc(MNETable, sizeof(Esc));
|
MNETable = (Esc*)throw_realloc(MNETable, sizeof(Esc));
|
||||||
fseek(fp, ((long)CFG->xlatcharset.size()*(long)sizeof(Chs)) + ((long)n*(long)sizeof(Esc)), SEEK_SET);
|
fp.Fread(MNETable, sizeof(Esc));
|
||||||
fread(MNETable, sizeof(Esc), 1, fp);
|
|
||||||
MNETP = MNETable->t;
|
MNETP = MNETable->t;
|
||||||
fclose(fp);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -248,9 +242,8 @@ static void ReadEscsets() {
|
|||||||
|
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
|
|
||||||
static void ReadAddrMacros() {
|
static void ReadAddrMacros()
|
||||||
|
{
|
||||||
FILE* fp;
|
|
||||||
char* ptr;
|
char* ptr;
|
||||||
char buf[256], path[GMAXPATH];
|
char buf[256], path[GMAXPATH];
|
||||||
|
|
||||||
@ -262,17 +255,16 @@ static void ReadAddrMacros() {
|
|||||||
|
|
||||||
MakePathname(CFG->namesfile, path, CFG->namesfile);
|
MakePathname(CFG->namesfile, path, CFG->namesfile);
|
||||||
|
|
||||||
if(fexist(CFG->namesfile)) {
|
gfile fp(CFG->namesfile, "rt", CFG->sharemode);
|
||||||
fp = fsopen(CFG->namesfile, "rt", CFG->sharemode);
|
if (fp.isopen())
|
||||||
if(fp) {
|
{
|
||||||
update_statusline(LNG->ReadingAddrMacros);
|
update_statusline(LNG->ReadingAddrMacros);
|
||||||
while(fgets(buf, sizeof(buf), fp)) {
|
while (fp.Fgets(buf, sizeof(buf)))
|
||||||
|
{
|
||||||
strbtrim(buf);
|
strbtrim(buf);
|
||||||
if(*buf != ';' and *buf)
|
if(*buf != ';' and *buf)
|
||||||
CfgAddressmacro(buf);
|
CfgAddressmacro(buf);
|
||||||
}
|
}
|
||||||
fclose(fp);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2980,14 +2980,12 @@ static bool CheckLevel(const char* imp, const char* imp2, int n, int ¤t_ta
|
|||||||
if (CharTable && (n == current_table) && (level <= CharTable->level))
|
if (CharTable && (n == current_table) && (level <= CharTable->level))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
FILE* fp = fsopen(AddPath(CFG->goldpath, CFG->xlatged), "rb", CFG->sharemode);
|
gfile fp(AddPath(CFG->goldpath, CFG->xlatged), "rb", CFG->sharemode);
|
||||||
|
if (fp.isopen())
|
||||||
if (fp)
|
|
||||||
{
|
{
|
||||||
if (!CharTable) CharTable = (Chs*)throw_calloc(1, sizeof(Chs));
|
if (!CharTable) CharTable = (Chs*)throw_calloc(1, sizeof(Chs));
|
||||||
fseek(fp, ((long)n*(long)sizeof(Chs)), SEEK_SET);
|
fp.FseekSet(n, sizeof(Chs));
|
||||||
fread(CharTable, sizeof(Chs), 1, fp);
|
fp.Fread(CharTable, sizeof(Chs));
|
||||||
fclose(fp);
|
|
||||||
|
|
||||||
ChsTP = CharTable->t;
|
ChsTP = CharTable->t;
|
||||||
current_table = n;
|
current_table = n;
|
||||||
|
@ -604,25 +604,28 @@ void AskAttributes(GMsg* __msg) {
|
|||||||
|
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
|
|
||||||
int SelectFromFile(const char* file, char* selection, const char* title, const char* nolines) {
|
int SelectFromFile(const char* file, char* selection, const char* title, const char* nolines)
|
||||||
|
{
|
||||||
char buf[256];
|
char buf[256];
|
||||||
int n;
|
int n;
|
||||||
bool retval=false;
|
bool retval=false;
|
||||||
char** Listi;
|
char** Listi;
|
||||||
int lines = 0;
|
int lines = 0;
|
||||||
|
|
||||||
FILE* fp = fsopen(AddPath(CFG->goldpath, file), "rt", CFG->sharemode);
|
gfile fp(AddPath(CFG->goldpath, file), "rt", CFG->sharemode);
|
||||||
if(fp) {
|
if (fp.isopen())
|
||||||
while(fgets(buf, sizeof(buf), fp))
|
{
|
||||||
|
while (fp.Fgets(buf, sizeof(buf)))
|
||||||
lines++;
|
lines++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(lines) {
|
if (lines)
|
||||||
|
{
|
||||||
Listi = (char**)throw_calloc(lines+1, sizeof(char*));
|
Listi = (char**)throw_calloc(lines+1, sizeof(char*));
|
||||||
rewind(fp);
|
fp.Rewind();
|
||||||
for(n=0; n<lines; n++) {
|
for (n = 0; n < lines; n++)
|
||||||
fgets(buf, sizeof(buf)-2, fp);
|
{
|
||||||
|
fp.Fgets(buf, sizeof(buf)-2);
|
||||||
strtrim(buf);
|
strtrim(buf);
|
||||||
strins(" ", buf, 0);
|
strins(" ", buf, 0);
|
||||||
strcat(buf, " ");
|
strcat(buf, " ");
|
||||||
@ -649,9 +652,6 @@ int SelectFromFile(const char* file, char* selection, const char* title, const c
|
|||||||
w_info(NULL);
|
w_info(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(fp)
|
|
||||||
fclose(fp);
|
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -566,19 +566,19 @@ void TokenXlat(int mode, std::string &input, GMsg* msg, GMsg* oldmsg, int __orig
|
|||||||
{
|
{
|
||||||
std::string param = input.substr(pbeg-input.begin(), pend-pbeg);
|
std::string param = input.substr(pbeg-input.begin(), pend-pbeg);
|
||||||
|
|
||||||
FILE *pipe_in;
|
gfile pipe_in;
|
||||||
std::string pipe_buff;
|
std::string pipe_buff;
|
||||||
|
|
||||||
if ((pipe_in = popen(param.c_str(), "rt")) != NULL )
|
if ((pipe_in.Popen(param, "rt")) != NULL )
|
||||||
{
|
{
|
||||||
char buffer[1024];
|
char buffer[1024];
|
||||||
while (!feof(pipe_in))
|
while (!pipe_in.feof_())
|
||||||
{
|
{
|
||||||
if (fgets(buffer, sizeof(buffer), pipe_in) != NULL)
|
if (pipe_in.Fgets(buffer, sizeof(buffer)) != NULL)
|
||||||
pipe_buff += buffer;
|
pipe_buff += buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
pclose(pipe_in);
|
pipe_in.Pclose();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < pipe_buff.length(); i++)
|
for (size_t i = 0; i < pipe_buff.length(); i++)
|
||||||
@ -746,9 +746,8 @@ void Rot13(GMsg* msg) {
|
|||||||
|
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
|
|
||||||
void LoadText(GMsg* msg, const char* textfile) {
|
void LoadText(GMsg* msg, const char* textfile)
|
||||||
|
{
|
||||||
FILE* fp;
|
|
||||||
uint size;
|
uint size;
|
||||||
char* buf;
|
char* buf;
|
||||||
char* ptr;
|
char* ptr;
|
||||||
@ -756,9 +755,9 @@ void LoadText(GMsg* msg, const char* textfile) {
|
|||||||
int hardcr = NO, hardlen;
|
int hardcr = NO, hardlen;
|
||||||
char hardline[20];
|
char hardline[20];
|
||||||
|
|
||||||
fp = fsopen(textfile, "rt", CFG->sharemode);
|
gfile fp(textfile, "rt", CFG->sharemode);
|
||||||
if(fp) {
|
if (fp.isopen())
|
||||||
|
{
|
||||||
#define PBUFSIZE 4096 // Allow a 4k long paragraph
|
#define PBUFSIZE 4096 // Allow a 4k long paragraph
|
||||||
|
|
||||||
size_t buf_len = PBUFSIZE;
|
size_t buf_len = PBUFSIZE;
|
||||||
@ -773,7 +772,7 @@ void LoadText(GMsg* msg, const char* textfile) {
|
|||||||
memset(spaces, ' ', tabsz);
|
memset(spaces, ' ', tabsz);
|
||||||
spaces[tabsz] = NUL;
|
spaces[tabsz] = NUL;
|
||||||
|
|
||||||
uint tlen = (uint)(fsize(fp)+512);
|
uint tlen = (uint)(fp.FileLength()+512);
|
||||||
msg->txt = txtptr = (char*)throw_realloc(msg->txt, tlen);
|
msg->txt = txtptr = (char*)throw_realloc(msg->txt, tlen);
|
||||||
memset(msg->txt, NUL, tlen);
|
memset(msg->txt, NUL, tlen);
|
||||||
|
|
||||||
@ -785,8 +784,8 @@ void LoadText(GMsg* msg, const char* textfile) {
|
|||||||
hardlen = strlen(hardline);
|
hardlen = strlen(hardline);
|
||||||
*txtptr = NUL;
|
*txtptr = NUL;
|
||||||
|
|
||||||
while(fgets(buf, PBUFSIZE-1, fp)) {
|
while (fp.Fgets(buf, PBUFSIZE-1))
|
||||||
|
{
|
||||||
if(EDIT->HardLines() and strneql(buf, hardline, hardlen)) {
|
if(EDIT->HardLines() and strneql(buf, hardline, hardlen)) {
|
||||||
hardcr = not hardcr;
|
hardcr = not hardcr;
|
||||||
if(*txtptr == LF)
|
if(*txtptr == LF)
|
||||||
@ -891,7 +890,6 @@ void LoadText(GMsg* msg, const char* textfile) {
|
|||||||
if(*txtptr != CR)
|
if(*txtptr != CR)
|
||||||
*(++txtptr) = CR;
|
*(++txtptr) = CR;
|
||||||
*(++txtptr) = NUL;
|
*(++txtptr) = NUL;
|
||||||
fclose(fp);
|
|
||||||
throw_free(buf);
|
throw_free(buf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1247,13 +1247,14 @@ void CheckNodelists() {
|
|||||||
|
|
||||||
update_statusline(LNG->CheckingNodelists);
|
update_statusline(LNG->CheckingNodelists);
|
||||||
|
|
||||||
FILE* fp = fsopen(file, "rt", CFG->sharemode);
|
gfile fp(file, "rt", CFG->sharemode);
|
||||||
if(fp) {
|
if (fp)
|
||||||
|
{
|
||||||
// Read the list index
|
// Read the list index
|
||||||
char buf[256];
|
char buf[256];
|
||||||
NODE->nodelists = 0;
|
NODE->nodelists = 0;
|
||||||
while(fgets(buf, sizeof(buf), fp)) {
|
while (fp.Fgets(buf, sizeof(buf)))
|
||||||
|
{
|
||||||
NODE->nodelist = (Stamp*)throw_realloc(NODE->nodelist, (NODE->nodelists+1)*sizeof(Stamp));
|
NODE->nodelist = (Stamp*)throw_realloc(NODE->nodelist, (NODE->nodelists+1)*sizeof(Stamp));
|
||||||
char* key;
|
char* key;
|
||||||
char* val=buf;
|
char* val=buf;
|
||||||
@ -1263,7 +1264,7 @@ void CheckNodelists() {
|
|||||||
NODE->nodelist[NODE->nodelists].ft = atol(val);
|
NODE->nodelist[NODE->nodelists].ft = atol(val);
|
||||||
NODE->nodelists++;
|
NODE->nodelists++;
|
||||||
}
|
}
|
||||||
fclose(fp);
|
fp.Fclose();
|
||||||
|
|
||||||
// Check the files
|
// Check the files
|
||||||
if(CFG->switches.get(nodelistwarn)) {
|
if(CFG->switches.get(nodelistwarn)) {
|
||||||
|
@ -1100,13 +1100,14 @@ void MakeMsg(int mode, GMsg* omsg, bool ignore_replyto) {
|
|||||||
if (confirm)
|
if (confirm)
|
||||||
{
|
{
|
||||||
throw_release(msg->txt);
|
throw_release(msg->txt);
|
||||||
FILE* fp = fsopen(AddPath(CFG->goldpath, CFG->confirmfile), "rt", CFG->sharemode);
|
gfile fp(AddPath(CFG->goldpath, CFG->confirmfile), "rt", CFG->sharemode);
|
||||||
if(fp) {
|
|
||||||
|
if (fp.isopen())
|
||||||
LoadText(msg, AddPath(CFG->goldpath, CFG->confirmfile));
|
LoadText(msg, AddPath(CFG->goldpath, CFG->confirmfile));
|
||||||
fclose(fp);
|
|
||||||
}
|
|
||||||
if (msg->txt == NULL)
|
if (msg->txt == NULL)
|
||||||
msg->txt = throw_strdup("\r\rConfirmation Receipt\r\r");
|
msg->txt = throw_strdup("\r\rConfirmation Receipt\r\r");
|
||||||
|
|
||||||
TokenXlat(mode, msg->txt, strlen(msg->txt)+1, true, msg, omsg, CurrArea);
|
TokenXlat(mode, msg->txt, strlen(msg->txt)+1, true, msg, omsg, CurrArea);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -293,9 +293,6 @@ int MsgIsTwit(GMsg* msg, bool& istwitto, bool& istwitsubj);
|
|||||||
uint32_t MsgHasReplies(GMsg* msg);
|
uint32_t MsgHasReplies(GMsg* msg);
|
||||||
gkey ViewMessage(int istwit=NOT_TWIT);
|
gkey ViewMessage(int istwit=NOT_TWIT);
|
||||||
int LoadMessage(GMsg* msg, int margin);
|
int LoadMessage(GMsg* msg, int margin);
|
||||||
#ifdef OLD_STYLE_HEADER
|
|
||||||
void DispHeader(GMsg* msg, bool prn, FILE* fp=NULL, int width=-1);
|
|
||||||
#endif
|
|
||||||
void LoadRawMsg(GMsg* msg, int margin);
|
void LoadRawMsg(GMsg* msg, int margin);
|
||||||
|
|
||||||
void make_pathreport(char* reportfile);
|
void make_pathreport(char* reportfile);
|
||||||
|
@ -32,15 +32,14 @@
|
|||||||
|
|
||||||
static void ReadGldFile() {
|
static void ReadGldFile() {
|
||||||
|
|
||||||
if(QWK->FoundBBS()) {
|
if (QWK->FoundBBS())
|
||||||
|
{
|
||||||
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());
|
||||||
gfile fp(gldfile, "rt");
|
|
||||||
|
|
||||||
|
gfile fp(gldfile, "rt");
|
||||||
if (fp.isopen())
|
if (fp.isopen())
|
||||||
{
|
{
|
||||||
char* key;
|
char* key;
|
||||||
@ -54,7 +53,6 @@ static void ReadGldFile() {
|
|||||||
if(QWK->FindEcho(val))
|
if(QWK->FindEcho(val))
|
||||||
QWK->ConfNo(atoi(key));
|
QWK->ConfNo(atoi(key));
|
||||||
}
|
}
|
||||||
fp.Fclose();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -336,7 +334,6 @@ int ImportQWK() {
|
|||||||
}
|
}
|
||||||
na++;
|
na++;
|
||||||
}
|
}
|
||||||
fp.Fclose();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,8 +29,8 @@
|
|||||||
|
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
|
|
||||||
char* GetRandomLine(char* __buf, size_t __bufsize, const char* file) {
|
char* GetRandomLine(char* __buf, size_t __bufsize, const char* file)
|
||||||
|
{
|
||||||
Path indexfile;
|
Path indexfile;
|
||||||
Path __file;
|
Path __file;
|
||||||
|
|
||||||
@ -39,10 +39,10 @@ char* GetRandomLine(char* __buf, size_t __bufsize, const char* file) {
|
|||||||
|
|
||||||
replaceextension(indexfile, __file, ".sdx");
|
replaceextension(indexfile, __file, ".sdx");
|
||||||
|
|
||||||
FILE* fp = fsopen(AddPath(CFG->goldpath, __file), "rb", CFG->sharemode);
|
gfile fp(AddPath(CFG->goldpath, __file), "rb", CFG->sharemode);
|
||||||
if(fp) {
|
if (fp.isopen())
|
||||||
|
{
|
||||||
setvbuf(fp, NULL, _IOFBF, 32000);
|
fp.SetvBuf(NULL, _IOFBF, 32000);
|
||||||
|
|
||||||
// Check if index exists or if it is older than the textfile
|
// Check if index exists or if it is older than the textfile
|
||||||
const char* idxfile = AddPath(CFG->goldpath, indexfile);
|
const char* idxfile = AddPath(CFG->goldpath, indexfile);
|
||||||
@ -52,45 +52,45 @@ char* GetRandomLine(char* __buf, size_t __bufsize, const char* file) {
|
|||||||
idxexist = false;
|
idxexist = false;
|
||||||
|
|
||||||
// Create index if one was missing
|
// Create index if one was missing
|
||||||
if(not idxexist) {
|
if (not idxexist)
|
||||||
FILE* fpi = fsopen(idxfile, "wb", CFG->sharemode);
|
{
|
||||||
if(fpi) {
|
gfile fpi(idxfile, "wb", CFG->sharemode);
|
||||||
setvbuf(fpi, NULL, _IOFBF, 16000);
|
if (fpi.isopen())
|
||||||
|
{
|
||||||
|
fpi.SetvBuf(NULL, _IOFBF, 16000);
|
||||||
long fpos = 0;
|
long fpos = 0;
|
||||||
char buf[512];
|
char buf[512];
|
||||||
while(fgets(buf, sizeof(buf), fp)) {
|
while (fp.Fgets(buf, sizeof(buf)))
|
||||||
fwrite(&fpos, sizeof(long), 1, fpi);
|
{
|
||||||
|
fpi.Fwrite(&fpos, sizeof(long));
|
||||||
fpos += strlen(buf);
|
fpos += strlen(buf);
|
||||||
}
|
}
|
||||||
fclose(fpi);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FILE* fpi = fsopen(idxfile, "rb", CFG->sharemode);
|
gfile fpi(idxfile, "rb", CFG->sharemode);
|
||||||
if(fpi) {
|
if (fpi.isopen())
|
||||||
|
{
|
||||||
setvbuf(fpi, NULL, _IOFBF, 16000);
|
fpi.SetvBuf(NULL, _IOFBF, 16000);
|
||||||
|
|
||||||
// Get random line if there is at least one
|
// Get random line if there is at least one
|
||||||
int _lines = (int)(fsize(fpi)/sizeof(long));
|
int _lines = (int)(fpi.FileLength()/sizeof(long));
|
||||||
if(_lines > 0) {
|
if(_lines > 0) {
|
||||||
|
|
||||||
// Select a random line
|
// Select a random line
|
||||||
long _offset = 0;
|
long _offset = 0;
|
||||||
long _ourline = rand() % _lines;
|
long _ourline = rand() % _lines;
|
||||||
fseek(fpi, _ourline*(long)sizeof(long), SEEK_SET);
|
fpi.FseekSet(_ourline, (long)sizeof(long));
|
||||||
fread(&_offset, sizeof(long), 1, fpi);
|
fpi.Fread(&_offset, sizeof(long));
|
||||||
|
|
||||||
// Get it
|
// Get it
|
||||||
char buf[512];
|
char buf[512];
|
||||||
fseek(fp, _offset, SEEK_SET);
|
fp.FseekSet(_offset);
|
||||||
fgets(buf, sizeof(buf), fp);
|
fp.Fgets(buf, sizeof(buf));
|
||||||
StripQuotes(strbtrim(buf));
|
StripQuotes(strbtrim(buf));
|
||||||
strxcpy(__buf, buf, __bufsize);
|
strxcpy(__buf, buf, __bufsize);
|
||||||
}
|
}
|
||||||
fclose(fpi);
|
|
||||||
}
|
}
|
||||||
fclose(fp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return __buf;
|
return __buf;
|
||||||
|
@ -516,12 +516,13 @@ void DosShell() {
|
|||||||
|
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
|
|
||||||
void TouchNetscan(int popup) {
|
void TouchNetscan(int popup)
|
||||||
|
{
|
||||||
FILE* fp = fsopen(AddPath(CFG->areapath, CFG->semaphore.netscan), "wb", CFG->sharemode);
|
gfile fp(AddPath(CFG->areapath, CFG->semaphore.netscan), "wb", CFG->sharemode);
|
||||||
if(fp) {
|
if (fp.isopen())
|
||||||
fclose(fp);
|
{
|
||||||
if(popup) {
|
if (popup)
|
||||||
|
{
|
||||||
w_infof(" %s ", CFG->semaphore.netscan);
|
w_infof(" %s ", CFG->semaphore.netscan);
|
||||||
HandleGEvent(EVTT_JOBDONE);
|
HandleGEvent(EVTT_JOBDONE);
|
||||||
waitkeyt(10000);
|
waitkeyt(10000);
|
||||||
@ -584,7 +585,6 @@ int ExternUtil(GMsg *msg, ExtUtil *extutil) {
|
|||||||
fp.Printf("--- %s\n", msg->tearline);
|
fp.Printf("--- %s\n", msg->tearline);
|
||||||
if (*msg->origin)
|
if (*msg->origin)
|
||||||
fp.Printf(" * Origin: %s\n", msg->origin);
|
fp.Printf(" * Origin: %s\n", msg->origin);
|
||||||
fp.Fclose();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -873,9 +873,8 @@ void UUDecode(GMsg* msg) {
|
|||||||
|
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
|
|
||||||
void Make_Userlist(const char* userlist) {
|
void Make_Userlist(const char* userlist)
|
||||||
|
{
|
||||||
FILE* fp;
|
|
||||||
word* crclist;
|
word* crclist;
|
||||||
word crc, crcs=0;
|
word crc, crcs=0;
|
||||||
uint n, x;
|
uint n, x;
|
||||||
@ -884,8 +883,9 @@ void Make_Userlist(const char* userlist) {
|
|||||||
GMsg* msg = (GMsg*)throw_calloc(1, sizeof(GMsg));
|
GMsg* msg = (GMsg*)throw_calloc(1, sizeof(GMsg));
|
||||||
|
|
||||||
crclist = (word*)throw_calloc(AA->Msgn.Count()+1, sizeof(word));
|
crclist = (word*)throw_calloc(AA->Msgn.Count()+1, sizeof(word));
|
||||||
fp = fsopen(userlist, "ab", CFG->sharemode);
|
gfile fp(userlist, "ab", CFG->sharemode);
|
||||||
if(fp) {
|
if (fp.isopen())
|
||||||
|
{
|
||||||
w_progress(MODE_NEW, C_INFOW, 0, AA->Msgn.Count(), LNG->GenUserlist);
|
w_progress(MODE_NEW, C_INFOW, 0, AA->Msgn.Count(), LNG->GenUserlist);
|
||||||
for(n=AA->Msgn.Count(); n; n--) {
|
for(n=AA->Msgn.Count(); n; n--) {
|
||||||
update_statuslinef(LNG->ReadingMsg, "ST_READINGMSG", n, AA->Msgn.Count());
|
update_statuslinef(LNG->ReadingMsg, "ST_READINGMSG", n, AA->Msgn.Count());
|
||||||
@ -895,16 +895,16 @@ void Make_Userlist(const char* userlist) {
|
|||||||
for(x=0; x<crcs; x++)
|
for(x=0; x<crcs; x++)
|
||||||
if(crclist[x] == crc)
|
if(crclist[x] == crc)
|
||||||
break; // We have already used it
|
break; // We have already used it
|
||||||
if(x >= crcs) {
|
if (x >= crcs)
|
||||||
|
{
|
||||||
crclist[crcs++] = crc;
|
crclist[crcs++] = crc;
|
||||||
strrevname(userline, msg->by);
|
strrevname(userline, msg->by);
|
||||||
msg->orig.make_string(adrs);
|
msg->orig.make_string(adrs);
|
||||||
fprintf(fp, "%-36.36s%24.24s\r\n", userline, adrs);
|
fp.Printf("%-36.36s%24.24s\r\n", userline, adrs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw_free(crclist);
|
throw_free(crclist);
|
||||||
w_progress(MODE_QUIT, BLACK_|_BLACK, 0, 0, NULL);
|
w_progress(MODE_QUIT, BLACK_|_BLACK, 0, 0, NULL);
|
||||||
fclose(fp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ResetMsg(msg);
|
ResetMsg(msg);
|
||||||
@ -983,7 +983,6 @@ void make_pathreport(const char* reportfile)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
w_progress(MODE_QUIT, BLACK_|_BLACK, 0, 0, NULL);
|
w_progress(MODE_QUIT, BLACK_|_BLACK, 0, 0, NULL);
|
||||||
fp.Fclose();
|
|
||||||
ResetMsg(msg);
|
ResetMsg(msg);
|
||||||
throw_free(msg);
|
throw_free(msg);
|
||||||
}
|
}
|
||||||
|
@ -554,8 +554,6 @@ int ImportSOUP() {
|
|||||||
AA->Close();
|
AA->Close();
|
||||||
|
|
||||||
if (msgs) importedmsgs += msgs;
|
if (msgs) importedmsgs += msgs;
|
||||||
|
|
||||||
fpm.Fclose();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,15 +69,13 @@ inline int IsInitial(char c) {
|
|||||||
|
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
|
|
||||||
int TemplateToText(int mode, GMsg* msg, GMsg* oldmsg, const char* tpl, int origarea) {
|
int TemplateToText(int mode, GMsg* msg, GMsg* oldmsg, const char* tpl, int origarea)
|
||||||
|
{
|
||||||
FILE* fp;
|
|
||||||
long fpos;
|
long fpos;
|
||||||
Path tplfile;
|
Path tplfile;
|
||||||
int n;
|
int n;
|
||||||
int x;
|
int x;
|
||||||
FILE *tfp;
|
gfile fp;
|
||||||
FILE *ifp;
|
|
||||||
char* tptr;
|
char* tptr;
|
||||||
char* ptr;
|
char* ptr;
|
||||||
char* ptr2;
|
char* ptr2;
|
||||||
@ -220,27 +218,28 @@ int TemplateToText(int mode, GMsg* msg, GMsg* oldmsg, const char* tpl, int origa
|
|||||||
tmptpl = YES; // Create a temporary template
|
tmptpl = YES; // Create a temporary template
|
||||||
mktemp(strcpy(tplfile, AddPath(CFG->temppath, "GDXXXXXX")));
|
mktemp(strcpy(tplfile, AddPath(CFG->temppath, "GDXXXXXX")));
|
||||||
|
|
||||||
if ((fp = fsopen(tplfile, "wt", CFG->sharemode)) != NULL)
|
fp.Fopen(tplfile, "wt", CFG->sharemode);
|
||||||
|
if (fp.isopen())
|
||||||
{
|
{
|
||||||
fputs("@header= @oecho (@caddr) @align{79}{=}\n"
|
fp.Fputs("@header= @oecho (@caddr) @align{79}{=}\n"
|
||||||
"@header Msg : @msgno of @msgs@align{44}@attr\n", fp);
|
"@header Msg : @msgno of @msgs@align{44}@attr\n");
|
||||||
|
|
||||||
if (AA->isinternet())
|
if (AA->isinternet())
|
||||||
{
|
{
|
||||||
fputs("@header From : @ofrom@align{60}@odtime\n"
|
fp.Fputs("@header From : @ofrom@align{60}@odtime\n"
|
||||||
"@header To : @oto\n", fp);
|
"@header To : @oto\n");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fputs("@header From : @oname@align{44}@oaddr@align{60}@odtime\n", fp);
|
fp.Fputs("@header From : @oname@align{44}@oaddr@align{60}@odtime\n");
|
||||||
|
|
||||||
if (AA->isnet())
|
if (AA->isnet())
|
||||||
fputs("@header To : @dname@align{44}@daddr\n", fp);
|
fp.Fputs("@header To : @dname@align{44}@daddr\n");
|
||||||
else
|
else
|
||||||
fputs("@header To : @dname\n", fp);
|
fp.Fputs("@header To : @dname\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
fputs("@header Subj : @subject\n"
|
fp.Fputs("@header Subj : @subject\n"
|
||||||
"@header@align{79}{=}\n"
|
"@header@align{79}{=}\n"
|
||||||
"@moved* Replying to a msg in @oecho (@odesc)\n@moved\n"
|
"@moved* Replying to a msg in @oecho (@odesc)\n@moved\n"
|
||||||
"@changed* Changed by @cname (@caddr), @cdate @ctime.\n@changed\n"
|
"@changed* Changed by @cname (@caddr), @cdate @ctime.\n@changed\n"
|
||||||
@ -263,13 +262,14 @@ int TemplateToText(int mode, GMsg* msg, GMsg* oldmsg, const char* tpl, int origa
|
|||||||
"@quotebuf@odate @otime, @oname{I}{you} wrote to @dname{me}{you}{all}:\n"
|
"@quotebuf@odate @otime, @oname{I}{you} wrote to @dname{me}{you}{all}:\n"
|
||||||
"@quotebuf\n"
|
"@quotebuf\n"
|
||||||
"@quote\n\n"
|
"@quote\n\n"
|
||||||
"@cfname\n\n", fp);
|
"@cfname\n\n");
|
||||||
fclose(fp);
|
fp.Fclose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fp = fsopen(tplfile, "rt", CFG->sharemode);
|
fp.Fopen(tplfile, "rt", CFG->sharemode);
|
||||||
if(fp == NULL) {
|
if (!fp.isopen())
|
||||||
|
{
|
||||||
LOG.ErrOpen();
|
LOG.ErrOpen();
|
||||||
LOG.printf("! A template file could not be opened.");
|
LOG.printf("! A template file could not be opened.");
|
||||||
LOG.printf(": %s", tplfile);
|
LOG.printf(": %s", tplfile);
|
||||||
@ -332,7 +332,7 @@ int TemplateToText(int mode, GMsg* msg, GMsg* oldmsg, const char* tpl, int origa
|
|||||||
size_t oldmsg_size = oldmsg->txt ? strlen(oldmsg->txt) : REALLOC_CACHE_SIZE;
|
size_t oldmsg_size = oldmsg->txt ? strlen(oldmsg->txt) : REALLOC_CACHE_SIZE;
|
||||||
size_t msg_txt_realloc_cache = 0;
|
size_t msg_txt_realloc_cache = 0;
|
||||||
|
|
||||||
while(fgets(buf, sizeofbuf, fp))
|
while (fp.Fgets(buf, sizeofbuf))
|
||||||
{
|
{
|
||||||
ptr = strskip_wht(buf);
|
ptr = strskip_wht(buf);
|
||||||
if(*ptr != ';') {
|
if(*ptr != ';') {
|
||||||
@ -589,17 +589,21 @@ int TemplateToText(int mode, GMsg* msg, GMsg* oldmsg, const char* tpl, int origa
|
|||||||
CookieIndex(textfile, indexfile);
|
CookieIndex(textfile, indexfile);
|
||||||
|
|
||||||
// Get a random cookie
|
// Get a random cookie
|
||||||
tfp = fsopen(textfile, "rt", CFG->sharemode);
|
gfile tfp(textfile, "rt", CFG->sharemode);
|
||||||
if(tfp) {
|
if (tfp.isopen())
|
||||||
ifp = fsopen(indexfile, "rb", CFG->sharemode);
|
{
|
||||||
if(ifp) {
|
gfile ifp(indexfile, "rb", CFG->sharemode);
|
||||||
fseek(ifp, 0L, SEEK_END);
|
if (ifp.isopen())
|
||||||
int idxs = (int)(ftell(ifp)/sizeof(long));
|
{
|
||||||
if(idxs) {
|
ifp.Fseek(0L, SEEK_END);
|
||||||
fseek(ifp, (long)(rand()%idxs)*sizeof(long), SEEK_SET);
|
int idxs = (int)(ifp.Ftell()/sizeof(long));
|
||||||
fread(&fpos, sizeof(long), 1, ifp);
|
if (idxs)
|
||||||
fseek(tfp, fpos, SEEK_SET);
|
{
|
||||||
while(fgets(buf, 255, tfp)) {
|
ifp.FseekSet((long)(rand()%idxs), sizeof(long));
|
||||||
|
ifp.Fread(&fpos, sizeof(long));
|
||||||
|
tfp.FseekSet(fpos);
|
||||||
|
while (tfp.Fgets(buf, 255))
|
||||||
|
{
|
||||||
strtrim(buf);
|
strtrim(buf);
|
||||||
if(*buf) {
|
if(*buf) {
|
||||||
if(*buf == '+' and buf[1] == NUL)
|
if(*buf == '+' and buf[1] == NUL)
|
||||||
@ -623,21 +627,22 @@ int TemplateToText(int mode, GMsg* msg, GMsg* oldmsg, const char* tpl, int origa
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fclose(ifp);
|
|
||||||
}
|
}
|
||||||
fclose(tfp);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case TPLTOKEN_INCLUDE:
|
case TPLTOKEN_INCLUDE:
|
||||||
if(mode != MODE_QUOTEBUF) {
|
if(mode != MODE_QUOTEBUF)
|
||||||
|
{
|
||||||
strbtrim(ptr);
|
strbtrim(ptr);
|
||||||
strcpy(textfile, ptr);
|
strcpy(textfile, ptr);
|
||||||
MakePathname(textfile, CFG->templatepath, textfile);
|
MakePathname(textfile, CFG->templatepath, textfile);
|
||||||
tfp = fsopen(textfile, "rt", CFG->sharemode);
|
gfile tfp(textfile, "rt", CFG->sharemode);
|
||||||
if(tfp) {
|
if (tfp.isopen())
|
||||||
while(fgets(buf, 255, tfp)) {
|
{
|
||||||
|
while (tfp.Fgets(buf, 255))
|
||||||
|
{
|
||||||
TokenXlat(mode, buf, sizeofbuf, true, msg, oldmsg, origarea);
|
TokenXlat(mode, buf, sizeofbuf, true, msg, oldmsg, origarea);
|
||||||
strtrim(buf);
|
strtrim(buf);
|
||||||
strcat(buf, "\r");
|
strcat(buf, "\r");
|
||||||
@ -653,7 +658,6 @@ int TemplateToText(int mode, GMsg* msg, GMsg* oldmsg, const char* tpl, int origa
|
|||||||
strcpy(&(msg->txt[pos]), buf);
|
strcpy(&(msg->txt[pos]), buf);
|
||||||
pos += len;
|
pos += len;
|
||||||
}
|
}
|
||||||
fclose(tfp);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
@ -882,7 +886,7 @@ int TemplateToText(int mode, GMsg* msg, GMsg* oldmsg, const char* tpl, int origa
|
|||||||
loop_next:
|
loop_next:
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
fclose(fp);
|
fp.Fclose();
|
||||||
|
|
||||||
if((mode != MODE_CHANGE) and (mode != MODE_QUOTEBUF) and
|
if((mode != MODE_CHANGE) and (mode != MODE_QUOTEBUF) and
|
||||||
(mode != MODE_HEADER) and (mode != MODE_WRITEHEADER) and
|
(mode != MODE_HEADER) and (mode != MODE_WRITEHEADER) and
|
||||||
|
@ -86,7 +86,6 @@ void WriteNoDupes(const char* file, const char* line) {
|
|||||||
fp.Fseek(0, SEEK_END);
|
fp.Fseek(0, SEEK_END);
|
||||||
fp.Printf("%s\n", line);
|
fp.Printf("%s\n", line);
|
||||||
}
|
}
|
||||||
fp.Fclose();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -136,10 +135,11 @@ void FreqWaZOO(const char* files, const Addr& dest, const Attr& attr) {
|
|||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
FILE* fcs = fopen(tmp, "at");
|
gfile fcs(tmp, "at");
|
||||||
if(fcs) {
|
if (fcs.isopen())
|
||||||
fprintf(fcs, "%s\n", buf);
|
{
|
||||||
fclose(fcs);
|
fcs.Printf("%s\n", buf);
|
||||||
|
fcs.Fclose();
|
||||||
}
|
}
|
||||||
|
|
||||||
strcpy(tmp, filename);
|
strcpy(tmp, filename);
|
||||||
|
@ -119,13 +119,6 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------------ */
|
|
||||||
#if defined(_MSC_VER)
|
|
||||||
#define popen(f,m) _popen(f,m)
|
|
||||||
#define pclose(fh) _pclose(fh)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------------
|
/* ------------------------------------------------------------------
|
||||||
// Special character constants */
|
// Special character constants */
|
||||||
|
|
||||||
|
@ -31,6 +31,9 @@
|
|||||||
|
|
||||||
#if defined(_MSC_VER) /*&& (_MSC_VER >= 1400)*/
|
#if defined(_MSC_VER) /*&& (_MSC_VER >= 1400)*/
|
||||||
|
|
||||||
|
#define g_popen(comm, mode) _tpopen(comm, mode)
|
||||||
|
#define g_pclose(fp) _pclose(fp)
|
||||||
|
|
||||||
#define g_sopen(fn, of, sh, pm) _tsopen(fn, of, sh, pm)
|
#define g_sopen(fn, of, sh, pm) _tsopen(fn, of, sh, pm)
|
||||||
#define g_close(fh) _close(fh)
|
#define g_close(fh) _close(fh)
|
||||||
#define g_read(fh, buf, cnt) _read(fh, buf, cnt)
|
#define g_read(fh, buf, cnt) _read(fh, buf, cnt)
|
||||||
@ -46,6 +49,9 @@
|
|||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
#define g_popen(comm, mode) popen(comm, mode)
|
||||||
|
#define g_pclose(fp) pclose(fp)
|
||||||
|
|
||||||
#define g_sopen(fn, of, sh, pm) sopen(fn, of, sh, pm)
|
#define g_sopen(fn, of, sh, pm) sopen(fn, of, sh, pm)
|
||||||
#define g_close(fh) close(fh)
|
#define g_close(fh) close(fh)
|
||||||
#define g_read(fh, buf, cnt) read(fh, buf, cnt)
|
#define g_read(fh, buf, cnt) read(fh, buf, cnt)
|
||||||
@ -86,24 +92,24 @@ gfile::gfile()
|
|||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
|
/*
|
||||||
gfile::gfile(int __fh)
|
gfile::gfile(int __fh)
|
||||||
{
|
{
|
||||||
fh = __fh;
|
fh = __fh;
|
||||||
fp = NULL;
|
fp = NULL;
|
||||||
status = 0;
|
status = 0;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
|
/*
|
||||||
gfile::gfile(FILE* __fp)
|
gfile::gfile(FILE* __fp)
|
||||||
{
|
{
|
||||||
fh = -1;
|
fh = -1;
|
||||||
fp = __fp;
|
fp = __fp;
|
||||||
status = 0;
|
status = 0;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
|
|
||||||
@ -290,6 +296,17 @@ FILE* gfile::Fopen(const char* __path, const char* __mode, int __shflag)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------
|
||||||
|
|
||||||
|
FILE* gfile::Popen(const char* __path, const char* __mode)
|
||||||
|
{
|
||||||
|
fp = g_popen(__path, __mode);
|
||||||
|
status = (fp == NULL) ? errno : 0;
|
||||||
|
if (fp) fh = g_fileno(fp);
|
||||||
|
return fp;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
|
|
||||||
FILE* gfile::Fdopen(const char* __mode)
|
FILE* gfile::Fdopen(const char* __mode)
|
||||||
@ -312,6 +329,18 @@ int gfile::Fclose()
|
|||||||
return _ret;
|
return _ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------
|
||||||
|
|
||||||
|
int gfile::Pclose()
|
||||||
|
{
|
||||||
|
int _ret = 0;
|
||||||
|
if (fp) _ret = g_pclose(fp);
|
||||||
|
status = _ret ? errno : 0;
|
||||||
|
fp = NULL; fh = -1;
|
||||||
|
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)
|
||||||
|
@ -72,8 +72,8 @@ public:
|
|||||||
// Constructors and destructor
|
// Constructors and destructor
|
||||||
|
|
||||||
gfile(); // Bare constructor
|
gfile(); // Bare constructor
|
||||||
gfile(int __fh); // Construct from Unix file handle
|
// gfile(int __fh); // Construct from Unix file handle
|
||||||
gfile(FILE* __fp); // Construct from ANSI stream pointer
|
// gfile(FILE* __fp); // Construct from ANSI stream pointer
|
||||||
gfile(const char* __path, int __access, int __shflag=SH_DENYNO, int __mode=S_IREAD|S_IWRITE);
|
gfile(const char* __path, int __access, int __shflag=SH_DENYNO, int __mode=S_IREAD|S_IWRITE);
|
||||||
gfile(const char* __path, const char* __mode, int __shflag=SH_DENYNO);
|
gfile(const char* __path, const char* __mode, int __shflag=SH_DENYNO);
|
||||||
|
|
||||||
@ -120,6 +120,10 @@ public:
|
|||||||
FILE* Fdopen (const char* __mode);
|
FILE* Fdopen (const char* __mode);
|
||||||
int Fclose ();
|
int Fclose ();
|
||||||
|
|
||||||
|
FILE* Popen (const char* __path, const char* __mode);
|
||||||
|
FILE* Popen (const std::string& __path, const char* __mode) { return Popen(__path.c_str(), __mode); }
|
||||||
|
int Pclose ();
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
|
@ -642,13 +642,13 @@ UUDecodeLine (char *s, char *d, int method)
|
|||||||
cc |= (c >> 2);
|
cc |= (c >> 2);
|
||||||
|
|
||||||
if(i-- > 0)
|
if(i-- > 0)
|
||||||
d[count++] = cc;
|
d[count++] = (char)(cc & 0xFF);
|
||||||
|
|
||||||
c <<= 6;
|
c <<= 6;
|
||||||
c |= table[ACAST(*s++)];
|
c |= table[ACAST(*s++)];
|
||||||
|
|
||||||
if(i-- > 0)
|
if(i-- > 0)
|
||||||
d[count++] = c;
|
d[count++] = (char)(c & 0xFF);
|
||||||
|
|
||||||
j -= 4;
|
j -= 4;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user