source: trunk/dll/init.c@ 756

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

Cleanup for ticket 138 & 24

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