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: gxraecho.cpp,v 1.6 2006/01/20 11:55:12 stas_degteff Exp $
23 // ------------------------------------------------------------------
24 // Read areas from RA-ECHO (1.00 - 1.xx)
25 // ------------------------------------------------------------------
26
27 #include <cstdlib>
28 #include <gstrall.h>
29 #if defined(__GOLD_GUI__)
30 #include <gvidall.h>
31 #include <gvidgui.h>
32 #endif
33 #undef GCFG_NORAECHO
34 #include <gedacfg.h>
35 #include <gs_recho.h>
36
37
38 // ------------------------------------------------------------------
39 // Read Ra-Echo AREAS.RAE
40
ReadRaEcho(char * tag)41 void gareafile::ReadRaEcho(char* tag) {
42
43 AreaCfg aa;
44 FILE* fp;
45 char* ptr;
46 long raesize;
47 char options[80];
48 Path repath, file;
49 int raever, areano;
50 TRaEchoArea101 area;
51
52 *repath = NUL;
53 strcpy(options, tag);
54 ptr = strtok(tag, " \t");
55 while(ptr) {
56 if(*ptr != '-') {
57 AddBackslash(strcpy(repath, ptr));
58 break;
59 }
60 ptr = strtok(NULL, " \t");
61 }
62 if(*repath == NUL) {
63 ptr = getenv("RAECHO");
64 if(ptr)
65 AddBackslash(strcpy(repath, ptr));
66 }
67 if(*repath == NUL)
68 strcpy(repath, areapath);
69
70 MakePathname(file, repath, "areas.rae");
71
72 raesize = GetFilesize(file);
73 raever = 0;
74 if(raesize == -1) {
75 // Determine RA-ECHO version...
76 if((raesize%(long)sizeof(TRaEchoArea100)) == 0)
77 raever = sizeof(TRaEchoArea100);
78 else if((raesize%(long)sizeof(TRaEchoArea101)) == 0)
79 raever = sizeof(TRaEchoArea101);
80 }
81 if (raever == 0)
82 {
83 if (not quiet)
84 STD_PRINTNL("* Could not determine version of RA-ECHO - skipping.");
85
86 return;
87 }
88
89 fp = fsopen(file, "rb", sharemode);
90 if (fp)
91 {
92 setvbuf(fp, NULL, _IOFBF, 8192);
93
94 if (not quiet)
95 STD_PRINTNL("* Reading " << file);
96
97 areano = 1;
98 while(fread(&area, raever, 1, fp) == 1) {
99
100 if(*area.echoid) {
101 aa.reset();
102 STRNP2C(area.desc);
103 STRNP2C(area.path);
104 STRNP2C(area.echoid);
105 STRNP2C(area.origin);
106 if(area.isopus and *area.path and stricmp(area.path, "P")) {
107 aa.basetype = fidomsgtype;
108 aa.setpath(area.path);
109 }
110 else if(areano <= 200) {
111 aa.basetype = "HUDSON";
112 aa.board = areano;
113 }
114 if(aa.basetype[0] != '\0') {
115 aa.aka = area.addr;
116 switch(area.type) {
117 case RAE_LOCAL:
118 aa.type = GMB_LOCAL;
119 aa.attr = attribslocal;
120 break;
121 case RAE_NET:
122 aa.type = GMB_NET;
123 aa.attr = attribsnet;
124 break;
125 case RAE_ECHO:
126 default:
127 aa.type = GMB_ECHO;
128 aa.attr = attribsecho;
129 }
130 aa.setdesc(area.desc);
131 aa.setechoid(area.echoid);
132 aa.setorigin(area.origin);
133 AddNewArea(aa);
134 }
135 }
136
137 areano++;
138 }
139
140 fclose(fp);
141 }
142 }
143
144
145 // ------------------------------------------------------------------
146