source: trunk/dll/init.c@ 789

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

Rework SaveDirCnrState to return better error info
Make FILESTOGET_MIN/MAX to avoid hardcoded numbers
Ensure FilesToGet in valid range on init
Correct load_setups error reporting

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