source: trunk/dll/init.c@ 705

Last change on this file since 705 was 705, checked in by Gregg Young, 18 years ago

Minor code cleanup fix ramdisk on states list & WORPLACE_PROCESS logic

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 42.8 KB
Line 
1
2/***********************************************************************
3
4 $Id: init.c 705 2007-06-24 19:17:37Z gyoung $
5
6 Initialization
7
8 Copyright (c) 1993-98 M. Kimes
9 Copyright (c) 2001, 2007 Steven H. Levine
10
11 11 Jun 02 SHL Add CheckVersion
12 11 Jun 03 SHL Add JFS and FAT32 support
13 25 Nov 03 SHL InitFM3DLL: correct strings error mesage
14 23 May 05 SHL Use datamin.h
15 26 May 05 SHL Comments
16 06 Jun 05 SHL indent -i2
17 06 Jun 05 SHL Rework FindSwapperDat for VAC3.65 compat
18 13 Jul 06 SHL Use Runtime_Error
19 13 Jul 06 SHL Sync with current style
20 29 Jul 06 SHL Use xfgets
21 22 Oct 06 GKY Add NDFS32 support
22 18 Feb 07 GKY Add ISOFS, RAMFS support
23 30 Mar 07 GKY Defined golbals for removing GetPString for window class names
24 21 Apr 07 GKY Find FM2Utils by path or utils directory eleminate fAddUtils global
25 15 Jun 07 SHL Make OpenWatcom compatible
26 23 Jun 07 GKY Fix WORPLACE_PROCESS enviroment check logic
27
28***********************************************************************/
29
30#define DEFINE_GLOBALS 1
31
32#define INCL_DOS
33#define INCL_WIN
34#define INCL_MMIOOS2
35#define INCL_GPI
36
37#include <os2.h>
38#include <os2me.h>
39#include <stdlib.h>
40#include <stdio.h>
41#include <string.h>
42#include <ctype.h>
43#include <share.h>
44#include <time.h>
45#include <process.h>
46
47#include "fm3dll.h"
48#include "fm3dlg.h"
49#include "datamin.h"
50#include "tools.h"
51#include "fm3str.h"
52#include "version.h"
53
54#ifdef __WATCOMC__
55#pragma alloc_text(INIT,LibMain,InitFM3DLL,DeInitFM3DLL)
56#else // __IBMC__
57#pragma alloc_text(INIT,_DLL_InitTerm,InitFM3DLL,DeInitFM3DLL)
58#endif
59
60#pragma alloc_text(INIT1,StartFM3,FindSwapperDat)
61
62extern int _CRT_init(void);
63extern void _CRT_term(void);
64
65static PSZ pszSrcFile = __FILE__;
66
67VOID FindSwapperDat(VOID)
68{
69 CHAR filename[] = "C:\\CONFIG.SYS";
70 CHAR input[8192];
71 CHAR *p;
72 CHAR *pp;
73 FILE *fp;
74 FILEFINDBUF3 ffb;
75 ULONG nm;
76 ULONG size = sizeof(SwapperDat);
77 HDIR hdir = HDIR_CREATE;
78 APIRET rc = 1;
79
80 *SwapperDat = 0;
81 // Check already known
82 PrfQueryProfileData(fmprof,
83 FM3Str, "SwapperDat", (PVOID) SwapperDat, &size);
84 if (*SwapperDat) {
85 nm = 1;
86 rc = DosFindFirst(SwapperDat,
87 &hdir,
88 FILE_NORMAL | FILE_ARCHIVED |
89 FILE_HIDDEN | FILE_SYSTEM | FILE_READONLY,
90 &ffb, sizeof(ffb), &nm, FIL_STANDARD);
91 if (!rc) {
92 DosFindClose(hdir);
93 fp = fopen(SwapperDat, "r");
94 if (fp) {
95 fclose(fp);
96 *SwapperDat = 0;
97 rc = 1; // Force config.sys scan
98 }
99 }
100 else
101 *SwapperDat = 0;
102 }
103 // If not defined in INI or INI wrong, scan config.sys for SWAPPATH statement
104 if (rc) {
105 if (DosQuerySysInfo(QSV_BOOT_DRIVE,
106 QSV_BOOT_DRIVE,
107 (PVOID) & nm, (ULONG) sizeof(ULONG))) {
108 nm = 3; // Assume drive C:
109 }
110 *filename = (CHAR) nm + '@';
111 fp = xfsopen(filename, "r", SH_DENYNO, pszSrcFile, __LINE__);
112 if (fp) {
113 while (!feof(fp)) {
114 if (!xfgets(input, sizeof(input), fp, pszSrcFile, __LINE__))
115 break;
116 lstrip(input);
117 if (!strnicmp(input, "SWAPPATH", 8)) {
118 p = input + 8;
119 while (*p == ' ')
120 p++;
121 if (*p == '=') {
122 p++;
123 stripcr(p);
124 rstrip(p);
125 while (*p == ' ')
126 p++;
127 if (*p == '\"') {
128 p++;
129 pp = p;
130 while (*pp && *pp != '\"')
131 *pp += 1;
132 if (*pp)
133 *pp = 0;
134 }
135 else {
136 pp = strchr(p, ' ');
137 if (pp)
138 *pp = 0;
139 }
140 if (*p) {
141 strncpy(SwapperDat, p, CCHMAXPATH);
142 SwapperDat[CCHMAXPATH - 1] = 0;
143 if (SwapperDat[strlen(SwapperDat) - 1] != '\\')
144 strcat(SwapperDat, "\\");
145 strcat(SwapperDat, "SWAPPER.DAT");
146 hdir = HDIR_CREATE;
147 nm = 1;
148 if (!DosFindFirst(SwapperDat,
149 &hdir,
150 FILE_NORMAL | FILE_ARCHIVED |
151 FILE_HIDDEN | FILE_SYSTEM | FILE_READONLY,
152 &ffb, sizeof(ffb), &nm, FIL_STANDARD)) {
153 DosFindClose(hdir);
154 PrfWriteProfileString(fmprof,
155 FM3Str, "SwapperDat", SwapperDat);
156 }
157 else
158 *SwapperDat = 0;
159 break;
160 }
161 }
162 } // if SWAPPATH
163 } // while
164 fclose(fp);
165 }
166 }
167}
168
169#ifdef __WATCOMC__
170
171unsigned APIENTRY LibMain(unsigned hModule,
172 unsigned ulFlag)
173{
174 CHAR *env;
175 CHAR stringfile[CCHMAXPATH];
176 FILESTATUS3 fsa;
177 APIRET rc;
178
179 switch (ulFlag) {
180 case 0:
181 // 14 Jun 07 SHL Already done for us
182 // if (_CRT_init() == -1)
183 // return 0UL;
184 FM3DllHandle = hModule;
185 strcpy(stringfile, "FM3RES.STR");
186 env = getenv("FM3INI");
187 if (env) {
188 DosError(FERR_DISABLEHARDERR);
189 rc = DosQueryPathInfo(env, FIL_STANDARD, &fsa, (ULONG) sizeof(fsa));
190 if (!rc) {
191 if (fsa.attrFile & FILE_DIRECTORY) {
192 strcpy(stringfile, env);
193 if (stringfile[strlen(stringfile) - 1] != '\\')
194 strcat(stringfile, "\\");
195 strcat(stringfile, "FM3RES.STR");
196 DosError(FERR_DISABLEHARDERR);
197 if (DosQueryPathInfo(stringfile, FIL_STANDARD, &fsa, sizeof(fsa)))
198 strcpy(stringfile, "FM3RES.STR");
199 }
200 }
201 }
202 LoadStrings(stringfile);
203
204 DosError(FERR_DISABLEHARDERR);
205 /* strings here to prevent multiple occurences in DLL */
206 FM2Str = "FM/2";
207 FM3Str = "FM/3";
208 NullStr = "";
209 Default = "DEFAULT";
210 Settings = "SETTINGS";
211 WPProgram = "WPProgram";
212 FM3Folder = "<FM3_Folder>";
213 FM3Tools = "<FM3_Tools>";
214 DRM_OS2FILE = "DRM_OS2FILE";
215 DRM_FM2ARCMEMBER = "DRM_FM2ARCMEMBER";
216 DRF_FM2ARCHIVE = "DRF_FM2ARCHIVE";
217 DRMDRFLIST = "<DRM_OS2FILE,DRF_UNKNOWN>,"
218 "<DRM_DISCARD,DRF_UNKNOWN>," "<DRM_PRINT,DRF_UNKNOWN>";
219 DRMDRFOS2FILE = "<DRM_OS2FILE,DRF_UNKNOWN>";
220 DRMDRFFM2ARC = "<DRM_FM2ARCMEMBER,DRF_FM2ARCHIVE>";
221 DRM_FM2INIRECORD = "DRM_FM2INIRECORD";
222 DRF_FM2INI = "DRF_FM2INI";
223 SUBJECT = ".SUBJECT";
224 LONGNAME = ".LONGNAME";
225 HPFS = "HPFS";
226 JFS = "JFS";
227 CDFS = "CDFS";
228 ISOFS = "ISOFS";
229 FAT32 = "FAT32";
230 HPFS386 = "HPFS386";
231 CBSIFS = "CBSIFS";
232 NDFS32 = "NDFS32";
233 RAMFS = "RAMFS";
234 NTFS = "NTFS";
235 WC_OBJECTWINDOW = "WC_OBJECTWINDOW";
236 WC_BUBBLE = "WC_BUBBLE";
237 WC_TOOLBUTTONS = "WC_TOOLBUTTONS";
238 WC_DRIVEBUTTONS = "WC_DRIVEBUTTONS";
239 WC_DIRCONTAINER = "WC_DIRCONTAINER";
240 WC_DIRSTATUS = "WC_DIRSTATUS";
241 WC_TREECONTAINER = "WC_TREECONTAINER";
242 WC_TREEOPENBUTTON = "WC_TREEOPENBUTTON";
243 WC_TREESTATUS = "WC_TREESTATUS";
244 WC_MAINWND = "WC_MAINWND";
245 WC_MAINWND2 = "WC_MAINWND2";
246 WC_AUTOVIEW = "WC_AUTOVIEW";
247 WC_LED = "WC_LED";
248 WC_COLLECTOR = "WC_COLLECTOR";
249 WC_COLSTATUS = "WC_COLSTATUS";
250 WC_STATUS = "WC_STATUS";
251 WC_TOOLBACK = "WC_TOOLBACK";
252 WC_DRIVEBACK = "WC_DRIVEBACK";
253 WC_ARCCONTAINER = "WC_ARCCONTAINER";
254 WC_ARCSTATUS = "WC_ARCSTATUS";
255 WC_MLEEDITOR = "WC_MLEEDITOR";
256 WC_INIEDITOR = "WC_INIEDITOR";
257 WC_SEEALL = "WC_SEEALL";
258 WC_NEWVIEW = "WC_NEWVIEW";
259 WC_SEESTATUS = "WC_SEESTATUS";
260 WC_VIEWSTATUS = "WC_VIEWSTATUS";
261 WC_ERRORWND = "WC_ERRORWND";
262 WC_MINITIME = "WC_MINITIME";
263 WC_DATABAR = "WC_DATABAR";
264
265 /* end of strings */
266 memset(&RGBBLACK, 0, sizeof(RGB2));
267 RGBGREY.bRed = RGBGREY.bGreen = RGBGREY.bBlue = (BYTE)204;
268 RGBGREY.fcOptions = 0;
269 FM3UL = *(ULONG *) FM3Str;
270 DEBUG_STRING = "Debug -- please report to author";
271 break;
272 case 1:
273 StopPrinting = 1;
274 if (fmprof)
275 PrfCloseProfile(fmprof);
276 DosError(FERR_ENABLEHARDERR);
277 // 14 Jun 07 SHL Already done for us
278 // _CRT_term();
279 break;
280 default:
281 return 0UL;
282 }
283 return 1UL;
284}
285
286#else // __IBMC__
287
288unsigned long _System _DLL_InitTerm(unsigned long hModule,
289 unsigned long ulFlag)
290{
291 CHAR *env;
292 CHAR stringfile[CCHMAXPATH];
293 FILESTATUS3 fsa;
294 APIRET rc;
295
296 switch (ulFlag) {
297 case 0:
298 if (_CRT_init() == -1)
299 return 0UL;
300 FM3DllHandle = hModule;
301 strcpy(stringfile, "FM3RES.STR");
302 env = getenv("FM3INI");
303 if (env) {
304 DosError(FERR_DISABLEHARDERR);
305 rc = DosQueryPathInfo(env, FIL_STANDARD, &fsa, (ULONG) sizeof(fsa));
306 if (!rc) {
307 if (fsa.attrFile & FILE_DIRECTORY) {
308 strcpy(stringfile, env);
309 if (stringfile[strlen(stringfile) - 1] != '\\')
310 strcat(stringfile, "\\");
311 strcat(stringfile, "FM3RES.STR");
312 DosError(FERR_DISABLEHARDERR);
313 if (DosQueryPathInfo(stringfile, FIL_STANDARD, &fsa, sizeof(fsa)))
314 strcpy(stringfile, "FM3RES.STR");
315 }
316 }
317 }
318 LoadStrings(stringfile);
319
320 DosError(FERR_DISABLEHARDERR);
321 /* strings here to prevent multiple occurences in DLL */
322 FM2Str = "FM/2";
323 FM3Str = "FM/3";
324 NullStr = "";
325 Default = "DEFAULT";
326 Settings = "SETTINGS";
327 WPProgram = "WPProgram";
328 FM3Folder = "<FM3_Folder>";
329 FM3Tools = "<FM3_Tools>";
330 DRM_OS2FILE = "DRM_OS2FILE";
331 DRM_FM2ARCMEMBER = "DRM_FM2ARCMEMBER";
332 DRF_FM2ARCHIVE = "DRF_FM2ARCHIVE";
333 DRMDRFLIST = "<DRM_OS2FILE,DRF_UNKNOWN>,"
334 "<DRM_DISCARD,DRF_UNKNOWN>," "<DRM_PRINT,DRF_UNKNOWN>";
335 DRMDRFOS2FILE = "<DRM_OS2FILE,DRF_UNKNOWN>";
336 DRMDRFFM2ARC = "<DRM_FM2ARCMEMBER,DRF_FM2ARCHIVE>";
337 DRM_FM2INIRECORD = "DRM_FM2INIRECORD";
338 DRF_FM2INI = "DRF_FM2INI";
339 SUBJECT = ".SUBJECT";
340 LONGNAME = ".LONGNAME";
341 HPFS = "HPFS";
342 JFS = "JFS";
343 CDFS = "CDFS";
344 ISOFS = "ISOFS";
345 FAT32 = "FAT32";
346 HPFS386 = "HPFS386";
347 CBSIFS = "CBSIFS";
348 NDFS32 = "NDFS32";
349 RAMFS = "RAMFS";
350 NTFS = "NTFS";
351 WC_OBJECTWINDOW = "WC_OBJECTWINDOW";
352 WC_BUBBLE = "WC_BUBBLE";
353 WC_TOOLBUTTONS = "WC_TOOLBUTTONS";
354 WC_DRIVEBUTTONS = "WC_DRIVEBUTTONS";
355 WC_DIRCONTAINER = "WC_DIRCONTAINER";
356 WC_DIRSTATUS = "WC_DIRSTATUS";
357 WC_TREECONTAINER = "WC_TREECONTAINER";
358 WC_TREEOPENBUTTON = "WC_TREEOPENBUTTON";
359 WC_TREESTATUS = "WC_TREESTATUS";
360 WC_MAINWND = "WC_MAINWND";
361 WC_MAINWND2 = "WC_MAINWND2";
362 WC_AUTOVIEW = "WC_AUTOVIEW";
363 WC_LED = "WC_LED";
364 WC_COLLECTOR = "WC_COLLECTOR";
365 WC_COLSTATUS = "WC_COLSTATUS";
366 WC_STATUS = "WC_STATUS";
367 WC_TOOLBACK = "WC_TOOLBACK";
368 WC_DRIVEBACK = "WC_DRIVEBACK";
369 WC_ARCCONTAINER = "WC_ARCCONTAINER";
370 WC_ARCSTATUS = "WC_ARCSTATUS";
371 WC_MLEEDITOR = "WC_MLEEDITOR";
372 WC_INIEDITOR = "WC_INIEDITOR";
373 WC_SEEALL = "WC_SEEALL";
374 WC_NEWVIEW = "WC_NEWVIEW";
375 WC_SEESTATUS = "WC_SEESTATUS";
376 WC_VIEWSTATUS = "WC_VIEWSTATUS";
377 WC_ERRORWND = "WC_ERRORWND";
378 WC_MINITIME = "WC_MINITIME";
379 WC_DATABAR = "WC_DATABAR";
380
381 /* end of strings */
382 memset(&RGBBLACK, 0, sizeof(RGB2));
383 RGBGREY.bRed = RGBGREY.bGreen = RGBGREY.bBlue = (BYTE)204;
384 RGBGREY.fcOptions = 0;
385 FM3UL = *(ULONG *) FM3Str;
386 DEBUG_STRING = "Debug -- please report to author";
387 break;
388 case 1:
389 StopPrinting = 1;
390 if (fmprof)
391 PrfCloseProfile(fmprof);
392 DosError(FERR_ENABLEHARDERR);
393 _CRT_term();
394 break;
395 default:
396 return 0UL;
397 }
398 return 1UL;
399}
400
401#endif // __IBMC__
402
403VOID APIENTRY DeInitFM3DLL(ULONG why)
404{
405 /* cleanup */
406 static CHAR s[CCHMAXPATH];
407 CHAR *enddir;
408 HDIR search_handle;
409 ULONG num_matches;
410 static FILEFINDBUF3 f;
411
412 StopTimer();
413 StopPrinting = 1;
414
415 if (LogFileHandle)
416 fclose(LogFileHandle);
417
418 if (fmprof) {
419 PrfCloseProfile(fmprof);
420 fmprof = (HINI) 0;
421 if (fIniExisted) {
422 DosError(FERR_DISABLEHARDERR);
423 DosCopy("FM3.INI", "FM3INI.BAK", DCPY_EXISTING);
424 }
425 }
426
427 if (fToolsChanged)
428 save_tools(NULL);
429
430# ifdef __IBMC__
431 _fcloseall();
432# else // __WATCOMC__
433 fcloseall();
434# endif
435
436 save_dir(s);
437 if (s[strlen(s) - 1] != '\\')
438 strcat(s, "\\");
439 enddir = &s[strlen(s)];
440 if (*ArcTempRoot) {
441 strcat(s, ArcTempRoot);
442 strcat(s, "*");
443 search_handle = HDIR_CREATE;
444 num_matches = 1L;
445 if (!DosFindFirst(s,
446 &search_handle,
447 FILE_NORMAL | FILE_DIRECTORY |
448 FILE_SYSTEM | FILE_READONLY | FILE_HIDDEN |
449 FILE_ARCHIVED,
450 &f, sizeof(FILEFINDBUF3), &num_matches, FIL_STANDARD)) {
451 do {
452 strcpy(enddir, f.achName);
453 if (f.attrFile & FILE_DIRECTORY) {
454 wipeallf("%s\\*", s);
455 DosDeleteDir(s);
456 }
457 else
458 unlinkf("%s", s);
459 }
460 while (!DosFindNext(search_handle,
461 &f, sizeof(FILEFINDBUF3), &num_matches));
462 DosFindClose(search_handle);
463 }
464 }
465
466 save_dir(s);
467 if (s[strlen(s) - 1] != '\\')
468 strcat(s, "\\");
469 enddir = &s[strlen(s)];
470 strcat(s, LISTTEMPROOT);
471 strcat(s, "???");
472 search_handle = HDIR_CREATE;
473 num_matches = 1L;
474 if (!DosFindFirst(s,
475 &search_handle,
476 FILE_NORMAL | FILE_DIRECTORY |
477 FILE_SYSTEM | FILE_READONLY | FILE_HIDDEN |
478 FILE_ARCHIVED,
479 &f, sizeof(FILEFINDBUF3), &num_matches, FIL_STANDARD)) {
480 do {
481 if (!(f.attrFile & FILE_DIRECTORY)) {
482 strcpy(enddir, f.achName);
483 unlinkf("%s", s);
484 }
485 }
486 while (!DosFindNext(search_handle,
487 &f, sizeof(FILEFINDBUF3), &num_matches));
488 DosFindClose(search_handle);
489 }
490
491 DosForceDelete("$FM2PLAY.$$$");
492
493 EndNote();
494
495 if (FM3ModHandle)
496 DosFreeModule(FM3ModHandle);
497
498 DosExitList(EXLST_REMOVE, DeInitFM3DLL);
499}
500
501BOOL InitFM3DLL(HAB hab, int argc, char **argv)
502{
503 /*
504 * this function should be called by any application using this DLL right
505 * after setting up a message queue
506 */
507
508 CLASSINFO clinfo;
509 APIRET rc;
510 APIRET rcl = 1;
511 APIRET rcq = 1;
512 PFN pfnResVersion = (PFN) NULL;
513 ULONG RVMajor = 0;
514 ULONG RVMinor = 0;
515 ULONG ret = 0;
516 FILESTATUS3 fsa;
517 CHAR *env;
518 CHAR dllfile[CCHMAXPATH];
519 ULONG size;
520
521 if (!StringsLoaded()) {
522 saymsg(MB_ENTER,
523 HWND_DESKTOP,
524 "Error",
525 "FM3RES.STR isn't in right format, at least "
526 "for this version of FM/2.");
527 return FALSE;
528 }
529
530 strcpy(dllfile, "FM3RES");
531 env = getenv("FM3INI");
532 if (env) {
533 FILESTATUS3 fsa;
534 APIRET rc;
535
536 DosError(FERR_DISABLEHARDERR);
537 rc = DosQueryPathInfo(env, FIL_STANDARD, &fsa, (ULONG) sizeof(fsa));
538 if (!rc) {
539 if (fsa.attrFile & FILE_DIRECTORY) {
540 strcpy(dllfile, env);
541 if (dllfile[strlen(dllfile) - 1] != '\\')
542 strcat(dllfile, "\\");
543 strcat(dllfile, "FM3RES");
544 DosError(FERR_DISABLEHARDERR);
545 if (DosQueryPathInfo(dllfile, FIL_STANDARD, &fsa, sizeof(fsa)))
546 strcpy(dllfile, "FM3RES");
547 }
548 }
549 }
550 rcl = DosLoadModule(NULL, 0, dllfile, &FM3ModHandle);
551 if (rcl) {
552 saymsg(MB_CANCEL | MB_ICONEXCLAMATION,
553 HWND_DESKTOP,
554 GetPString(IDS_ERRORTEXT), GetPString(IDS_FM3RESERROR1TEXT));
555 return FALSE;
556 }
557 else {
558 rc = DosExitList(EXLST_ADD, DeInitFM3DLL);
559 if (rc) {
560 Dos_Error(MB_ENTER,
561 rc, HWND_DESKTOP, pszSrcFile, __LINE__, "DosExitList failed");
562 }
563 rcq = DosQueryProcAddr(FM3ModHandle, 1, "ResVersion", &pfnResVersion);
564 if (!rcq)
565 ret = pfnResVersion(&RVMajor, &RVMinor);
566 }
567
568 if (RVMajor < VERMAJOR || (RVMajor == VERMAJOR && RVMinor < VERMINOR)) {
569 saymsg(MB_ENTER,
570 HWND_DESKTOP,
571 GetPString(IDS_ERRORTEXT),
572 GetPString(IDS_FM3RESERROR2TEXT),
573 !rcq ?
574 GetPString(IDS_FM3RESERROR3TEXT) :
575 !rcl ?
576 GetPString(IDS_FM3RESERROR4TEXT) :
577 GetPString(IDS_FM3RESERROR5TEXT), RVMajor, RVMinor, rcl, rcq, ret);
578 return FALSE;
579 }
580
581 ArgDriveFlags(argc, argv);
582 FillInDriveFlags(NULL);
583
584 if (!*profile)
585 strcpy(profile, "FM3.INI");
586 mypid = getpid();
587 /* give default appname if none set by caller */
588 if (!*appname)
589 strcpy(appname, FM3Str);
590 /* save appname; may be reset below */
591 strcpy(realappname, appname);
592 if (!strcmp(appname, FM3Str))
593 DosSetMaxFH(100L);
594 else if (!strcmp(appname, "VDir") ||
595 !strcmp(appname, "VTree") ||
596 !strcmp(appname, "VCollect") ||
597 !strcmp(appname, "SEEALL") || !strcmp(appname, "FM/4"))
598 DosSetMaxFH(60L);
599 else
600 DosSetMaxFH(40L);
601
602 if (DosQuerySysInfo(QSV_VERSION_MAJOR,
603 QSV_VERSION_MINOR,
604 (PVOID) OS2ver, (ULONG) sizeof(OS2ver))) {
605 OS2ver[0] = 2;
606 OS2ver[1] = 1;
607 }
608
609 /* set up default root names for temp archive goodies */
610 if (!fAmAV2)
611 strcpy(ArcTempRoot, "$FM$ARC$");
612 else
613 strcpy(ArcTempRoot, "$AV$ARC$");
614
615 /* initialize random number generator */
616 srand(time(NULL) + clock());
617
618 priority_bumped();
619
620 /* _heapmin() is done in a separate thread -- start it */
621 if (_beginthread(HeapThread, NULL, 32768, NULL) == -1) {
622 Runtime_Error(pszSrcFile, __LINE__,
623 GetPString(IDS_COULDNTSTARTTHREADTEXT));
624 return FALSE;
625 }
626 /* timer messages are sent from a separate thread -- start it */
627 if (!StartTimer())
628 return FALSE;
629
630 /* are we the workplace shell? */
631 env = getenv("WORKPLACE_PROCESS");
632 if (!env || stricmp(env, "YES"))
633 fWorkPlace = TRUE;
634
635 if ((!strchr(profile, '\\') && !strchr(profile, ':')) ||
636 !(fmprof = PrfOpenProfile((HAB) 0, profile))) {
637 /* figure out where to put INI file... */
638 CHAR *env, inipath[CCHMAXPATH];
639
640 DosError(FERR_DISABLEHARDERR);
641 save_dir2(HomePath);
642 DosError(FERR_DISABLEHARDERR);
643 memset(driveserial, -1, sizeof(driveserial));
644 *inipath = 0;
645 env = getenv("FM3INI");
646 if (env) {
647 strcpy(inipath, env);
648 DosError(FERR_DISABLEHARDERR);
649 rc = DosQueryPathInfo(inipath, FIL_STANDARD, &fsa, (ULONG) sizeof(fsa));
650 if (!rc) {
651 if (fsa.attrFile & FILE_DIRECTORY) {
652 if (inipath[strlen(inipath) - 1] != '\\')
653 strcat(inipath, "\\");
654 strcat(inipath, profile);
655 }
656 }
657 }
658 if (!env) {
659 env = searchpath(profile);
660 if (!env)
661 env = profile;
662 strcpy(inipath, env);
663 }
664
665 /* in some odd cases the INI file can get set to readonly status */
666 /* here we test it and reset the readonly bit if necessary */
667 if (!*inipath)
668 strcpy(inipath, profile);
669 DosError(FERR_DISABLEHARDERR);
670 if (!DosQueryPathInfo(inipath, FIL_STANDARD, &fsa, (ULONG) sizeof(fsa))) {
671 fIniExisted = TRUE;
672 if (fsa.attrFile & (FILE_READONLY | FILE_HIDDEN | FILE_SYSTEM)) {
673 fsa.attrFile &= (~(FILE_READONLY | FILE_HIDDEN | FILE_SYSTEM));
674 if (DosSetPathInfo(inipath, FIL_STANDARD, (PVOID) & fsa,
675 (ULONG) sizeof(fsa), 0L))
676 saymsg(MB_ENTER,
677 HWND_DESKTOP,
678 GetPString(IDS_ERRORTEXT),
679 GetPString(IDS_INIREADONLYTEXT), inipath);
680 }
681 }
682
683 fmprof = PrfOpenProfile((HAB) 0, inipath);
684 if (!fmprof) {
685 strcpy(inipath, "FM3.INI");
686 fmprof = PrfOpenProfile((HAB) 0, inipath);
687 }
688
689 if (!fmprof) {
690 Win_Error(NULLHANDLE, NULLHANDLE, pszSrcFile, __LINE__,
691 "PrfOpenProfile failed");
692 return FALSE;
693 }
694 }
695
696 FindSwapperDat();
697
698 size = sizeof(BOOL);
699 PrfQueryProfileData(fmprof,
700 FM3Str,
701 "SeparateParms", (PVOID) & fSeparateParms, &size);
702 if (!fSeparateParms)
703 strcpy(appname, FM3Str);
704
705 /* start help */
706 memset(&hini, 0, sizeof(HELPINIT));
707 hini.cb = sizeof(HELPINIT);
708 hini.ulReturnCode = 0L;
709 hini.pszTutorialName = NULL;
710 hini.phtHelpTable = (PHELPTABLE) MAKELONG(ID_HELPTABLE, 0xffff);
711 hini.hmodAccelActionBarModule = (HMODULE) 0;
712 hini.idAccelTable = 0;
713 hini.idActionBar = 0;
714 hini.pszHelpWindowTitle = GetPString(IDS_FM2HELPTITLETEXT);
715 hini.fShowPanelId = CMIC_HIDE_PANEL_ID;
716 hini.pszHelpLibraryName = "FM3.HLP";
717 hwndHelp = WinCreateHelpInstance(hab, &hini);
718 if (!hwndHelp) {
719 static CHAR helppath[CCHMAXPATH]; // fixme to be local?
720
721 env = getenv("FM3INI");
722 if (env) {
723 FILESTATUS3 fsa;
724 APIRET rc;
725
726 strcpy(helppath, env);
727 DosError(FERR_DISABLEHARDERR);
728 rc =
729 DosQueryPathInfo(helppath, FIL_STANDARD, &fsa, (ULONG) sizeof(fsa));
730 if (!rc) {
731 if (fsa.attrFile & FILE_DIRECTORY) {
732 if (helppath[strlen(helppath) - 1] != '\\')
733 strcat(helppath, "\\");
734 strcat(helppath, "FM3.HLP");
735 hini.pszHelpLibraryName = helppath;
736 hwndHelp = WinCreateHelpInstance(hab, &hini);
737 }
738 }
739 }
740 }
741 if (!hwndHelp) {
742 saymsg(MB_ENTER | MB_ICONEXCLAMATION,
743 HWND_DESKTOP,
744 GetPString(IDS_FM2TROUBLETEXT),
745 GetPString(IDS_CANTLOADHELPTEXT),
746 GetPString(IDS_NOHELPACCEPTTEXT));
747 }
748
749 /* a couple of default window procs so we don't have to look them up later */
750 if (WinQueryClassInfo(hab, WC_CONTAINER, &clinfo))
751 PFNWPCnr = clinfo.pfnWindowProc;
752 // saymsg(MB_ENTER,HWND_DESKTOP,"Container flags:","%08lx",clinfo.flClassStyle);
753 if (WinQueryClassInfo(hab, WC_FRAME, &clinfo))
754 PFNWPFrame = clinfo.pfnWindowProc;
755 // saymsg(MB_ENTER,HWND_DESKTOP,"Frame flags:","%08lx",clinfo.flClassStyle);
756 if (WinQueryClassInfo(hab, WC_BUTTON, &clinfo))
757 PFNWPButton = clinfo.pfnWindowProc;
758 // saymsg(MB_ENTER,HWND_DESKTOP,"Button flags:","%08lx",clinfo.flClassStyle);
759 if (WinQueryClassInfo(hab, WC_STATIC, &clinfo))
760 PFNWPStatic = clinfo.pfnWindowProc;
761 // saymsg(MB_ENTER,HWND_DESKTOP,"Static flags:","%08lx",clinfo.flClassStyle);
762 if (WinQueryClassInfo(hab, WC_MLE, &clinfo))
763 PFNWPMLE = clinfo.pfnWindowProc;
764 // saymsg(MB_ENTER,HWND_DESKTOP,"MLE flags:","%08lx",clinfo.flClassStyle);
765 if (!PFNWPCnr || !PFNWPFrame || !PFNWPButton || !PFNWPStatic || !PFNWPMLE) {
766 Runtime_Error(pszSrcFile, __LINE__, "WinQueryClassInfo");
767 return FALSE;
768 }
769
770 /* register window classes we use */
771 WinRegisterClass(hab,
772 WC_MAINWND,
773 MainWndProc,
774 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 8);
775 WinRegisterClass(hab,
776 WC_MAINWND2,
777 MainWndProc2,
778 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 4);
779 WinRegisterClass(hab,
780 WC_TREECONTAINER,
781 TreeClientWndProc,
782 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 2);
783 WinRegisterClass(hab,
784 WC_DIRCONTAINER,
785 DirClientWndProc,
786 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 2);
787 WinRegisterClass(hab,
788 WC_COLLECTOR,
789 CollectorClientWndProc,
790 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 2);
791 WinRegisterClass(hab,
792 WC_ARCCONTAINER,
793 ArcClientWndProc,
794 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 2);
795 WinRegisterClass(hab,
796 WC_MLEEDITOR,
797 MLEEditorProc,
798 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 2);
799 WinRegisterClass(hab,
800 WC_INIEDITOR,
801 IniProc,
802 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 2);
803 WinRegisterClass(hab,
804 WC_TOOLBACK,
805 ToolBackProc, CS_SIZEREDRAW, sizeof(PVOID));
806 WinRegisterClass(hab,
807 WC_DRIVEBACK,
808 DriveBackProc,
809 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
810 sizeof(PVOID));
811 WinRegisterClass(hab,
812 WC_SEEALL,
813 SeeAllWndProc,
814 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID));
815 WinRegisterClass(hab,
816 WC_NEWVIEW,
817 ViewWndProc,
818 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID));
819 WinRegisterClass(hab,
820 WC_TOOLBUTTONS,
821 ChildButtonProc,
822 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
823 sizeof(PVOID));
824 WinRegisterClass(hab,
825 WC_DRIVEBUTTONS,
826 DriveProc,
827 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
828 sizeof(PVOID));
829 WinRegisterClass(hab,
830 WC_BUBBLE,
831 BubbleProc,
832 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
833 sizeof(ULONG) * 2);
834 WinRegisterClass(hab,
835 WC_STATUS,
836 StatusProc,
837 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
838 sizeof(ULONG));
839 WinRegisterClass(hab,
840 WC_DIRSTATUS,
841 DirTextProc,
842 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
843 sizeof(ULONG));
844 WinRegisterClass(hab,
845 WC_TREESTATUS,
846 TreeStatProc,
847 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
848 sizeof(ULONG));
849 WinRegisterClass(hab,
850 WC_ARCSTATUS,
851 ArcTextProc,
852 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
853 sizeof(ULONG));
854 WinRegisterClass(hab,
855 WC_COLSTATUS,
856 CollectorTextProc,
857 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
858 sizeof(ULONG));
859 WinRegisterClass(hab,
860 WC_SEESTATUS,
861 SeeStatusProc,
862 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
863 sizeof(ULONG));
864 WinRegisterClass(hab,
865 WC_VIEWSTATUS,
866 ViewStatusProc,
867 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
868 sizeof(ULONG));
869 WinRegisterClass(hab,
870 WC_ERRORWND,
871 NotifyWndProc,
872 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
873 sizeof(PVOID));
874 WinRegisterClass(hab,
875 WC_MINITIME,
876 MiniTimeProc,
877 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
878 sizeof(PVOID) * 2);
879 WinRegisterClass(hab,
880 WC_DATABAR,
881 DataProc, CS_SIZEREDRAW, sizeof(PVOID));
882 WinRegisterClass(hab,
883 WC_TREEOPENBUTTON,
884 OpenButtonProc,
885 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
886 sizeof(PVOID));
887 WinRegisterClass(hab,
888 WC_AUTOVIEW,
889 AutoViewProc,
890 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
891 sizeof(PVOID));
892 WinRegisterClass(hab,
893 WC_LED,
894 LEDProc,
895 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
896 sizeof(PVOID));
897
898 /*
899 * set some defaults (note: everything else automatically initialized
900 * to 0)
901 */
902 detailssize = detailsea = detailslwdate = detailslwtime = detailsattr =
903 detailsicon = fAutoTile = fConfirmDelete = fLoadSubject = fUnHilite =
904 fLoadLongnames = fToolbar = fSaveState = fGuessType = fToolbarHelp =
905 fAutoAddDirs = fUseNewViewer = fDataToFore = fDataShowDrives =
906 fSplitStatus = fDragndropDlg = fQuickArcFind = fKeepCmdLine =
907 fMoreButtons = fDrivebar = fCollapseFirst = fSwitchTree =
908 fSwitchTreeExpand = fNoSearch = fCustomFileDlg = fOtherHelp =
909 fSaveMiniCmds = fUserComboBox = fFM2Deletes = fConfirmTarget =
910 fShowTarget = fDrivebarHelp = fCheckMM = TRUE;
911 ulCnrType = CCS_EXTENDSEL;
912 FilesToGet = 128L;
913 AutoviewHeight = 48L;
914 strcpy(printer, "PRN");
915 prnwidth = 80;
916 prnlength = 66;
917 prntmargin = 6;
918 prnbmargin = 6;
919 prnlmargin = 6;
920 prnrmargin = 3;
921 prnspacing = 1;
922 prntabspaces = 8;
923 CollectorsortFlags = sortFlags = SORT_DIRSFIRST;
924
925 // load preferences from profile (INI) file
926 size = sizeof(BOOL);
927 PrfQueryProfileData(fmprof,
928 appname, "ShowTarget", (PVOID) & fShowTarget, &size);
929 size = sizeof(BOOL);
930 PrfQueryProfileData(fmprof, appname, "CheckMM", (PVOID) & fCheckMM, &size);
931 size = sizeof(BOOL);
932 PrfQueryProfileData(fmprof,
933 appname,
934 "ChangeTarget", (PVOID) & fChangeTarget, &size);
935 size = sizeof(BOOL);
936 PrfQueryProfileData(fmprof,
937 appname,
938 "ConfirmTarget", (PVOID) & fConfirmTarget, &size);
939 size = sizeof(BOOL);
940 PrfQueryProfileData(fmprof,
941 FM3Str,
942 "CustomFileDlg", (PVOID) & fCustomFileDlg, &size);
943 size = sizeof(BOOL);
944 PrfQueryProfileData(fmprof,
945 FM3Str, "SaveMiniCmds", (PVOID) & fSaveMiniCmds, &size);
946 size = sizeof(BOOL);
947 PrfQueryProfileData(fmprof,
948 appname, "SaveBigCmds", (PVOID) & fSaveBigCmds, &size);
949 size = sizeof(BOOL);
950 PrfQueryProfileData(fmprof,
951 appname, "NoFoldMenu", (PVOID) & fNoFoldMenu, &size);
952 size = sizeof(BOOL);
953 PrfQueryProfileData(fmprof,
954 FM3Str, "ThreadNotes", (PVOID) & fThreadNotes, &size);
955 size = sizeof(BOOL);
956 PrfQueryProfileData(fmprof, FM3Str, "Prnpagenums", (PVOID) & prnpagenums,
957 &size);
958 size = sizeof(BOOL);
959 PrfQueryProfileData(fmprof, FM3Str, "Prnalt", (PVOID) & prnalt, &size);
960 size = sizeof(BOOL);
961 PrfQueryProfileData(fmprof, FM3Str, "Prnformat", (PVOID) & prnformat,
962 &size);
963 size = sizeof(BOOL);
964 PrfQueryProfileData(fmprof, FM3Str, "Prnformfeedbefore",
965 (PVOID) & prnformfeedbefore, &size);
966 size = sizeof(BOOL);
967 PrfQueryProfileData(fmprof,
968 FM3Str,
969 "Prnformfeedafter", (PVOID) & prnformfeedafter, &size);
970 size = sizeof(ULONG);
971 PrfQueryProfileData(fmprof, FM3Str, "Prntabspaces",
972 (PVOID) & prntabspaces, &size);
973 size = sizeof(ULONG);
974 PrfQueryProfileData(fmprof, FM3Str, "Prnwidth", (PVOID) & prnwidth, &size);
975 size = sizeof(ULONG);
976 PrfQueryProfileData(fmprof, FM3Str, "Prnlength", (PVOID) & prnlength,
977 &size);
978 size = sizeof(ULONG);
979 PrfQueryProfileData(fmprof, FM3Str, "Prntmargin", (PVOID) & prntmargin,
980 &size);
981 size = sizeof(ULONG);
982 PrfQueryProfileData(fmprof, FM3Str, "Prnbmargin", (PVOID) & prnbmargin,
983 &size);
984 size = sizeof(ULONG);
985 PrfQueryProfileData(fmprof, FM3Str, "Prnlmargin", (PVOID) & prnlmargin,
986 &size);
987 size = sizeof(ULONG);
988 PrfQueryProfileData(fmprof, FM3Str, "Prnrmargin", (PVOID) & prnrmargin,
989 &size);
990 size = sizeof(ULONG);
991 PrfQueryProfileData(fmprof, FM3Str, "Prnspacing", (PVOID) & prnspacing,
992 &size);
993 size = sizeof(BOOL);
994 PrfQueryProfileData(fmprof, FM3Str, "NoDead", (PVOID) & fNoDead, &size);
995 size = sizeof(BOOL);
996 PrfQueryProfileData(fmprof, FM3Str, "NoFinger", (PVOID) & fNoFinger, &size);
997 size = sizeof(BOOL);
998 PrfQueryProfileData(fmprof, appname, "SwitchTree", (PVOID) & fSwitchTree,
999 &size);
1000 size = sizeof(BOOL);
1001 PrfQueryProfileData(fmprof, appname, "SwitchTreeExpand",
1002 (PVOID) & fSwitchTreeExpand, &size);
1003 size = sizeof(BOOL);
1004 PrfQueryProfileData(fmprof, appname, "SwitchTreeOnFocus",
1005 (PVOID) & fSwitchTreeOnFocus, &size);
1006 size = sizeof(BOOL);
1007 PrfQueryProfileData(fmprof, appname, "CollapseFirst",
1008 (PVOID) & fCollapseFirst, &size);
1009 size = sizeof(BOOL);
1010 PrfQueryProfileData(fmprof, appname, "FilesInTree",
1011 (PVOID) & fFilesInTree, &size);
1012 size = sizeof(BOOL);
1013 PrfQueryProfileData(fmprof, FM3Str, "TopDir", (PVOID) & fTopDir, &size);
1014 size = sizeof(BOOL);
1015 PrfQueryProfileData(fmprof, FM3Str, "LookInDir", (PVOID) & fLookInDir,
1016 &size);
1017 PrfQueryProfileString(fmprof, appname, "DefArc", NULL, szDefArc,
1018 sizeof(szDefArc));
1019 size = sizeof(ULONG);
1020 PrfQueryProfileData(fmprof, FM3Str, "AutoviewHeight",
1021 (PVOID) & AutoviewHeight, &size);
1022 size = sizeof(BOOL);
1023 PrfQueryProfileData(fmprof, FM3Str, "KeepCmdLine", (PVOID) & fKeepCmdLine,
1024 &size);
1025 if (strcmp(realappname, "FM/4")) {
1026 size = sizeof(BOOL);
1027 PrfQueryProfileData(fmprof,
1028 FM3Str, "MoreButtons", (PVOID) & fMoreButtons, &size);
1029 size = sizeof(BOOL);
1030 PrfQueryProfileData(fmprof,
1031 FM3Str, "Drivebar", (PVOID) & fDrivebar, &size);
1032 }
1033 else
1034 fDrivebar = fMoreButtons = TRUE;
1035 size = sizeof(BOOL);
1036 PrfQueryProfileData(fmprof,
1037 appname, "NoSearch", (PVOID) & fNoSearch, &size);
1038 size = sizeof(BOOL);
1039 PrfQueryProfileData(fmprof,
1040 appname, "GuessType", (PVOID) & fGuessType, &size);
1041 size = sizeof(BOOL);
1042 PrfQueryProfileData(fmprof,
1043 appname, "ViewChild", (PVOID) & fViewChild, &size);
1044 size = sizeof(BOOL);
1045 PrfQueryProfileData(fmprof, appname, "ShowEnv", (PVOID) & fShowEnv, &size);
1046 size = sizeof(BOOL);
1047 PrfQueryProfileData(fmprof,
1048 appname, "LeaveTree", (PVOID) & fLeaveTree, &size);
1049 size = sizeof(BOOL);
1050 PrfQueryProfileData(fmprof, FM3Str, "Comments", (PVOID) & fComments, &size);
1051 size = sizeof(ULONG);
1052 PrfQueryProfileData(fmprof, appname, "WS_ANIMATE", (PVOID) & fwsAnimate,
1053 &size);
1054 if (fwsAnimate)
1055 fwsAnimate = WS_ANIMATE;
1056 size = sizeof(ULONG);
1057 size = sizeof(BOOL);
1058 PrfQueryProfileData(fmprof, appname, "SelectedAlways",
1059 (PVOID) & fSelectedAlways, &size);
1060 size = sizeof(BOOL);
1061 PrfQueryProfileData(fmprof, FM3Str, "ToolbarHelp", (PVOID) & fToolbarHelp,
1062 &size);
1063 size = sizeof(BOOL);
1064 PrfQueryProfileData(fmprof, FM3Str, "OtherHelp", (PVOID) & fOtherHelp,
1065 &size);
1066 size = sizeof(BOOL);
1067 PrfQueryProfileData(fmprof, FM3Str, "DrivebarHelp", (PVOID) & fDrivebarHelp,
1068 &size);
1069 size = sizeof(BOOL);
1070 PrfQueryProfileData(fmprof,
1071 appname, "AutoAddDirs", (PVOID) & fAutoAddDirs, &size);
1072 size = sizeof(BOOL);
1073 PrfQueryProfileData(fmprof,
1074 appname,
1075 "AutoAddAllDirs", (PVOID) & fAutoAddAllDirs, &size);
1076 size = sizeof(BOOL);
1077 PrfQueryProfileData(fmprof, FM3Str, "UserListSwitches",
1078 (PVOID) & fUserListSwitches, &size);
1079 size = sizeof(BOOL);
1080 PrfQueryProfileData(fmprof, appname, "UseNewViewer",
1081 (PVOID) & fUseNewViewer, &size);
1082 size = sizeof(BOOL);
1083 PrfQueryProfileData(fmprof, appname, "DefaultDeletePerm",
1084 (PVOID) & fDefaultDeletePerm, &size);
1085 size = sizeof(BOOL);
1086 PrfQueryProfileData(fmprof, FM3Str, "ExternalINIs",
1087 (PVOID) & fExternalINIs, &size);
1088 size = sizeof(BOOL);
1089 PrfQueryProfileData(fmprof, FM3Str, "ExternalCollector",
1090 (PVOID) & fExternalCollector, &size);
1091 size = sizeof(BOOL);
1092 PrfQueryProfileData(fmprof, FM3Str, "ExternalArcboxes",
1093 (PVOID) & fExternalArcboxes, &size);
1094 size = sizeof(BOOL);
1095 PrfQueryProfileData(fmprof, FM3Str, "ExternalViewer",
1096 (PVOID) & fExternalViewer, &size);
1097 size = sizeof(BOOL);
1098 PrfQueryProfileData(fmprof, FM3Str, "UseQProcStat",
1099 (PVOID) & fUseQProcStat, &size);
1100 size = sizeof(BOOL);
1101 PrfQueryProfileData(fmprof, FM3Str, "DataMin", (PVOID) & fDataMin, &size);
1102 size = sizeof(BOOL);
1103 PrfQueryProfileData(fmprof, appname, "DataToFore", (PVOID) & fDataToFore,
1104 &size);
1105 size = sizeof(BOOL);
1106 PrfQueryProfileData(fmprof, appname, "DataShowDrives",
1107 (PVOID) & fDataShowDrives, &size);
1108 size = sizeof(BOOL);
1109 PrfQueryProfileData(fmprof, appname, "DataInclRemote",
1110 (PVOID) & fDataInclRemote, &size);
1111 size = sizeof(BOOL);
1112 PrfQueryProfileData(fmprof, FM3Str, "SplitStatus", (PVOID) & fSplitStatus,
1113 &size);
1114 size = sizeof(BOOL);
1115 PrfQueryProfileData(fmprof, appname, "FolderAfterExtract",
1116 (PVOID) & fFolderAfterExtract, &size);
1117 size = sizeof(BOOL);
1118 PrfQueryProfileData(fmprof, FM3Str, "DullDatabar", (PVOID) & fDullMin,
1119 &size);
1120 size = sizeof(BOOL);
1121 PrfQueryProfileData(fmprof, appname, "BlueLED", (PVOID) & fBlueLED, &size);
1122 size = sizeof(BOOL);
1123 PrfQueryProfileData(fmprof, appname, "ConfirmDelete",
1124 (PVOID) & fConfirmDelete, &size);
1125 size = sizeof(BOOL);
1126 PrfQueryProfileData(fmprof, FM3Str, "SaveState", (PVOID) & fSaveState,
1127 &size);
1128 size = sizeof(BOOL);
1129 PrfQueryProfileData(fmprof, appname, "SyncUpdates", (PVOID) & fSyncUpdates,
1130 &size);
1131 size = sizeof(BOOL);
1132 PrfQueryProfileData(fmprof, appname, "LoadSubject", (PVOID) & fLoadSubject,
1133 &size);
1134 size = sizeof(BOOL);
1135 PrfQueryProfileData(fmprof, appname, "UnHilite", (PVOID) & fUnHilite,
1136 &size);
1137 size = sizeof(BOOL);
1138 PrfQueryProfileData(fmprof, FM3Str, "TileBackwards",
1139 (PVOID) & fTileBackwards, &size);
1140 size = sizeof(BOOL);
1141 PrfQueryProfileData(fmprof, appname, "LoadLongname",
1142 (PVOID) & fLoadLongnames, &size);
1143 size = sizeof(BOOL);
1144 PrfQueryProfileData(fmprof, appname, "VerifyWrites", (PVOID) & fVerify,
1145 &size);
1146 DosSetVerify(fVerify);
1147 size = sizeof(BOOL);
1148 PrfQueryProfileData(fmprof, appname, "DontMoveMouse",
1149 (PVOID) & fDontMoveMouse, &size);
1150 size = sizeof(BOOL);
1151 PrfQueryProfileData(fmprof, appname, "NoIconsFiles",
1152 (PVOID) & fNoIconsFiles, &size);
1153 size = sizeof(BOOL);
1154 PrfQueryProfileData(fmprof, appname, "NoIconsDirs", (PVOID) & fNoIconsDirs,
1155 &size);
1156 size = sizeof(BOOL);
1157 PrfQueryProfileData(fmprof, appname, "ForceUpper", (PVOID) & fForceUpper,
1158 &size);
1159 size = sizeof(BOOL);
1160 PrfQueryProfileData(fmprof, appname, "ForceLower", (PVOID) & fForceLower,
1161 &size);
1162 size = sizeof(BOOL);
1163 PrfQueryProfileData(fmprof, FM3Str, "TextTools", (PVOID) & fTextTools,
1164 &size);
1165 size = sizeof(BOOL);
1166 PrfQueryProfileData(fmprof, FM3Str, "ToolTitles", (PVOID) & fToolTitles,
1167 &size);
1168 size = sizeof(BOOL);
1169 PrfQueryProfileData(fmprof, appname, "DoubleClickOpens", (PVOID) & fDCOpens,
1170 &size);
1171 size = sizeof(BOOL);
1172 PrfQueryProfileData(fmprof, appname, "LinkSetsIcon",
1173 (PVOID) & fLinkSetsIcon, &size);
1174 size = sizeof(INT);
1175 PrfQueryProfileData(fmprof, appname, "Sort", (PVOID) & sortFlags, &size);
1176 size = sizeof(INT);
1177 PrfQueryProfileData(fmprof, appname, "TreeSort", (PVOID) & TreesortFlags,
1178 &size);
1179 size = sizeof(INT);
1180 PrfQueryProfileData(fmprof,
1181 appname,
1182 "CollectorSort", (PVOID) & CollectorsortFlags, &size);
1183 size = sizeof(targetdir);
1184 PrfQueryProfileData(fmprof, appname, "Targetdir", (PVOID) targetdir, &size);
1185 if (!IsValidDir(targetdir))
1186 *targetdir = 0;
1187 size = sizeof(extractpath);
1188 PrfQueryProfileData(fmprof,
1189 appname, "ExtractPath", (PVOID) extractpath, &size);
1190 if (!IsValidDir(extractpath))
1191 *extractpath = 0;
1192 size = sizeof(printer);
1193 PrfQueryProfileData(fmprof, appname, "Printer", (PVOID) printer, &size);
1194 size = sizeof(dircompare);
1195 PrfQueryProfileData(fmprof, appname, "DirCompare", (PVOID) dircompare,
1196 &size);
1197 size = sizeof(viewer);
1198 PrfQueryProfileData(fmprof, appname, "Viewer", (PVOID) viewer, &size);
1199 size = sizeof(editor);
1200 PrfQueryProfileData(fmprof, appname, "Editor", (PVOID) editor, &size);
1201 size = sizeof(binview);
1202 PrfQueryProfileData(fmprof, appname, "BinView", (PVOID) binview, &size);
1203 size = sizeof(bined);
1204 PrfQueryProfileData(fmprof, appname, "BinEd", (PVOID) bined, &size);
1205 size = sizeof(compare);
1206 PrfQueryProfileData(fmprof, appname, "Compare", (PVOID) compare, &size);
1207 size = sizeof(virus);
1208 PrfQueryProfileData(fmprof, appname, "Virus", (PVOID) virus, &size);
1209 size = sizeof(ftprun);
1210 PrfQueryProfileData(fmprof, appname, "FTPRun", (PVOID) ftprun, &size);
1211 if (!*ftprun && !size)
1212 strcpy(ftprun, "ftppm.exe");
1213 size = sizeof(httprun);
1214 PrfQueryProfileData(fmprof, appname, "HTTPRun", (PVOID) httprun, &size);
1215 if (!*httprun && !size)
1216 strcpy(httprun, "explore.exe -q");
1217 size = sizeof(lasttoolbox);
1218 PrfQueryProfileData(fmprof, FM3Str, "LastToolBox", (PVOID) lasttoolbox,
1219 &size);
1220 size = sizeof(BOOL);
1221 PrfQueryProfileData(fmprof, appname, "FollowTree", (PVOID) & fFollowTree,
1222 &size);
1223 size = sizeof(BOOL);
1224 PrfQueryProfileData(fmprof, appname, "StartMaximized",
1225 (PVOID) & fStartMaximized, &size);
1226 if (!fStartMaximized) {
1227 size = sizeof(BOOL);
1228 PrfQueryProfileData(fmprof, appname, "StartMinimized",
1229 (PVOID) & fStartMinimized, &size);
1230 }
1231 size = sizeof(BOOL);
1232 PrfQueryProfileData(fmprof, appname, "DefaultCopy", (PVOID) & fCopyDefault,
1233 &size);
1234 size = sizeof(BOOL);
1235 PrfQueryProfileData(fmprof, appname, "IdleCopy", (PVOID) & fRealIdle,
1236 &size);
1237 size = sizeof(BOOL);
1238 PrfQueryProfileData(fmprof, appname, "ArcStuffVisible",
1239 (PVOID) & fArcStuffVisible, &size);
1240 size = sizeof(BOOL);
1241 PrfQueryProfileData(fmprof, FM3Str, "NoTreeGap", (PVOID) & fNoTreeGap,
1242 &size);
1243 size = sizeof(BOOL);
1244 PrfQueryProfileData(fmprof, FM3Str, "VTreeOpensWPS",
1245 (PVOID) & fVTreeOpensWPS, &size);
1246 size = sizeof(BOOL);
1247 PrfQueryProfileData(fmprof, appname, "RemoteBug", (PVOID) & fRemoteBug,
1248 &size);
1249 size = sizeof(BOOL);
1250 PrfQueryProfileData(fmprof, appname, "Drag&DropDlg",
1251 (PVOID) & fDragndropDlg, &size);
1252 size = sizeof(BOOL);
1253 PrfQueryProfileData(fmprof, FM3Str, "UserComboBox", (PVOID) & fUserComboBox,
1254 &size);
1255 size = sizeof(BOOL);
1256 PrfQueryProfileData(fmprof, FM3Str, "MinDirOnOpen", (PVOID) & fMinOnOpen,
1257 &size);
1258 size = sizeof(BOOL);
1259 PrfQueryProfileData(fmprof, appname, "QuickArcFind",
1260 (PVOID) & fQuickArcFind, &size);
1261 size = sizeof(BOOL);
1262 PrfQueryProfileData(fmprof, FM3Str, "NoRemovableScan",
1263 (PVOID) & fNoRemovableScan, &size);
1264 size = sizeof(ULONG);
1265 PrfQueryProfileData(fmprof, FM3Str, "NoBrokenNotify",
1266 (PVOID) & NoBrokenNotify, &size);
1267 size = sizeof(ULONG);
1268 PrfQueryProfileData(fmprof, appname, "ContainerType", (PVOID) & ulCnrType,
1269 &size);
1270 size = sizeof(ULONG);
1271 PrfQueryProfileData(fmprof, appname, "FilesToGet", (PVOID) & FilesToGet,
1272 &size);
1273 size = sizeof(BOOL);
1274 PrfQueryProfileData(fmprof, FM3Str, "AutoView", (PVOID) & fAutoView, &size);
1275 size = sizeof(BOOL);
1276 PrfQueryProfileData(fmprof, FM3Str, "FM2Deletes", (PVOID) & fFM2Deletes,
1277 &size);
1278
1279 /* load pointers and icons we use */
1280 hptrArrow = WinQuerySysPointer(HWND_DESKTOP, SPTR_ARROW, FALSE);
1281 hptrBusy = WinQuerySysPointer(HWND_DESKTOP, SPTR_WAIT, FALSE);
1282 hptrNS = WinQuerySysPointer(HWND_DESKTOP, SPTR_SIZENS, FALSE);
1283 hptrEW = WinQuerySysPointer(HWND_DESKTOP, SPTR_SIZEWE, FALSE);
1284 hptrFloppy = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, FLOPPY_ICON);
1285 hptrDrive = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, DRIVE_ICON);
1286 hptrRemovable = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, REMOVABLE_ICON);
1287 hptrCDROM = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, CDROM_ICON);
1288 hptrFile = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, FILE_ICON);
1289 hptrDir = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, DIR_FRAME);
1290 hptrArc = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, ARC_FRAME);
1291 hptrArt = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, ART_ICON);
1292 hptrSystem = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, FILE_SYSTEM_ICON);
1293 hptrHidden = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, FILE_HIDDEN_ICON);
1294 hptrReadonly = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, FILE_READONLY_ICON);
1295 hptrLast = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, LASTITEM_ICON);
1296 hptrRemote = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, REMOTE_ICON);
1297 hptrVirtual = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, VIRTUAL_ICON);
1298 hptrRamdisk = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, RAMDISK_ICON);
1299 if (!fNoDead)
1300 hptrFinger = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, FINGER_ICON);
1301 else
1302 hptrFinger = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, FINGER2_ICON);
1303 hptrApp = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, APP_ICON);
1304 hptrDunno = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, DUNNO_ICON);
1305 hptrEnv = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, ENV_ICON);
1306 hptrZipstrm = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, ZIPSTREAM_ICON);
1307
1308 // set up color array used by seeall.c and newview.c color dialog
1309
1310 standardcolors[0] = CLR_WHITE;
1311 standardcolors[1] = CLR_BLACK;
1312 standardcolors[2] = CLR_BLUE;
1313 standardcolors[3] = CLR_RED;
1314 standardcolors[4] = CLR_PINK;
1315 standardcolors[5] = CLR_GREEN;
1316 standardcolors[6] = CLR_CYAN;
1317 standardcolors[7] = CLR_YELLOW;
1318 standardcolors[8] = CLR_DARKGRAY;
1319 standardcolors[9] = CLR_DARKBLUE;
1320 standardcolors[10] = CLR_DARKRED;
1321 standardcolors[11] = CLR_DARKPINK;
1322 standardcolors[12] = CLR_DARKGREEN;
1323 standardcolors[13] = CLR_DARKCYAN;
1324 standardcolors[14] = CLR_BROWN;
1325 standardcolors[15] = CLR_PALEGRAY;
1326
1327 return TRUE;
1328}
1329
1330HWND StartFM3(HAB hab, INT argc, CHAR ** argv)
1331{
1332 HWND hwndFrame;
1333 HWND hwndClient;
1334 UINT x;
1335 ULONG FrameFlags = FCF_TITLEBAR | FCF_SYSMENU |
1336 FCF_SIZEBORDER | FCF_MINMAX |
1337 FCF_ACCELTABLE | FCF_MENU | FCF_ICON | FCF_TASKLIST | FCF_NOBYTEALIGN;
1338
1339 for (x = 1; x < argc; x++) {
1340 if (*argv[x] == '~' && !argv[x][1])
1341 fReminimize = TRUE;
1342 if (*argv[x] == '+' && !argv[x][1])
1343 fLogFile = TRUE;
1344 if (*argv[x] == '-') {
1345 if (!argv[x][1])
1346 fNoSaveState = TRUE;
1347 else
1348 strcpy(profile, &argv[x][1]);
1349 }
1350 }
1351
1352 hwndFrame = WinCreateStdWindow(HWND_DESKTOP,
1353 WS_VISIBLE,
1354 &FrameFlags,
1355 WC_MAINWND,
1356 NULL,
1357 WS_VISIBLE | WS_ANIMATE,
1358 FM3ModHandle, MAIN_FRAME, &hwndClient);
1359 if (hwndFrame) {
1360 WinSetWindowUShort(hwndFrame, QWS_ID, MAIN_FRAME);
1361 if (!WinRestoreWindowPos(FM2Str, "MainWindowPos", hwndFrame)) {
1362
1363 ULONG fl = SWP_MOVE | SWP_SIZE;
1364 RECTL rcl;
1365 ULONG icz = WinQuerySysValue(HWND_DESKTOP, SV_CYICON) * 3L;
1366 ULONG bsz = WinQuerySysValue(HWND_DESKTOP, SV_CYSIZEBORDER);
1367
1368 WinQueryWindowRect(HWND_DESKTOP, &rcl);
1369 rcl.yBottom += icz;
1370 rcl.yTop -= bsz;
1371 rcl.xLeft += bsz;
1372 rcl.xRight -= bsz;
1373 WinSetWindowPos(hwndFrame,
1374 HWND_TOP,
1375 rcl.xLeft,
1376 rcl.yBottom,
1377 rcl.xRight - rcl.xLeft, rcl.yTop - rcl.yBottom, fl);
1378 }
1379 if (fLogFile)
1380 LogFileHandle = _fsopen("FM2.LOG", "a+", SH_DENYWR);
1381 if (hwndHelp)
1382 WinAssociateHelpInstance(hwndHelp, hwndFrame);
1383 PostMsg(hwndClient, UM_SETUP, MPFROMLONG(argc), MPFROMP(argv));
1384 }
1385 return hwndFrame;
1386}
1387
1388int CheckVersion(int vermajor, int verminor)
1389{
1390 int ok = 0;
1391
1392 // fixme to do useful check - was missing in base source
1393
1394#if 0
1395 if (vermajor && verminor) {
1396 *vermajor = VERMAJOR;
1397 *verminor = VERMINOR;
1398 ok = 1;
1399 }
1400#endif
1401
1402 ok = 1;
1403
1404 return ok;
1405}
Note: See TracBrowser for help on using the repository browser.