source: trunk/dll/init.c@ 1073

Last change on this file since 1073 was 1073, checked in by Gregg Young, 17 years ago

Fm2 uses TMP/TEMP directory if set for temporary files and directories. Ticket 20

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