forked from oe5hpm/openBCM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
desktop.cpp
299 lines (261 loc) · 6.89 KB
/
desktop.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
/***************************************************************
BayCom(R) Packet-Radio fuer IBM PC
OpenBCM-Mailbox
---------------------
Desktop-Hauptprogramm
---------------------
Copyright (c) Florian Radlherr
Taubenbergstr. 32
83627 Warngau
Alle Rechte vorbehalten / All Rights reserved
***************************************************************/
//19980215 OE3DZW tracelevel always 0 at startup
//19980923 OE3DZW added mkdir fwd-path
#include "baycom.h"
/*---------------------------------------------------------------------------*/
unsigned long cpuindex = 0;
#ifdef __FLAT__
struct edstruct *e;
char *buf;
int boxopen = 0;
unsigned bildzeilen = 25;
unsigned bildspalten = 80;
int wa = 0;
int video_off = 1;
/*---------------------------------------------------------------------------*/
static void int_handler (int)
{
runterfahren = 1;
strcpy(stopreason, "SIGINT");
}
/*---------------------------------------------------------------------------*/
static void term_handler (int)
{
runterfahren = 1;
strcpy(stopreason, "SIGTERM");
}
/*---------------------------------------------------------------------------*/
static void ill_handler (int)
{
post_mortem_dump("SIGILL");
#ifdef __UNIX__
kill(getpid(), SIGILL);
#else
abort();
#endif
}
/*---------------------------------------------------------------------------*/
static void segv_handler (int)
{
#ifdef __UNIX__
post_mortem_dump("SIGSEGV");
signal(SIGSEGV, SIG_DFL); //dg2fef
raise(SIGSEGV);
//kill(getpid(), SIGSEGV);
#else
abort();
#endif
}
#else
/*---------------------------------------------------------------------------*/
unsigned alt_taste(unsigned scan)
//**********************************************************************
//
// wird mit dem Bioscode einer Taste aufgerufen
//
//**********************************************************************
{
static char tasttab[52]=
{ '1','2','3','4','5','6','7','8','9','0',0,0,0,0,0,0,
'Q','W','E','R','T','Y','U','I','O','P',0,0,0,0,
'A','S','D','F','G','H','J','K','L',0,0,0,0,0,
'Z','X','C','V','B','N','M'
};
if (scan & 255)
return 0;
else
scan>>=8;
if (scan < 16)
return 0;
if ((scan>=104) && (scan<=113)) // Funktionstasten ALT-F1 .. ALT-F10
scan-=104;
if ((scan>=120) && (scan<=129)) // Tasten 1 .. 0
scan-=120;
if (scan<51) // Buchstaben-Code ?
return tasttab[scan];
else
return 0;
}
/*---------------------------------------------------------------------------*/
unsigned f_taste(unsigned scan)
//**********************************************************************
//
// wertet einen Scancode aus, und gibt zurueck, wenn es eine Funktions-
// Taste war.
//
// Returnwerte:
// 0 keine Funktionstaste
// 1 -10 F1 - F10
// 11-20 SHIFT F1 - SHIFT F10
// 21-30 CTRL F1 - CTRL F10
// 31-40 ALT F1 - ALT F10
//
//**********************************************************************
{
if (scan&255)
return 0;
else
scan>>=8;
if (scan<59)
return 0;
if (scan<69)
return scan-58;
if ((scan>83) && (scan<=113))
return scan-73;
return 0;
}
/*---------------------------------------------------------------------------*/
static int desktopupdate (int full)
{
if (full)
wclear(color.desktop);
return 1;
}
#endif // __FLAT__
/*---------------------------------------------------------------------------*/
void desktop (char *)
{
lastfunc("desktop");
#ifndef __FLAT__
char instr[50];
char *msg[12] = { "",
" OpenBCM Packet-Radio Mailbox",
" / \\",
" / \\ Version "VNUMMER,
" \\ /",
" \\ / ",
" __ __",
" (c) GNU Copyright 1992-"YEAR,
" Florian Radlherr DL8MBT et al.",
" Copy Policy is GNU GPL",
NULL
};
#endif
mkdir(LOGPATH);
mkdir(TRACEPATH);
mkdir(TEMPPATH);
mkdir(FWDPATH); // OE3DZW
mkdir(FWDEXPATH); // DH8YMB
mkdir(FWDIMPATH); // DH8YMB
mkdir(MSGPATH);
mkdir(FBBPATH); // DH3MB
mkdir(WLOGPATH); // DH8YMB
m.tracelevel = 0;
#ifdef __FLAT__
mkdir(HTTPPATH); // DH8YMB
#ifndef _DEBUG
signal(SIGTERM, term_handler);
signal(SIGINT, int_handler);
signal(SIGSEGV, segv_handler);
signal(SIGILL, ill_handler);
#endif
#ifdef __LINUX__
//ignore sigpipe
signal(SIGPIPE, SIG_IGN);
#endif
fork(P_WIND, 0, tracewindow, "Console");
// fork(P_WIND, 0, monwindow, "Monitor");
fork(P_MAIL | P_WIND | P_KEYB, 0, mbwindow, "Sysop");
while (! runterfahren)
{
wdelay(146);
desk_cyclic();
}
#else
e->x = 0;
e->xend = bildspalten - 1;
e->y = 0;
e->yend = bildzeilen - 1;
e->update = desktopupdate;
wopen();
wclear(color.desktop);
fork(P_WIND, 0, monwindow, "Monitor");
fork(P_WIND, 0, tracewindow, "Console");
fork(P_MAIL | P_WIND | P_KEYB, 0, mbwindow, "Sysop");
testcputask();
deskkey = 1;
message("About", msg, 6);
deskkey = 0;
while (! runterfahren)
{
wdelay(146);
if (deskkey)
{
switch (deskkey)
{
case 23:
*instr = 0;
if (inputwin("Login", "Call [Boxcall]:", instr, 20) != ESC)
{
strupr(instr);
fork(P_WIND | P_KEYB | P_MAIL, 0, mbwin2, instr);
}
break;
#ifdef FEATURE_EDITOR
case 24:
*instr = 0;
if (inputwin("Editor", "Filename:", instr, 20) != ESC)
{
strupr(instr);
fork(P_WIND | P_KEYB, 0, editfile, instr);
}
break;
#endif
case 'Z':
case 25: resize(keywindow(), 0); break;
case 'N':
case 26: newkeywin = keywindow() + 1; break;
#ifdef FEATURE_COLOR
case 'C': colselect(); break;
#endif
case 'R':
case 27: resize(keywindow(), 1); break;
case 33:
if (yesno("Close window?", 1) == YES) killtask(keytaskid, 0);
break;
case 'S': video_checkoff(1); break;
#ifdef __MSDOS__
case 35:
set_watchdog(2);
video_close();
waitdoskey();
video_open();
set_watchdog(1);
newkeywin = keywindow();
break;
#endif
case 'X':
if (yesno("Mailbox shutdown?", 1) == YES)
{
runterfahren = 1;
strcpy(stopreason, "alt-x pressed");
}
break;
case '0':
{
sprintf(instr, "%d", keywindow());
if (inputwin("Window", "new window:", instr, 20) != ESC)
{
if (atoi(instr))
newkeywin = atoi(instr);
}
}
break;
}
deskkey = 0;
}
video_checkoff(0);
desk_cyclic();
}
#endif
}