2000-02-25 10:15:17 +00:00
|
|
|
// This may look like C code, but it is really -*- C++ -*-
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------
|
|
|
|
// The Goldware Library
|
2002-05-12 13:07:37 +00:00
|
|
|
// Copyright (C) 1999-2002 Alexander S. Aganichev
|
2000-02-25 10:15:17 +00:00
|
|
|
// ------------------------------------------------------------------
|
|
|
|
// This library is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU Library General Public
|
|
|
|
// License as published by the Free Software Foundation; either
|
|
|
|
// version 2 of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This library 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
|
|
|
|
// Library General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Library 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$
|
|
|
|
// ------------------------------------------------------------------
|
2001-05-05 21:41:41 +00:00
|
|
|
// Read areas from Crashmail II/CrashEcho
|
2000-02-25 10:15:17 +00:00
|
|
|
// ------------------------------------------------------------------
|
|
|
|
|
|
|
|
#include <cstdlib>
|
|
|
|
#include <gcrcall.h>
|
|
|
|
#include <gstrall.h>
|
2000-08-23 19:24:19 +00:00
|
|
|
#undef GCFG_NOCMAIL
|
2000-02-25 10:15:17 +00:00
|
|
|
#include <gedacfg.h>
|
|
|
|
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------
|
|
|
|
|
|
|
|
bool gareafile::jbstrcpy(char *dest, char *src, size_t maxlen, size_t *jbc) {
|
|
|
|
size_t d=0;
|
|
|
|
size_t stopchar1,stopchar2;
|
|
|
|
size_t jbcpos;
|
|
|
|
|
|
|
|
jbcpos= *jbc;
|
|
|
|
|
|
|
|
while(isspace(src[jbcpos])) jbcpos++;
|
|
|
|
|
|
|
|
if(src[jbcpos]=='\"') {
|
|
|
|
jbcpos++;
|
|
|
|
stopchar1='\"';
|
|
|
|
stopchar2=0;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
stopchar1=' ';
|
|
|
|
stopchar2=9;
|
|
|
|
}
|
|
|
|
|
|
|
|
while(src[jbcpos]!=stopchar1 and src[jbcpos]!=stopchar2 and src[jbcpos]!='\n' and src[jbcpos]!=NUL and d<maxlen-1) {
|
|
|
|
if(src[jbcpos]=='\\' and src[jbcpos+1]!=NUL and src[jbcpos+1]!='\n') {
|
|
|
|
jbcpos++;
|
|
|
|
dest[d++]=src[jbcpos++];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
dest[d++]=src[jbcpos++];
|
|
|
|
}
|
|
|
|
dest[d]=0;
|
|
|
|
if(isspace(src[jbcpos]) or src[jbcpos]=='\"') jbcpos++;
|
|
|
|
|
|
|
|
*jbc=jbcpos;
|
|
|
|
|
|
|
|
if(d!=0 or stopchar1=='\"') return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------
|
2001-05-05 21:41:41 +00:00
|
|
|
// Read areas from Crashmail II/CrashEcho (echomail processor)
|
2000-02-25 10:15:17 +00:00
|
|
|
|
2001-12-14 15:51:37 +00:00
|
|
|
void gareafile::ReadCrashmailCfg(const char* file) {
|
2000-02-25 10:15:17 +00:00
|
|
|
|
|
|
|
FILE* fp = fsopen(file, "rb", sharemode);
|
|
|
|
if(fp) {
|
|
|
|
setvbuf(fp, NULL, _IOFBF, 8192);
|
|
|
|
|
|
|
|
if(not quiet)
|
2001-07-16 20:35:42 +00:00
|
|
|
std::cout << "* Reading " << file << std::endl;
|
2000-02-25 10:15:17 +00:00
|
|
|
|
|
|
|
char buf[4000];
|
|
|
|
char key[30];
|
|
|
|
char tmp[100], address[50], domain[50];
|
2001-12-14 15:51:37 +00:00
|
|
|
Path path;
|
2000-02-25 10:15:17 +00:00
|
|
|
bool unconfirmed = true;
|
|
|
|
size_t jbcpos;
|
|
|
|
AreaCfg aa;
|
|
|
|
aa.reset();
|
2002-09-29 16:06:10 +00:00
|
|
|
aa.type = GMB_NONE;
|
2000-02-25 10:15:17 +00:00
|
|
|
address[0] = NUL;
|
2000-12-10 08:29:00 +00:00
|
|
|
domain[0] = NUL;
|
2000-02-25 10:15:17 +00:00
|
|
|
|
|
|
|
const word CRC_AKA = 0x13A4;
|
|
|
|
const word CRC_AREA = 0x010B;
|
2001-12-03 22:31:10 +00:00
|
|
|
#ifndef GCFG_NOCECHO
|
|
|
|
const word CRC_AREAFILE = 0xB487;
|
|
|
|
#endif
|
2000-05-25 05:24:33 +00:00
|
|
|
const word CRC_LOCALAREA = 0xAEC1;
|
2000-02-25 10:15:17 +00:00
|
|
|
const word CRC_DESCRIPTION = 0x2DF1;
|
|
|
|
const word CRC_DOMAIN = 0xFFCA;
|
|
|
|
const word CRC_GROUP = 0x1C9B;
|
|
|
|
const word CRC_NETMAIL = 0xE42E;
|
2001-12-03 22:31:10 +00:00
|
|
|
#ifndef GCFG_NOCECHO
|
2001-05-05 21:41:41 +00:00
|
|
|
const word CRC_NETMAILDIR = 0x180A;
|
2001-12-03 22:31:10 +00:00
|
|
|
#endif
|
2000-02-25 10:15:17 +00:00
|
|
|
const word CRC_SYSOP = 0x967F;
|
|
|
|
const word CRC_UNCONFIRMED = 0x195E;
|
|
|
|
|
|
|
|
const word CRC_MSG = 0xCA2E;
|
|
|
|
const word CRC_JAM = 0xA8C3;
|
|
|
|
const word CRC_SQUISH = 0xFCF6;
|
|
|
|
|
2000-05-25 05:24:33 +00:00
|
|
|
word crc16;
|
|
|
|
|
|
|
|
while(fgets(buf, 4000, fp) != NULL) {
|
2000-02-25 10:15:17 +00:00
|
|
|
jbcpos=0;
|
|
|
|
jbstrcpy(key, buf, 30, &jbcpos);
|
2000-05-25 05:24:33 +00:00
|
|
|
switch(crc16 = strCrc16(key)) {
|
2000-02-25 10:15:17 +00:00
|
|
|
case CRC_SYSOP:
|
|
|
|
jbstrcpy(tmp, buf, 100, &jbcpos);
|
|
|
|
CfgUsername(tmp);
|
|
|
|
break;
|
|
|
|
case CRC_AKA:
|
|
|
|
if(address[0]) {
|
|
|
|
strxmerge(tmp, 100, address, "@", domain, NULL);
|
|
|
|
CfgAddress(tmp);
|
|
|
|
}
|
|
|
|
jbstrcpy(address, buf, 50, &jbcpos);
|
|
|
|
break;
|
|
|
|
case CRC_DOMAIN:
|
|
|
|
jbstrcpy(domain, buf, 50, &jbcpos);
|
|
|
|
break;
|
2001-05-05 21:41:41 +00:00
|
|
|
#ifndef GCFG_NOCECHO
|
2001-12-03 22:31:10 +00:00
|
|
|
case CRC_AREAFILE:
|
2001-12-14 15:51:37 +00:00
|
|
|
jbstrcpy(path, buf, sizeof(Path), &jbcpos);
|
|
|
|
ReadCrashmail(path);
|
2001-12-03 22:31:10 +00:00
|
|
|
break;
|
2001-05-05 21:41:41 +00:00
|
|
|
case CRC_NETMAILDIR:
|
2002-09-29 16:06:10 +00:00
|
|
|
if(aa.type != GMB_NONE) {
|
2001-05-05 21:41:41 +00:00
|
|
|
if(not unconfirmed)
|
|
|
|
AddNewArea(aa);
|
|
|
|
aa.reset();
|
|
|
|
}
|
|
|
|
aa.aka = primary_aka;
|
|
|
|
aa.type = GMB_NET;
|
|
|
|
aa.attr = attribsnet;
|
|
|
|
aa.msgbase = fidomsgtype;
|
|
|
|
jbstrcpy(path, buf, sizeof(Path), &jbcpos);
|
|
|
|
aa.setpath(path);
|
|
|
|
aa.setdesc("CrashEcho Netmail");
|
|
|
|
aa.setautoid("NETMAIL");
|
|
|
|
unconfirmed = false;
|
|
|
|
break;
|
|
|
|
#endif
|
2000-02-25 10:15:17 +00:00
|
|
|
case CRC_AREA:
|
|
|
|
case CRC_NETMAIL:
|
2000-09-01 16:23:15 +00:00
|
|
|
case CRC_LOCALAREA:
|
2002-09-29 16:06:10 +00:00
|
|
|
if(aa.type != GMB_NONE) {
|
2000-02-25 10:15:17 +00:00
|
|
|
if(not unconfirmed)
|
|
|
|
AddNewArea(aa);
|
|
|
|
aa.reset();
|
|
|
|
}
|
2000-12-10 08:29:00 +00:00
|
|
|
unconfirmed = false;
|
|
|
|
jbstrcpy(tmp, buf, 100, &jbcpos);
|
|
|
|
if(strieql(tmp, "DEFAULT") or strnieql(tmp, "DEFAULT_", 8)) {
|
2002-09-29 16:06:10 +00:00
|
|
|
aa.type = GMB_NONE;
|
2000-12-10 08:29:00 +00:00
|
|
|
break;
|
|
|
|
}
|
2000-09-01 16:23:15 +00:00
|
|
|
switch(crc16) {
|
|
|
|
case CRC_NETMAIL:
|
|
|
|
aa.type = GMB_NET;
|
2000-02-25 10:15:17 +00:00
|
|
|
aa.attr = attribsnet;
|
|
|
|
break;
|
2000-09-01 16:23:15 +00:00
|
|
|
case CRC_AREA:
|
|
|
|
aa.type = GMB_ECHO;
|
2000-02-25 10:15:17 +00:00
|
|
|
aa.attr = attribsecho;
|
|
|
|
break;
|
2000-09-01 16:23:15 +00:00
|
|
|
case CRC_LOCALAREA:
|
|
|
|
aa.type = GMB_LOCAL;
|
|
|
|
aa.attr = attribslocal;
|
|
|
|
break;
|
2000-02-25 10:15:17 +00:00
|
|
|
}
|
|
|
|
aa.setechoid(tmp);
|
|
|
|
jbstrcpy(tmp, buf, 50, &jbcpos);
|
|
|
|
aa.aka = primary_aka;
|
|
|
|
aa.aka.set(tmp);
|
|
|
|
jbstrcpy(tmp, buf, 10, &jbcpos);
|
|
|
|
switch(strCrc16(tmp)) {
|
|
|
|
case CRC_MSG:
|
|
|
|
aa.msgbase = fidomsgtype;
|
|
|
|
break;
|
|
|
|
case CRC_JAM:
|
|
|
|
aa.msgbase = GMB_JAM;
|
|
|
|
break;
|
|
|
|
case CRC_SQUISH:
|
|
|
|
aa.msgbase = GMB_SQUISH;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
aa.reset();
|
2002-09-29 16:06:10 +00:00
|
|
|
aa.type = GMB_NONE;
|
2000-02-25 10:15:17 +00:00
|
|
|
break;
|
|
|
|
}
|
2002-09-29 16:06:10 +00:00
|
|
|
if(aa.type == GMB_NONE)
|
2000-02-25 10:15:17 +00:00
|
|
|
break;
|
|
|
|
jbstrcpy(path, buf, sizeof(Path), &jbcpos);
|
2001-05-05 21:41:41 +00:00
|
|
|
aa.setpath(path);
|
2000-02-25 10:15:17 +00:00
|
|
|
break;
|
|
|
|
case CRC_DESCRIPTION:
|
|
|
|
jbstrcpy(tmp, buf, 100, &jbcpos);
|
|
|
|
aa.setdesc(tmp);
|
|
|
|
break;
|
|
|
|
case CRC_UNCONFIRMED:
|
|
|
|
unconfirmed = true;
|
|
|
|
break;
|
|
|
|
case CRC_GROUP:
|
2002-05-12 13:07:37 +00:00
|
|
|
if(jbstrcpy(tmp, buf, 100, &jbcpos)) {
|
|
|
|
if(isdigit(tmp[0]))
|
|
|
|
aa.groupid = 0x8000+atoi(tmp);
|
|
|
|
else if(isalpha(tmp[0]))
|
|
|
|
aa.groupid = toupper(tmp[0]);
|
|
|
|
}
|
2000-02-25 10:15:17 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2002-09-29 16:06:10 +00:00
|
|
|
if(aa.type != GMB_NONE) {
|
2000-02-25 10:15:17 +00:00
|
|
|
if(not unconfirmed) {
|
|
|
|
AddNewArea(aa);
|
|
|
|
}
|
2002-09-06 08:43:14 +00:00
|
|
|
}
|
|
|
|
if(address[0]) {
|
2000-02-25 10:15:17 +00:00
|
|
|
strxmerge(tmp, 100, address, "@", domain, NULL);
|
|
|
|
CfgAddress(tmp);
|
|
|
|
}
|
2000-12-20 19:53:25 +00:00
|
|
|
fclose(fp);
|
2000-02-25 10:15:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-12-14 15:51:37 +00:00
|
|
|
// ------------------------------------------------------------------
|
|
|
|
// Initialize parser
|
|
|
|
|
|
|
|
void gareafile::ReadCrashmail(char* tag) {
|
|
|
|
|
|
|
|
Path file, path;
|
|
|
|
char options[80];
|
|
|
|
|
|
|
|
strcpy(options, tag);
|
|
|
|
char* ptr = strtok(tag, " \t");
|
|
|
|
while(ptr) {
|
|
|
|
if(*ptr != '-') {
|
|
|
|
strcpy(file, ptr);
|
2002-04-21 12:01:13 +00:00
|
|
|
strschg_environ(file);
|
2001-12-14 15:51:37 +00:00
|
|
|
}
|
|
|
|
ptr = strtok(NULL, " \t");
|
|
|
|
}
|
|
|
|
|
|
|
|
extractdirname(path, file);
|
|
|
|
|
|
|
|
CfgSquishuserpath(path);
|
|
|
|
|
|
|
|
ReadCrashmailCfg(file);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-02-25 10:15:17 +00:00
|
|
|
// ------------------------------------------------------------------
|