source: trunk/dll/init.c@ 690

Last change on this file since 690 was 690, checked in by Steven Levine, 18 years ago

Commit more OpenWatcom compatibility updates

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