source: trunk/dll/init.c@ 1045

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

One last piece of the trashcan stuff (ticket 43)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 49.1 KB
Line 
1
2/***********************************************************************
3
4 $Id: init.c 1045 2008-07-06 23:40:18Z 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/*# ifdef FORTIFY
541 Fortify_LeaveScope();
542# endif*/
543 if (FM3ModHandle)
544 DosFreeModule(FM3ModHandle);
545
546 DosExitList(EXLST_REMOVE, DeInitFM3DLL);
547}
548
549BOOL InitFM3DLL(HAB hab, int argc, char **argv)
550{
551 /*
552 * this function should be called by any application using this DLL right
553 * after setting up a message queue
554 */
555
556 CLASSINFO clinfo;
557 APIRET rc;
558 APIRET rcl = 1;
559 APIRET rcq = 1;
560 PFN pfnResVersion = (PFN)NULL;
561 ULONG RVMajor = 0;
562 ULONG RVMinor = 0;
563 ULONG ret = 0;
564 FILESTATUS3 fs3; // 25 Aug 07 SHL
565 PSZ env;
566 CHAR dllfile[CCHMAXPATH];
567 ULONG size;
568
569 if (!StringsLoaded()) {
570 saymsg(MB_ENTER,
571 HWND_DESKTOP,
572 "Error",
573 "FM3RES.STR isn't in right format, at least "
574 "for this version of FM/2.");
575 return FALSE;
576 }
577
578 strcpy(dllfile, "FM3RES");
579 env = getenv("FM3INI");
580 if (env) {
581 DosError(FERR_DISABLEHARDERR);
582 rc = DosQueryPathInfo(env, FIL_STANDARD, &fs3, sizeof(fs3));
583 if (!rc) {
584 if (fs3.attrFile & FILE_DIRECTORY) {
585 BldFullPathName(dllfile, env, "FM3RES"); // 23 Aug 07 SHL
586 DosError(FERR_DISABLEHARDERR);
587 if (DosQueryPathInfo(dllfile, FIL_STANDARD, &fs3, sizeof(fs3)))
588 strcpy(dllfile, "FM3RES");
589 }
590 }
591 }
592 rcl = DosLoadModule(NULL, 0, dllfile, &FM3ModHandle);
593 if (rcl) {
594 saymsg(MB_CANCEL | MB_ICONEXCLAMATION,
595 HWND_DESKTOP,
596 GetPString(IDS_ERRORTEXT), GetPString(IDS_FM3RESERROR1TEXT));
597 return FALSE;
598 }
599 else {
600 rc = DosExitList(EXLST_ADD, DeInitFM3DLL);
601 if (rc) {
602 Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
603 "DosExitList");
604 }
605 rcq = DosQueryProcAddr(FM3ModHandle, 1, "ResVersion", &pfnResVersion);
606 if (!rcq)
607 ret = pfnResVersion(&RVMajor, &RVMinor);
608 }
609/*# ifdef FORTIFY
610 Fortify_EnterScope();
611# endif*/
612 if (RVMajor < VERMAJOR || (RVMajor == VERMAJOR && RVMinor < VERMINOR)) {
613 saymsg(MB_ENTER,
614 HWND_DESKTOP,
615 GetPString(IDS_ERRORTEXT),
616 GetPString(IDS_FM3RESERROR2TEXT),
617 !rcq ?
618 GetPString(IDS_FM3RESERROR3TEXT) :
619 !rcl ?
620 GetPString(IDS_FM3RESERROR4TEXT) :
621 GetPString(IDS_FM3RESERROR5TEXT), RVMajor, RVMinor, rcl, rcq, ret);
622 return FALSE;
623 }
624
625 ArgDriveFlags(argc, argv);
626 FillInDriveFlags(NULL);
627
628 if (!*profile)
629 strcpy(profile, "FM3.INI");
630 mypid = getpid();
631 /* give default appname if none set by caller */
632 if (!*appname)
633 strcpy(appname, FM3Str);
634 /* save appname; may be reset below */
635 strcpy(realappname, appname);
636 if (!strcmp(appname, FM3Str))
637 DosSetMaxFH(100);
638 else if (!strcmp(appname, "VDir") ||
639 !strcmp(appname, "VTree") ||
640 !strcmp(appname, "VCollect") ||
641 !strcmp(appname, "SEEALL") || !strcmp(appname, "FM/4"))
642 DosSetMaxFH(60);
643 else
644 DosSetMaxFH(40);
645
646 if (DosQuerySysInfo(QSV_VERSION_MAJOR,
647 QSV_VERSION_MINOR,
648 OS2ver,
649 sizeof(OS2ver))) {
650 OS2ver[0] = 2;
651 OS2ver[1] = 1;
652 }
653
654 /* set up default root names for temp archive goodies */
655 if (!fAmAV2)
656 strcpy(ArcTempRoot, "$FM$ARC$");
657 else
658 strcpy(ArcTempRoot, "$AV$ARC$");
659
660 /* initialize random number generator */
661 srand(time(NULL) + clock());
662
663 priority_bumped();
664
665 /* _heapmin() is done in a separate thread -- start it */
666 if (_beginthread(HeapThread, NULL, 32768, NULL) == -1) {
667 Runtime_Error(pszSrcFile, __LINE__,
668 GetPString(IDS_COULDNTSTARTTHREADTEXT));
669 return FALSE;
670 }
671
672 /* timer messages are sent from a separate thread -- start it */
673 if (!StartTimer()) {
674 Runtime_Error(pszSrcFile, __LINE__,
675 GetPString(IDS_COULDNTSTARTTHREADTEXT));
676 return FALSE;
677 }
678
679 /* Are we the workplace shell? */
680 env = getenv("WORKPLACE_PROCESS");
681 fWorkPlace = env != NULL &&
682 (stricmp(env, "YES") == 0 || atoi(env) == 1);
683
684 if ((!strchr(profile, '\\') && !strchr(profile, ':')) ||
685 !(fmprof = PrfOpenProfile((HAB)0, profile)))
686 {
687 /* figure out where to put INI file... */
688 CHAR inipath[CCHMAXPATH];
689
690 DosError(FERR_DISABLEHARDERR);
691 save_dir2(HomePath);
692 DosError(FERR_DISABLEHARDERR);
693 memset(driveserial, -1, sizeof(driveserial));
694 *inipath = 0;
695 env = getenv("FM3INI");
696 if (env) {
697 strcpy(inipath, env);
698 DosError(FERR_DISABLEHARDERR);
699 rc = DosQueryPathInfo(inipath, FIL_STANDARD, &fs3, sizeof(fs3));
700 if (!rc) {
701 if (fs3.attrFile & FILE_DIRECTORY)
702 BldFullPathName(inipath, inipath, profile);
703 }
704 }
705 if (!env) {
706 env = searchpath(profile);
707 if (!env)
708 env = profile;
709 strcpy(inipath, env);
710 }
711
712 /* in some odd cases the INI file can get set to readonly status */
713 /* here we test it and reset the readonly bit if necessary */
714 if (!*inipath)
715 strcpy(inipath, profile);
716 DosError(FERR_DISABLEHARDERR);
717
718 rc = DosQueryPathInfo(inipath, FIL_STANDARD, &fs3, sizeof(fs3));
719 if (rc) {
720 if (rc == ERROR_FILE_NOT_FOUND)
721 fWantFirstTimeInit = TRUE;
722 }
723 else {
724 if (!CheckFileHeader(inipath, "\xff\xff\xff\xff\x14\x00\x00\x00", 0L)) {
725 saymsg(MB_ENTER,HWND_DESKTOP,DEBUG_STRING,
726 "Check INI header failed will attempt to replace with backup \\
727 if backup fails or not found will open with new ini");
728 DosCopy("FM3.INI", "FM3INI.BAD", DCPY_EXISTING);
729 DosCopy("FM3INI.BAK", "FM3.INI", DCPY_EXISTING);
730 if (!CheckFileHeader(inipath, "\xff\xff\xff\xff\x14\x00\x00\x00", 0L)) {
731 DosCopy("FM3.INI", "FM3INI2.BAD", DCPY_EXISTING);
732 fWantFirstTimeInit = TRUE;
733 }
734 }
735 if (!fWantFirstTimeInit) {
736 fIniExisted = TRUE;
737 if (fs3.attrFile & (FILE_READONLY | FILE_HIDDEN | FILE_SYSTEM)) {
738 fs3.attrFile &= ~(FILE_READONLY | FILE_HIDDEN | FILE_SYSTEM);
739 rc = xDosSetPathInfo(inipath, FIL_STANDARD, &fs3, sizeof(fs3), 0);
740 if (rc) {
741 Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
742 GetPString(IDS_INIREADONLYTEXT), inipath);
743 }
744 }
745 }
746 }
747 fmprof = PrfOpenProfile((HAB)0, inipath);
748 if (!fmprof) {
749 strcpy(inipath, "FM3.INI");
750 fmprof = PrfOpenProfile((HAB)0, inipath);
751 }
752
753 // 10 Jan 08 SHL fixme to do first time if new ini
754 // 10 Jan 08 SHL post UM_FIRSTTIME to main window
755 if (!fmprof) {
756 Win_Error(NULLHANDLE, NULLHANDLE, pszSrcFile, __LINE__,
757 "PrfOpenProfile");
758 return FALSE;
759 }
760 }
761
762 FindSwapperDat();
763
764 size = sizeof(BOOL);
765 PrfQueryProfileData(fmprof,
766 FM3Str,
767 "SeparateParms",
768 &fSeparateParms,
769 &size);
770 if (!fSeparateParms)
771 strcpy(appname, FM3Str);
772
773 /* start help */
774 memset(&hini, 0, sizeof(HELPINIT));
775 hini.cb = sizeof(HELPINIT);
776 hini.ulReturnCode = 0;
777 hini.pszTutorialName = NULL;
778 hini.phtHelpTable = (PHELPTABLE) MAKELONG(ID_HELPTABLE, 0xffff);
779 hini.hmodAccelActionBarModule = (HMODULE) 0;
780 hini.idAccelTable = 0;
781 hini.idActionBar = 0;
782 hini.pszHelpWindowTitle = GetPString(IDS_FM2HELPTITLETEXT);
783 hini.fShowPanelId = CMIC_HIDE_PANEL_ID;
784 hini.pszHelpLibraryName = "FM3.HLP";
785 hwndHelp = WinCreateHelpInstance(hab, &hini);
786 if (!hwndHelp) {
787 static CHAR helppath[CCHMAXPATH]; // fixme to be local?
788
789 env = getenv("FM3INI");
790 if (env) {
791 strcpy(helppath, env);
792 DosError(FERR_DISABLEHARDERR);
793 rc = DosQueryPathInfo(helppath, FIL_STANDARD, &fs3, sizeof(fs3));
794 if (!rc) {
795 if (fs3.attrFile & FILE_DIRECTORY) {
796 BldFullPathName(helppath, helppath, "FM3.HLP");
797 hini.pszHelpLibraryName = helppath;
798 hwndHelp = WinCreateHelpInstance(hab, &hini);
799 }
800 }
801 }
802 }
803 if (!hwndHelp) {
804 saymsg(MB_ENTER | MB_ICONEXCLAMATION,
805 HWND_DESKTOP,
806 GetPString(IDS_FM2TROUBLETEXT),
807 GetPString(IDS_CANTLOADHELPTEXT),
808 GetPString(IDS_NOHELPACCEPTTEXT));
809 }
810
811 /* a couple of default window procs so we don't have to look them up later */
812 if (WinQueryClassInfo(hab, WC_CONTAINER, &clinfo))
813 PFNWPCnr = clinfo.pfnWindowProc;
814 // saymsg(MB_ENTER,HWND_DESKTOP,"Container flags:","%08lx",clinfo.flClassStyle);
815 if (WinQueryClassInfo(hab, WC_FRAME, &clinfo))
816 PFNWPFrame = clinfo.pfnWindowProc;
817 // saymsg(MB_ENTER,HWND_DESKTOP,"Frame flags:","%08lx",clinfo.flClassStyle);
818 if (WinQueryClassInfo(hab, WC_BUTTON, &clinfo))
819 PFNWPButton = clinfo.pfnWindowProc;
820 // saymsg(MB_ENTER,HWND_DESKTOP,"Button flags:","%08lx",clinfo.flClassStyle);
821 if (WinQueryClassInfo(hab, WC_STATIC, &clinfo))
822 PFNWPStatic = clinfo.pfnWindowProc;
823 // saymsg(MB_ENTER,HWND_DESKTOP,"Static flags:","%08lx",clinfo.flClassStyle);
824 if (WinQueryClassInfo(hab, WC_MLE, &clinfo))
825 PFNWPMLE = clinfo.pfnWindowProc;
826 // saymsg(MB_ENTER,HWND_DESKTOP,"MLE flags:","%08lx",clinfo.flClassStyle);
827 if (!PFNWPCnr || !PFNWPFrame || !PFNWPButton || !PFNWPStatic || !PFNWPMLE) {
828 Runtime_Error(pszSrcFile, __LINE__, "WinQueryClassInfo");
829 return FALSE;
830 }
831
832 /* register window classes we use */
833 WinRegisterClass(hab,
834 WC_MAINWND,
835 MainWndProc,
836 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 8);
837 WinRegisterClass(hab,
838 WC_MAINWND2,
839 MainWndProc2,
840 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 4);
841 WinRegisterClass(hab,
842 WC_TREECONTAINER,
843 TreeClientWndProc,
844 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 2);
845 WinRegisterClass(hab,
846 WC_DIRCONTAINER,
847 DirClientWndProc,
848 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 2);
849 WinRegisterClass(hab,
850 WC_COLLECTOR,
851 CollectorClientWndProc,
852 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 2);
853 WinRegisterClass(hab,
854 WC_ARCCONTAINER,
855 ArcClientWndProc,
856 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 2);
857 WinRegisterClass(hab,
858 WC_MLEEDITOR,
859 MLEEditorProc,
860 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 2);
861 WinRegisterClass(hab,
862 WC_INIEDITOR,
863 IniProc,
864 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 2);
865 WinRegisterClass(hab,
866 WC_TOOLBACK,
867 ToolBackProc,
868 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
869 sizeof(PVOID));
870 WinRegisterClass(hab,
871 WC_DRIVEBACK,
872 DriveBackProc,
873 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
874 sizeof(PVOID));
875 WinRegisterClass(hab,
876 WC_SEEALL,
877 SeeAllWndProc,
878 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID));
879 WinRegisterClass(hab,
880 WC_NEWVIEW,
881 ViewWndProc,
882 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID));
883 WinRegisterClass(hab,
884 WC_TOOLBUTTONS,
885 ChildButtonProc,
886 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
887 sizeof(PVOID));
888 WinRegisterClass(hab,
889 WC_DRIVEBUTTONS,
890 DriveProc,
891 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
892 sizeof(PVOID));
893 WinRegisterClass(hab,
894 WC_BUBBLE,
895 BubbleProc,
896 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
897 sizeof(ULONG) * 2);
898 WinRegisterClass(hab,
899 WC_STATUS,
900 StatusProc,
901 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
902 sizeof(ULONG));
903 WinRegisterClass(hab,
904 WC_DIRSTATUS,
905 DirTextProc,
906 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
907 sizeof(ULONG));
908 WinRegisterClass(hab,
909 WC_TREESTATUS,
910 TreeStatProc,
911 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
912 sizeof(ULONG));
913 WinRegisterClass(hab,
914 WC_ARCSTATUS,
915 ArcTextProc,
916 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
917 sizeof(ULONG));
918 WinRegisterClass(hab,
919 WC_COLSTATUS,
920 CollectorTextProc,
921 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
922 sizeof(ULONG));
923 WinRegisterClass(hab,
924 WC_SEESTATUS,
925 SeeStatusProc,
926 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
927 sizeof(ULONG));
928 WinRegisterClass(hab,
929 WC_VIEWSTATUS,
930 ViewStatusProc,
931 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
932 sizeof(ULONG));
933 WinRegisterClass(hab,
934 WC_ERRORWND,
935 NotifyWndProc,
936 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
937 sizeof(PVOID));
938 WinRegisterClass(hab,
939 WC_MINITIME,
940 MiniTimeProc,
941 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
942 sizeof(PVOID) * 2);
943 WinRegisterClass(hab,
944 WC_DATABAR,
945 DataProc, CS_SIZEREDRAW, sizeof(PVOID));
946 WinRegisterClass(hab,
947 WC_TREEOPENBUTTON,
948 OpenButtonProc,
949 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
950 sizeof(PVOID));
951 WinRegisterClass(hab,
952 WC_AUTOVIEW,
953 AutoViewProc,
954 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
955 sizeof(PVOID));
956 WinRegisterClass(hab,
957 WC_LED,
958 LEDProc,
959 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
960 sizeof(PVOID));
961
962 /*
963 * set some defaults (note: everything else automatically initialized
964 * to 0)
965 */
966 detailssize = detailsea = detailslwdate = detailslwtime = detailsattr =
967 detailsicon = fAutoTile = fConfirmDelete = fLoadSubject = fUnHilite =
968 fLoadLongnames = fToolbar = fSaveState = fGuessType = fToolbarHelp =
969 fAutoAddDirs = fUseNewViewer = fDataToFore = fDataShowDrives =
970 fSplitStatus = fDragndropDlg = fQuickArcFind = fKeepCmdLine =
971 fMoreButtons = fDrivebar = fCollapseFirst = fSwitchTree =
972 fSwitchTreeExpand = fNoSearch = fCustomFileDlg = fOtherHelp =
973 fSaveMiniCmds = fUserComboBox = fFM2Deletes = fConfirmTarget =
974 fShowTarget = fDrivebarHelp = fCheckMM = TRUE;
975 ulCnrType = CCS_EXTENDSEL;
976 FilesToGet = FILESTOGET_MIN;
977 MaxComLineStrg = MAXCOMLINESTRGDEFAULT;
978 AutoviewHeight = 48;
979 strcpy(printer, "PRN");
980 prnwidth = 80;
981 prnlength = 66;
982 prntmargin = 6;
983 prnbmargin = 6;
984 prnlmargin = 6;
985 prnrmargin = 3;
986 prnspacing = 1;
987 prntabspaces = 8;
988 CollectorsortFlags = sortFlags = SORT_DIRSFIRST;
989
990 //Get default Country info
991 {
992 COUNTRYCODE Country = {0};
993 ULONG ulInfoLen = 0;
994 COUNTRYINFO CtryInfo = {0};
995
996 DosQueryCtryInfo(sizeof(CtryInfo), &Country,
997 &CtryInfo, &ulInfoLen);
998 *ThousandsSeparator = CtryInfo.szThousandsSeparator[0];
999 }
1000
1001 // load preferences from profile (INI) file
1002 size = sizeof(ULONG);
1003 PrfQueryProfileData(fmprof, appname, "MaxComLineStrg", &MaxComLineStrg, &size);
1004 // Give user one chance to reset the default command line length to 1024 (4os2's unexpanded max)
1005 if (MaxComLineStrg == 2048) {
1006 BOOL MaxComLineChecked = FALSE;
1007
1008 size = sizeof(BOOL);
1009 PrfQueryProfileData(fmprof, appname, "MaxComLineChecked", &MaxComLineChecked, &size);
1010 if (!MaxComLineChecked) {
1011 ret = saymsg(MB_YESNO,
1012 HWND_DESKTOP,
1013 NullStr,
1014 GetPString(IDS_CHANGECMDLINELENGTHDEFAULT));
1015 if (ret == MBID_YES)
1016 MaxComLineStrg = 1024;
1017 MaxComLineChecked = TRUE;
1018 PrfWriteProfileData(fmprof, appname, "MaxComLineChecked", &MaxComLineChecked, sizeof(BOOL));
1019 }
1020 }
1021 if (MaxComLineStrg < CMDLNLNGTH_MIN)
1022 MaxComLineStrg = CMDLNLNGTH_MIN;
1023 else if (MaxComLineStrg > CMDLNLNGTH_MAX)
1024 MaxComLineStrg = CMDLNLNGTH_MAX;
1025 editor = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
1026 if (!editor)
1027 return 0; //already complained
1028 viewer = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
1029 if (!viewer)
1030 return 0; //already complained
1031 virus = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
1032 if (!virus)
1033 return 0; //already complained
1034 compare = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
1035 if (!compare)
1036 return 0; //already complained
1037 binview = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
1038 if (!binview)
1039 return 0; //already complained
1040 bined = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
1041 if (!bined)
1042 return 0; //already complained
1043 dircompare = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
1044 if (!dircompare)
1045 return 0; //already complained
1046 ftprun = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
1047 if (!ftprun)
1048 return 0; //already complained
1049 httprun = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
1050 if (!httprun)
1051 return 0; //already complained
1052 mailrun = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
1053 if (!mailrun)
1054 return 0; //already complained
1055 size = sizeof(BOOL);
1056 PrfQueryProfileData(fmprof, appname, "ShowTarget", &fShowTarget, &size);
1057 size = sizeof(BOOL);
1058 PrfQueryProfileData(fmprof, appname, "CheckMM", &fCheckMM, &size);
1059 size = sizeof(BOOL);
1060 PrfQueryProfileData(fmprof, appname, "ChangeTarget", &fChangeTarget, &size);
1061 size = sizeof(BOOL);
1062 PrfQueryProfileData(fmprof, appname, "ConfirmTarget", &fConfirmTarget, &size);
1063 size = sizeof(BOOL);
1064 PrfQueryProfileData(fmprof, FM3Str, "CustomFileDlg", &fCustomFileDlg, &size);
1065 size = sizeof(BOOL);
1066 PrfQueryProfileData(fmprof, FM3Str, "SaveMiniCmds", &fSaveMiniCmds, &size);
1067 size = sizeof(BOOL);
1068 PrfQueryProfileData(fmprof, appname, "SaveBigCmds", &fSaveBigCmds, &size);
1069 size = sizeof(BOOL);
1070 PrfQueryProfileData(fmprof, appname, "NoFoldMenu", &fNoFoldMenu, &size);
1071 size = sizeof(BOOL);
1072 PrfQueryProfileData(fmprof, FM3Str, "ThreadNotes", &fThreadNotes, &size);
1073 size = sizeof(BOOL);
1074 PrfQueryProfileData(fmprof, FM3Str, "Prnpagenums", &prnpagenums, &size);
1075 size = sizeof(BOOL);
1076 PrfQueryProfileData(fmprof, FM3Str, "Prnalt", &prnalt, &size);
1077 size = sizeof(BOOL);
1078 PrfQueryProfileData(fmprof, FM3Str, "Prnformat", &prnformat, &size);
1079 size = sizeof(BOOL);
1080 PrfQueryProfileData(fmprof, FM3Str, "Prnformfeedbefore",
1081 &prnformfeedbefore, &size);
1082 size = sizeof(BOOL);
1083 PrfQueryProfileData(fmprof, FM3Str,
1084 "Prnformfeedafter",&prnformfeedafter, &size);
1085 size = sizeof(ULONG);
1086 PrfQueryProfileData(fmprof, FM3Str, "Prntabspaces", &prntabspaces, &size);
1087 size = sizeof(ULONG);
1088 PrfQueryProfileData(fmprof, FM3Str, "Prnwidth", &prnwidth, &size);
1089 size = sizeof(ULONG);
1090 PrfQueryProfileData(fmprof, FM3Str, "Prnlength", &prnlength, &size);
1091 size = sizeof(ULONG);
1092 PrfQueryProfileData(fmprof, FM3Str, "Prntmargin", &prntmargin, &size);
1093 size = sizeof(ULONG);
1094 PrfQueryProfileData(fmprof, FM3Str, "Prnbmargin", &prnbmargin, &size);
1095 size = sizeof(ULONG);
1096 PrfQueryProfileData(fmprof, FM3Str, "Prnlmargin", &prnlmargin, &size);
1097 size = sizeof(ULONG);
1098 PrfQueryProfileData(fmprof, FM3Str, "Prnrmargin", &prnrmargin, &size);
1099 size = sizeof(ULONG);
1100 PrfQueryProfileData(fmprof, FM3Str, "Prnspacing", &prnspacing, &size);
1101 size = sizeof(BOOL);
1102 PrfQueryProfileData(fmprof, FM3Str, "NoDead", &fNoDead, &size);
1103 size = sizeof(BOOL);
1104 PrfQueryProfileData(fmprof, FM3Str, "NoFinger", &fNoFinger, &size);
1105 size = sizeof(BOOL);
1106 PrfQueryProfileData(fmprof, appname, "SwitchTree", &fSwitchTree, &size);
1107 size = sizeof(BOOL);
1108 PrfQueryProfileData(fmprof, appname, "SwitchTreeExpand",
1109 &fSwitchTreeExpand, &size);
1110 size = sizeof(BOOL);
1111 PrfQueryProfileData(fmprof, appname, "SwitchTreeOnFocus",
1112 &fSwitchTreeOnFocus, &size);
1113 size = sizeof(BOOL);
1114 PrfQueryProfileData(fmprof, appname, "CollapseFirst",
1115 &fCollapseFirst, &size);
1116 size = sizeof(BOOL);
1117 PrfQueryProfileData(fmprof, appname, "FilesInTree",
1118 &fFilesInTree, &size);
1119 size = sizeof(BOOL);
1120 PrfQueryProfileData(fmprof, FM3Str, "TopDir", &fTopDir, &size);
1121 size = sizeof(BOOL);
1122 PrfQueryProfileData(fmprof, FM3Str, "LookInDir", &fLookInDir, &size);
1123 PrfQueryProfileString(fmprof, appname, "DefArc", NULL, szDefArc,
1124 sizeof(szDefArc));
1125 size = sizeof(ULONG);
1126 PrfQueryProfileData(fmprof, FM3Str, "AutoviewHeight",
1127 &AutoviewHeight, &size);
1128 size = sizeof(BOOL);
1129 PrfQueryProfileData(fmprof, FM3Str, "KeepCmdLine", &fKeepCmdLine, &size);
1130 if (strcmp(realappname, "FM/4")) {
1131 size = sizeof(BOOL);
1132 PrfQueryProfileData(fmprof, FM3Str, "MoreButtons", &fMoreButtons, &size);
1133 size = sizeof(BOOL);
1134 PrfQueryProfileData(fmprof, FM3Str, "Drivebar", &fDrivebar, &size);
1135 }
1136 else
1137 fDrivebar = fMoreButtons = TRUE;
1138 size = sizeof(BOOL);
1139 PrfQueryProfileData(fmprof, appname, "NoSearch", &fNoSearch, &size);
1140 size = sizeof(BOOL);
1141 PrfQueryProfileData(fmprof, appname, "GuessType", &fGuessType, &size);
1142 size = sizeof(BOOL);
1143 PrfQueryProfileData(fmprof, appname, "ViewChild", &fViewChild, &size);
1144 size = sizeof(BOOL);
1145 PrfQueryProfileData(fmprof, appname, "ShowEnv", &fShowEnv, &size);
1146 size = sizeof(BOOL);
1147 PrfQueryProfileData(fmprof, appname, "LeaveTree", &fLeaveTree, &size);
1148 size = sizeof(BOOL);
1149 PrfQueryProfileData(fmprof, FM3Str, "Comments", &fComments, &size);
1150 size = sizeof(ULONG);
1151 PrfQueryProfileData(fmprof, appname, "WS_ANIMATE", &fwsAnimate, &size);
1152 if (fwsAnimate)
1153 fwsAnimate = WS_ANIMATE;
1154 size = sizeof(ULONG);
1155 size = sizeof(BOOL);
1156 PrfQueryProfileData(fmprof, appname, "SelectedAlways",
1157 &fSelectedAlways, &size);
1158 size = sizeof(BOOL);
1159 PrfQueryProfileData(fmprof, FM3Str, "ToolbarHelp", &fToolbarHelp, &size);
1160 size = sizeof(BOOL);
1161 PrfQueryProfileData(fmprof, FM3Str, "OtherHelp", &fOtherHelp, &size);
1162 size = sizeof(BOOL);
1163 PrfQueryProfileData(fmprof, FM3Str, "DrivebarHelp", &fDrivebarHelp, &size);
1164 size = sizeof(BOOL);
1165 PrfQueryProfileData(fmprof, appname, "AutoAddDirs", &fAutoAddDirs, &size);
1166 size = sizeof(BOOL);
1167 PrfQueryProfileData(fmprof, appname,
1168 "AutoAddAllDirs", &fAutoAddAllDirs, &size);
1169 size = sizeof(BOOL);
1170 PrfQueryProfileData(fmprof, FM3Str, "UserListSwitches",
1171 &fUserListSwitches, &size);
1172 size = sizeof(BOOL);
1173 PrfQueryProfileData(fmprof, appname, "UseNewViewer",
1174 &fUseNewViewer, &size);
1175 size = sizeof(BOOL);
1176 PrfQueryProfileData(fmprof, appname, "DefaultDeletePerm",
1177 &fDefaultDeletePerm, &size);
1178 size = sizeof(BOOL);
1179 PrfQueryProfileData(fmprof, FM3Str, "ExternalINIs",
1180 &fExternalINIs, &size);
1181 size = sizeof(BOOL);
1182 PrfQueryProfileData(fmprof, FM3Str, "ExternalCollector",
1183 &fExternalCollector, &size);
1184 size = sizeof(BOOL);
1185 PrfQueryProfileData(fmprof, FM3Str, "ExternalArcboxes",
1186 &fExternalArcboxes, &size);
1187 size = sizeof(BOOL);
1188 PrfQueryProfileData(fmprof, FM3Str, "ExternalViewer",
1189 &fExternalViewer, &size);
1190 size = sizeof(BOOL);
1191 PrfQueryProfileData(fmprof, FM3Str, "UseQProcStat",
1192 &fUseQProcStat, &size);
1193 size = sizeof(BOOL);
1194 PrfQueryProfileData(fmprof, FM3Str, "UseQSysState",
1195 &fUseQSysState, &size);
1196 size = sizeof(BOOL);
1197 PrfQueryProfileData(fmprof, FM3Str, "DataMin", &fDataMin, &size);
1198 size = sizeof(BOOL);
1199 PrfQueryProfileData(fmprof, appname, "DataToFore", &fDataToFore, &size);
1200 size = sizeof(BOOL);
1201 PrfQueryProfileData(fmprof, appname, "DataShowDrives",
1202 &fDataShowDrives, &size);
1203 size = sizeof(BOOL);
1204 PrfQueryProfileData(fmprof, appname, "DataInclRemote",
1205 &fDataInclRemote, &size);
1206 size = sizeof(BOOL);
1207 PrfQueryProfileData(fmprof, FM3Str, "SplitStatus", &fSplitStatus, &size);
1208 size = sizeof(BOOL);
1209 PrfQueryProfileData(fmprof, appname, "FolderAfterExtract",
1210 &fFolderAfterExtract, &size);
1211 size = sizeof(BOOL);
1212 PrfQueryProfileData(fmprof, FM3Str, "DullDatabar", &fDullMin, &size);
1213 size = sizeof(BOOL);
1214 PrfQueryProfileData(fmprof, appname, "BlueLED", &fBlueLED, &size);
1215 size = sizeof(BOOL);
1216 PrfQueryProfileData(fmprof, appname, "ConfirmDelete",
1217 &fConfirmDelete, &size);
1218 size = sizeof(BOOL);
1219 PrfQueryProfileData(fmprof, FM3Str, "SaveState", &fSaveState, &size);
1220 size = sizeof(BOOL);
1221 PrfQueryProfileData(fmprof, appname, "SyncUpdates", &fSyncUpdates, &size);
1222 size = sizeof(BOOL);
1223 PrfQueryProfileData(fmprof, appname, "LoadSubject", &fLoadSubject, &size);
1224 size = sizeof(BOOL);
1225 PrfQueryProfileData(fmprof, appname, "UnHilite", &fUnHilite, &size);
1226 size = sizeof(BOOL);
1227 PrfQueryProfileData(fmprof, FM3Str, "TileBackwards", &fTileBackwards, &size);
1228 size = sizeof(BOOL);
1229 PrfQueryProfileData(fmprof, appname, "LoadLongname", &fLoadLongnames, &size);
1230 size = sizeof(BOOL);
1231 PrfQueryProfileData(fmprof, appname, "VerifyWrites", &fVerify, &size);
1232 DosSetVerify(fVerify);
1233 size = sizeof(BOOL);
1234 PrfQueryProfileData(fmprof, appname, "DontMoveMouse", &fDontMoveMouse, &size);
1235 size = sizeof(BOOL);
1236 PrfQueryProfileData(fmprof, appname, "NoIconsFiles", &fNoIconsFiles, &size);
1237 size = sizeof(BOOL);
1238 PrfQueryProfileData(fmprof, appname, "NoIconsDirs", &fNoIconsDirs, &size);
1239 size = sizeof(BOOL);
1240 PrfQueryProfileData(fmprof, appname, "ForceUpper", &fForceUpper, &size);
1241 size = sizeof(BOOL);
1242 PrfQueryProfileData(fmprof, appname, "ForceLower", &fForceLower, &size);
1243 size = sizeof(BOOL);
1244 PrfQueryProfileData(fmprof, FM3Str, "TextTools", &fTextTools, &size);
1245 size = sizeof(BOOL);
1246 PrfQueryProfileData(fmprof, FM3Str, "ToolTitles", &fToolTitles, &size);
1247 size = sizeof(BOOL);
1248 PrfQueryProfileData(fmprof, appname, "DoubleClickOpens", &fDCOpens, &size);
1249 size = sizeof(BOOL);
1250 PrfQueryProfileData(fmprof, appname, "LinkSetsIcon", &fLinkSetsIcon, &size);
1251 size = sizeof(INT);
1252 PrfQueryProfileData(fmprof, appname, "Sort", &sortFlags, &size);
1253 size = sizeof(INT);
1254 PrfQueryProfileData(fmprof, appname, "TreeSort", &TreesortFlags, &size);
1255 size = sizeof(INT);
1256 PrfQueryProfileData(fmprof, appname,
1257 "CollectorSort", &CollectorsortFlags, &size);
1258 size = sizeof(targetdir);
1259 PrfQueryProfileData(fmprof, appname, "Targetdir", targetdir, &size);
1260 if (!IsValidDir(targetdir))
1261 *targetdir = 0;
1262 size = sizeof(extractpath);
1263 PrfQueryProfileData(fmprof, appname, "ExtractPath", extractpath, &size);
1264 size = sizeof(printer);
1265 PrfQueryProfileData(fmprof, appname, "Printer", printer, &size);
1266 size = MaxComLineStrg;
1267 PrfQueryProfileData(fmprof, appname, "DirCompare", dircompare,
1268 &size);
1269 size = MaxComLineStrg;
1270 PrfQueryProfileData(fmprof, appname, "Viewer", viewer, &size);
1271 size = MaxComLineStrg;
1272 PrfQueryProfileData(fmprof, appname, "Editor", editor, &size);
1273 size = MaxComLineStrg;
1274 PrfQueryProfileData(fmprof, appname, "BinView", binview, &size);
1275 size = MaxComLineStrg;
1276 PrfQueryProfileData(fmprof, appname, "BinEd", bined, &size);
1277 size = MaxComLineStrg;
1278 PrfQueryProfileData(fmprof, appname, "Compare", compare, &size);
1279 size = MaxComLineStrg;
1280 PrfQueryProfileData(fmprof, appname, "Virus", virus, &size);
1281 size = sizeof(BOOL);
1282 PrfQueryProfileData(fmprof, appname, "FtpRunWPSDefault", &fFtpRunWPSDefault, &size);
1283 size = MaxComLineStrg;
1284 PrfQueryProfileData(fmprof, appname, "FTPRun", ftprun, &size);
1285 if (!*ftprun)
1286 fFtpRunWPSDefault = TRUE;
1287 size = sizeof(BOOL);
1288 PrfQueryProfileData(fmprof, appname, "HttpRunWPSDefault", &fHttpRunWPSDefault, &size);
1289 size = MaxComLineStrg;
1290 PrfQueryProfileData(fmprof, appname, "HTTPRun", httprun, &size);
1291 if (!*httprun)
1292 fHttpRunWPSDefault = TRUE;
1293 size = MaxComLineStrg;
1294 PrfQueryProfileData(fmprof, appname, "MailRun", mailrun, &size);
1295 size = sizeof(ftprundir);
1296 PrfQueryProfileData(fmprof, appname, "FtpRunDir", ftprundir, &size);
1297 size = sizeof(httprundir);
1298 PrfQueryProfileData(fmprof, appname, "HttpRunDir", httprundir, &size);
1299 size = sizeof(mailrundir);
1300 PrfQueryProfileData(fmprof, appname, "MailRunDir", mailrundir, &size);
1301 size = sizeof(lasttoolbox);
1302 PrfQueryProfileData(fmprof, FM3Str, "LastToolBox", lasttoolbox,
1303 &size);
1304 size = sizeof(BOOL);
1305 PrfQueryProfileData(fmprof, appname, "LibPathStrictHttpRun", &fLibPathStrictHttpRun,
1306 &size);
1307 size = sizeof(BOOL);
1308 PrfQueryProfileData(fmprof, appname, "LibPathStrictFtpRun", &fLibPathStrictFtpRun,
1309 &size);
1310 size = sizeof(BOOL);
1311 PrfQueryProfileData(fmprof, appname, "LibPathStrictMailRun", &fLibPathStrictMailRun,
1312 &size);
1313 size = sizeof(BOOL);
1314 PrfQueryProfileData(fmprof, appname, "NoMailtoMailRun", &fNoMailtoMailRun,
1315 &size);
1316 size = sizeof(BOOL);
1317 PrfQueryProfileData(fmprof, appname, "FollowTree", &fFollowTree,
1318 &size);
1319 size = sizeof(BOOL);
1320 PrfQueryProfileData(fmprof, appname, "StartMaximized",
1321 &fStartMaximized, &size);
1322 if (!fStartMaximized) {
1323 size = sizeof(BOOL);
1324 PrfQueryProfileData(fmprof, appname, "StartMinimized",
1325 &fStartMinimized, &size);
1326 }
1327 size = sizeof(BOOL);
1328 PrfQueryProfileData(fmprof, appname, "DefaultCopy", &fCopyDefault, &size);
1329 size = sizeof(BOOL);
1330 PrfQueryProfileData(fmprof, appname, "IdleCopy", &fRealIdle, &size);
1331 size = sizeof(BOOL);
1332 PrfQueryProfileData(fmprof, appname, "ArcStuffVisible",
1333 &fArcStuffVisible, &size);
1334 size = sizeof(BOOL);
1335 PrfQueryProfileData(fmprof, FM3Str, "NoTreeGap", &fNoTreeGap, &size);
1336 size = sizeof(BOOL);
1337 PrfQueryProfileData(fmprof, FM3Str, "VTreeOpensWPS",
1338 &fVTreeOpensWPS, &size);
1339 size = sizeof(BOOL);
1340 PrfQueryProfileData(fmprof, appname, "RemoteBug", &fRemoteBug, &size);
1341 size = sizeof(BOOL);
1342 PrfQueryProfileData(fmprof, appname, "Drag&DropDlg",
1343 &fDragndropDlg, &size);
1344 size = sizeof(BOOL);
1345 PrfQueryProfileData(fmprof, FM3Str, "UserComboBox", &fUserComboBox, &size);
1346 size = sizeof(BOOL);
1347 PrfQueryProfileData(fmprof, FM3Str, "MinDirOnOpen", &fMinOnOpen, &size);
1348 size = sizeof(BOOL);
1349 PrfQueryProfileData(fmprof, appname, "QuickArcFind",
1350 &fQuickArcFind, &size);
1351 size = sizeof(BOOL);
1352 PrfQueryProfileData(fmprof, FM3Str, "NoRemovableScan",
1353 &fNoRemovableScan, &size);
1354 size = sizeof(ULONG);
1355 PrfQueryProfileData(fmprof, FM3Str, "NoBrokenNotify",
1356 &NoBrokenNotify, &size);
1357 size = sizeof(ULONG);
1358 PrfQueryProfileData(fmprof, appname, "ContainerType", &ulCnrType,
1359 &size);
1360 size = sizeof(ULONG);
1361 PrfQueryProfileData(fmprof, appname, "FilesToGet", &FilesToGet, &size);
1362 if (FilesToGet < FILESTOGET_MIN)
1363 FilesToGet = FILESTOGET_MIN;
1364 else if (FilesToGet > FILESTOGET_MAX)
1365 FilesToGet = FILESTOGET_MAX;
1366 size = sizeof(BOOL);
1367 PrfQueryProfileData(fmprof, FM3Str, "AutoView", &fAutoView, &size);
1368 size = sizeof(BOOL);
1369 PrfQueryProfileData(fmprof, FM3Str, "FM2Deletes", &fFM2Deletes, &size);
1370 size = sizeof(BOOL);
1371 PrfQueryProfileData(fmprof, FM3Str, "TrashCan", &fTrashCan, &size);
1372
1373 LoadDetailsSwitches("DirCnr", NULL);
1374
1375 /* load pointers and icons we use */
1376 hptrArrow = WinQuerySysPointer(HWND_DESKTOP, SPTR_ARROW, FALSE);
1377 hptrBusy = WinQuerySysPointer(HWND_DESKTOP, SPTR_WAIT, FALSE);
1378 hptrNS = WinQuerySysPointer(HWND_DESKTOP, SPTR_SIZENS, FALSE);
1379 hptrEW = WinQuerySysPointer(HWND_DESKTOP, SPTR_SIZEWE, FALSE);
1380 hptrFloppy = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, FLOPPY_ICON);
1381 hptrDrive = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, DRIVE_ICON);
1382 hptrRemovable = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, REMOVABLE_ICON);
1383 hptrCDROM = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, CDROM_ICON);
1384 hptrFile = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, FILE_ICON);
1385 hptrDir = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, DIR_FRAME);
1386 hptrArc = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, ARC_FRAME);
1387 hptrArt = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, ART_ICON);
1388 hptrSystem = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, FILE_SYSTEM_ICON);
1389 hptrHidden = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, FILE_HIDDEN_ICON);
1390 hptrReadonly = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, FILE_READONLY_ICON);
1391 hptrLast = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, LASTITEM_ICON);
1392 hptrRemote = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, REMOTE_ICON);
1393 hptrVirtual = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, VIRTUAL_ICON);
1394 hptrRamdisk = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, RAMDISK_ICON);
1395 if (!fNoDead)
1396 hptrFinger = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, FINGER_ICON);
1397 else
1398 hptrFinger = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, FINGER2_ICON);
1399 hptrApp = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, APP_ICON);
1400 hptrDunno = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, DUNNO_ICON);
1401 hptrEnv = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, ENV_ICON);
1402 hptrZipstrm = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, ZIPSTREAM_ICON);
1403
1404 // set up color array used by seeall.c and newview.c color dialog
1405
1406 standardcolors[0] = CLR_WHITE;
1407 standardcolors[1] = CLR_BLACK;
1408 standardcolors[2] = CLR_BLUE;
1409 standardcolors[3] = CLR_RED;
1410 standardcolors[4] = CLR_PINK;
1411 standardcolors[5] = CLR_GREEN;
1412 standardcolors[6] = CLR_CYAN;
1413 standardcolors[7] = CLR_YELLOW;
1414 standardcolors[8] = CLR_DARKGRAY;
1415 standardcolors[9] = CLR_DARKBLUE;
1416 standardcolors[10] = CLR_DARKRED;
1417 standardcolors[11] = CLR_DARKPINK;
1418 standardcolors[12] = CLR_DARKGREEN;
1419 standardcolors[13] = CLR_DARKCYAN;
1420 standardcolors[14] = CLR_BROWN;
1421 standardcolors[15] = CLR_PALEGRAY;
1422
1423 return TRUE;
1424}
1425
1426HWND StartFM3(HAB hab, INT argc, CHAR ** argv)
1427{
1428 HWND hwndFrame;
1429 HWND hwndClient;
1430 UINT x;
1431 ULONG FrameFlags = FCF_TITLEBAR | FCF_SYSMENU |
1432 FCF_SIZEBORDER | FCF_MINMAX |
1433 FCF_ACCELTABLE | FCF_MENU | FCF_ICON | FCF_TASKLIST | FCF_NOBYTEALIGN;
1434
1435 for (x = 1; x < argc; x++) {
1436 if (*argv[x] == '~' && !argv[x][1])
1437 fReminimize = TRUE;
1438 if (*argv[x] == '+' && !argv[x][1])
1439 fLogFile = TRUE;
1440 if (*argv[x] == '-') {
1441 if (!argv[x][1])
1442 fNoSaveState = TRUE;
1443 else
1444 strcpy(profile, &argv[x][1]);
1445 }
1446 }
1447
1448 hwndFrame = WinCreateStdWindow(HWND_DESKTOP,
1449 WS_VISIBLE,
1450 &FrameFlags,
1451 WC_MAINWND,
1452 NULL,
1453 WS_VISIBLE | WS_ANIMATE,
1454 FM3ModHandle, MAIN_FRAME, &hwndClient);
1455 if (hwndFrame) {
1456 WinSetWindowUShort(hwndFrame, QWS_ID, MAIN_FRAME);
1457 hwndMainMenu = WinWindowFromID(hwndFrame, FID_MENU);
1458 if (!WinRestoreWindowPos(FM2Str, "MainWindowPos", hwndFrame)) {
1459
1460 ULONG fl = SWP_MOVE | SWP_SIZE;
1461 RECTL rcl;
1462 ULONG icz = WinQuerySysValue(HWND_DESKTOP, SV_CYICON) * 3L;
1463 ULONG bsz = WinQuerySysValue(HWND_DESKTOP, SV_CYSIZEBORDER);
1464
1465 WinQueryWindowRect(HWND_DESKTOP, &rcl);
1466 rcl.yBottom += icz;
1467 rcl.yTop -= bsz;
1468 rcl.xLeft += bsz;
1469 rcl.xRight -= bsz;
1470 WinSetWindowPos(hwndFrame,
1471 HWND_TOP,
1472 rcl.xLeft,
1473 rcl.yBottom,
1474 rcl.xRight - rcl.xLeft, rcl.yTop - rcl.yBottom, fl);
1475 }
1476 if (fLogFile)
1477 LogFileHandle = _fsopen("FM2.LOG", "a+", SH_DENYWR);
1478 if (hwndHelp)
1479 WinAssociateHelpInstance(hwndHelp, hwndFrame);
1480 PostMsg(hwndClient, UM_SETUP, MPFROMLONG(argc), MPFROMP(argv));
1481 }
1482 return hwndFrame;
1483}
1484
1485BOOL CheckFileHeader(CHAR *filespec, CHAR *signature, LONG offset)
1486{
1487 HFILE handle;
1488 ULONG action;
1489 ULONG len = strlen(signature);
1490 ULONG l;
1491 // CHAR buffer[80];
1492 CHAR buffer[4096]; // 06 Oct 07 SHL Protect against NTFS defect
1493 BOOL ret = FALSE;
1494
1495 DosError(FERR_DISABLEHARDERR);
1496 if (DosOpen(filespec,
1497 &handle,
1498 &action,
1499 0,
1500 0,
1501 OPEN_ACTION_FAIL_IF_NEW |
1502 OPEN_ACTION_OPEN_IF_EXISTS,
1503 OPEN_FLAGS_FAIL_ON_ERROR |
1504 OPEN_FLAGS_NOINHERIT |
1505 OPEN_FLAGS_RANDOMSEQUENTIAL |
1506 OPEN_SHARE_DENYNONE | OPEN_ACCESS_READONLY, 0))
1507 ret = FALSE;
1508 else {
1509 // Try signature match
1510 l = len;
1511 l = min(l, 79);
1512 if (!DosChgFilePtr(handle,
1513 abs(offset),
1514 (offset >= 0) ?
1515 FILE_BEGIN : FILE_END, &len)) {
1516 if (!DosRead(handle, buffer, l, &len) && len == l) {
1517 if (!memcmp(signature, buffer, l))
1518 ret = TRUE; // Matched
1519 }
1520 }
1521 }
1522 DosClose(handle); /* Either way, we're done for now */
1523 return ret; /* Return TRUE if matched */
1524}
1525
1526int CheckVersion(int vermajor, int verminor)
1527{
1528 int ok = 0;
1529
1530 // fixme to do useful check - was missing in base source
1531
1532#if 0
1533 if (vermajor && verminor) {
1534 *vermajor = VERMAJOR;
1535 *verminor = VERMINOR;
1536 ok = 1;
1537 }
1538#endif
1539
1540 ok = 1;
1541
1542 return ok;
1543}
1544
1545#ifdef __WATCOMC__
1546#pragma alloc_text(INIT,LibMain,InitFM3DLL,DeInitFM3DLL)
1547#pragma alloc_text(INIT1,StartFM3,FindSwapperDat)
1548#endif
Note: See TracBrowser for help on using the repository browser.