source: trunk/dll/init.c@ 1452

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

Change protectonly check from command.com to VKBD module loaded (Ticket 392)

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