1 // This may look like C code, but it is really -*- C++ -*-
2
3 // ------------------------------------------------------------------
4 // The Goldware Library
5 // Copyright (C) 1990-1999 Odinn Sorensen
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: gxezy102.cpp,v 1.8 2006/05/13 16:13:48 ssianky Exp $
23 // ------------------------------------------------------------------
24 // Read areas from Ezycom
25 // ------------------------------------------------------------------
26
27 #include <gstrall.h>
28 #include <gmemdbg.h>
29 #if defined(__GOLD_GUI__)
30 #include <gvidall.h>
31 #include <gvidgui.h>
32 #endif
33 #undef GCFG_NOEZY
34 #include <gedacfg.h>
35 #include <gs_ez102.h>
36
37
38 // ------------------------------------------------------------------
39
ReadEzycom102(gfile & fp,char * path,char * file,char * options)40 void gareafile::ReadEzycom102(gfile &fp, char* path, char* file, char* options)
41 {
42 int n;
43 AreaCfg aa;
44 char abuf[40];
45
46 CONFIGRECORD* config = new CONFIGRECORD; throw_new(config);
47 CONSTANTRECORD* constant = new CONSTANTRECORD; throw_new(constant);
48 MESSAGERECORD* messages = new MESSAGERECORD; throw_new(messages);
49
50 fp.Fread(config, sizeof(CONFIGRECORD));
51 fp.Fclose();
52
53 MakePathname(file, path, "constant.ezy");
54 fp.Fopen(file, "rb", sharemode);
55 if (fp.isopen())
56 {
57 if (not quiet)
58 STD_PRINTNL("* Reading " << file);
59
60 fp.Fread(constant, sizeof(CONSTANTRECORD));
61 fp.Fclose();
62
63 STRNP2C(config->defaultorigin);
64 STRNP2C(config->userbasepath);
65 STRNP2C(config->msgpath);
66 STRNP2C(config->netmailpath);
67 CfgOrigin(config->defaultorigin);
68
69 STRNP2C(constant->sysopname);
70 STRNP2C(constant->sysopalias);
71
72 CfgEzycommsgbase(config->msgpath);
73 CfgEzycomuserbase(config->userbasepath);
74
75 // Fido netmail directory
76 if(not strblank(config->netmailpath)) {
77 aa.reset();
78 aa.basetype = fidomsgtype;
79 aa.type = GMB_NET;
80 aa.attr = attribsnet;
81 aa.aka.zone = constant->netaddress[0].zone;
82 aa.aka.net = constant->netaddress[0].net;
83 aa.aka.node = constant->netaddress[0].node;
84 aa.aka.point = constant->netaddress[0].point;
85 aa.setpath(config->netmailpath);
86 aa.setdesc("Ezycom Netmail");
87 aa.setautoid("NETMAIL");
88 AddNewArea(aa);
89 }
90
91 // Ezycom aka netmail boards
92 for(n=0; n<MAXAKA; n++) {
93 if(constant->netaddress[n].net) {
94 if(constant->netmailboard[n]) {
95 aa.reset();
96 aa.basetype = "EZYCOM";
97 aa.type = GMB_NET;
98 aa.attr = attribsnet;
99 aa.aka.zone = constant->netaddress[n].zone;
100 aa.aka.net = constant->netaddress[n].net;
101 aa.aka.node = constant->netaddress[n].node;
102 aa.aka.point = constant->netaddress[n].point;
103 aa.board = constant->netmailboard[n];
104 Desc desc;
105 sprintf(desc, "Ezycom Netmail Board, %s", constant->netaddress[n].make_string(abuf));
106 aa.setdesc(desc);
107 sprintf(desc, "NET_AKA%u", n);
108 aa.setautoid(desc);
109 AddNewArea(aa);
110 }
111 }
112 }
113
114 // Ezycom watchdog board
115 if(constant->watchmess) {
116 aa.reset();
117 aa.basetype = "EZYCOM";
118 aa.type = GMB_LOCAL;
119 aa.attr = attribslocal;
120 aa.aka.zone = constant->netaddress[0].zone;
121 aa.aka.net = constant->netaddress[0].net;
122 aa.aka.node = constant->netaddress[0].node;
123 aa.aka.point = constant->netaddress[0].point;
124 aa.board = constant->watchmess;
125 aa.setdesc("Ezycom Watchdog Board");
126 aa.setautoid("LOCAL_WATCHDOG");
127 AddNewArea(aa);
128 }
129
130 // Ezycom paging board
131 if(constant->pagemessboard) {
132 aa.reset();
133 aa.basetype = "EZYCOM";
134 aa.type = GMB_LOCAL;
135 aa.attr = attribslocal;
136 aa.aka.zone = constant->netaddress[0].zone;
137 aa.aka.net = constant->netaddress[0].net;
138 aa.aka.node = constant->netaddress[0].node;
139 aa.aka.point = constant->netaddress[0].point;
140 aa.board = constant->pagemessboard;
141 aa.setdesc("Ezycom Paging Board");
142 aa.setautoid("LOCAL_PAGING");
143 AddNewArea(aa);
144 }
145
146 // Ezycom bad logon board
147 if(constant->badpwdmsgboard) {
148 aa.reset();
149 aa.basetype = "EZYCOM";
150 aa.type = GMB_LOCAL;
151 aa.attr = attribslocal;
152 aa.aka.zone = constant->netaddress[0].zone;
153 aa.aka.net = constant->netaddress[0].net;
154 aa.aka.node = constant->netaddress[0].node;
155 aa.aka.point = constant->netaddress[0].point;
156 aa.board = constant->badpwdmsgboard;
157 aa.setdesc("Ezycom Bad Logon Board");
158 aa.setautoid("LOCAL_BADLOGON");
159 AddNewArea(aa);
160 }
161
162 // Ezycom bad qwk board
163 if(constant->qwkmsgboard) {
164 aa.reset();
165 aa.basetype = "EZYCOM";
166 aa.type = GMB_ECHO;
167 aa.attr = attribsecho;
168 aa.aka.zone = constant->netaddress[0].zone;
169 aa.aka.net = constant->netaddress[0].net;
170 aa.aka.node = constant->netaddress[0].node;
171 aa.aka.point = constant->netaddress[0].point;
172 aa.board = constant->qwkmsgboard;
173 aa.setdesc("Ezycom Bad QWK Board");
174 aa.setautoid("ECHO_BADQWK");
175 AddNewArea(aa);
176 }
177
178 // Ezycom bad echomail board
179 if(constant->badmsgboard) {
180 aa.reset();
181 aa.basetype = "EZYCOM";
182 aa.type = GMB_ECHO;
183 aa.attr = attribsecho;
184 aa.aka.zone = constant->netaddress[0].zone;
185 aa.aka.net = constant->netaddress[0].net;
186 aa.aka.node = constant->netaddress[0].node;
187 aa.aka.point = constant->netaddress[0].point;
188 aa.board = constant->badmsgboard;
189 aa.setdesc("Ezycom Bad Echomail Board");
190 aa.setautoid("ECHO_BAD");
191 AddNewArea(aa);
192 }
193
194 MakePathname(file, path, "messages.ezy");
195 fp.Fopen(file, "rb", sharemode);
196 if (fp.isopen())
197 {
198 if (not quiet)
199 STD_PRINTNL("* Reading " << file);
200
201 int record = 1;
202
203 while (fp.Fread(messages, sizeof(MESSAGERECORD)))
204 {
205 if(record <= constant->maxmess) {
206
207 if(*messages->name) {
208
209 switch(messages->typ) {
210
211 case 0: // localmail
212 case 1: // netmail
213 case 2: // echomail
214 case 5: // allmail
215
216 aa.reset();
217
218 STRNP2C(messages->name);
219 STRNP2C(messages->areatag);
220 STRNP2C(messages->originline);
221
222 aa.board = record;
223 aa.basetype = "EZYCOM";
224 aa.groupid = messages->areagroup;
225 aa.setorigin(*messages->originline ? messages->originline : config->defaultorigin);
226
227 aa.setdesc(messages->name);
228 aa.setechoid(messages->areatag);
229
230 switch(messages->typ) {
231 case 0:
232 aa.type = GMB_LOCAL;
233 aa.attr = attribslocal;
234 break;
235 case 1:
236 aa.type = GMB_NET;
237 aa.attr = attribsnet;
238 break;
239 default:
240 aa.type = GMB_ECHO;
241 aa.attr = attribsecho;
242 break;
243 }
244
245 switch(messages->msgkinds) {
246 case 1:
247 aa.attr.pvt1();
248 break;
249 case 0:
250 case 2:
251 aa.attr.pvt0();
252 break;
253 }
254
255 aa.aka.zone = constant->netaddress[messages->originaddress-1].zone;
256 aa.aka.net = constant->netaddress[messages->originaddress-1].net;
257 aa.aka.node = constant->netaddress[messages->originaddress-1].node;
258 aa.aka.point = constant->netaddress[messages->originaddress-1].point;
259
260 AddNewArea(aa);
261
262 break;
263 }
264 }
265 }
266
267 record++;
268 }
269
270 fp.Fclose();
271 }
272 }
273
274 throw_delete(messages);
275 throw_delete(constant);
276 throw_delete(config);
277 }
278
279
280 // ------------------------------------------------------------------
281