source: trunk/dll/init.c@ 989

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

Refactor fm3dll.h to create command.h; broken ini is now replaced with backup or new ini as available; more variable command line ledth changes

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