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/goldlib/gcfg/gxqecho.cpp

115 lines
3.3 KiB
C++
Raw Normal View History

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$
// ------------------------------------------------------------------
// Read areas from QEcho (by Eugene Sorochinsky)
// ------------------------------------------------------------------
#include <cstdlib>
#include <gcrcall.h>
#include <gstrall.h>
#undef GCFG_NOQECHO
2000-02-25 10:15:17 +00:00
#include <gedacfg.h>
// ------------------------------------------------------------------
void gareafile::ReadQEchoFile(char* file, char* options, char* origin) {
AreaCfg aa;
char buf[512];
FILE* fp = fsopen(file, "rb", sharemode);
if(fp) {
setvbuf(fp, NULL, _IOFBF, 8192);
if(not quiet)
std::cout << "* Reading " << file << std::endl;
2000-02-25 10:15:17 +00:00
while(fgets(buf, sizeof(buf), fp)) {
char* ptr = strtok(buf, " \t");
aa.reset();
2002-05-12 13:07:37 +00:00
if(isdigit(*ptr))
aa.groupid = 0x8000+atoi(ptr);
else if(isalpha(*ptr))
aa.groupid = toupper(*ptr);
2000-02-25 10:15:17 +00:00
if((ptr = strtok(NULL, " \t")) != NULL) {
if(*ptr == '*') {
// skip ExpireDays
if((ptr = strtok(NULL, " \t")) == NULL)
continue;
if((ptr = strtok(NULL, " \t")) == NULL)
continue;
}
aa.type = GMB_ECHO;
aa.setechoid(ptr);
if((ptr = strtok(NULL, " \t")) != NULL)
if(not strieql("Passthrough", ptr)) {
aa.setpath(ptr);
2003-12-10 08:35:16 +00:00
aa.basetype = "JAM";
2000-02-25 10:15:17 +00:00
if((ptr = strtok(NULL, " \t")) != NULL)
if((*ptr == '*') and ((ptr = strtok(NULL, " \t")) != NULL)) {
CfgAddress(ptr);
aa.aka.set(ptr);
aa.attr = attribsecho;
aa.setorigin(origin);
AddNewArea(aa);
}
}
}
}
fclose(fp);
}
}
// ------------------------------------------------------------------
// Read areas from QEcho (echomail processor)
void gareafile::ReadQEcho(char* tag) {
char origin[80];
char options[80];
Path file;
*origin = NUL;
*file = NUL;
strcpy(options, tag);
char* ptr = strtok(tag, " \t");
while(ptr) {
if(*ptr != '-')
strcpy(file, ptr);
ptr = strtok(NULL, " \t");
}
if(not *file)
strcpy(file, "/etc/qecho/AreaList");
ReadQEchoFile(file, options, origin);
}
// ------------------------------------------------------------------