source: trunk/dll/init.c@ 1065

Last change on this file since 1065 was 1065, checked in by John Small, 17 years ago

Ticket 230: Simplified code and eliminated some local variables by incorporating
all the details view settings (both the global variables and those in the
DIRCNRDATA struct) into a new struct: DETAILS_SETTINGS.

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