1
2 // ------------------------------------------------------------------
3 // GoldED+
4 // Copyright (C) 1990-1999 Odinn Sorensen
5 // Copyright (C) 1999-2000 Alexander S. Aganichev
6 // ------------------------------------------------------------------
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
11 //
12 // This program 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 // General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 59 Temple Place, Suite 330, Boston,
20 // MA 02111-1307 USA
21 // ------------------------------------------------------------------
22 // $Id: geglob.cpp,v 1.19 2006/05/14 01:19:15 ssianky Exp $
23 // ------------------------------------------------------------------
24 // Global data.
25 // ------------------------------------------------------------------
26
27 #include <golded.h>
28 #include <gcprot.h>
29
30
31 // ------------------------------------------------------------------
32 // Various global data
33
34 gareafile* AFILE = NULL;
35 CfgGed* CFG = NULL;
36 LangGed* LNG = NULL;
37 NodeIxl* NODE = NULL;
38 Qwk* QWK = NULL;
39 GoldedCfgEdit* EDIT = NULL;
40
41 uint locpost=0, netpost=0, echopost=0;
42
43 Subj information = "";
44
45 Area* AA = NULL;
46
47 char m_title[80]; // Menu title string
48 int m_titlepos; // Menu title position
49 vattr m_titleattr; // Menu title color
50
51 int AreaKeys = 0;
52 int ReadKeys = 0;
53 int ListKeys = 0;
54 int NodeKeys = 0;
55 int EditKeys = 0;
56 int FileKeys = 0;
57 int AddressbookKeys = 0;
58 int HeaderKeys = 0;
59 std::list<CmdKey>::iterator AreaKey, ReadKey, ListKey, NodeKey, EditKey, FileKey, AddressbookKey, HeaderKey;
60
61 int inforow = 18;
62
63 char goldmark = ' ';
64
65 int startecho = -1;
66 Echo stecho = "";
67
68 int fieldupd = 2; // State of field mode in winpdef()
69
70 int CurrArea = 0;
71 int OrigArea = 0;
72
73 Esc* MNETable = NULL;
74 Esc* I51Table = NULL;
75 Esc* CompTable = NULL;
76 Chs* CharTable = NULL;
77 EscTab* CompTP = NULL;
78 EscTab* I51TP = NULL;
79 EscTab* MNETP = NULL;
80 ChsTab* ChsTP = NULL;
81
82 #ifdef HAS_ICONV
83 iconv_t iconv_cd = (iconv_t)(-1);
84 #endif
85
86 bool quiet = true;
87 bool ignore = false;
88 int cfgerrors = 0;
89 bool veryverbose = false;
90 bool shellvid = true;
91 vsavebuf* oldscreen = NULL;
92
93 bool disablesound = false;
94
95 int _in_editor = NO;
96 int _in_msglist = NO;
97 int savedirect = NO;
98
99 void(*SIGINT_OldHandler)(void) = NULL;
100
101 int arealistnumgrps = false;
102
103 int startupscan_success = false;
104
105
106 // ------------------------------------------------------------------
107 // 0 1 2 3 4 5 6 7 8 9 10 11
108
109 Win gold_color1[16] = {
110 {5, { 7, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0}, 2}, // Back 0
111 {5, { 31, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7}, 1}, // Stat 1
112 {0, { 15, 14, 14, 7, 12, 7, 7, 9, 7, 7, 7, 14}, 0}, // Brag 2
113 {0, { 7, 9, 14, 31, 15, 7, 7, 7, 7, 7, 7, 9}, 0}, // Area 3
114 {0, { 7, 7, 15, 14, 113, 8, 15, 79, 15, 15, 8, 7, 8, 15, 15}, 5}, // Read 4
115 {0, { 7, 9, 14, 7, 15, 7, 15, 113, 7, 7, 7, 9}, 0}, // Head 5
116 {0, { 7, 12, 14, 31, 15, 8, 7, 7, 7, 7, 7, 12}, 0}, // Ask 6
117 {0, { 7, 12, 14, 31, 15, 8, 7, 2, 12, 15, 7, 12}, 0}, // Menu 7
118 {0, { 7, 14, 7, 79, 15, 7, 7, 7, 7, 7, 7, 14}, 0}, // Help 8
119 {3, { 7, 12, 14, 31, 15, 8, 7, 7, 7, 7, 7, 12}, 0}, // Cfg 9
120 {0, { 15, 12, 14, 7, 7, 7, 7, 7, 7, 7, 7, 12}, 0}, // Info 10
121 {3, { 7, 12, 14, 31, 15, 8, 7, 7, 7, 7, 7, 12}, 0}, // Cfgb 11
122 {0, { 7, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15}, 0}, // Style 12
123 {0, { 7, 7, 7, 7, 7, 7, 7, 8, 7, 7, 7, 7}, 0}, // Shad 13
124 #if defined(GCFG_SPELL_INCLUDED)
125 {0, { 15, }, 0 }, // SpellCheker
126 #endif
127 };
128
129
130 // ------------------------------------------------------------------
131 // 0 1 2 3 4 5 6 7 8 9
132
133 Win gold_color2[16] = {
134 {5, { 240, 15, 7, 7, 7, 7, 7, 7, 7, 7, 7, 15}, 2}, // Back 0
135 {5, { 143, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7}, 1}, // Stat 1
136 {0, { 15, 14, 14, 7, 12, 7, 7, 9, 7, 7, 7, 14}, 0}, // Brag 2
137 {0, { 240, 241, 244, 143, 244, 7, 7, 7, 7, 7, 7, 241}, 0}, // Area 3
138 {0, { 241, 240, 242, 244, 64, 248, 240, 64, 240, 240, 248, 240, 248, 241, 249}, 5}, // Read 4
139 {0, { 135, 142, 142, 135, 143, 7, 143, 64, 135, 135, 7, 142}, 0}, // Head 5
140 {0, { 224, 230, 232, 143, 228, 231, 7, 7, 7, 7, 7, 230}, 0}, // Ask 6
141 {0, { 112, 126, 116, 143, 126, 120, 117, 113, 125, 121, 7, 126}, 0}, // Menu 7
142 {0, { 135, 142, 7, 228, 143, 7, 7, 7, 7, 7, 7, 142}, 0}, // Help 8
143 {3, { 224, 230, 232, 143, 228, 231, 7, 7, 7, 7, 7, 230}, 0}, // Cfg 9
144 {0, { 15, 12, 14, 7, 7, 7, 7, 7, 7, 7, 7, 12}, 0}, // Info 10
145 {3, { 240, 241, 244, 143, 244, 7, 7, 7, 7, 7, 7, 241}, 0}, // Cfgb 11
146 {0, { 135, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249}, 0}, // Style 12
147 {0, { 7, 7, 7, 7, 7, 7, 7, 8, 7, 7, 7, 7}, 0}, // Shad 13
148 #if defined(GCFG_SPELL_INCLUDED)
149 {0, { 15, }, 0 }, // SpellCheker
150 #endif
151 };
152
153
154 // ------------------------------------------------------------------
155 // 0 1 2 3 4 5 6 7 8 9
156
157 Win gold_mono1[16] = {
158 {5, { 15, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0}, 2}, // Back 0
159 {5, { 112, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7}, 1}, // Stat 1
160 {0, { 15, 7, 15, 7, 15, 7, 7, 7, 7, 7, 7, 7}, 0}, // Brag 2
161 {0, { 7, 7, 15, 112, 15, 7, 7, 7, 7, 7, 7, 7}, 0}, // Area 3
162 {0, { 7, 7, 15, 15, 112, 15, 7, 7, 7, 7, 15, 7, 7, 15, 7}, 5}, // Read 4
163 {0, { 7, 7, 15, 7, 15, 7, 112, 15, 7, 7, 7, 7}, 0}, // Head 5
164 {0, { 112, 112, 112, 15, 15, 7, 7, 7, 7, 7, 7, 112}, 0}, // Ask 6
165 {0, { 7, 7, 112, 112, 15, 7, 15, 15, 15, 15, 7, 7}, 0}, // Menu 7
166 {0, { 112, 112, 7, 15, 112, 7, 7, 7, 7, 7, 7, 112}, 0}, // Help 8
167 {3, { 7, 7, 112, 112, 15, 7, 7, 7, 7, 7, 7, 7}, 0}, // Cfg 9
168 {0, { 15, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7}, 0}, // Info A
169 {3, { 7, 7, 112, 112, 15, 7, 7, 7, 7, 7, 7, 7}, 0}, // Cfgb B
170 {0, { 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7}, 0}, // Style C
171 {0, { 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7}, 0}, // Shad F
172 #if defined(GCFG_SPELL_INCLUDED)
173 {0, { 15, }, 0 }, // SpellCheker
174 #endif
175 };
176
177
178 // ------------------------------------------------------------------
179 // Deallocate CFG at exit
180
CfgReset(void)181 void CfgReset(void) {
182
183 throw_delete(QWK);
184 throw_delete(EDIT);
185 throw_delete(AFILE);
186
187 if(NODE)
188 throw_xrelease(NODE->nodelist);
189 throw_xrelease(NODE);
190 throw_delete(CFG);
191 }
192
193
194 // ------------------------------------------------------------------
195 // Assign default CFG values
196
CfgInit()197 void CfgInit() {
198
199 CFG = new CfgGed;
200 throw_new(CFG);
201
202 NODE = (NodeIxl*)throw_calloc(1, sizeof(NodeIxl));
203
204 AFILE = new gareafile;
205 throw_new(AFILE);
206
207 EDIT = new GoldedCfgEdit;
208 throw_new(EDIT);
209
210 QWK = new Qwk;
211 throw_new(QWK);
212
213 LangInit();
214 }
215
216
217 // ------------------------------------------------------------------
218 // Assign default CFG values before reading the .CFG's
219
CfgInit2()220 void CfgInit2() {
221
222 // ----------------------------------------------------------------
223 // Set some default robotnames
224
225 CfgRobotname("AreaFix, AreaMgr, FileFix, AreaLink, SqaFix, AllFix, SqaFixHost, Raid, GEcho");
226
227
228 // ----------------------------------------------------------------
229 // Set some default filerequest extensions
230
231 CfgFrqext(".ARC .ARJ .EXE .LHA .LZH .PAK .RUN .SDA .SDN .ZIP .ZOO .DOC .TXT .GIF .RAR .PNG .JPG .HA");
232
233
234 // ----------------------------------------------------------------
235 // Setup the standard beeping effects
236
237 static char Attention[] = "Attention PLAY ToYou";
238 CfgEvent(Attention);
239 static char EditComment[] = "EditComment PLAY ToYou";
240 CfgEvent(EditComment);
241 static char EndOfMsgs[] = "EndOfMsgs PLAY TheEnd";
242 CfgEvent(EndOfMsgs);
243 static char JobDone[] = "JobDone PLAY GotIt";
244 CfgEvent(JobDone);
245 static char JobFailed[] = "JobFailed PLAY TooBad";
246 CfgEvent(JobFailed);
247 static char MsgIsLocal[] = "MsgIsLocal PLAY ToYou";
248 CfgEvent(MsgIsLocal);
249 static char MsgToYou[] = "MsgToYou PLAY ToYou";
250 CfgEvent(MsgToYou);
251 static char SayBiBi[] = "SayBiBi PLAY SayBiBi";
252 CfgEvent(SayBiBi);
253 static char SearchFailed[] = "SearchFailed PLAY TooBad";
254 CfgEvent(SearchFailed);
255 static char SearchSuccess[] = "SearchSuccess PLAY GotIt";
256 CfgEvent(SearchSuccess);
257
258
259 // ----------------------------------------------------------------
260 }
261
262
263 // ------------------------------------------------------------------
264
samekey(gkey key1,gkey key2)265 bool inline samekey(gkey key1, gkey key2) {
266
267 if(key1 >= KK_Commands) // special key
268 return false;
269 if(key1 == key2)
270 return true;
271 if((key1 > 0xFF) or (key2 > 0xFF))
272 return false;
273 return (g_tolower(key1) == key2) or (g_tolower(key2) == key1);
274 }
275
276
277 // ------------------------------------------------------------------
278
IsMacro(gkey key,int type)279 int IsMacro(gkey key, int type) {
280
281 std::vector<Macro>::iterator m = CFG->macro.begin();
282 while(m != CFG->macro.end()) {
283 if(samekey(key, m->key) and (type == m->type))
284 return true;
285 m++;
286 }
287
288 return false;
289 }
290
291
292 // ------------------------------------------------------------------
293
PlayMacro(gkey key,int type)294 int PlayMacro(gkey key, int type) {
295
296 std::vector<Macro>::iterator m = CFG->macro.begin();
297 while(m != CFG->macro.end()) {
298 if(samekey(key, m->key) and (type == m->type)) {
299 RunMacro(&(*m));
300 return true;
301 }
302 m++;
303 }
304
305 return false;
306 }
307
308
309 // ------------------------------------------------------------------
310