source: trunk/dll/init.c@ 1077

Last change on this file since 1077 was 1077, checked in by Steven Levine, 17 years ago

Enhance Fortify infrastructure
Add Fortify_SetOwner Fortify_ChangeOwner Fortify_ChangeScope
Add FORTIFY_VERBOSE_SCOPE_ENTER_EXIT support
Add more fm/2 Fortify tooling and rework existing tooling for correct nesting
Still lots to do for cross-thread allocations
Add misc.h
Add walkem.h

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