source: trunk/dll/init.c@ 1436

Last change on this file since 1436 was 1436, checked in by Gregg Young, 16 years ago

Drive letter incorporated into bitmaps for drivebar buttons. (tickets 13 & 91)

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