source: trunk/dll/init.c@ 1074

Last change on this file since 1074 was 1074, checked in by Steven Levine, 17 years ago

Reduce code bulk in fUseTmp setup

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