source: trunk/dll/init.c@ 1217

Last change on this file since 1217 was 1217, checked in by John Small, 17 years ago

init.c: moved a misplaced function declaration.

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