source: trunk/dll/init.c@ 985

Last change on this file since 985 was 985, checked in by Gregg Young, 18 years ago

Update sizes dialog (ticket 44); Make max command line length user settable (ticket 199); use xfree for free in most cases (ticket 212); initial code to check for valid ini file (ticket 102); Some additional refactoring and structure rework; Some documentation updates;

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