/
HELP.C
290 lines (255 loc) · 11 KB
/
HELP.C
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
/* help.c - constant help screens
*
* Author:
* Benjamin W. Slivka
* (c) 1987,1988
* Microsoft Corporation
*
* History:
* 18-Aug-1987 bws Use keyboard queue for keystrokes
* 08-Oct-1987 bws Signal handling modifications
* 19-Oct-1987 bws Added delay time to command line
* 20-Oct-1987 bws Fix usage display
* 19-Feb-1988 bws Add explanation screens
* 27-Feb-1988 bws Improved SysSem explanation screen
* 01-Sep-1988 bws Rev number for FMT speedup
*/
#include <stddef.h>
#include <malloc.h>
#include <memory.h>
#include <string.h>
#include "asrt.h" /* assertion checking */
#include "vio.h"
#include "os2.h"
#include "queue.h"
#include "ps.h"
#include "vars.h"
#include "os2def.h"
extern qu_t *pQu; /* ptr to keyboard queue */
char *ExplainLibScreen[] = {
"ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͵ Libraries ÆÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»",
"º º",
"º PID - Process ID of program º",
"º SGID - Screen Group ID of program º",
"º Name - Name of program module º",
"º Library List - Directed, Acyclic Graph of modules imported by º",
"º the program module. º",
"º º",
"º * = indicates a cycle in the graph º",
"º º",
"ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͵ Press Esc to return ÆÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ"
};
#define H_EXPLIB (sizeof(ExplainLibScreen)/sizeof(char *))
char *ExplainMemScreen[] = {
"ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͵ Shared Memory ÆÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»",
"º º",
"º owner hndl - Internal ID of shared memory segment º",
"º sel - LDT selector of shared memory segment º",
"º ref - Number of references to shared memory segment º",
"º name - Name of shared memory segment º",
"º º",
"ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͵ Press Esc to return ÆÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ"
};
#define H_EXPMEM (sizeof(ExplainMemScreen)/sizeof(char *))
char *ExplainProcScreen[] = {
"ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͵ Processes and Threads ÆÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»",
"º º",
"º PID - Process ID TID - Thread ID º",
"º SGID - Screen Group ID Pri - Thread priority º",
"º Name - Name of program module º",
"º Nest - Parent/child nesting level. 1 is top-level process. º",
"º State - Thread state: º",
"º zombie - Waiting for parent to finish CWAIT º",
"º ready - Ready for CPU º",
"º block - Waiting for I/O completion or a resource º",
"º froze - Waiting to come foreground (usually 3xBox) º",
"º critsec - Blocked by other thread in DosEnterCritSec º",
"º boost - Just received I/O boost º",
"º BlockID - When state is 'block', ID of event being waited upon º",
"º º",
"ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͵ Press Esc to return ÆÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ"
};
#define H_EXPPROC (sizeof(ExplainProcScreen)/sizeof(char *))
char *ExplainSemScreen[] = {
"ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͵ System Semaphores ÆÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»",
"º º",
"º name,PID,TID - Name, PID, and TID of process owning semaphore º",
"º flags/status - waiters - thread(s) are waiting for sem º",
"º muxwaiters - thread(s) are muxwaiting for sem º",
"º process died - process owning semaphore died º",
"º exclusive - exclusive semaphore º",
"º cleanup - semaphore is being cleaned up º",
"º thread died - thread owning semaphore died º",
"º exit owner - exitlist thread owns semaphore º",
"º ref - Count of processes referencing semaphore º",
"º want - Count of processes waiting for semaphore º",
"º hndl - Internal semaphore handle º",
"º name - System semaphore name º",
"º º",
"ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͵ Press Esc to return ÆÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ"
};
#define H_EXPSEM (sizeof(ExplainSemScreen)/sizeof(char *))
char *helpScreen[] = {
"ÉÍÍÍÍÍÍÍÍÍÍÍÍÍËÍÍÍÍÍÍÍÍÍÍÍ͵ Help ÆÍÍÍÍÍÍÍÍÍÍÍÍËÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»",
"º 01 Sep 1988 º Process Status º Version 1.13 º",
"ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÊÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÊÍÍÍÍÍÍÍÍÍÍÍÍÍ͹",
"º º",
"º Window Scrolling: \x18 - Scroll Window UP º",
"º \x19 - Scroll Window DOWN º",
"º PgUp - Scroll Window UP one PAGE º",
"º PgDn - Scroll Window DOWN one PAGE º",
"º º",
"º Menu Selection: \x1A - Move Cursor RIGHT º",
"º \x1B - Move Cursor LEFT º",
"º Enter - Do cursor item º",
"º Space - Do cursor item º",
"º <letter> - Do item starting with <letter> º",
"º º",
"º Use EXPLAIN to get explanation of screen data. º",
"º º",
"º Use -? flag to see command line flags. º",
"º º",
"ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͵ Press Esc to return ÆÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ"
};
#define H_HELP (sizeof(helpScreen)/sizeof(char *))
char *optHelpScreen[] = {
"ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͵ Options - HELP ÆÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»",
"º º",
"º Moving Between Fields: º",
"º \x18 - UP to previous field º",
"º \x19 - DOWN to next field º",
"º º",
"º Field WITH cursor: º",
"º \x1A - Move cursor RIGHT º",
"º \x1B - Move cursor LEFT º",
"º Del - Delete character at cursor º",
"º Home - Move cursor to LEFT edge of field º",
"º BS - Delecte character to left of cursor º",
"º <other> - Insert character, if valid º",
"º º",
"º Field WITHOUT cursor: º",
"º \x1A - Change field to NEXT value º",
"º \x1B - Change field to PREVIOUS value º",
"º º",
"ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͵ Press Esc to return ÆÍÍÍÍÍÍÍÍÍÍÍÍÍͼ"
};
#define H_OPTION (sizeof(optHelpScreen)/sizeof(char *))
typedef struct {
int scNScreen; /* Number of rows in screen */
int scWidth; /* Width of screen in columns */
char **scScreen; /* Screen screen */
} screen_t;
screen_t screen[] = {
{H_EXPLIB, 0, ExplainLibScreen},
{H_EXPMEM, 0, ExplainMemScreen},
{H_EXPPROC, 0, ExplainProcScreen},
{H_EXPSEM, 0, ExplainSemScreen},
{H_HELP, 0, helpScreen},
{H_OPTION, 0, optHelpScreen}
};
#define nScreen (sizeof(screen)/sizeof(screen_t))
#define iExpLib 0 /* index of library explanation screen */
#define iExpMem 1 /* index of memory explanation screen */
#define iExpProc 2 /* index of process explanation screen */
#define iExpSem 3 /* index of semaphore explanation screen */
#define iHelp 4 /* index of main help screen */
#define iOption 5 /* index of option help screen */
/*** helpInit - initialize help control structures
*
*/
helpInit ()
{
int i;
for (i=0; i<nScreen; i++)
screen[i].scWidth = strlen(screen[i].scScreen[0]);
}
/*** PopUpStart - Prepare for "pop-up"
*
* We allocate buffer large enough for screen memory, then copy
* screen memory to buffer. This allows for the "appearance" of
* a "pop-up", since we can write to the screen, then later copy
* this saved image back, thus "bringing down" the "pop-up". This
* is not to be confused with VioPopUp. PopUpEnd does the restore
* and frees the buffer.
*/
char *PopUpStart ()
{
unsigned size;
char *buf;
size = N_of_Rows*N_of_Cols*2;
if (buf = malloc(size))
VioReadCellStr ((FPCe)buf, (FPI)&size, 0, 0, VioHandle);
return buf;
}
/*** PopUpEnd - Restore screen after pop-up
*
*/
PopUpEnd (buf)
char *buf;
{
int size;
size = N_of_Rows*N_of_Cols*2;
VioWrtCellStr ((FPCe)buf, size, 0, 0, VioHandle);
free(buf);
}
/*** doPopUp - Do pop-up processing for specified text "window"
*
* EXIT FALSE, normal exit
* TRUE, kill requested
*/
BOOL doPopUp (i)
int i;
{
int height,width;
int row,col;
int hRow,hCol;
Attr a;
char *buf;
word key;
BOOL fDie=FALSE;
if (buf=PopUpStart()) {
height = screen[i].scNScreen;
width = screen[i].scWidth;
hRow = (N_of_Rows - height)/2;
hCol = (N_of_Cols - width)/2;
a = color[helpC];
for (row=0; row<height; row++)
VioWrtCharStrAtt ((FPC)screen[i].scScreen[row], width,
row+hRow,hCol, (FPAt)&a, VioHandle);
do {
key = (word)QueueRead(pQu);
if (key == NULL) {
key = escKey; /* Change kill into exit command */
fDie = TRUE;
}
} while (key != escKey); /* wait for Esc key */
PopUpEnd(buf);
}
return (fDie);
}
/*** showHelp - pop-up help window
*
*/
void showHelp (i)
int i;
{
doPopUp(iHelp);
}
/*** showExplain - pop-up an explanation window
*
*/
void showExplain (i)
int i;
{
doPopUp(i);
}
/*** helpOption - pop-up help window for Option window
*
* EXIT FALSE, normal exit
* TRUE, kill requested
*/
BOOL helpOption (i)
int i;
{
return ( doPopUp(iOption) );
}