source: trunk/dll/init.c@ 841

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

This implements large file support; The wrappers to allow WARP3 compatibility are not done so this will not run on Warp3or Warp 4 pre fixpack 12(?)

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