1 // This may look like C code, but it is really -*- C++ -*-
2
3 // ------------------------------------------------------------------
4 // The Goldware Library
5 // Copyright (C) 1999, 2002 Alexander S. Aganichev
6 // ------------------------------------------------------------------
7 // This library is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU Library General Public
9 // License as published by the Free Software Foundation; either
10 // version 2 of the License, or (at your option) any later version.
11 //
12 // This library is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 // Library General Public License for more details.
16 //
17 // You should have received a copy of the GNU Library General Public
18 // License along with this program; if not, write to the Free
19 // Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
20 // MA 02111-1307, USA
21 // ------------------------------------------------------------------
22 // $Id: gxqecho.cpp,v 1.10 2006/01/20 11:55:12 stas_degteff Exp $
23 // ------------------------------------------------------------------
24 // Read areas from QEcho (by Eugene Sorochinsky)
25 // ------------------------------------------------------------------
26
27 #include <cstdlib>
28 #include <gcrcall.h>
29 #include <gstrall.h>
30 #if defined(__GOLD_GUI__)
31 #include <gvidall.h>
32 #include <gvidgui.h>
33 #endif
34 #undef GCFG_NOQECHO
35 #include <gedacfg.h>
36
37
38 // ------------------------------------------------------------------
39
ReadQEchoFile(char * file,char * options,char * origin)40 void gareafile::ReadQEchoFile(char* file, char* options, char* origin) {
41
42 AreaCfg aa;
43 char buf[512];
44
45 FILE* fp = fsopen(file, "rb", sharemode);
46 if (fp)
47 {
48 setvbuf(fp, NULL, _IOFBF, 8192);
49
50 if (not quiet)
51 STD_PRINTNL("* Reading " << file);
52
53 while(fgets(buf, sizeof(buf), fp)) {
54
55 char* ptr = strtok(buf, " \t");
56 aa.reset();
57
58 if(isdigit(*ptr))
59 aa.groupid = 0x8000+atoi(ptr);
60 else if(g_isalpha(*ptr))
61 aa.groupid = g_toupper(*ptr);
62
63 if((ptr = strtok(NULL, " \t")) != NULL) {
64 if(*ptr == '*') {
65 // skip ExpireDays
66 if((ptr = strtok(NULL, " \t")) == NULL)
67 continue;
68 if((ptr = strtok(NULL, " \t")) == NULL)
69 continue;
70 }
71 aa.type = GMB_ECHO;
72 aa.setechoid(ptr);
73 if((ptr = strtok(NULL, " \t")) != NULL)
74 if(not strieql("Passthrough", ptr)) {
75 aa.setpath(ptr);
76 aa.basetype = "JAM";
77 if((ptr = strtok(NULL, " \t")) != NULL)
78 if((*ptr == '*') and ((ptr = strtok(NULL, " \t")) != NULL)) {
79 CfgAddress(ptr);
80 aa.aka.set(ptr);
81 aa.attr = attribsecho;
82 aa.setorigin(origin);
83 AddNewArea(aa);
84 }
85 }
86 }
87 }
88 fclose(fp);
89 }
90 }
91
92
93 // ------------------------------------------------------------------
94 // Read areas from QEcho (echomail processor)
95
ReadQEcho(char * tag)96 void gareafile::ReadQEcho(char* tag) {
97
98 char origin[80];
99 char options[80];
100 Path file;
101
102 *origin = NUL;
103 *file = NUL;
104 options[79] = 0;
105 strncpy(options, tag, 79);
106 char* ptr = strtok(tag, " \t");
107 while(ptr) {
108 if(*ptr != '-')
109 strcpy(file, ptr);
110 ptr = strtok(NULL, " \t");
111 }
112
113 if(not *file)
114 strcpy(file, "/etc/qecho/AreaList");
115
116 ReadQEchoFile(file, options, origin);
117 }
118
119
120 // ------------------------------------------------------------------
121