source: trunk/dll/init.c@ 1089

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

Delete orphaned tmp directories without deleting another active session's temp directory

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