source: trunk/dll/sysinfo.c@ 1178

Last change on this file since 1178 was 1178, checked in by John Small, 17 years ago

Ticket 187: Draft 2: Move remaining function declarations

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 11.5 KB
RevLine 
[47]1
2/***********************************************************************
3
4 $Id: sysinfo.c 1178 2008-09-10 21:53:43Z jbs $
5
6 System Info Display
7
8 Copyright (c) 1993-98 M. Kimes
[326]9 Copyright (c) 2002, 2006 Steven H.Levine
[47]10
[326]11 16 Oct 02 SHL Baseline
12 08 Feb 03 SHL Enable display
13 01 Aug 04 SHL RunRmview: avoid buffer overflow
[374]14 26 Jul 06 SHL Report open errors
[404]15 29 Jul 06 SHL Use xfgets
[793]16 20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat
[1075]17 16 JUL 08 GKY Use TMP directory for temp files
[47]18
19***********************************************************************/
20
[907]21#include <string.h>
22
[2]23#define INCL_DOS
24#define INCL_WIN
[907]25#define INCL_LONGLONG
[2]26
[1178]27#include "fm3dll.h"
28#include "fm3dlg.h"
[1073]29#include "pathutil.h" // BldFullPathName
[1156]30#include "sysinfo.h"
[1178]31#include "copyf.h" // unlinkf
32#include "wrappers.h" // xfgets
33#include "systemf.h" // runemf2
34#include "misc.h" // PostMsg
35#include "strips.h" // bstrip
[2]36
37#pragma data_seg(DATA1)
[375]38
39static PSZ pszSrcFile = __FILE__;
40
[551]41VOID RunRmview(VOID * arg)
[326]42{
[551]43 HWND hwnd = (HWND) arg;
[1073]44 CHAR s[2048], *p, szTempFile[CCHMAXPATH];
[551]45 HAB thab;
46 HMQ thmq;
[2]47 FILE *fp;
[551]48 HFILE oldstdout, newstdout;
[2]49
50 DosError(FERR_DISABLEHARDERR);
51
52 thab = WinInitialize(0);
[551]53 thmq = WinCreateMsgQueue(thab, 0);
54 WinCancelShutdown(thmq, TRUE);
55 if (thab && thmq) {
56 if (!WinIsWindow(thab, hwnd))
[2]57 goto Abort;
[1075]58 BldFullPathName(szTempFile, pTmpDir, "$RMVIEW.#$#");
[1073]59 unlinkf("%s", szTempFile);
60 fp = xfopen(szTempFile, "w", pszSrcFile, __LINE__);
[374]61 if (!fp)
62 goto Abort;
63 else {
[2]64 newstdout = -1;
[551]65 if (DosDupHandle(fileno(stdout), &newstdout)) {
66 fclose(fp);
67 goto Abort;
[2]68 }
69 oldstdout = fileno(stdout);
[551]70 DosDupHandle(fileno(fp), &oldstdout);
[2]71 runemf2(SEPARATE | INVISIBLE | FULLSCREEN | BACKGROUND | WAIT,
[888]72 hwnd, pszSrcFile, __LINE__,
[1073]73 NULL, NULL, "%s", szTempFile);
[2]74 oldstdout = fileno(stdout);
[551]75 DosDupHandle(newstdout, &oldstdout);
[2]76 DosClose(newstdout);
77 fclose(fp);
78 }
[551]79 if (!WinIsWindow(thab, hwnd))
[2]80 goto Abort;
[1073]81 fp = xfopen(szTempFile, "r", pszSrcFile, __LINE__);
[374]82 if (fp) {
[551]83 xfgets(s, sizeof(s), fp, pszSrcFile, __LINE__);
84 xfgets(s, sizeof(s), fp, pszSrcFile, __LINE__);
85 if (!feof(fp) && WinIsWindow(thab, hwnd))
86 WinSendDlgItemMsg(hwnd, SYS_LISTBOX, LM_INSERTITEM,
87 MPFROM2SHORT(LIT_END, 0),
88 MPFROMP(" -= RMView Physical Info =-"));
89 while (!feof(fp)) {
90 strset(s, 0);
91 if (!xfgets(s, sizeof(s), fp, pszSrcFile, __LINE__))
92 break;
93 stripcr(s);
94 rstrip(s);
95 p = s;
96 while (*p == '\r' || *p == '\n')
97 p++;
98 if (!WinIsWindow(thab, hwnd))
99 break;
100 WinSendDlgItemMsg(hwnd, SYS_LISTBOX, LM_INSERTITEM,
101 MPFROM2SHORT(LIT_END, 0), MPFROMP(p));
[2]102 }
103 fclose(fp);
104 }
[551]105 Abort:
[2]106 WinDestroyMsgQueue(thmq);
107 WinTerminate(thab);
108 }
[1073]109 if (szTempFile)
110 DosForceDelete(szTempFile);
[2]111}
112
[551]113MRESULT EXPENTRY SysInfoDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
[47]114{
[551]115 static HWND me = (HWND) 0;
116 static LONG ypos = 0;
117 static HPOINTER hptrIcon = (HPOINTER) 0;
[2]118
[551]119 switch (msg) {
120 case WM_INITDLG:
121 if (me) {
122 WinSetWindowPos(me, HWND_TOP, 0, 0, 0, 0, SWP_ACTIVATE |
123 SWP_SHOW | SWP_RESTORE | SWP_ZORDER);
124 WinDismissDlg(hwnd, 0);
125 break;
126 }
127 hptrIcon = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, SYS_FRAME);
128 WinDefDlgProc(hwnd, WM_SETICON, MPFROMLONG(hptrIcon), MPVOID);
129 {
130 static CHAR *names[] = { "Max. Path Length", /* 1 */
131 "Max. Text Sessions", /* 2 */
132 "Max. PM Sessions", /* 3 */
133 "Max. VDM Sessions", /* 4 */
134 "Boot Drive", /* 5 */
135 "Dynamic Priority", /* 6 */
136 "Max. Wait", /* 7 */
137 "Min. Timeslice", /* 8 */
138 "Max. Timeslice", /* 9 */
139 "Page Size", /* 10 */
140 "Version Major", /* 11 */
141 "Version Minor", /* 12 */
142 "Version Revision", /* 13 */
143 "Millisecs Up", /* 14 */
144 "Unixtime Low", /* 15 */
145 "Unixtime High", /* 16 */
146 "Physical Memory", /* 17 */
147 "Resident Memory", /* 18 */
148 "Total Available Memory", /* 19 */
149 "Max. Private Memory", /* 20 */
150 "Max. Shared Memory", /* 21 */
151 "Timer Interval", /* 22 */
152 "Max. Path Comp. Length", /* 23 */
153 "Foreground FS Session ID", /* 24 */
154 "Foreground Process PID", /* 25 */
155 NULL
156 };
157 static CHAR *pnames[] = { "Swap button",
158 "Dblclk time",
159 "CX dblclk",
160 "CY dblclk",
161 "CX sizeborder",
162 "CY sizeborder",
163 "Alarm",
164 "",
165 "",
166 "Cursor rate",
167 "First scroll rate",
168 "Scroll rate",
169 "Numbered lists",
170 "Warning freq",
171 "Note freq",
172 "Error freq",
173 "Warning duration",
174 "Note duration",
175 "Error duration",
176 "",
177 "CX screen",
178 "CY screen",
179 "CX vscroll",
180 "CY hscroll",
181 "CY vscroll arrow",
182 "CX hscroll arrow",
183 "CX border",
184 "CY border",
185 "CX dlgframe",
186 "CY dlgframe",
187 "CY titlebar",
188 "CY vslider",
189 "CX hslider",
190 "CX minmaxbutton",
191 "CY minmaxbutton",
192 "CY menu",
193 "CX fullscreen",
194 "CY fullscreen",
195 "CX icon",
196 "CY icon",
197 "CX pointer",
198 "CY pointer",
199 "Debug",
200 "# Mouse buttons",
201 "Pointer level",
202 "Cursor level",
203 "Track rect level",
204 "# timers",
205 "Mouse present",
206 "CX bytealign",
207 "CY bytealign",
208 "",
209 "",
210 "",
211 "",
212 "",
213 "Not reserved",
214 "Extra key beep",
215 "Set lights",
216 "Insert mode",
217 "",
218 "",
219 "",
220 "",
221 "Menu rolldown delay",
222 "Menu rollup delay",
223 "Alt mnemonic",
224 "Tasklist mouse access",
225 "CX icon text width",
226 "# Icon text lines",
227 "Chord time",
228 "CX chord",
229 "CY chord",
230 "CX motion",
231 "CY motion",
232 "Begin drag",
233 "End drag",
234 "Single select",
235 "Open",
236 "Context menu",
237 "Context help",
238 "Text edit",
239 "Begin select",
240 "End select",
241 "Begin drag kb",
242 "End drag kb",
243 "Select kb",
244 "Open kb",
245 "Context menu kb",
246 "Context help kb",
247 "Text edit kb",
248 "Begin select kb",
249 "End select kb",
250 "Animation",
251 "Animation speed",
252 "Mono icons",
253 "Kbd id",
254 "Print screen",
255 NULL
256 };
257 static CHAR *dnames[] = { "# printers",
258 "# RS232 ports",
259 "# diskette drives",
260 "Coprocessor present",
261 "PC submodel",
262 "PC model",
263 "Display",
264 NULL
265 };
266 ULONG vals[26], val, x;
267 CHAR s[134], dev;
268
[766]269 if (DosQuerySysInfo(QSV_MAX_PATH_LENGTH, QSV_MAX_COMP_LENGTH + 2,
[551]270 (PVOID) vals, (ULONG) sizeof(vals))) {
271 WinDismissDlg(hwnd, 0);
272 break;
[2]273 }
[551]274 me = hwnd;
275 WinSendDlgItemMsg(hwnd, SYS_LISTBOX, LM_INSERTITEM,
276 MPFROMLONG(LIT_END), MPFROMP(" -= Base OS Info =-"));
277 for (x = 0; names[x]; x++) {
278 switch (x) {
279 case 0:
280 case 9:
281 case 22:
282 sprintf(s, "%-28.28s%lu bytes", names[x], vals[x]);
283 break;
284 case 16:
285 case 17:
286 case 18:
287 case 19:
288 case 20:
289 sprintf(s, "%-28.28s%lu bytes (%lu mb)", names[x], vals[x],
290 vals[x] / (1024 * 1024));
291 break;
292 case 4:
293 sprintf(s, "%-28.28s%c:", names[x], (CHAR) vals[x] + '@');
294 break;
295 case 5:
296 sprintf(s, "%-28.28s%s", names[x], (vals[x]) ? "On" : "Off");
297 break;
298 case 6:
299 sprintf(s, "%-28.28s%lu seconds", names[x], vals[x]);
300 break;
301 case 7:
302 case 8:
303 sprintf(s, "%-28.28s%lu milliseconds", names[x], vals[x]);
304 break;
305 case 13:
306 {
307 ULONG numdays, nummins;
[2]308
[551]309 sprintf(s, "%-28.28s%lu (", names[x], vals[x]);
[766]310 vals[x] /= 60000;
311 numdays = vals[x] / (60 * 24);
[551]312 if (numdays)
313 sprintf(s + strlen(s), "%lu day%s, ", numdays,
[766]314 &"s"[numdays == 1]);
315 nummins = vals[x] % (60 * 24);
[551]316 sprintf(s + strlen(s), "%luh:%02lum)", nummins / 60,
317 nummins % 60);
318 }
319 break;
320 case 21:
321 sprintf(s, "%-28.28s%lu.%01lu milliseconds", names[x],
322 vals[x] / 10, vals[x] % 10);
323 break;
324 default:
325 sprintf(s, "%-28.28s%lu", names[x], vals[x]);
326 break;
327 }
328 if (*s)
329 WinSendDlgItemMsg(hwnd, SYS_LISTBOX, LM_INSERTITEM,
330 MPFROMLONG(LIT_END), MPFROMP(s));
[2]331 }
[551]332 WinSendDlgItemMsg(hwnd, SYS_LISTBOX, LM_INSERTITEM,
333 MPFROMLONG(LIT_END), MPFROMP(" -= PM Info =-"));
334 for (x = 0; pnames[x]; x++) {
335 if (*pnames[x]) {
336 val = WinQuerySysValue(HWND_DESKTOP, x);
337 switch (x) {
338 case SV_CXBYTEALIGN:
339 case SV_CYBYTEALIGN:
340 case SV_CYMOTIONSTART:
341 case SV_CXMOTIONSTART:
342 case SV_CYDBLCLK:
343 case SV_CXDBLCLK:
344 case SV_CYPOINTER:
345 case SV_CXPOINTER:
346 case SV_CYICON:
347 case SV_CXICON:
348 case SV_CXFULLSCREEN:
349 case SV_CYFULLSCREEN:
350 case SV_CYMENU:
351 case SV_CYMINMAXBUTTON:
352 case SV_CXMINMAXBUTTON:
353 case SV_CXHSLIDER:
354 case SV_CYVSLIDER:
355 case SV_CXDLGFRAME:
356 case SV_CYDLGFRAME:
357 case SV_CXSIZEBORDER:
358 case SV_CYSIZEBORDER:
359 case SV_CXBORDER:
360 case SV_CYBORDER:
361 case SV_CYTITLEBAR:
362 case SV_CXHSCROLLARROW:
363 case SV_CYVSCROLLARROW:
364 case SV_CXVSCROLL:
365 case SV_CYHSCROLL:
366 case SV_CYSCREEN:
367 case SV_CXSCREEN:
368 case SV_CXICONTEXTWIDTH:
369 case SV_CXCHORD:
370 case SV_CYCHORD:
371 sprintf(s, "%-28.28s%lu pels", pnames[x], val);
372 break;
373 case SV_CONTEXTMENU:
374 case SV_OPEN:
375 case SV_TEXTEDIT:
376 case SV_BEGINSELECT:
377 case SV_ENDSELECT:
378 case SV_BEGINDRAG:
379 case SV_ENDDRAG:
380 case SV_CONTEXTHELP:
381 case SV_SINGLESELECT:
382 sprintf(s, "%-28.28sWM: %04xh KC: %04xh", pnames[x],
383 LOUSHORT(val), HIUSHORT(val));
384 break;
385 case SV_TASKLISTMOUSEACCESS:
386 sprintf(s, "%-28.28sWM: %04xh", pnames[x], LOUSHORT(val));
387 break;
388 case SV_CONTEXTMENUKB:
389 case SV_TEXTEDITKB:
390 case SV_BEGINDRAGKB:
391 case SV_ENDDRAGKB:
392 case SV_SELECTKB:
393 case SV_OPENKB:
394 case SV_CONTEXTHELPKB:
395 case SV_BEGINSELECTKB:
396 case SV_ENDSELECTKB:
397 sprintf(s, "%-28.28sVK: %04xh KC: %04xh", pnames[x],
398 LOUSHORT(val), HIUSHORT(val));
399 break;
400 case SV_CHORDTIME:
401 case SV_DBLCLKTIME:
402 case SV_CURSORRATE:
403 case SV_FIRSTSCROLLRATE:
404 case SV_SCROLLRATE:
405 case SV_MENUROLLDOWNDELAY:
406 case SV_MENUROLLUPDELAY:
407 case SV_ANIMATIONSPEED:
408 case SV_WARNINGDURATION:
409 case SV_NOTEDURATION:
410 case SV_ERRORDURATION:
411 sprintf(s, "%-28.28s%lu milliseconds", pnames[x], val);
412 break;
413 case SV_MOUSEPRESENT:
414 sprintf(s, "%-28.28s%s", pnames[x], (val) ? "True" : "False");
415 break;
416 case SV_ALARM:
417 case SV_ANIMATION:
418 case SV_MONOICONS:
419 case SV_PRINTSCREEN:
420 case SV_SETLIGHTS:
421 case SV_INSERTMODE:
422 case SV_SWAPBUTTON:
423 case SV_DEBUG:
424 sprintf(s, "%-28.28s%s", pnames[x], (val) ? "On" : "Off");
425 break;
426 default:
427 sprintf(s, "%-28.28s%lu", pnames[x], val);
428 break;
429 }
430 WinSendDlgItemMsg(hwnd, SYS_LISTBOX, LM_INSERTITEM,
431 MPFROMLONG(LIT_END), MPFROMP(s));
432 }
433 }
434 WinSendDlgItemMsg(hwnd, SYS_LISTBOX, LM_INSERTITEM,
435 MPFROMLONG(LIT_END), MPFROMP(" -= Hardware info =-"));
436 for (x = 0; dnames[x]; x++) {
437 if (*dnames[x]) {
438 if (!DosDevConfig(&dev, x)) {
439 switch (x) {
440 case DEVINFO_COPROCESSOR:
441 sprintf(s, "%-28.28s%s", dnames[x], (dev) ? "True" : "False");
442 break;
443 case DEVINFO_ADAPTER:
444 sprintf(s, "%-28.28s%sMonochrome or printer", dnames[x],
445 (dev) ? "Not " : NullStr);
446 break;
447 default:
448 sprintf(s, "%-28.28s%lu", dnames[x], dev);
449 break;
450 }
451 }
452 WinSendDlgItemMsg(hwnd, SYS_LISTBOX, LM_INSERTITEM,
453 MPFROMLONG(LIT_END), MPFROMP(s));
454 }
455 }
456 }
457 break;
[2]458
[551]459 case WM_ADJUSTWINDOWPOS:
460 PostMsg(hwnd, UM_STRETCH, MPVOID, MPVOID);
461 break;
[2]462
[551]463 case UM_STRETCH:
464 {
465 SWP swpC, swp;
[2]466
[551]467 WinQueryWindowPos(hwnd, &swp);
468 if (!(swp.fl & (SWP_HIDE | SWP_MINIMIZE))) {
469 WinQueryWindowPos(WinWindowFromID(hwnd, SYS_LISTBOX), &swpC);
470 if (!ypos)
471 ypos = swpC.y;
472 WinSetWindowPos(WinWindowFromID(hwnd, SYS_LISTBOX), HWND_TOP,
473 SysVal(SV_CXSIZEBORDER),
474 ypos,
475 swp.cx - (SysVal(SV_CXSIZEBORDER) * 2),
476 (swp.cy - ypos) - (SysVal(SV_CYTITLEBAR) +
477 SysVal(SV_CYSIZEBORDER)),
478 SWP_MOVE | SWP_SIZE);
[2]479 }
[551]480 }
481 return 0;
[2]482
[551]483 case WM_COMMAND:
484 WinDismissDlg(hwnd, 0);
485 return 0;
[2]486
[551]487 case WM_DESTROY:
488 if (me == hwnd) {
489 me = (HWND) 0;
490 if (hptrIcon)
491 WinDestroyPointer(hptrIcon);
492 hptrIcon = (HPOINTER) 0;
493 }
494 break;
[2]495 }
496
[551]497 return WinDefDlgProc(hwnd, msg, mp1, mp2);
[2]498}
[793]499
500#pragma alloc_text(SYSINFO,SysInfoDlgProc,RunRmview)
Note: See TracBrowser for help on using the repository browser.