source: trunk/dll/init.c@ 1082

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

Changes so FM2 will use TMP/TEMP directory for all temp files; Replaced save_dir2 with global variable so BldFullPathName could easily replace code that performed the same function; Added #ifdef FORTIFY to free_ function that are only used when fortified.

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