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: gxxbbs.cpp,v 1.11 2007/01/08 12:09:42 ssianky Exp $
23 // ------------------------------------------------------------------
24 // Read areas from AdeptXBBS
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_NOXBBS
35 #include <gedacfg.h>
36 #include <gs_xbbs.h>
37
38
39 // ------------------------------------------------------------------
40
ReadAdeptXbbsFile(char * path,char * file,char * options)41 void gareafile::ReadAdeptXbbsFile(char* path, char* file, char* options) {
42
43 const word CRC_ADDRESS = 0xFDD6;
44 const word CRC_AREABEGIN = 0x44D7;
45 const word CRC_AREAEND = 0xBDEF;
46 const word CRC_DESC = 0x8A2A;
47 const word CRC_FLAGS = 0xF81A;
48 const word CRC_NAME = 0x3B63;
49 const word CRC_NUMBER = 0x2FBC;
50 const word CRC_ORIGIN = 0x4CE5;
51 const word CRC_PATH = 0x0212;
52 const word CRC_USENET = 0xD087;
53
54 AreaCfg aa;
55 uint32_t flags;
56 char buf[512];
57 char name[256];
58 char usenet[256];
59 Path apath;
60
61 FILE* fp = fsopen(file, "rb", sharemode);
62 if (fp)
63 {
64 setvbuf(fp, NULL, _IOFBF, 8192);
65
66 if (not quiet)
67 STD_PRINTNL("* Reading " << file);
68
69 aa.reset();
70
71 while(fgets(buf, sizeof(buf), fp)) {
72
73 char* ptr = strskip_wht(strtrim(buf));
74 if(*ptr != ';' and *ptr) {
75
76 char* key;
77 char* val = ptr;
78 switch(getkeyvalcrc(&key, &val)) {
79 case CRC_AREABEGIN:
80 aa.reset();
81 sprintf(apath, "%sMessage_Bases\\", path);
82 *usenet = NUL;
83 break;
84 case CRC_AREAEND:
85 aa.setechoid(*usenet ? usenet : name);
86 if ((aa.basetype == "OPUS") || (aa.basetype == "FTS1"))
87 aa.setpath(apath);
88 else {
89 sprintf(buf, "%s%s", apath, name);
90 aa.setpath(buf);
91 }
92 AddNewArea(aa);
93 aa.reset();
94 break;
95 case CRC_ADDRESS:
96 aa.aka.set(val);
97 break;
98 case CRC_DESC:
99 aa.setdesc(val);
100 break;
101 case CRC_FLAGS:
102 flags = atol(val);
103 if(flags & (M_NET | M_EMAIL)) {
104 if(flags & M_EMAIL) {
105 aa.type = GMB_NET|GMB_EMAIL;
106 aa.attr = attribsemail;
107 }
108 else {
109 aa.type = GMB_NET;
110 aa.attr = attribsnet;
111 }
112 }
113 else if(flags & (M_ECHO | M_GROUP | M_USENET)) {
114 if(flags & M_USENET) {
115 aa.type = GMB_ECHO|GMB_NEWSGROUP;
116 aa.attr = attribsnews;
117 }
118 else {
119 aa.type = GMB_ECHO;
120 aa.attr = attribsecho;
121 }
122 }
123 else {
124 aa.type = GMB_LOCAL;
125 aa.attr = attribslocal;
126 }
127 if(flags & M_SQUISH)
128 aa.basetype = "SQUISH";
129 else if(flags & M_FIDO)
130 aa.basetype = "OPUS";
131 else if(flags & M_JAM)
132 aa.basetype = "JAM";
133 else
134 aa.basetype = "ADEPTXBBS";
135 break;
136 case CRC_USENET:
137 strcpy(usenet, val);
138 break;
139 case CRC_NAME:
140 strcpy(name, val);
141 break;
142 case CRC_NUMBER:
143 aa.board = atoi(val);
144 break;
145 case CRC_ORIGIN:
146 aa.setorigin(val);
147 break;
148 case CRC_PATH:
149 PathCopy(apath, val);
150 break;
151 }
152 }
153 }
154
155 fclose(fp);
156 }
157 }
158
159
160 // ------------------------------------------------------------------
161 // Read areas from AdeptXBBS
162
ReadAdeptXBBS(char * tag)163 void gareafile::ReadAdeptXBBS(char* tag) {
164
165 char options[80];
166 Path file, path, cfg;
167
168 *path = NUL;
169 options[79] = 0;
170 strcpy(cfg, "System\\Message_Areas");
171 strncpy(options, tag, 79);
172 char* ptr = strtok(tag, " \t");
173 while(ptr) {
174 if(*ptr != '-')
175 AddBackslash(strcpy(path, ptr));
176 ptr = strtok(NULL, " \t");
177 }
178 if(*path == NUL)
179 strcpy(path, areapath);
180
181 strcpy(stpcpy(file, path), cfg);
182
183 CfgAdeptxbbspath(path);
184
185 ReadAdeptXbbsFile(path, file, options);
186 }
187
188
189 // ------------------------------------------------------------------
190