source: trunk/dll/init.c@ 775

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

Minor clean up add comments re recent changes

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