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: gxfm092.cpp,v 1.5 2006/05/13 16:13:48 ssianky Exp $
23 //  ------------------------------------------------------------------
24 //  Read areas from FMail
25 //  ------------------------------------------------------------------
26 
27 #include <gstrall.h>
28 #include <gmemdbg.h>
29 #undef GCFG_NOFMAIL
30 #include <gedacfg.h>
31 #include <gs_fm092.h>
32 
33 
34 //  ------------------------------------------------------------------
35 
ReadFMail092(gfile & fp,char * path,char * file,char * options)36 void gareafile::ReadFMail092(gfile &fp, char* path, char* file, char* options)
37 {
38   AreaCfg aa;
39 
40   configType* cfg = new configType; throw_new(cfg);
41 
42   fp.Fread(cfg, sizeof(configType));
43   fp.Fclose();
44 
45   // Get Hudson msgbase path
46   CfgHudsonpath(cfg->bbsPath);
47 
48   // Opus-.MSG style netmail
49   if(not strblank(cfg->netPath)) {
50     aa.reset();
51     aa.aka = cfg->akaList[0].nodeNum;
52     aa.basetype = fidomsgtype;
53     aa.type = GMB_NET;
54     aa.attr = attribsnet;
55     aa.setpath(cfg->netPath);
56     aa.setdesc("FMail Netmail");
57     aa.setautoid("NETMAIL");
58     AddNewArea(aa);
59   }
60 
61   // Opus-.MSG style netmail sent
62   if(not strblank(cfg->sentPath)) {
63     aa.reset();
64     aa.aka = cfg->akaList[0].nodeNum;
65     aa.basetype = fidomsgtype;
66     aa.type = GMB_NET;
67     aa.attr = attribsnet;
68     aa.setpath(cfg->sentPath);
69     aa.setdesc("FMail Netmail Sent");
70     aa.setautoid("NET_SENT");
71     AddNewArea(aa);
72   }
73 
74   // Opus-.MSG style netmail rcvd
75   if(not strblank(cfg->rcvdPath)) {
76     aa.reset();
77     aa.aka = cfg->akaList[0].nodeNum;
78     aa.basetype = fidomsgtype;
79     aa.type = GMB_NET;
80     aa.attr = attribsnet;
81     aa.setpath(cfg->rcvdPath);
82     aa.setdesc("FMail Netmail Received");
83     aa.setautoid("NET_RECEIVED");
84     AddNewArea(aa);
85   }
86 
87   // Q-style netmail
88   for(int x=0; x<MAX_AKAS; x++) {
89     if(cfg->netmailBoard[x] and cfg->netmailBoard[x] < 201) {
90       aa.reset();
91       aa.basetype = "HUDSON";
92       aa.type = GMB_NET;
93       aa.attr = attribsnet;
94       aa.board = cfg->netmailBoard[x];
95       aa.aka = cfg->akaList[x].nodeNum;
96       Desc desc;
97       sprintf(desc, "%s", cfg->descrAKA[x]);
98       aa.setdesc(desc);
99       sprintf(desc, "NET_AKA%u", x);
100       aa.setautoid(desc);
101       AddNewArea(aa);
102     }
103   }
104 
105   // Q-style recovery board
106   if(cfg->recBoard and cfg->recBoard < 201) {
107     aa.reset();
108     aa.aka = cfg->akaList[0].nodeNum;
109     aa.basetype = "HUDSON";
110     aa.type = GMB_ECHO;
111     aa.attr = attribsecho;
112     aa.board = cfg->recBoard;
113     aa.setdesc("FMail Recovery Board");
114     aa.setautoid("ECHO_RECOVERY");
115     AddNewArea(aa);
116   }
117 
118   // Q-style badmsgs
119   if(cfg->badBoard and cfg->badBoard < 201) {
120     aa.reset();
121     aa.aka = cfg->akaList[0].nodeNum;
122     aa.basetype = "HUDSON";
123     aa.type = GMB_ECHO;
124     aa.attr = attribsecho;
125     aa.board = cfg->badBoard;
126     aa.setdesc("FMail Bad Echomail Board");
127     aa.setautoid("ECHO_BAD");
128     AddNewArea(aa);
129   }
130 
131   // Q-style dupmsgs
132   if(cfg->dupBoard and cfg->dupBoard < 201) {
133     aa.reset();
134     aa.aka = cfg->akaList[0].nodeNum;
135     aa.basetype = "HUDSON";
136     aa.type = GMB_ECHO;
137     aa.attr = attribsecho;
138     aa.board = cfg->dupBoard;
139     aa.setdesc("FMail Duplicates Board");
140     aa.setautoid("ECHO_DUPES");
141     AddNewArea(aa);
142   }
143 
144   // Personal mail
145   if(not strblank(cfg->pmailPath)) {
146     aa.reset();
147     aa.aka = cfg->akaList[0].nodeNum;
148     aa.basetype = fidomsgtype;
149     aa.type = GMB_ECHO;
150     aa.attr = attribsecho;
151     aa.setpath(cfg->pmailPath);
152     aa.setdesc("FMail Personal Mail");
153     aa.setautoid("ECHO_PERSONAL");
154     AddNewArea(aa);
155   }
156 
157 
158   rawEchoType* ar = new rawEchoType; throw_new(ar);
159 
160   MakePathname(file, path, "fmail.ar");
161 
162   fp.Fopen(file, "rb", sharemode);
163   if (fp.isopen())
164   {
165     while (fp.Fread(ar, sizeof(rawEchoType)))
166     {
167       if(ar->options.active and ar->board and ar->board < 201) {
168 
169         aa.reset();
170         aa.aka = cfg->akaList[ar->address].nodeNum;
171         if(ar->options.local) {
172           aa.type = GMB_LOCAL;
173           aa.attr = attribslocal;
174         }
175         else {
176           aa.type = GMB_ECHO;
177           aa.attr = attribsecho;
178         }
179         switch(ar->msgKindsRA) {
180           case 1:
181             aa.attr.pvt1();
182             break;
183           case 0:
184           case 2:
185             aa.attr.pvt0();
186             break;
187           case 3:
188             aa.attr.r_o1();
189             break;
190         }
191         aa.board = ar->board;
192         aa.basetype = "HUDSON";
193         aa.setdesc(ar->comment);
194         aa.setechoid(ar->areaNameOld[0] ? ar->areaNameOld : ar->areaName);
195         aa.setorigin(ar->originLine);
196         AddNewArea(aa);
197       }
198     }
199 
200     fp.Fclose();
201   }
202 
203   throw_delete(ar);
204   throw_delete(cfg);
205 }
206 
207 
208 //  ------------------------------------------------------------------
209