source: trunk/dll/init.c@ 917

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

Correct/enhance settings notebook navigation, ticket #188 (Steven)
Reopen settings notebook to last selected page unless overridden, ticket #188 (Steven)
More Compare Directory overflow tweaks (Steven)

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