source: trunk/dll/init.c@ 707

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

Changed again since both WORKPLACE_PROCESS (2.0 beta) and WORKPLACEPROCESS (1.2) are used

  • 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 707 2007-06-24 20:33:29Z 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){
633 env = getenv("WORKPLACE__PROCESS");
634 if (!env || stricmp(env, "YES"))
635 fWorkPlace = TRUE;
636 }
637 else{
638 if (stricmp(env, "YES"))
639 fWorkPlace = TRUE;
640 }
641 if ((!strchr(profile, '\\') && !strchr(profile, ':')) ||
642 !(fmprof = PrfOpenProfile((HAB) 0, profile))) {
643 /* figure out where to put INI file... */
644 CHAR *env, inipath[CCHMAXPATH];
645
646 DosError(FERR_DISABLEHARDERR);
647 save_dir2(HomePath);
648 DosError(FERR_DISABLEHARDERR);
649 memset(driveserial, -1, sizeof(driveserial));
650 *inipath = 0;
651 env = getenv("FM3INI");
652 if (env) {
653 strcpy(inipath, env);
654 DosError(FERR_DISABLEHARDERR);
655 rc = DosQueryPathInfo(inipath, FIL_STANDARD, &fsa, (ULONG) sizeof(fsa));
656 if (!rc) {
657 if (fsa.attrFile & FILE_DIRECTORY) {
658 if (inipath[strlen(inipath) - 1] != '\\')
659 strcat(inipath, "\\");
660 strcat(inipath, profile);
661 }
662 }
663 }
664 if (!env) {
665 env = searchpath(profile);
666 if (!env)
667 env = profile;
668 strcpy(inipath, env);
669 }
670
671 /* in some odd cases the INI file can get set to readonly status */
672 /* here we test it and reset the readonly bit if necessary */
673 if (!*inipath)
674 strcpy(inipath, profile);
675 DosError(FERR_DISABLEHARDERR);
676 if (!DosQueryPathInfo(inipath, FIL_STANDARD, &fsa, (ULONG) sizeof(fsa))) {
677 fIniExisted = TRUE;
678 if (fsa.attrFile & (FILE_READONLY | FILE_HIDDEN | FILE_SYSTEM)) {
679 fsa.attrFile &= (~(FILE_READONLY | FILE_HIDDEN | FILE_SYSTEM));
680 if (DosSetPathInfo(inipath, FIL_STANDARD, (PVOID) & fsa,
681 (ULONG) sizeof(fsa), 0L))
682 saymsg(MB_ENTER,
683 HWND_DESKTOP,
684 GetPString(IDS_ERRORTEXT),
685 GetPString(IDS_INIREADONLYTEXT), inipath);
686 }
687 }
688
689 fmprof = PrfOpenProfile((HAB) 0, inipath);
690 if (!fmprof) {
691 strcpy(inipath, "FM3.INI");
692 fmprof = PrfOpenProfile((HAB) 0, inipath);
693 }
694
695 if (!fmprof) {
696 Win_Error(NULLHANDLE, NULLHANDLE, pszSrcFile, __LINE__,
697 "PrfOpenProfile failed");
698 return FALSE;
699 }
700 }
701
702 FindSwapperDat();
703
704 size = sizeof(BOOL);
705 PrfQueryProfileData(fmprof,
706 FM3Str,
707 "SeparateParms", (PVOID) & fSeparateParms, &size);
708 if (!fSeparateParms)
709 strcpy(appname, FM3Str);
710
711 /* start help */
712 memset(&hini, 0, sizeof(HELPINIT));
713 hini.cb = sizeof(HELPINIT);
714 hini.ulReturnCode = 0L;
715 hini.pszTutorialName = NULL;
716 hini.phtHelpTable = (PHELPTABLE) MAKELONG(ID_HELPTABLE, 0xffff);
717 hini.hmodAccelActionBarModule = (HMODULE) 0;
718 hini.idAccelTable = 0;
719 hini.idActionBar = 0;
720 hini.pszHelpWindowTitle = GetPString(IDS_FM2HELPTITLETEXT);
721 hini.fShowPanelId = CMIC_HIDE_PANEL_ID;
722 hini.pszHelpLibraryName = "FM3.HLP";
723 hwndHelp = WinCreateHelpInstance(hab, &hini);
724 if (!hwndHelp) {
725 static CHAR helppath[CCHMAXPATH]; // fixme to be local?
726
727 env = getenv("FM3INI");
728 if (env) {
729 FILESTATUS3 fsa;
730 APIRET rc;
731
732 strcpy(helppath, env);
733 DosError(FERR_DISABLEHARDERR);
734 rc =
735 DosQueryPathInfo(helppath, FIL_STANDARD, &fsa, (ULONG) sizeof(fsa));
736 if (!rc) {
737 if (fsa.attrFile & FILE_DIRECTORY) {
738 if (helppath[strlen(helppath) - 1] != '\\')
739 strcat(helppath, "\\");
740 strcat(helppath, "FM3.HLP");
741 hini.pszHelpLibraryName = helppath;
742 hwndHelp = WinCreateHelpInstance(hab, &hini);
743 }
744 }
745 }
746 }
747 if (!hwndHelp) {
748 saymsg(MB_ENTER | MB_ICONEXCLAMATION,
749 HWND_DESKTOP,
750 GetPString(IDS_FM2TROUBLETEXT),
751 GetPString(IDS_CANTLOADHELPTEXT),
752 GetPString(IDS_NOHELPACCEPTTEXT));
753 }
754
755 /* a couple of default window procs so we don't have to look them up later */
756 if (WinQueryClassInfo(hab, WC_CONTAINER, &clinfo))
757 PFNWPCnr = clinfo.pfnWindowProc;
758 // saymsg(MB_ENTER,HWND_DESKTOP,"Container flags:","%08lx",clinfo.flClassStyle);
759 if (WinQueryClassInfo(hab, WC_FRAME, &clinfo))
760 PFNWPFrame = clinfo.pfnWindowProc;
761 // saymsg(MB_ENTER,HWND_DESKTOP,"Frame flags:","%08lx",clinfo.flClassStyle);
762 if (WinQueryClassInfo(hab, WC_BUTTON, &clinfo))
763 PFNWPButton = clinfo.pfnWindowProc;
764 // saymsg(MB_ENTER,HWND_DESKTOP,"Button flags:","%08lx",clinfo.flClassStyle);
765 if (WinQueryClassInfo(hab, WC_STATIC, &clinfo))
766 PFNWPStatic = clinfo.pfnWindowProc;
767 // saymsg(MB_ENTER,HWND_DESKTOP,"Static flags:","%08lx",clinfo.flClassStyle);
768 if (WinQueryClassInfo(hab, WC_MLE, &clinfo))
769 PFNWPMLE = clinfo.pfnWindowProc;
770 // saymsg(MB_ENTER,HWND_DESKTOP,"MLE flags:","%08lx",clinfo.flClassStyle);
771 if (!PFNWPCnr || !PFNWPFrame || !PFNWPButton || !PFNWPStatic || !PFNWPMLE) {
772 Runtime_Error(pszSrcFile, __LINE__, "WinQueryClassInfo");
773 return FALSE;
774 }
775
776 /* register window classes we use */
777 WinRegisterClass(hab,
778 WC_MAINWND,
779 MainWndProc,
780 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 8);
781 WinRegisterClass(hab,
782 WC_MAINWND2,
783 MainWndProc2,
784 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 4);
785 WinRegisterClass(hab,
786 WC_TREECONTAINER,
787 TreeClientWndProc,
788 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 2);
789 WinRegisterClass(hab,
790 WC_DIRCONTAINER,
791 DirClientWndProc,
792 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 2);
793 WinRegisterClass(hab,
794 WC_COLLECTOR,
795 CollectorClientWndProc,
796 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 2);
797 WinRegisterClass(hab,
798 WC_ARCCONTAINER,
799 ArcClientWndProc,
800 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 2);
801 WinRegisterClass(hab,
802 WC_MLEEDITOR,
803 MLEEditorProc,
804 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 2);
805 WinRegisterClass(hab,
806 WC_INIEDITOR,
807 IniProc,
808 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 2);
809 WinRegisterClass(hab,
810 WC_TOOLBACK,
811 ToolBackProc, CS_SIZEREDRAW, sizeof(PVOID));
812 WinRegisterClass(hab,
813 WC_DRIVEBACK,
814 DriveBackProc,
815 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
816 sizeof(PVOID));
817 WinRegisterClass(hab,
818 WC_SEEALL,
819 SeeAllWndProc,
820 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID));
821 WinRegisterClass(hab,
822 WC_NEWVIEW,
823 ViewWndProc,
824 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID));
825 WinRegisterClass(hab,
826 WC_TOOLBUTTONS,
827 ChildButtonProc,
828 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
829 sizeof(PVOID));
830 WinRegisterClass(hab,
831 WC_DRIVEBUTTONS,
832 DriveProc,
833 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
834 sizeof(PVOID));
835 WinRegisterClass(hab,
836 WC_BUBBLE,
837 BubbleProc,
838 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
839 sizeof(ULONG) * 2);
840 WinRegisterClass(hab,
841 WC_STATUS,
842 StatusProc,
843 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
844 sizeof(ULONG));
845 WinRegisterClass(hab,
846 WC_DIRSTATUS,
847 DirTextProc,
848 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
849 sizeof(ULONG));
850 WinRegisterClass(hab,
851 WC_TREESTATUS,
852 TreeStatProc,
853 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
854 sizeof(ULONG));
855 WinRegisterClass(hab,
856 WC_ARCSTATUS,
857 ArcTextProc,
858 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
859 sizeof(ULONG));
860 WinRegisterClass(hab,
861 WC_COLSTATUS,
862 CollectorTextProc,
863 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
864 sizeof(ULONG));
865 WinRegisterClass(hab,
866 WC_SEESTATUS,
867 SeeStatusProc,
868 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
869 sizeof(ULONG));
870 WinRegisterClass(hab,
871 WC_VIEWSTATUS,
872 ViewStatusProc,
873 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
874 sizeof(ULONG));
875 WinRegisterClass(hab,
876 WC_ERRORWND,
877 NotifyWndProc,
878 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
879 sizeof(PVOID));
880 WinRegisterClass(hab,
881 WC_MINITIME,
882 MiniTimeProc,
883 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
884 sizeof(PVOID) * 2);
885 WinRegisterClass(hab,
886 WC_DATABAR,
887 DataProc, CS_SIZEREDRAW, sizeof(PVOID));
888 WinRegisterClass(hab,
889 WC_TREEOPENBUTTON,
890 OpenButtonProc,
891 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
892 sizeof(PVOID));
893 WinRegisterClass(hab,
894 WC_AUTOVIEW,
895 AutoViewProc,
896 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
897 sizeof(PVOID));
898 WinRegisterClass(hab,
899 WC_LED,
900 LEDProc,
901 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
902 sizeof(PVOID));
903
904 /*
905 * set some defaults (note: everything else automatically initialized
906 * to 0)
907 */
908 detailssize = detailsea = detailslwdate = detailslwtime = detailsattr =
909 detailsicon = fAutoTile = fConfirmDelete = fLoadSubject = fUnHilite =
910 fLoadLongnames = fToolbar = fSaveState = fGuessType = fToolbarHelp =
911 fAutoAddDirs = fUseNewViewer = fDataToFore = fDataShowDrives =
912 fSplitStatus = fDragndropDlg = fQuickArcFind = fKeepCmdLine =
913 fMoreButtons = fDrivebar = fCollapseFirst = fSwitchTree =
914 fSwitchTreeExpand = fNoSearch = fCustomFileDlg = fOtherHelp =
915 fSaveMiniCmds = fUserComboBox = fFM2Deletes = fConfirmTarget =
916 fShowTarget = fDrivebarHelp = fCheckMM = TRUE;
917 ulCnrType = CCS_EXTENDSEL;
918 FilesToGet = 128L;
919 AutoviewHeight = 48L;
920 strcpy(printer, "PRN");
921 prnwidth = 80;
922 prnlength = 66;
923 prntmargin = 6;
924 prnbmargin = 6;
925 prnlmargin = 6;
926 prnrmargin = 3;
927 prnspacing = 1;
928 prntabspaces = 8;
929 CollectorsortFlags = sortFlags = SORT_DIRSFIRST;
930
931 // load preferences from profile (INI) file
932 size = sizeof(BOOL);
933 PrfQueryProfileData(fmprof,
934 appname, "ShowTarget", (PVOID) & fShowTarget, &size);
935 size = sizeof(BOOL);
936 PrfQueryProfileData(fmprof, appname, "CheckMM", (PVOID) & fCheckMM, &size);
937 size = sizeof(BOOL);
938 PrfQueryProfileData(fmprof,
939 appname,
940 "ChangeTarget", (PVOID) & fChangeTarget, &size);
941 size = sizeof(BOOL);
942 PrfQueryProfileData(fmprof,
943 appname,
944 "ConfirmTarget", (PVOID) & fConfirmTarget, &size);
945 size = sizeof(BOOL);
946 PrfQueryProfileData(fmprof,
947 FM3Str,
948 "CustomFileDlg", (PVOID) & fCustomFileDlg, &size);
949 size = sizeof(BOOL);
950 PrfQueryProfileData(fmprof,
951 FM3Str, "SaveMiniCmds", (PVOID) & fSaveMiniCmds, &size);
952 size = sizeof(BOOL);
953 PrfQueryProfileData(fmprof,
954 appname, "SaveBigCmds", (PVOID) & fSaveBigCmds, &size);
955 size = sizeof(BOOL);
956 PrfQueryProfileData(fmprof,
957 appname, "NoFoldMenu", (PVOID) & fNoFoldMenu, &size);
958 size = sizeof(BOOL);
959 PrfQueryProfileData(fmprof,
960 FM3Str, "ThreadNotes", (PVOID) & fThreadNotes, &size);
961 size = sizeof(BOOL);
962 PrfQueryProfileData(fmprof, FM3Str, "Prnpagenums", (PVOID) & prnpagenums,
963 &size);
964 size = sizeof(BOOL);
965 PrfQueryProfileData(fmprof, FM3Str, "Prnalt", (PVOID) & prnalt, &size);
966 size = sizeof(BOOL);
967 PrfQueryProfileData(fmprof, FM3Str, "Prnformat", (PVOID) & prnformat,
968 &size);
969 size = sizeof(BOOL);
970 PrfQueryProfileData(fmprof, FM3Str, "Prnformfeedbefore",
971 (PVOID) & prnformfeedbefore, &size);
972 size = sizeof(BOOL);
973 PrfQueryProfileData(fmprof,
974 FM3Str,
975 "Prnformfeedafter", (PVOID) & prnformfeedafter, &size);
976 size = sizeof(ULONG);
977 PrfQueryProfileData(fmprof, FM3Str, "Prntabspaces",
978 (PVOID) & prntabspaces, &size);
979 size = sizeof(ULONG);
980 PrfQueryProfileData(fmprof, FM3Str, "Prnwidth", (PVOID) & prnwidth, &size);
981 size = sizeof(ULONG);
982 PrfQueryProfileData(fmprof, FM3Str, "Prnlength", (PVOID) & prnlength,
983 &size);
984 size = sizeof(ULONG);
985 PrfQueryProfileData(fmprof, FM3Str, "Prntmargin", (PVOID) & prntmargin,
986 &size);
987 size = sizeof(ULONG);
988 PrfQueryProfileData(fmprof, FM3Str, "Prnbmargin", (PVOID) & prnbmargin,
989 &size);
990 size = sizeof(ULONG);
991 PrfQueryProfileData(fmprof, FM3Str, "Prnlmargin", (PVOID) & prnlmargin,
992 &size);
993 size = sizeof(ULONG);
994 PrfQueryProfileData(fmprof, FM3Str, "Prnrmargin", (PVOID) & prnrmargin,
995 &size);
996 size = sizeof(ULONG);
997 PrfQueryProfileData(fmprof, FM3Str, "Prnspacing", (PVOID) & prnspacing,
998 &size);
999 size = sizeof(BOOL);
1000 PrfQueryProfileData(fmprof, FM3Str, "NoDead", (PVOID) & fNoDead, &size);
1001 size = sizeof(BOOL);
1002 PrfQueryProfileData(fmprof, FM3Str, "NoFinger", (PVOID) & fNoFinger, &size);
1003 size = sizeof(BOOL);
1004 PrfQueryProfileData(fmprof, appname, "SwitchTree", (PVOID) & fSwitchTree,
1005 &size);
1006 size = sizeof(BOOL);
1007 PrfQueryProfileData(fmprof, appname, "SwitchTreeExpand",
1008 (PVOID) & fSwitchTreeExpand, &size);
1009 size = sizeof(BOOL);
1010 PrfQueryProfileData(fmprof, appname, "SwitchTreeOnFocus",
1011 (PVOID) & fSwitchTreeOnFocus, &size);
1012 size = sizeof(BOOL);
1013 PrfQueryProfileData(fmprof, appname, "CollapseFirst",
1014 (PVOID) & fCollapseFirst, &size);
1015 size = sizeof(BOOL);
1016 PrfQueryProfileData(fmprof, appname, "FilesInTree",
1017 (PVOID) & fFilesInTree, &size);
1018 size = sizeof(BOOL);
1019 PrfQueryProfileData(fmprof, FM3Str, "TopDir", (PVOID) & fTopDir, &size);
1020 size = sizeof(BOOL);
1021 PrfQueryProfileData(fmprof, FM3Str, "LookInDir", (PVOID) & fLookInDir,
1022 &size);
1023 PrfQueryProfileString(fmprof, appname, "DefArc", NULL, szDefArc,
1024 sizeof(szDefArc));
1025 size = sizeof(ULONG);
1026 PrfQueryProfileData(fmprof, FM3Str, "AutoviewHeight",
1027 (PVOID) & AutoviewHeight, &size);
1028 size = sizeof(BOOL);
1029 PrfQueryProfileData(fmprof, FM3Str, "KeepCmdLine", (PVOID) & fKeepCmdLine,
1030 &size);
1031 if (strcmp(realappname, "FM/4")) {
1032 size = sizeof(BOOL);
1033 PrfQueryProfileData(fmprof,
1034 FM3Str, "MoreButtons", (PVOID) & fMoreButtons, &size);
1035 size = sizeof(BOOL);
1036 PrfQueryProfileData(fmprof,
1037 FM3Str, "Drivebar", (PVOID) & fDrivebar, &size);
1038 }
1039 else
1040 fDrivebar = fMoreButtons = TRUE;
1041 size = sizeof(BOOL);
1042 PrfQueryProfileData(fmprof,
1043 appname, "NoSearch", (PVOID) & fNoSearch, &size);
1044 size = sizeof(BOOL);
1045 PrfQueryProfileData(fmprof,
1046 appname, "GuessType", (PVOID) & fGuessType, &size);
1047 size = sizeof(BOOL);
1048 PrfQueryProfileData(fmprof,
1049 appname, "ViewChild", (PVOID) & fViewChild, &size);
1050 size = sizeof(BOOL);
1051 PrfQueryProfileData(fmprof, appname, "ShowEnv", (PVOID) & fShowEnv, &size);
1052 size = sizeof(BOOL);
1053 PrfQueryProfileData(fmprof,
1054 appname, "LeaveTree", (PVOID) & fLeaveTree, &size);
1055 size = sizeof(BOOL);
1056 PrfQueryProfileData(fmprof, FM3Str, "Comments", (PVOID) & fComments, &size);
1057 size = sizeof(ULONG);
1058 PrfQueryProfileData(fmprof, appname, "WS_ANIMATE", (PVOID) & fwsAnimate,
1059 &size);
1060 if (fwsAnimate)
1061 fwsAnimate = WS_ANIMATE;
1062 size = sizeof(ULONG);
1063 size = sizeof(BOOL);
1064 PrfQueryProfileData(fmprof, appname, "SelectedAlways",
1065 (PVOID) & fSelectedAlways, &size);
1066 size = sizeof(BOOL);
1067 PrfQueryProfileData(fmprof, FM3Str, "ToolbarHelp", (PVOID) & fToolbarHelp,
1068 &size);
1069 size = sizeof(BOOL);
1070 PrfQueryProfileData(fmprof, FM3Str, "OtherHelp", (PVOID) & fOtherHelp,
1071 &size);
1072 size = sizeof(BOOL);
1073 PrfQueryProfileData(fmprof, FM3Str, "DrivebarHelp", (PVOID) & fDrivebarHelp,
1074 &size);
1075 size = sizeof(BOOL);
1076 PrfQueryProfileData(fmprof,
1077 appname, "AutoAddDirs", (PVOID) & fAutoAddDirs, &size);
1078 size = sizeof(BOOL);
1079 PrfQueryProfileData(fmprof,
1080 appname,
1081 "AutoAddAllDirs", (PVOID) & fAutoAddAllDirs, &size);
1082 size = sizeof(BOOL);
1083 PrfQueryProfileData(fmprof, FM3Str, "UserListSwitches",
1084 (PVOID) & fUserListSwitches, &size);
1085 size = sizeof(BOOL);
1086 PrfQueryProfileData(fmprof, appname, "UseNewViewer",
1087 (PVOID) & fUseNewViewer, &size);
1088 size = sizeof(BOOL);
1089 PrfQueryProfileData(fmprof, appname, "DefaultDeletePerm",
1090 (PVOID) & fDefaultDeletePerm, &size);
1091 size = sizeof(BOOL);
1092 PrfQueryProfileData(fmprof, FM3Str, "ExternalINIs",
1093 (PVOID) & fExternalINIs, &size);
1094 size = sizeof(BOOL);
1095 PrfQueryProfileData(fmprof, FM3Str, "ExternalCollector",
1096 (PVOID) & fExternalCollector, &size);
1097 size = sizeof(BOOL);
1098 PrfQueryProfileData(fmprof, FM3Str, "ExternalArcboxes",
1099 (PVOID) & fExternalArcboxes, &size);
1100 size = sizeof(BOOL);
1101 PrfQueryProfileData(fmprof, FM3Str, "ExternalViewer",
1102 (PVOID) & fExternalViewer, &size);
1103 size = sizeof(BOOL);
1104 PrfQueryProfileData(fmprof, FM3Str, "UseQProcStat",
1105 (PVOID) & fUseQProcStat, &size);
1106 size = sizeof(BOOL);
1107 PrfQueryProfileData(fmprof, FM3Str, "DataMin", (PVOID) & fDataMin, &size);
1108 size = sizeof(BOOL);
1109 PrfQueryProfileData(fmprof, appname, "DataToFore", (PVOID) & fDataToFore,
1110 &size);
1111 size = sizeof(BOOL);
1112 PrfQueryProfileData(fmprof, appname, "DataShowDrives",
1113 (PVOID) & fDataShowDrives, &size);
1114 size = sizeof(BOOL);
1115 PrfQueryProfileData(fmprof, appname, "DataInclRemote",
1116 (PVOID) & fDataInclRemote, &size);
1117 size = sizeof(BOOL);
1118 PrfQueryProfileData(fmprof, FM3Str, "SplitStatus", (PVOID) & fSplitStatus,
1119 &size);
1120 size = sizeof(BOOL);
1121 PrfQueryProfileData(fmprof, appname, "FolderAfterExtract",
1122 (PVOID) & fFolderAfterExtract, &size);
1123 size = sizeof(BOOL);
1124 PrfQueryProfileData(fmprof, FM3Str, "DullDatabar", (PVOID) & fDullMin,
1125 &size);
1126 size = sizeof(BOOL);
1127 PrfQueryProfileData(fmprof, appname, "BlueLED", (PVOID) & fBlueLED, &size);
1128 size = sizeof(BOOL);
1129 PrfQueryProfileData(fmprof, appname, "ConfirmDelete",
1130 (PVOID) & fConfirmDelete, &size);
1131 size = sizeof(BOOL);
1132 PrfQueryProfileData(fmprof, FM3Str, "SaveState", (PVOID) & fSaveState,
1133 &size);
1134 size = sizeof(BOOL);
1135 PrfQueryProfileData(fmprof, appname, "SyncUpdates", (PVOID) & fSyncUpdates,
1136 &size);
1137 size = sizeof(BOOL);
1138 PrfQueryProfileData(fmprof, appname, "LoadSubject", (PVOID) & fLoadSubject,
1139 &size);
1140 size = sizeof(BOOL);
1141 PrfQueryProfileData(fmprof, appname, "UnHilite", (PVOID) & fUnHilite,
1142 &size);
1143 size = sizeof(BOOL);
1144 PrfQueryProfileData(fmprof, FM3Str, "TileBackwards",
1145 (PVOID) & fTileBackwards, &size);
1146 size = sizeof(BOOL);
1147 PrfQueryProfileData(fmprof, appname, "LoadLongname",
1148 (PVOID) & fLoadLongnames, &size);
1149 size = sizeof(BOOL);
1150 PrfQueryProfileData(fmprof, appname, "VerifyWrites", (PVOID) & fVerify,
1151 &size);
1152 DosSetVerify(fVerify);
1153 size = sizeof(BOOL);
1154 PrfQueryProfileData(fmprof, appname, "DontMoveMouse",
1155 (PVOID) & fDontMoveMouse, &size);
1156 size = sizeof(BOOL);
1157 PrfQueryProfileData(fmprof, appname, "NoIconsFiles",
1158 (PVOID) & fNoIconsFiles, &size);
1159 size = sizeof(BOOL);
1160 PrfQueryProfileData(fmprof, appname, "NoIconsDirs", (PVOID) & fNoIconsDirs,
1161 &size);
1162 size = sizeof(BOOL);
1163 PrfQueryProfileData(fmprof, appname, "ForceUpper", (PVOID) & fForceUpper,
1164 &size);
1165 size = sizeof(BOOL);
1166 PrfQueryProfileData(fmprof, appname, "ForceLower", (PVOID) & fForceLower,
1167 &size);
1168 size = sizeof(BOOL);
1169 PrfQueryProfileData(fmprof, FM3Str, "TextTools", (PVOID) & fTextTools,
1170 &size);
1171 size = sizeof(BOOL);
1172 PrfQueryProfileData(fmprof, FM3Str, "ToolTitles", (PVOID) & fToolTitles,
1173 &size);
1174 size = sizeof(BOOL);
1175 PrfQueryProfileData(fmprof, appname, "DoubleClickOpens", (PVOID) & fDCOpens,
1176 &size);
1177 size = sizeof(BOOL);
1178 PrfQueryProfileData(fmprof, appname, "LinkSetsIcon",
1179 (PVOID) & fLinkSetsIcon, &size);
1180 size = sizeof(INT);
1181 PrfQueryProfileData(fmprof, appname, "Sort", (PVOID) & sortFlags, &size);
1182 size = sizeof(INT);
1183 PrfQueryProfileData(fmprof, appname, "TreeSort", (PVOID) & TreesortFlags,
1184 &size);
1185 size = sizeof(INT);
1186 PrfQueryProfileData(fmprof,
1187 appname,
1188 "CollectorSort", (PVOID) & CollectorsortFlags, &size);
1189 size = sizeof(targetdir);
1190 PrfQueryProfileData(fmprof, appname, "Targetdir", (PVOID) targetdir, &size);
1191 if (!IsValidDir(targetdir))
1192 *targetdir = 0;
1193 size = sizeof(extractpath);
1194 PrfQueryProfileData(fmprof,
1195 appname, "ExtractPath", (PVOID) extractpath, &size);
1196 if (!IsValidDir(extractpath))
1197 *extractpath = 0;
1198 size = sizeof(printer);
1199 PrfQueryProfileData(fmprof, appname, "Printer", (PVOID) printer, &size);
1200 size = sizeof(dircompare);
1201 PrfQueryProfileData(fmprof, appname, "DirCompare", (PVOID) dircompare,
1202 &size);
1203 size = sizeof(viewer);
1204 PrfQueryProfileData(fmprof, appname, "Viewer", (PVOID) viewer, &size);
1205 size = sizeof(editor);
1206 PrfQueryProfileData(fmprof, appname, "Editor", (PVOID) editor, &size);
1207 size = sizeof(binview);
1208 PrfQueryProfileData(fmprof, appname, "BinView", (PVOID) binview, &size);
1209 size = sizeof(bined);
1210 PrfQueryProfileData(fmprof, appname, "BinEd", (PVOID) bined, &size);
1211 size = sizeof(compare);
1212 PrfQueryProfileData(fmprof, appname, "Compare", (PVOID) compare, &size);
1213 size = sizeof(virus);
1214 PrfQueryProfileData(fmprof, appname, "Virus", (PVOID) virus, &size);
1215 size = sizeof(ftprun);
1216 PrfQueryProfileData(fmprof, appname, "FTPRun", (PVOID) ftprun, &size);
1217 if (!*ftprun && !size)
1218 strcpy(ftprun, "ftppm.exe");
1219 size = sizeof(httprun);
1220 PrfQueryProfileData(fmprof, appname, "HTTPRun", (PVOID) httprun, &size);
1221 if (!*httprun && !size)
1222 strcpy(httprun, "explore.exe -q");
1223 size = sizeof(lasttoolbox);
1224 PrfQueryProfileData(fmprof, FM3Str, "LastToolBox", (PVOID) lasttoolbox,
1225 &size);
1226 size = sizeof(BOOL);
1227 PrfQueryProfileData(fmprof, appname, "FollowTree", (PVOID) & fFollowTree,
1228 &size);
1229 size = sizeof(BOOL);
1230 PrfQueryProfileData(fmprof, appname, "StartMaximized",
1231 (PVOID) & fStartMaximized, &size);
1232 if (!fStartMaximized) {
1233 size = sizeof(BOOL);
1234 PrfQueryProfileData(fmprof, appname, "StartMinimized",
1235 (PVOID) & fStartMinimized, &size);
1236 }
1237 size = sizeof(BOOL);
1238 PrfQueryProfileData(fmprof, appname, "DefaultCopy", (PVOID) & fCopyDefault,
1239 &size);
1240 size = sizeof(BOOL);
1241 PrfQueryProfileData(fmprof, appname, "IdleCopy", (PVOID) & fRealIdle,
1242 &size);
1243 size = sizeof(BOOL);
1244 PrfQueryProfileData(fmprof, appname, "ArcStuffVisible",
1245 (PVOID) & fArcStuffVisible, &size);
1246 size = sizeof(BOOL);
1247 PrfQueryProfileData(fmprof, FM3Str, "NoTreeGap", (PVOID) & fNoTreeGap,
1248 &size);
1249 size = sizeof(BOOL);
1250 PrfQueryProfileData(fmprof, FM3Str, "VTreeOpensWPS",
1251 (PVOID) & fVTreeOpensWPS, &size);
1252 size = sizeof(BOOL);
1253 PrfQueryProfileData(fmprof, appname, "RemoteBug", (PVOID) & fRemoteBug,
1254 &size);
1255 size = sizeof(BOOL);
1256 PrfQueryProfileData(fmprof, appname, "Drag&DropDlg",
1257 (PVOID) & fDragndropDlg, &size);
1258 size = sizeof(BOOL);
1259 PrfQueryProfileData(fmprof, FM3Str, "UserComboBox", (PVOID) & fUserComboBox,
1260 &size);
1261 size = sizeof(BOOL);
1262 PrfQueryProfileData(fmprof, FM3Str, "MinDirOnOpen", (PVOID) & fMinOnOpen,
1263 &size);
1264 size = sizeof(BOOL);
1265 PrfQueryProfileData(fmprof, appname, "QuickArcFind",
1266 (PVOID) & fQuickArcFind, &size);
1267 size = sizeof(BOOL);
1268 PrfQueryProfileData(fmprof, FM3Str, "NoRemovableScan",
1269 (PVOID) & fNoRemovableScan, &size);
1270 size = sizeof(ULONG);
1271 PrfQueryProfileData(fmprof, FM3Str, "NoBrokenNotify",
1272 (PVOID) & NoBrokenNotify, &size);
1273 size = sizeof(ULONG);
1274 PrfQueryProfileData(fmprof, appname, "ContainerType", (PVOID) & ulCnrType,
1275 &size);
1276 size = sizeof(ULONG);
1277 PrfQueryProfileData(fmprof, appname, "FilesToGet", (PVOID) & FilesToGet,
1278 &size);
1279 size = sizeof(BOOL);
1280 PrfQueryProfileData(fmprof, FM3Str, "AutoView", (PVOID) & fAutoView, &size);
1281 size = sizeof(BOOL);
1282 PrfQueryProfileData(fmprof, FM3Str, "FM2Deletes", (PVOID) & fFM2Deletes,
1283 &size);
1284
1285 /* load pointers and icons we use */
1286 hptrArrow = WinQuerySysPointer(HWND_DESKTOP, SPTR_ARROW, FALSE);
1287 hptrBusy = WinQuerySysPointer(HWND_DESKTOP, SPTR_WAIT, FALSE);
1288 hptrNS = WinQuerySysPointer(HWND_DESKTOP, SPTR_SIZENS, FALSE);
1289 hptrEW = WinQuerySysPointer(HWND_DESKTOP, SPTR_SIZEWE, FALSE);
1290 hptrFloppy = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, FLOPPY_ICON);
1291 hptrDrive = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, DRIVE_ICON);
1292 hptrRemovable = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, REMOVABLE_ICON);
1293 hptrCDROM = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, CDROM_ICON);
1294 hptrFile = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, FILE_ICON);
1295 hptrDir = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, DIR_FRAME);
1296 hptrArc = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, ARC_FRAME);
1297 hptrArt = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, ART_ICON);
1298 hptrSystem = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, FILE_SYSTEM_ICON);
1299 hptrHidden = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, FILE_HIDDEN_ICON);
1300 hptrReadonly = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, FILE_READONLY_ICON);
1301 hptrLast = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, LASTITEM_ICON);
1302 hptrRemote = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, REMOTE_ICON);
1303 hptrVirtual = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, VIRTUAL_ICON);
1304 hptrRamdisk = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, RAMDISK_ICON);
1305 if (!fNoDead)
1306 hptrFinger = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, FINGER_ICON);
1307 else
1308 hptrFinger = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, FINGER2_ICON);
1309 hptrApp = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, APP_ICON);
1310 hptrDunno = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, DUNNO_ICON);
1311 hptrEnv = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, ENV_ICON);
1312 hptrZipstrm = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, ZIPSTREAM_ICON);
1313
1314 // set up color array used by seeall.c and newview.c color dialog
1315
1316 standardcolors[0] = CLR_WHITE;
1317 standardcolors[1] = CLR_BLACK;
1318 standardcolors[2] = CLR_BLUE;
1319 standardcolors[3] = CLR_RED;
1320 standardcolors[4] = CLR_PINK;
1321 standardcolors[5] = CLR_GREEN;
1322 standardcolors[6] = CLR_CYAN;
1323 standardcolors[7] = CLR_YELLOW;
1324 standardcolors[8] = CLR_DARKGRAY;
1325 standardcolors[9] = CLR_DARKBLUE;
1326 standardcolors[10] = CLR_DARKRED;
1327 standardcolors[11] = CLR_DARKPINK;
1328 standardcolors[12] = CLR_DARKGREEN;
1329 standardcolors[13] = CLR_DARKCYAN;
1330 standardcolors[14] = CLR_BROWN;
1331 standardcolors[15] = CLR_PALEGRAY;
1332
1333 return TRUE;
1334}
1335
1336HWND StartFM3(HAB hab, INT argc, CHAR ** argv)
1337{
1338 HWND hwndFrame;
1339 HWND hwndClient;
1340 UINT x;
1341 ULONG FrameFlags = FCF_TITLEBAR | FCF_SYSMENU |
1342 FCF_SIZEBORDER | FCF_MINMAX |
1343 FCF_ACCELTABLE | FCF_MENU | FCF_ICON | FCF_TASKLIST | FCF_NOBYTEALIGN;
1344
1345 for (x = 1; x < argc; x++) {
1346 if (*argv[x] == '~' && !argv[x][1])
1347 fReminimize = TRUE;
1348 if (*argv[x] == '+' && !argv[x][1])
1349 fLogFile = TRUE;
1350 if (*argv[x] == '-') {
1351 if (!argv[x][1])
1352 fNoSaveState = TRUE;
1353 else
1354 strcpy(profile, &argv[x][1]);
1355 }
1356 }
1357
1358 hwndFrame = WinCreateStdWindow(HWND_DESKTOP,
1359 WS_VISIBLE,
1360 &FrameFlags,
1361 WC_MAINWND,
1362 NULL,
1363 WS_VISIBLE | WS_ANIMATE,
1364 FM3ModHandle, MAIN_FRAME, &hwndClient);
1365 if (hwndFrame) {
1366 WinSetWindowUShort(hwndFrame, QWS_ID, MAIN_FRAME);
1367 if (!WinRestoreWindowPos(FM2Str, "MainWindowPos", hwndFrame)) {
1368
1369 ULONG fl = SWP_MOVE | SWP_SIZE;
1370 RECTL rcl;
1371 ULONG icz = WinQuerySysValue(HWND_DESKTOP, SV_CYICON) * 3L;
1372 ULONG bsz = WinQuerySysValue(HWND_DESKTOP, SV_CYSIZEBORDER);
1373
1374 WinQueryWindowRect(HWND_DESKTOP, &rcl);
1375 rcl.yBottom += icz;
1376 rcl.yTop -= bsz;
1377 rcl.xLeft += bsz;
1378 rcl.xRight -= bsz;
1379 WinSetWindowPos(hwndFrame,
1380 HWND_TOP,
1381 rcl.xLeft,
1382 rcl.yBottom,
1383 rcl.xRight - rcl.xLeft, rcl.yTop - rcl.yBottom, fl);
1384 }
1385 if (fLogFile)
1386 LogFileHandle = _fsopen("FM2.LOG", "a+", SH_DENYWR);
1387 if (hwndHelp)
1388 WinAssociateHelpInstance(hwndHelp, hwndFrame);
1389 PostMsg(hwndClient, UM_SETUP, MPFROMLONG(argc), MPFROMP(argv));
1390 }
1391 return hwndFrame;
1392}
1393
1394int CheckVersion(int vermajor, int verminor)
1395{
1396 int ok = 0;
1397
1398 // fixme to do useful check - was missing in base source
1399
1400#if 0
1401 if (vermajor && verminor) {
1402 *vermajor = VERMAJOR;
1403 *verminor = VERMINOR;
1404 ok = 1;
1405 }
1406#endif
1407
1408 ok = 1;
1409
1410 return ok;
1411}
Note: See TracBrowser for help on using the repository browser.