This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
deb-goldedplus/golded3/gmarea.cpp

363 lines
7.9 KiB
C++
Raw Normal View History

2000-02-25 11:04:07 +00:00
// ------------------------------------------------------------------
// GoldED+
// Copyright (C) 1990-1999 Odinn Sorensen
// Copyright (C) 1999-2000 Alexander S. Aganichev
// ------------------------------------------------------------------
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; either version 2 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston,
// MA 02111-1307 USA
// ------------------------------------------------------------------
// $Id$
// ------------------------------------------------------------------
// Area functions.
// ------------------------------------------------------------------
#include <golded.h>
// ------------------------------------------------------------------
int SearchTaglist(Echo* taglist, char* tag) {
int n = 0;
while(*taglist[n]) {
if(strieql(taglist[n], tag))
break;
n++;
}
return(n);
}
// ------------------------------------------------------------------
// Update exportlist scanning file
void WriteNoDupes(const char* file, const char* line) {
gfile fp;
Path buf;
bool found = false;
long tries = 0;
do {
2006-04-24 16:38:44 +00:00
fp.Fopen(file, "at+", SH_DENYRW);
2000-02-25 11:04:07 +00:00
2006-04-24 16:38:44 +00:00
if (!fp.isopen())
{
2000-02-25 11:04:07 +00:00
if((errno != EACCES) or (PopupLocked(++tries, false, file) == false)) {
LOG.ErrOpen();
LOG.printf("! A semaphore file could not be opened.");
LOG.printf(": %s", file);
LOG.ErrOSInfo();
OpenErrorExit();
}
}
2006-04-24 16:38:44 +00:00
}
while(!fp.isopen());
2000-02-25 11:04:07 +00:00
2006-04-24 16:38:44 +00:00
if (tries)
2000-02-25 11:04:07 +00:00
PopupLocked(0, 0, NULL);
2006-04-24 16:38:44 +00:00
fp.FseekSet(0);
while (fp.Fgets(buf, sizeof(buf)))
{
2000-02-25 11:04:07 +00:00
if(strieql(strtrim(buf), line)) {
found = true;
break;
}
}
2006-04-24 16:38:44 +00:00
if (not found)
{
fp.Fseek(0, SEEK_END);
fp.Printf("%s\n", line);
2000-02-25 11:04:07 +00:00
}
}
// ------------------------------------------------------------------
void FreqWaZOO(const char* files, const Addr& dest, const Attr& attr) {
char* buf = throw_strdup(files);
Path filename, outbound, tmp;
StripBackslash(strcpy(outbound, CFG->outboundpath));
strcpy(filename, outbound);
if(dest.zone != CFG->aka[0].addr.zone) {
2001-07-03 04:27:54 +00:00
sprintf(tmp, ".%03x", dest.zone);
2000-02-25 11:04:07 +00:00
strcat(filename, tmp);
if(not is_dir(filename))
mkdir(filename, S_IWUSR);
}
AddBackslash(filename);
2001-07-03 04:27:54 +00:00
sprintf(tmp, "%04x%04x", dest.net, dest.node);
2000-02-25 11:04:07 +00:00
strcat(filename, tmp);
if(dest.point) {
strcat(filename, ".pnt");
if(not is_dir(filename))
mkdir(filename, S_IWUSR);
AddBackslash(filename);
2001-07-03 04:27:54 +00:00
sprintf(tmp, "%08x", dest.point);
2000-02-25 11:04:07 +00:00
strcat(filename, tmp);
}
strcpy(tmp, filename);
// filename now contains everything but the extension, and we are sure
// that the directory exists
strcat(tmp, ".req");
int i = 0;
while(buf[i]) {
if(buf[i] == ' ') {
if(buf[i+1] != '!' and buf[i+1] != '$')
buf[i] = '\n';
}
i++;
}
2006-04-26 17:06:23 +00:00
gfile fcs(tmp, "at");
if (fcs.isopen())
{
fcs.Printf("%s\n", buf);
fcs.Fclose();
2000-02-25 11:04:07 +00:00
}
strcpy(tmp, filename);
char m;
if(attr.imm())
m = 'i';
2000-02-25 11:04:07 +00:00
else if(attr.cra())
m = 'c';
2000-02-25 11:04:07 +00:00
else if(attr.dir())
m = 'd';
2000-02-25 11:04:07 +00:00
else if(attr.hld())
m = 'h';
2000-02-25 11:04:07 +00:00
else
m = 'f';
2000-02-25 11:04:07 +00:00
char buf2[5];
sprintf(buf2, ".%clo", m);
strcat(tmp, buf2);
if(*tmp)
TouchFile(tmp);
throw_free(buf);
}
// ------------------------------------------------------------------
void RenumberArea() {
if(not AA->Renumber()) {
HandleGEvent(EVTT_JOBFAILED);
update_statusline(LNG->NoRenum);
waitkeyt(5000);
reader_keyok = YES;
}
else {
AA->Mark.ResetAll();
AA->Expo.ResetAll();
// Touch the netmail rescan semaphore
if(AA->isnet())
TouchFile(AddPath(CFG->areapath, CFG->semaphore.netscan));
// Tell user we are finished
update_statuslinef("%u %s", "", AA->Msgn.Count(), LNG->Renumbered);
2000-02-25 11:04:07 +00:00
waitkeyt(5000);
}
}
// ------------------------------------------------------------------
void Area::Open() {
2006-11-25 07:26:20 +00:00
if(not adat)
{
// adat = (AreaData*)throw_calloc(1, sizeof(AreaData));
adat = new AreaData;
2000-02-25 11:04:07 +00:00
InitData();
}
area->Msgn = &Msgn;
area->PMrk = &PMrk;
area->open();
isscanned = true;
UpdateAreadata();
}
// ------------------------------------------------------------------
void Area::Close() {
if(isreadpm) {
set_lastread(Msgn.ToReln(lastreadentry()));
isreadpm = false;
}
PMrk.ResetAll();
isreadmark = false;
area->close();
UpdateAreadata();
2006-11-25 07:26:20 +00:00
// throw_release(adat);
delete adat;
adat = 0;
2000-02-25 11:04:07 +00:00
}
// ------------------------------------------------------------------
void Area::Scan() {
if(cmdlinedebughg)
LOG.printf("- Scan: %s", echoid());
scan();
isscanned = true;
UpdateAreadata();
}
// ------------------------------------------------------------------
void Area::SaveMsg(int mode, GMsg* msg) {
if(CFG->switches.get(frqwazoo) and msg->attr.frq()) {
2001-07-23 03:58:14 +00:00
if(not (mode & GMSG_NOLSTUPD))
FreqWaZOO(msg->re, msg->dest, msg->attr);
2000-02-25 11:04:07 +00:00
if(CFG->frqoptions & FREQ_NOWAZOOMSG)
return;
msg->attr.frq0();
}
if(isinternet() or isecho()) { // Adjust fields for compatibility
2000-02-25 11:04:07 +00:00
if(*msg->realby)
strcpy(msg->by, msg->realby);
if(*msg->realto and not isnet())
2000-02-25 11:04:07 +00:00
strcpy(msg->to, msg->realto);
}
// Translate softcr to configured char
2005-10-04 22:43:15 +00:00
if (adat->usesoftcrxlat && EDIT->SoftCrXlat())
{
2000-02-25 11:04:07 +00:00
strchg(msg->by, SOFTCR, EDIT->SoftCrXlat());
strchg(msg->to, SOFTCR, EDIT->SoftCrXlat());
strchg(msg->realby, SOFTCR, EDIT->SoftCrXlat());
strchg(msg->realto, SOFTCR, EDIT->SoftCrXlat());
if(not (msg->attr.frq() or msg->attr.att() or msg->attr.urq()))
strchg(msg->re, SOFTCR, EDIT->SoftCrXlat());
strchg(msg->txt, SOFTCR, EDIT->SoftCrXlat());
}
area->save_msg(mode, msg);
if(not (mode & GMSG_NOLSTUPD) or msg->attr.uns()) {
UpdateAreadata();
if(msg->attr.uns()) {
Path file, line;
if(islocal()) {
errorlevel |= EXIT_LOCAL;
locpost++;
}
else if(isnet()) {
errorlevel |= EXIT_NET;
netpost++;
}
else {
errorlevel |= EXIT_ECHO;
echopost++;
}
2007-01-08 12:09:42 +00:00
if ((basetype() == "JAM") && (isecho() or isnet()))
{
2000-02-25 11:04:07 +00:00
Path p;
sprintf(file, "%s%smail.jam", CFG->jampath, isecho() ? "echo" : "net");
2005-10-07 12:41:11 +00:00
sprintf(line, "%s %u", ReMapPath(strcpy(p, path())), msg->msgno);
2000-02-25 11:04:07 +00:00
WriteNoDupes(file, line);
}
if(isqwk()) {
strcpy(file, AddPath(CFG->goldpath, "goldqwk.lst"));
2005-10-07 12:41:11 +00:00
sprintf(line, "%s %u", echoid(), msg->msgno);
2000-02-25 11:04:07 +00:00
WriteNoDupes(file, line);
}
else if(isinternet()) {
strcpy(file, AddPath(CFG->goldpath, "goldsoup.lst"));
2005-10-07 12:41:11 +00:00
sprintf(line, "%s %u", echoid(), msg->msgno);
2000-02-25 11:04:07 +00:00
WriteNoDupes(file, line);
}
else {
if(not strblank(CFG->semaphore.exportlist)) {
strcpy(file, AddPath(CFG->areapath, CFG->semaphore.exportlist));
sprintf(line, "%s", echoid());
WriteNoDupes(file, line);
}
}
}
}
}
// ------------------------------------------------------------------
void HudsSizewarn() {
whelpcat(H_EWarnMsgtxt);
call_help();
whelpcat(H_General);
}
// ------------------------------------------------------------------
void HGWarnRebuild() {
whelpcat(H_EQbaseRebuild);
call_help();
}
// ------------------------------------------------------------------
void FidoRenumberProgress(const char* s) {
update_statusline(s);
}
// ------------------------------------------------------------------