source: trunk/dll/init.c@ 1377

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

Help file updates for recent changes; readme and def file updates for 3.15

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