source: trunk/dll/init.c@ 1063

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

Fortify ifdef reformat

  • 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 1063 2008-07-11 03:33:36Z 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 if (FM3ModHandle)
541 DosFreeModule(FM3ModHandle);
542
543 DosExitList(EXLST_REMOVE, DeInitFM3DLL);
544}
545
546BOOL InitFM3DLL(HAB hab, int argc, char **argv)
547{
548 /*
549 * this function should be called by any application using this DLL right
550 * after setting up a message queue
551 */
552
553 CLASSINFO clinfo;
554 APIRET rc;
555 APIRET rcl = 1;
556 APIRET rcq = 1;
557 PFN pfnResVersion = (PFN)NULL;
558 ULONG RVMajor = 0;
559 ULONG RVMinor = 0;
560 ULONG ret = 0;
561 FILESTATUS3 fs3; // 25 Aug 07 SHL
562 PSZ env;
563 CHAR dllfile[CCHMAXPATH];
564 ULONG size;
565
566 if (!StringsLoaded()) {
567 saymsg(MB_ENTER,
568 HWND_DESKTOP,
569 "Error",
570 "FM3RES.STR isn't in right format, at least "
571 "for this version of FM/2.");
572 return FALSE;
573 }
574
575 strcpy(dllfile, "FM3RES");
576 env = getenv("FM3INI");
577 if (env) {
578 DosError(FERR_DISABLEHARDERR);
579 rc = DosQueryPathInfo(env, FIL_STANDARD, &fs3, sizeof(fs3));
580 if (!rc) {
581 if (fs3.attrFile & FILE_DIRECTORY) {
582 BldFullPathName(dllfile, env, "FM3RES"); // 23 Aug 07 SHL
583 DosError(FERR_DISABLEHARDERR);
584 if (DosQueryPathInfo(dllfile, FIL_STANDARD, &fs3, sizeof(fs3)))
585 strcpy(dllfile, "FM3RES");
586 }
587 }
588 }
589 rcl = DosLoadModule(NULL, 0, dllfile, &FM3ModHandle);
590 if (rcl) {
591 saymsg(MB_CANCEL | MB_ICONEXCLAMATION,
592 HWND_DESKTOP,
593 GetPString(IDS_ERRORTEXT), GetPString(IDS_FM3RESERROR1TEXT));
594 return FALSE;
595 }
596 else {
597 rc = DosExitList(EXLST_ADD, DeInitFM3DLL);
598 if (rc) {
599 Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
600 "DosExitList");
601 }
602 rcq = DosQueryProcAddr(FM3ModHandle, 1, "ResVersion", &pfnResVersion);
603 if (!rcq)
604 ret = pfnResVersion(&RVMajor, &RVMinor);
605 }
606 if (RVMajor < VERMAJOR || (RVMajor == VERMAJOR && RVMinor < VERMINOR)) {
607 saymsg(MB_ENTER,
608 HWND_DESKTOP,
609 GetPString(IDS_ERRORTEXT),
610 GetPString(IDS_FM3RESERROR2TEXT),
611 !rcq ?
612 GetPString(IDS_FM3RESERROR3TEXT) :
613 !rcl ?
614 GetPString(IDS_FM3RESERROR4TEXT) :
615 GetPString(IDS_FM3RESERROR5TEXT), RVMajor, RVMinor, rcl, rcq, ret);
616 return FALSE;
617 }
618
619 ArgDriveFlags(argc, argv);
620 FillInDriveFlags(NULL);
621
622 if (!*profile)
623 strcpy(profile, "FM3.INI");
624 mypid = getpid();
625 /* give default appname if none set by caller */
626 if (!*appname)
627 strcpy(appname, FM3Str);
628 /* save appname; may be reset below */
629 strcpy(realappname, appname);
630 if (!strcmp(appname, FM3Str))
631 DosSetMaxFH(100);
632 else if (!strcmp(appname, "VDir") ||
633 !strcmp(appname, "VTree") ||
634 !strcmp(appname, "VCollect") ||
635 !strcmp(appname, "SEEALL") || !strcmp(appname, "FM/4"))
636 DosSetMaxFH(60);
637 else
638 DosSetMaxFH(40);
639
640 if (DosQuerySysInfo(QSV_VERSION_MAJOR,
641 QSV_VERSION_MINOR,
642 OS2ver,
643 sizeof(OS2ver))) {
644 OS2ver[0] = 2;
645 OS2ver[1] = 1;
646 }
647
648 /* set up default root names for temp archive goodies */
649 if (!fAmAV2)
650 strcpy(ArcTempRoot, "$FM$ARC$");
651 else
652 strcpy(ArcTempRoot, "$AV$ARC$");
653
654 /* initialize random number generator */
655 srand(time(NULL) + clock());
656
657 priority_bumped();
658
659 /* _heapmin() is done in a separate thread -- start it */
660 if (_beginthread(HeapThread, NULL, 32768, NULL) == -1) {
661 Runtime_Error(pszSrcFile, __LINE__,
662 GetPString(IDS_COULDNTSTARTTHREADTEXT));
663 return FALSE;
664 }
665
666 /* timer messages are sent from a separate thread -- start it */
667 if (!StartTimer()) {
668 Runtime_Error(pszSrcFile, __LINE__,
669 GetPString(IDS_COULDNTSTARTTHREADTEXT));
670 return FALSE;
671 }
672
673 /* Are we the workplace shell? */
674 env = getenv("WORKPLACE_PROCESS");
675 fWorkPlace = env != NULL &&
676 (stricmp(env, "YES") == 0 || atoi(env) == 1);
677
678 if ((!strchr(profile, '\\') && !strchr(profile, ':')) ||
679 !(fmprof = PrfOpenProfile((HAB)0, profile)))
680 {
681 /* figure out where to put INI file... */
682 CHAR inipath[CCHMAXPATH];
683
684 DosError(FERR_DISABLEHARDERR);
685 save_dir2(HomePath);
686 DosError(FERR_DISABLEHARDERR);
687 memset(driveserial, -1, sizeof(driveserial));
688 *inipath = 0;
689 env = getenv("FM3INI");
690 if (env) {
691 strcpy(inipath, env);
692 DosError(FERR_DISABLEHARDERR);
693 rc = DosQueryPathInfo(inipath, FIL_STANDARD, &fs3, sizeof(fs3));
694 if (!rc) {
695 if (fs3.attrFile & FILE_DIRECTORY)
696 BldFullPathName(inipath, inipath, profile);
697 }
698 }
699 if (!env) {
700 env = searchpath(profile);
701 if (!env)
702 env = profile;
703 strcpy(inipath, env);
704 }
705
706 /* in some odd cases the INI file can get set to readonly status */
707 /* here we test it and reset the readonly bit if necessary */
708 if (!*inipath)
709 strcpy(inipath, profile);
710 DosError(FERR_DISABLEHARDERR);
711
712 rc = DosQueryPathInfo(inipath, FIL_STANDARD, &fs3, sizeof(fs3));
713 if (rc) {
714 if (rc == ERROR_FILE_NOT_FOUND)
715 fWantFirstTimeInit = TRUE;
716 }
717 else {
718 if (!CheckFileHeader(inipath, "\xff\xff\xff\xff\x14\x00\x00\x00", 0L)) {
719 saymsg(MB_ENTER,HWND_DESKTOP,DEBUG_STRING,
720 "Check INI header failed will attempt to replace with backup \\
721 if backup fails or not found will open with new ini");
722 DosCopy("FM3.INI", "FM3INI.BAD", DCPY_EXISTING);
723 DosCopy("FM3INI.BAK", "FM3.INI", DCPY_EXISTING);
724 if (!CheckFileHeader(inipath, "\xff\xff\xff\xff\x14\x00\x00\x00", 0L)) {
725 DosCopy("FM3.INI", "FM3INI2.BAD", DCPY_EXISTING);
726 fWantFirstTimeInit = TRUE;
727 }
728 }
729 if (!fWantFirstTimeInit) {
730 fIniExisted = TRUE;
731 if (fs3.attrFile & (FILE_READONLY | FILE_HIDDEN | FILE_SYSTEM)) {
732 fs3.attrFile &= ~(FILE_READONLY | FILE_HIDDEN | FILE_SYSTEM);
733 rc = xDosSetPathInfo(inipath, FIL_STANDARD, &fs3, sizeof(fs3), 0);
734 if (rc) {
735 Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
736 GetPString(IDS_INIREADONLYTEXT), inipath);
737 }
738 }
739 }
740 }
741 fmprof = PrfOpenProfile((HAB)0, inipath);
742 if (!fmprof) {
743 strcpy(inipath, "FM3.INI");
744 fmprof = PrfOpenProfile((HAB)0, inipath);
745 }
746
747 // 10 Jan 08 SHL fixme to do first time if new ini
748 // 10 Jan 08 SHL post UM_FIRSTTIME to main window
749 if (!fmprof) {
750 Win_Error(NULLHANDLE, NULLHANDLE, pszSrcFile, __LINE__,
751 "PrfOpenProfile");
752 return FALSE;
753 }
754 }
755
756 FindSwapperDat();
757
758 size = sizeof(BOOL);
759 PrfQueryProfileData(fmprof,
760 FM3Str,
761 "SeparateParms",
762 &fSeparateParms,
763 &size);
764 if (!fSeparateParms)
765 strcpy(appname, FM3Str);
766
767 /* start help */
768 memset(&hini, 0, sizeof(HELPINIT));
769 hini.cb = sizeof(HELPINIT);
770 hini.ulReturnCode = 0;
771 hini.pszTutorialName = NULL;
772 hini.phtHelpTable = (PHELPTABLE) MAKELONG(ID_HELPTABLE, 0xffff);
773 hini.hmodAccelActionBarModule = (HMODULE) 0;
774 hini.idAccelTable = 0;
775 hini.idActionBar = 0;
776 hini.pszHelpWindowTitle = GetPString(IDS_FM2HELPTITLETEXT);
777 hini.fShowPanelId = CMIC_HIDE_PANEL_ID;
778 hini.pszHelpLibraryName = "FM3.HLP";
779 hwndHelp = WinCreateHelpInstance(hab, &hini);
780 if (!hwndHelp) {
781 static CHAR helppath[CCHMAXPATH]; // fixme to be local?
782
783 env = getenv("FM3INI");
784 if (env) {
785 strcpy(helppath, env);
786 DosError(FERR_DISABLEHARDERR);
787 rc = DosQueryPathInfo(helppath, FIL_STANDARD, &fs3, sizeof(fs3));
788 if (!rc) {
789 if (fs3.attrFile & FILE_DIRECTORY) {
790 BldFullPathName(helppath, helppath, "FM3.HLP");
791 hini.pszHelpLibraryName = helppath;
792 hwndHelp = WinCreateHelpInstance(hab, &hini);
793 }
794 }
795 }
796 }
797 if (!hwndHelp) {
798 saymsg(MB_ENTER | MB_ICONEXCLAMATION,
799 HWND_DESKTOP,
800 GetPString(IDS_FM2TROUBLETEXT),
801 GetPString(IDS_CANTLOADHELPTEXT),
802 GetPString(IDS_NOHELPACCEPTTEXT));
803 }
804
805 /* a couple of default window procs so we don't have to look them up later */
806 if (WinQueryClassInfo(hab, WC_CONTAINER, &clinfo))
807 PFNWPCnr = clinfo.pfnWindowProc;
808 // saymsg(MB_ENTER,HWND_DESKTOP,"Container flags:","%08lx",clinfo.flClassStyle);
809 if (WinQueryClassInfo(hab, WC_FRAME, &clinfo))
810 PFNWPFrame = clinfo.pfnWindowProc;
811 // saymsg(MB_ENTER,HWND_DESKTOP,"Frame flags:","%08lx",clinfo.flClassStyle);
812 if (WinQueryClassInfo(hab, WC_BUTTON, &clinfo))
813 PFNWPButton = clinfo.pfnWindowProc;
814 // saymsg(MB_ENTER,HWND_DESKTOP,"Button flags:","%08lx",clinfo.flClassStyle);
815 if (WinQueryClassInfo(hab, WC_STATIC, &clinfo))
816 PFNWPStatic = clinfo.pfnWindowProc;
817 // saymsg(MB_ENTER,HWND_DESKTOP,"Static flags:","%08lx",clinfo.flClassStyle);
818 if (WinQueryClassInfo(hab, WC_MLE, &clinfo))
819 PFNWPMLE = clinfo.pfnWindowProc;
820 // saymsg(MB_ENTER,HWND_DESKTOP,"MLE flags:","%08lx",clinfo.flClassStyle);
821 if (!PFNWPCnr || !PFNWPFrame || !PFNWPButton || !PFNWPStatic || !PFNWPMLE) {
822 Runtime_Error(pszSrcFile, __LINE__, "WinQueryClassInfo");
823 return FALSE;
824 }
825
826 /* register window classes we use */
827 WinRegisterClass(hab,
828 WC_MAINWND,
829 MainWndProc,
830 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 8);
831 WinRegisterClass(hab,
832 WC_MAINWND2,
833 MainWndProc2,
834 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 4);
835 WinRegisterClass(hab,
836 WC_TREECONTAINER,
837 TreeClientWndProc,
838 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 2);
839 WinRegisterClass(hab,
840 WC_DIRCONTAINER,
841 DirClientWndProc,
842 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 2);
843 WinRegisterClass(hab,
844 WC_COLLECTOR,
845 CollectorClientWndProc,
846 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 2);
847 WinRegisterClass(hab,
848 WC_ARCCONTAINER,
849 ArcClientWndProc,
850 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 2);
851 WinRegisterClass(hab,
852 WC_MLEEDITOR,
853 MLEEditorProc,
854 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 2);
855 WinRegisterClass(hab,
856 WC_INIEDITOR,
857 IniProc,
858 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 2);
859 WinRegisterClass(hab,
860 WC_TOOLBACK,
861 ToolBackProc,
862 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
863 sizeof(PVOID));
864 WinRegisterClass(hab,
865 WC_DRIVEBACK,
866 DriveBackProc,
867 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
868 sizeof(PVOID));
869 WinRegisterClass(hab,
870 WC_SEEALL,
871 SeeAllWndProc,
872 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID));
873 WinRegisterClass(hab,
874 WC_NEWVIEW,
875 ViewWndProc,
876 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID));
877 WinRegisterClass(hab,
878 WC_TOOLBUTTONS,
879 ChildButtonProc,
880 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
881 sizeof(PVOID));
882 WinRegisterClass(hab,
883 WC_DRIVEBUTTONS,
884 DriveProc,
885 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
886 sizeof(PVOID));
887 WinRegisterClass(hab,
888 WC_BUBBLE,
889 BubbleProc,
890 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
891 sizeof(ULONG) * 2);
892 WinRegisterClass(hab,
893 WC_STATUS,
894 StatusProc,
895 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
896 sizeof(ULONG));
897 WinRegisterClass(hab,
898 WC_DIRSTATUS,
899 DirTextProc,
900 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
901 sizeof(ULONG));
902 WinRegisterClass(hab,
903 WC_TREESTATUS,
904 TreeStatProc,
905 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
906 sizeof(ULONG));
907 WinRegisterClass(hab,
908 WC_ARCSTATUS,
909 ArcTextProc,
910 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
911 sizeof(ULONG));
912 WinRegisterClass(hab,
913 WC_COLSTATUS,
914 CollectorTextProc,
915 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
916 sizeof(ULONG));
917 WinRegisterClass(hab,
918 WC_SEESTATUS,
919 SeeStatusProc,
920 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
921 sizeof(ULONG));
922 WinRegisterClass(hab,
923 WC_VIEWSTATUS,
924 ViewStatusProc,
925 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
926 sizeof(ULONG));
927 WinRegisterClass(hab,
928 WC_ERRORWND,
929 NotifyWndProc,
930 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
931 sizeof(PVOID));
932 WinRegisterClass(hab,
933 WC_MINITIME,
934 MiniTimeProc,
935 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
936 sizeof(PVOID) * 2);
937 WinRegisterClass(hab,
938 WC_DATABAR,
939 DataProc, CS_SIZEREDRAW, sizeof(PVOID));
940 WinRegisterClass(hab,
941 WC_TREEOPENBUTTON,
942 OpenButtonProc,
943 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
944 sizeof(PVOID));
945 WinRegisterClass(hab,
946 WC_AUTOVIEW,
947 AutoViewProc,
948 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
949 sizeof(PVOID));
950 WinRegisterClass(hab,
951 WC_LED,
952 LEDProc,
953 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
954 sizeof(PVOID));
955
956 /*
957 * set some defaults (note: everything else automatically initialized
958 * to 0)
959 */
960 detailssize = detailsea = detailslwdate = detailslwtime = detailsattr =
961 detailsicon = fAutoTile = fConfirmDelete = fLoadSubject = fUnHilite =
962 fLoadLongnames = fToolbar = fSaveState = fGuessType = fToolbarHelp =
963 fAutoAddDirs = fUseNewViewer = fDataToFore = fDataShowDrives =
964 fSplitStatus = fDragndropDlg = fQuickArcFind = fKeepCmdLine =
965 fMoreButtons = fDrivebar = fCollapseFirst = fSwitchTree =
966 fSwitchTreeExpand = fNoSearch = fCustomFileDlg = fOtherHelp =
967 fSaveMiniCmds = fUserComboBox = fFM2Deletes = fConfirmTarget =
968 fShowTarget = fDrivebarHelp = fCheckMM = TRUE;
969 ulCnrType = CCS_EXTENDSEL;
970 FilesToGet = FILESTOGET_MIN;
971 MaxComLineStrg = MAXCOMLINESTRGDEFAULT;
972 AutoviewHeight = 48;
973 strcpy(printer, "PRN");
974 prnwidth = 80;
975 prnlength = 66;
976 prntmargin = 6;
977 prnbmargin = 6;
978 prnlmargin = 6;
979 prnrmargin = 3;
980 prnspacing = 1;
981 prntabspaces = 8;
982 CollectorsortFlags = sortFlags = SORT_DIRSFIRST;
983
984 //Get default Country info
985 {
986 COUNTRYCODE Country = {0};
987 ULONG ulInfoLen = 0;
988 COUNTRYINFO CtryInfo = {0};
989
990 DosQueryCtryInfo(sizeof(CtryInfo), &Country,
991 &CtryInfo, &ulInfoLen);
992 *ThousandsSeparator = CtryInfo.szThousandsSeparator[0];
993 }
994
995 // load preferences from profile (INI) file
996 size = sizeof(ULONG);
997 PrfQueryProfileData(fmprof, appname, "MaxComLineStrg", &MaxComLineStrg, &size);
998 // Give user one chance to reset the default command line length to 1024 (4os2's unexpanded max)
999 if (MaxComLineStrg == 2048) {
1000 BOOL MaxComLineChecked = FALSE;
1001
1002 size = sizeof(BOOL);
1003 PrfQueryProfileData(fmprof, appname, "MaxComLineChecked", &MaxComLineChecked, &size);
1004 if (!MaxComLineChecked) {
1005 ret = saymsg(MB_YESNO,
1006 HWND_DESKTOP,
1007 NullStr,
1008 GetPString(IDS_CHANGECMDLINELENGTHDEFAULT));
1009 if (ret == MBID_YES)
1010 MaxComLineStrg = 1024;
1011 MaxComLineChecked = TRUE;
1012 PrfWriteProfileData(fmprof, appname, "MaxComLineChecked", &MaxComLineChecked, sizeof(BOOL));
1013 }
1014 }
1015 if (MaxComLineStrg < CMDLNLNGTH_MIN)
1016 MaxComLineStrg = CMDLNLNGTH_MIN;
1017 else if (MaxComLineStrg > CMDLNLNGTH_MAX)
1018 MaxComLineStrg = CMDLNLNGTH_MAX;
1019 editor = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
1020 if (!editor)
1021 return 0; //already complained
1022 viewer = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
1023 if (!viewer)
1024 return 0; //already complained
1025 virus = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
1026 if (!virus)
1027 return 0; //already complained
1028 compare = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
1029 if (!compare)
1030 return 0; //already complained
1031 binview = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
1032 if (!binview)
1033 return 0; //already complained
1034 bined = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
1035 if (!bined)
1036 return 0; //already complained
1037 dircompare = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
1038 if (!dircompare)
1039 return 0; //already complained
1040 ftprun = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
1041 if (!ftprun)
1042 return 0; //already complained
1043 httprun = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
1044 if (!httprun)
1045 return 0; //already complained
1046 mailrun = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
1047 if (!mailrun)
1048 return 0; //already complained
1049 size = sizeof(BOOL);
1050 PrfQueryProfileData(fmprof, appname, "ShowTarget", &fShowTarget, &size);
1051 size = sizeof(BOOL);
1052 PrfQueryProfileData(fmprof, appname, "CheckMM", &fCheckMM, &size);
1053 size = sizeof(BOOL);
1054 PrfQueryProfileData(fmprof, appname, "ChangeTarget", &fChangeTarget, &size);
1055 size = sizeof(BOOL);
1056 PrfQueryProfileData(fmprof, appname, "ConfirmTarget", &fConfirmTarget, &size);
1057 size = sizeof(BOOL);
1058 PrfQueryProfileData(fmprof, FM3Str, "CustomFileDlg", &fCustomFileDlg, &size);
1059 size = sizeof(BOOL);
1060 PrfQueryProfileData(fmprof, FM3Str, "SaveMiniCmds", &fSaveMiniCmds, &size);
1061 size = sizeof(BOOL);
1062 PrfQueryProfileData(fmprof, appname, "SaveBigCmds", &fSaveBigCmds, &size);
1063 size = sizeof(BOOL);
1064 PrfQueryProfileData(fmprof, appname, "NoFoldMenu", &fNoFoldMenu, &size);
1065 size = sizeof(BOOL);
1066 PrfQueryProfileData(fmprof, FM3Str, "ThreadNotes", &fThreadNotes, &size);
1067 size = sizeof(BOOL);
1068 PrfQueryProfileData(fmprof, FM3Str, "Prnpagenums", &prnpagenums, &size);
1069 size = sizeof(BOOL);
1070 PrfQueryProfileData(fmprof, FM3Str, "Prnalt", &prnalt, &size);
1071 size = sizeof(BOOL);
1072 PrfQueryProfileData(fmprof, FM3Str, "Prnformat", &prnformat, &size);
1073 size = sizeof(BOOL);
1074 PrfQueryProfileData(fmprof, FM3Str, "Prnformfeedbefore",
1075 &prnformfeedbefore, &size);
1076 size = sizeof(BOOL);
1077 PrfQueryProfileData(fmprof, FM3Str,
1078 "Prnformfeedafter",&prnformfeedafter, &size);
1079 size = sizeof(ULONG);
1080 PrfQueryProfileData(fmprof, FM3Str, "Prntabspaces", &prntabspaces, &size);
1081 size = sizeof(ULONG);
1082 PrfQueryProfileData(fmprof, FM3Str, "Prnwidth", &prnwidth, &size);
1083 size = sizeof(ULONG);
1084 PrfQueryProfileData(fmprof, FM3Str, "Prnlength", &prnlength, &size);
1085 size = sizeof(ULONG);
1086 PrfQueryProfileData(fmprof, FM3Str, "Prntmargin", &prntmargin, &size);
1087 size = sizeof(ULONG);
1088 PrfQueryProfileData(fmprof, FM3Str, "Prnbmargin", &prnbmargin, &size);
1089 size = sizeof(ULONG);
1090 PrfQueryProfileData(fmprof, FM3Str, "Prnlmargin", &prnlmargin, &size);
1091 size = sizeof(ULONG);
1092 PrfQueryProfileData(fmprof, FM3Str, "Prnrmargin", &prnrmargin, &size);
1093 size = sizeof(ULONG);
1094 PrfQueryProfileData(fmprof, FM3Str, "Prnspacing", &prnspacing, &size);
1095 size = sizeof(BOOL);
1096 PrfQueryProfileData(fmprof, FM3Str, "NoDead", &fNoDead, &size);
1097 size = sizeof(BOOL);
1098 PrfQueryProfileData(fmprof, FM3Str, "NoFinger", &fNoFinger, &size);
1099 size = sizeof(BOOL);
1100 PrfQueryProfileData(fmprof, appname, "SwitchTree", &fSwitchTree, &size);
1101 size = sizeof(BOOL);
1102 PrfQueryProfileData(fmprof, appname, "SwitchTreeExpand",
1103 &fSwitchTreeExpand, &size);
1104 size = sizeof(BOOL);
1105 PrfQueryProfileData(fmprof, appname, "SwitchTreeOnFocus",
1106 &fSwitchTreeOnFocus, &size);
1107 size = sizeof(BOOL);
1108 PrfQueryProfileData(fmprof, appname, "CollapseFirst",
1109 &fCollapseFirst, &size);
1110 size = sizeof(BOOL);
1111 PrfQueryProfileData(fmprof, appname, "FilesInTree",
1112 &fFilesInTree, &size);
1113 size = sizeof(BOOL);
1114 PrfQueryProfileData(fmprof, FM3Str, "TopDir", &fTopDir, &size);
1115 size = sizeof(BOOL);
1116 PrfQueryProfileData(fmprof, FM3Str, "LookInDir", &fLookInDir, &size);
1117 PrfQueryProfileString(fmprof, appname, "DefArc", NULL, szDefArc,
1118 sizeof(szDefArc));
1119 size = sizeof(ULONG);
1120 PrfQueryProfileData(fmprof, FM3Str, "AutoviewHeight",
1121 &AutoviewHeight, &size);
1122 size = sizeof(BOOL);
1123 PrfQueryProfileData(fmprof, FM3Str, "KeepCmdLine", &fKeepCmdLine, &size);
1124 if (strcmp(realappname, "FM/4")) {
1125 size = sizeof(BOOL);
1126 PrfQueryProfileData(fmprof, FM3Str, "MoreButtons", &fMoreButtons, &size);
1127 size = sizeof(BOOL);
1128 PrfQueryProfileData(fmprof, FM3Str, "Drivebar", &fDrivebar, &size);
1129 }
1130 else
1131 fDrivebar = fMoreButtons = TRUE;
1132 size = sizeof(BOOL);
1133 PrfQueryProfileData(fmprof, appname, "NoSearch", &fNoSearch, &size);
1134 size = sizeof(BOOL);
1135 PrfQueryProfileData(fmprof, appname, "GuessType", &fGuessType, &size);
1136 size = sizeof(BOOL);
1137 PrfQueryProfileData(fmprof, appname, "ViewChild", &fViewChild, &size);
1138 size = sizeof(BOOL);
1139 PrfQueryProfileData(fmprof, appname, "ShowEnv", &fShowEnv, &size);
1140 size = sizeof(BOOL);
1141 PrfQueryProfileData(fmprof, appname, "LeaveTree", &fLeaveTree, &size);
1142 size = sizeof(BOOL);
1143 PrfQueryProfileData(fmprof, FM3Str, "Comments", &fComments, &size);
1144 size = sizeof(ULONG);
1145 PrfQueryProfileData(fmprof, appname, "WS_ANIMATE", &fwsAnimate, &size);
1146 if (fwsAnimate)
1147 fwsAnimate = WS_ANIMATE;
1148 size = sizeof(ULONG);
1149 size = sizeof(BOOL);
1150 PrfQueryProfileData(fmprof, appname, "SelectedAlways",
1151 &fSelectedAlways, &size);
1152 size = sizeof(BOOL);
1153 PrfQueryProfileData(fmprof, FM3Str, "ToolbarHelp", &fToolbarHelp, &size);
1154 size = sizeof(BOOL);
1155 PrfQueryProfileData(fmprof, FM3Str, "OtherHelp", &fOtherHelp, &size);
1156 size = sizeof(BOOL);
1157 PrfQueryProfileData(fmprof, FM3Str, "DrivebarHelp", &fDrivebarHelp, &size);
1158 size = sizeof(BOOL);
1159 PrfQueryProfileData(fmprof, appname, "AutoAddDirs", &fAutoAddDirs, &size);
1160 size = sizeof(BOOL);
1161 PrfQueryProfileData(fmprof, appname,
1162 "AutoAddAllDirs", &fAutoAddAllDirs, &size);
1163 size = sizeof(BOOL);
1164 PrfQueryProfileData(fmprof, FM3Str, "UserListSwitches",
1165 &fUserListSwitches, &size);
1166 size = sizeof(BOOL);
1167 PrfQueryProfileData(fmprof, appname, "UseNewViewer",
1168 &fUseNewViewer, &size);
1169 size = sizeof(BOOL);
1170 PrfQueryProfileData(fmprof, appname, "DefaultDeletePerm",
1171 &fDefaultDeletePerm, &size);
1172 size = sizeof(BOOL);
1173 PrfQueryProfileData(fmprof, FM3Str, "ExternalINIs",
1174 &fExternalINIs, &size);
1175 size = sizeof(BOOL);
1176 PrfQueryProfileData(fmprof, FM3Str, "ExternalCollector",
1177 &fExternalCollector, &size);
1178 size = sizeof(BOOL);
1179 PrfQueryProfileData(fmprof, FM3Str, "ExternalArcboxes",
1180 &fExternalArcboxes, &size);
1181 size = sizeof(BOOL);
1182 PrfQueryProfileData(fmprof, FM3Str, "ExternalViewer",
1183 &fExternalViewer, &size);
1184 size = sizeof(BOOL);
1185 PrfQueryProfileData(fmprof, FM3Str, "UseQProcStat",
1186 &fUseQProcStat, &size);
1187 size = sizeof(BOOL);
1188 PrfQueryProfileData(fmprof, FM3Str, "UseQSysState",
1189 &fUseQSysState, &size);
1190 size = sizeof(BOOL);
1191 PrfQueryProfileData(fmprof, FM3Str, "DataMin", &fDataMin, &size);
1192 size = sizeof(BOOL);
1193 PrfQueryProfileData(fmprof, appname, "DataToFore", &fDataToFore, &size);
1194 size = sizeof(BOOL);
1195 PrfQueryProfileData(fmprof, appname, "DataShowDrives",
1196 &fDataShowDrives, &size);
1197 size = sizeof(BOOL);
1198 PrfQueryProfileData(fmprof, appname, "DataInclRemote",
1199 &fDataInclRemote, &size);
1200 size = sizeof(BOOL);
1201 PrfQueryProfileData(fmprof, FM3Str, "SplitStatus", &fSplitStatus, &size);
1202 size = sizeof(BOOL);
1203 PrfQueryProfileData(fmprof, appname, "FolderAfterExtract",
1204 &fFolderAfterExtract, &size);
1205 size = sizeof(BOOL);
1206 PrfQueryProfileData(fmprof, FM3Str, "DullDatabar", &fDullMin, &size);
1207 size = sizeof(BOOL);
1208 PrfQueryProfileData(fmprof, appname, "BlueLED", &fBlueLED, &size);
1209 size = sizeof(BOOL);
1210 PrfQueryProfileData(fmprof, appname, "ConfirmDelete",
1211 &fConfirmDelete, &size);
1212 size = sizeof(BOOL);
1213 PrfQueryProfileData(fmprof, FM3Str, "SaveState", &fSaveState, &size);
1214 size = sizeof(BOOL);
1215 PrfQueryProfileData(fmprof, appname, "SyncUpdates", &fSyncUpdates, &size);
1216 size = sizeof(BOOL);
1217 PrfQueryProfileData(fmprof, appname, "LoadSubject", &fLoadSubject, &size);
1218 size = sizeof(BOOL);
1219 PrfQueryProfileData(fmprof, appname, "UnHilite", &fUnHilite, &size);
1220 size = sizeof(BOOL);
1221 PrfQueryProfileData(fmprof, FM3Str, "TileBackwards", &fTileBackwards, &size);
1222 size = sizeof(BOOL);
1223 PrfQueryProfileData(fmprof, appname, "LoadLongname", &fLoadLongnames, &size);
1224 size = sizeof(BOOL);
1225 PrfQueryProfileData(fmprof, appname, "VerifyWrites", &fVerify, &size);
1226 DosSetVerify(fVerify);
1227 size = sizeof(BOOL);
1228 PrfQueryProfileData(fmprof, appname, "DontMoveMouse", &fDontMoveMouse, &size);
1229 size = sizeof(BOOL);
1230 PrfQueryProfileData(fmprof, appname, "NoIconsFiles", &fNoIconsFiles, &size);
1231 size = sizeof(BOOL);
1232 PrfQueryProfileData(fmprof, appname, "NoIconsDirs", &fNoIconsDirs, &size);
1233 size = sizeof(BOOL);
1234 PrfQueryProfileData(fmprof, appname, "ForceUpper", &fForceUpper, &size);
1235 size = sizeof(BOOL);
1236 PrfQueryProfileData(fmprof, appname, "ForceLower", &fForceLower, &size);
1237 size = sizeof(BOOL);
1238 PrfQueryProfileData(fmprof, FM3Str, "TextTools", &fTextTools, &size);
1239 size = sizeof(BOOL);
1240 PrfQueryProfileData(fmprof, FM3Str, "ToolTitles", &fToolTitles, &size);
1241 size = sizeof(BOOL);
1242 PrfQueryProfileData(fmprof, appname, "DoubleClickOpens", &fDCOpens, &size);
1243 size = sizeof(BOOL);
1244 PrfQueryProfileData(fmprof, appname, "LinkSetsIcon", &fLinkSetsIcon, &size);
1245 size = sizeof(INT);
1246 PrfQueryProfileData(fmprof, appname, "Sort", &sortFlags, &size);
1247 size = sizeof(INT);
1248 PrfQueryProfileData(fmprof, appname, "TreeSort", &TreesortFlags, &size);
1249 size = sizeof(INT);
1250 PrfQueryProfileData(fmprof, appname,
1251 "CollectorSort", &CollectorsortFlags, &size);
1252 size = sizeof(targetdir);
1253 PrfQueryProfileData(fmprof, appname, "Targetdir", targetdir, &size);
1254 if (!IsValidDir(targetdir))
1255 *targetdir = 0;
1256 size = sizeof(extractpath);
1257 PrfQueryProfileData(fmprof, appname, "ExtractPath", extractpath, &size);
1258 size = sizeof(printer);
1259 PrfQueryProfileData(fmprof, appname, "Printer", printer, &size);
1260 size = MaxComLineStrg;
1261 PrfQueryProfileData(fmprof, appname, "DirCompare", dircompare,
1262 &size);
1263 size = MaxComLineStrg;
1264 PrfQueryProfileData(fmprof, appname, "Viewer", viewer, &size);
1265 size = MaxComLineStrg;
1266 PrfQueryProfileData(fmprof, appname, "Editor", editor, &size);
1267 size = MaxComLineStrg;
1268 PrfQueryProfileData(fmprof, appname, "BinView", binview, &size);
1269 size = MaxComLineStrg;
1270 PrfQueryProfileData(fmprof, appname, "BinEd", bined, &size);
1271 size = MaxComLineStrg;
1272 PrfQueryProfileData(fmprof, appname, "Compare", compare, &size);
1273 size = MaxComLineStrg;
1274 PrfQueryProfileData(fmprof, appname, "Virus", virus, &size);
1275 size = sizeof(BOOL);
1276 PrfQueryProfileData(fmprof, appname, "FtpRunWPSDefault", &fFtpRunWPSDefault, &size);
1277 size = MaxComLineStrg;
1278 PrfQueryProfileData(fmprof, appname, "FTPRun", ftprun, &size);
1279 if (!*ftprun)
1280 fFtpRunWPSDefault = TRUE;
1281 size = sizeof(BOOL);
1282 PrfQueryProfileData(fmprof, appname, "HttpRunWPSDefault", &fHttpRunWPSDefault, &size);
1283 size = MaxComLineStrg;
1284 PrfQueryProfileData(fmprof, appname, "HTTPRun", httprun, &size);
1285 if (!*httprun)
1286 fHttpRunWPSDefault = TRUE;
1287 size = MaxComLineStrg;
1288 PrfQueryProfileData(fmprof, appname, "MailRun", mailrun, &size);
1289 size = sizeof(ftprundir);
1290 PrfQueryProfileData(fmprof, appname, "FtpRunDir", ftprundir, &size);
1291 size = sizeof(httprundir);
1292 PrfQueryProfileData(fmprof, appname, "HttpRunDir", httprundir, &size);
1293 size = sizeof(mailrundir);
1294 PrfQueryProfileData(fmprof, appname, "MailRunDir", mailrundir, &size);
1295 size = sizeof(lasttoolbox);
1296 PrfQueryProfileData(fmprof, FM3Str, "LastToolBox", lasttoolbox,
1297 &size);
1298 size = sizeof(BOOL);
1299 PrfQueryProfileData(fmprof, appname, "LibPathStrictHttpRun", &fLibPathStrictHttpRun,
1300 &size);
1301 size = sizeof(BOOL);
1302 PrfQueryProfileData(fmprof, appname, "LibPathStrictFtpRun", &fLibPathStrictFtpRun,
1303 &size);
1304 size = sizeof(BOOL);
1305 PrfQueryProfileData(fmprof, appname, "LibPathStrictMailRun", &fLibPathStrictMailRun,
1306 &size);
1307 size = sizeof(BOOL);
1308 PrfQueryProfileData(fmprof, appname, "NoMailtoMailRun", &fNoMailtoMailRun,
1309 &size);
1310 size = sizeof(BOOL);
1311 PrfQueryProfileData(fmprof, appname, "FollowTree", &fFollowTree,
1312 &size);
1313 size = sizeof(BOOL);
1314 PrfQueryProfileData(fmprof, appname, "StartMaximized",
1315 &fStartMaximized, &size);
1316 if (!fStartMaximized) {
1317 size = sizeof(BOOL);
1318 PrfQueryProfileData(fmprof, appname, "StartMinimized",
1319 &fStartMinimized, &size);
1320 }
1321 size = sizeof(BOOL);
1322 PrfQueryProfileData(fmprof, appname, "DefaultCopy", &fCopyDefault, &size);
1323 size = sizeof(BOOL);
1324 PrfQueryProfileData(fmprof, appname, "IdleCopy", &fRealIdle, &size);
1325 size = sizeof(BOOL);
1326 PrfQueryProfileData(fmprof, appname, "ArcStuffVisible",
1327 &fArcStuffVisible, &size);
1328 size = sizeof(BOOL);
1329 PrfQueryProfileData(fmprof, FM3Str, "NoTreeGap", &fNoTreeGap, &size);
1330 size = sizeof(BOOL);
1331 PrfQueryProfileData(fmprof, FM3Str, "VTreeOpensWPS",
1332 &fVTreeOpensWPS, &size);
1333 size = sizeof(BOOL);
1334 PrfQueryProfileData(fmprof, appname, "RemoteBug", &fRemoteBug, &size);
1335 size = sizeof(BOOL);
1336 PrfQueryProfileData(fmprof, appname, "Drag&DropDlg",
1337 &fDragndropDlg, &size);
1338 size = sizeof(BOOL);
1339 PrfQueryProfileData(fmprof, FM3Str, "UserComboBox", &fUserComboBox, &size);
1340 size = sizeof(BOOL);
1341 PrfQueryProfileData(fmprof, FM3Str, "MinDirOnOpen", &fMinOnOpen, &size);
1342 size = sizeof(BOOL);
1343 PrfQueryProfileData(fmprof, appname, "QuickArcFind",
1344 &fQuickArcFind, &size);
1345 size = sizeof(BOOL);
1346 PrfQueryProfileData(fmprof, FM3Str, "NoRemovableScan",
1347 &fNoRemovableScan, &size);
1348 size = sizeof(ULONG);
1349 PrfQueryProfileData(fmprof, FM3Str, "NoBrokenNotify",
1350 &NoBrokenNotify, &size);
1351 size = sizeof(ULONG);
1352 PrfQueryProfileData(fmprof, appname, "ContainerType", &ulCnrType,
1353 &size);
1354 size = sizeof(ULONG);
1355 PrfQueryProfileData(fmprof, appname, "FilesToGet", &FilesToGet, &size);
1356 if (FilesToGet < FILESTOGET_MIN)
1357 FilesToGet = FILESTOGET_MIN;
1358 else if (FilesToGet > FILESTOGET_MAX)
1359 FilesToGet = FILESTOGET_MAX;
1360 size = sizeof(BOOL);
1361 PrfQueryProfileData(fmprof, FM3Str, "AutoView", &fAutoView, &size);
1362 size = sizeof(BOOL);
1363 PrfQueryProfileData(fmprof, FM3Str, "FM2Deletes", &fFM2Deletes, &size);
1364 size = sizeof(BOOL);
1365 PrfQueryProfileData(fmprof, FM3Str, "TrashCan", &fTrashCan, &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.