source: trunk/dll/init.c@ 1012

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

Fixed crash on directory container close with fortify enabled; fixed memory leak in assoc.c;added a fortify scope to correspond to the loading and unloading of fm3.dll

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