source: trunk/dll/init.c@ 1075

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

Debulked TMP code; Added comments;

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