source: trunk/dll/init.c@ 1475

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

Add comments rem dbgmsgs

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 59.8 KB
Line 
1
2/***********************************************************************
3
4 $Id: init.c 1475 2009-10-25 23:24:26Z 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 }
1194 else
1195 fProtectOnly = TRUE;
1196 }
1197
1198 // load preferences from profile (INI) file
1199 size = sizeof(ULONG);
1200 PrfQueryProfileData(fmprof, appname, "MaxComLineStrg", &MaxComLineStrg, &size);
1201 // Give user one chance to reset the default command line length to 1024 (4os2's unexpanded max)
1202 if (MaxComLineStrg == 2048) {
1203 BOOL MaxComLineChecked = FALSE;
1204
1205 size = sizeof(BOOL);
1206 PrfQueryProfileData(fmprof, appname, "MaxComLineChecked", &MaxComLineChecked, &size);
1207 if (!MaxComLineChecked) {
1208 ret = saymsg(MB_YESNO,
1209 HWND_DESKTOP,
1210 NullStr,
1211 GetPString(IDS_CHANGECMDLINELENGTHDEFAULT));
1212 if (ret == MBID_YES)
1213 MaxComLineStrg = 1024;
1214 MaxComLineChecked = TRUE;
1215 PrfWriteProfileData(fmprof, appname, "MaxComLineChecked", &MaxComLineChecked, sizeof(BOOL));
1216 }
1217 }
1218 if (MaxComLineStrg < CMDLNLNGTH_MIN)
1219 MaxComLineStrg = CMDLNLNGTH_MIN;
1220 else if (MaxComLineStrg > CMDLNLNGTH_MAX)
1221 MaxComLineStrg = CMDLNLNGTH_MAX;
1222 editor = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
1223 if (!editor)
1224 return 0; //already complained
1225 viewer = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
1226 if (!viewer)
1227 return 0; //already complained
1228 virus = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
1229 if (!virus)
1230 return 0; //already complained
1231 compare = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
1232 if (!compare)
1233 return 0; //already complained
1234 binview = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
1235 if (!binview)
1236 return 0; //already complained
1237 bined = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
1238 if (!bined)
1239 return 0; //already complained
1240 dircompare = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
1241 if (!dircompare)
1242 return 0; //already complained
1243 ftprun = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
1244 if (!ftprun)
1245 return 0; //already complained
1246 httprun = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
1247 if (!httprun)
1248 return 0; //already complained
1249 mailrun = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
1250 if (!mailrun)
1251 return 0; //already complained
1252 pszTreeEnvVarList = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
1253 if (!pszTreeEnvVarList)
1254 return 0; //already complained
1255 size = sizeof(BOOL);
1256 PrfQueryProfileData(fmprof, appname, "DontSuggestAgain", &fDontSuggestAgain, &size);
1257 size = sizeof(BOOL);
1258 PrfQueryProfileData(fmprof, appname, "ShowTarget", &fShowTarget, &size);
1259 size = sizeof(BOOL);
1260 PrfQueryProfileData(fmprof, appname, "CheckMM", &fCheckMM, &size);
1261 size = sizeof(BOOL);
1262 PrfQueryProfileData(fmprof, appname, "ChangeTarget", &fChangeTarget, &size);
1263 size = sizeof(BOOL);
1264 PrfQueryProfileData(fmprof, appname, "ConfirmTarget", &fConfirmTarget, &size);
1265 size = sizeof(BOOL);
1266 PrfQueryProfileData(fmprof, FM3Str, "CustomFileDlg", &fCustomFileDlg, &size);
1267 size = sizeof(BOOL);
1268 PrfQueryProfileData(fmprof, FM3Str, "SaveMiniCmds", &fSaveMiniCmds, &size);
1269 size = sizeof(BOOL);
1270 PrfQueryProfileData(fmprof, appname, "SaveBigCmds", &fSaveBigCmds, &size);
1271 size = sizeof(BOOL);
1272 PrfQueryProfileData(fmprof, appname, "NoFoldMenu", &fNoFoldMenu, &size);
1273 size = sizeof(BOOL);
1274 PrfQueryProfileData(fmprof, FM3Str, "ThreadNotes", &fThreadNotes, &size);
1275 size = sizeof(BOOL);
1276 PrfQueryProfileData(fmprof, FM3Str, "Prnpagenums", &prnpagenums, &size);
1277 size = sizeof(BOOL);
1278 PrfQueryProfileData(fmprof, FM3Str, "Prnalt", &prnalt, &size);
1279 size = sizeof(BOOL);
1280 PrfQueryProfileData(fmprof, FM3Str, "Prnformat", &prnformat, &size);
1281 size = sizeof(BOOL);
1282 PrfQueryProfileData(fmprof, FM3Str, "Prnformfeedbefore", &prnformfeedbefore, &size);
1283 size = sizeof(BOOL);
1284 PrfQueryProfileData(fmprof, FM3Str, "Prnformfeedafter",&prnformfeedafter, &size);
1285 size = sizeof(ULONG);
1286 PrfQueryProfileData(fmprof, FM3Str, "Prntabspaces", &prntabspaces, &size);
1287 size = sizeof(ULONG);
1288 PrfQueryProfileData(fmprof, FM3Str, "Prnwidth", &prnwidth, &size);
1289 size = sizeof(ULONG);
1290 PrfQueryProfileData(fmprof, FM3Str, "Prnlength", &prnlength, &size);
1291 size = sizeof(ULONG);
1292 PrfQueryProfileData(fmprof, FM3Str, "Prntmargin", &prntmargin, &size);
1293 size = sizeof(ULONG);
1294 PrfQueryProfileData(fmprof, FM3Str, "Prnbmargin", &prnbmargin, &size);
1295 size = sizeof(ULONG);
1296 PrfQueryProfileData(fmprof, FM3Str, "Prnlmargin", &prnlmargin, &size);
1297 size = sizeof(ULONG);
1298 PrfQueryProfileData(fmprof, FM3Str, "Prnrmargin", &prnrmargin, &size);
1299 size = sizeof(ULONG);
1300 PrfQueryProfileData(fmprof, FM3Str, "Prnspacing", &prnspacing, &size);
1301 size = sizeof(BOOL);
1302 PrfQueryProfileData(fmprof, FM3Str, "NoDead", &fNoDead, &size);
1303 size = sizeof(BOOL);
1304 PrfQueryProfileData(fmprof, FM3Str, "NoFinger", &fNoFinger, &size);
1305 size = sizeof(BOOL);
1306 PrfQueryProfileData(fmprof, FM3Str, "AlertBeepOff", &fAlertBeepOff, &size);
1307 size = sizeof(BOOL);
1308 PrfQueryProfileData(fmprof, FM3Str, "ErrorBeepOff", &fErrorBeepOff, &size);
1309 size = sizeof(BOOL);
1310 PrfQueryProfileData(fmprof, appname, "SwitchTree", &fSwitchTree, &size);
1311 size = sizeof(BOOL);
1312 PrfQueryProfileData(fmprof, appname, "SwitchTreeExpand", &fSwitchTreeExpand, &size);
1313 size = sizeof(BOOL);
1314 PrfQueryProfileData(fmprof, appname, "SwitchTreeOnFocus", &fSwitchTreeOnFocus, &size);
1315 size = sizeof(BOOL);
1316 PrfQueryProfileData(fmprof, appname, "CollapseFirst", &fCollapseFirst, &size);
1317 size = sizeof(BOOL);
1318 PrfQueryProfileData(fmprof, appname, "FilesInTree", &fFilesInTree, &size);
1319 size = sizeof(BOOL);
1320 PrfQueryProfileData(fmprof, FM3Str, "TopDir", &fTopDir, &size);
1321 size = sizeof(BOOL);
1322 PrfQueryProfileData(fmprof, FM3Str, "LookInDir", &fLookInDir, &size);
1323 PrfQueryProfileString(fmprof, appname, "DefArc", NULL, szDefArc, sizeof(szDefArc));
1324 size = sizeof(ULONG);
1325 PrfQueryProfileData(fmprof, FM3Str, "AutoviewHeight",
1326 &AutoviewHeight, &size);
1327 size = sizeof(BOOL);
1328 PrfQueryProfileData(fmprof, FM3Str, "KeepCmdLine", &fKeepCmdLine, &size);
1329 if (strcmp(realappname, "FM/4")) {
1330 size = sizeof(BOOL);
1331 PrfQueryProfileData(fmprof, FM3Str, "MoreButtons", &fMoreButtons, &size);
1332 size = sizeof(BOOL);
1333 PrfQueryProfileData(fmprof, FM3Str, "Drivebar", &fDrivebar, &size);
1334 }
1335 else
1336 fDrivebar = fMoreButtons = TRUE;
1337 size = sizeof(BOOL);
1338 PrfQueryProfileData(fmprof, appname, "NoSearch", &fNoSearch, &size);
1339 size = sizeof(BOOL);
1340 PrfQueryProfileData(fmprof, appname, "GuessType", &fGuessType, &size);
1341 size = sizeof(BOOL);
1342 PrfQueryProfileData(fmprof, appname, "ViewChild", &fViewChild, &size);
1343 size = sizeof(BOOL);
1344 PrfQueryProfileData(fmprof, appname, "ShowEnv", &fShowEnv, &size);
1345 PrfQueryProfileString(fmprof, appname, "TreeEnvVarList", "PATH;DPATH;LIBPATH;HELP;BOOKSHELF;",
1346 pszTreeEnvVarList, MaxComLineStrg);
1347 size = sizeof(BOOL);
1348 PrfQueryProfileData(fmprof, FM3Str, "ShowDriveOnly", &fShowDriveOnly, &size);
1349 size = sizeof(BOOL);
1350 PrfQueryProfileData(fmprof, FM3Str, "ShowFSTypeInTree", &fShowFSTypeInTree, &size);
1351 size = sizeof(BOOL);
1352 PrfQueryProfileData(fmprof, FM3Str, "ShowDriveLabelInTree", &fShowDriveLabelInTree, &size);
1353 if (!fShowDriveOnly && !fShowFSTypeInTree && !fShowDriveLabelInTree)
1354 fShowDriveOnly = TRUE;
1355 size = sizeof(BOOL);
1356 PrfQueryProfileData(fmprof, appname, "LeaveTree", &fLeaveTree, &size);
1357 size = sizeof(BOOL);
1358 PrfQueryProfileData(fmprof, FM3Str, "Comments", &fComments, &size);
1359 size = sizeof(ULONG);
1360 PrfQueryProfileData(fmprof, appname, "WS_ANIMATE", &fwsAnimate, &size);
1361 if (fwsAnimate)
1362 fwsAnimate = WS_ANIMATE;
1363 size = sizeof(BOOL);
1364 PrfQueryProfileData(fmprof, appname, "SelectedAlways", &fSelectedAlways, &size);
1365 size = sizeof(BOOL);
1366 PrfQueryProfileData(fmprof, FM3Str, "ToolbarHelp", &fToolbarHelp, &size);
1367 size = sizeof(BOOL);
1368 PrfQueryProfileData(fmprof, FM3Str, "OtherHelp", &fOtherHelp, &size);
1369 size = sizeof(BOOL);
1370 PrfQueryProfileData(fmprof, FM3Str, "DrivebarHelp", &fDrivebarHelp, &size);
1371 size = sizeof(BOOL);
1372 PrfQueryProfileData(fmprof, appname, "AutoAddDirs", &fAutoAddDirs, &size);
1373 size = sizeof(BOOL);
1374 PrfQueryProfileData(fmprof, appname, "AutoAddAllDirs", &fAutoAddAllDirs, &size);
1375 size = sizeof(BOOL);
1376 PrfQueryProfileData(fmprof, FM3Str, "UserListSwitches", &fUserListSwitches, &size);
1377 size = sizeof(BOOL);
1378 PrfQueryProfileData(fmprof, appname, "UseNewViewer", &fUseNewViewer, &size);
1379 size = sizeof(BOOL);
1380 PrfQueryProfileData(fmprof, appname, "DefaultDeletePerm", &fDefaultDeletePerm, &size);
1381 size = sizeof(BOOL);
1382 PrfQueryProfileData(fmprof, FM3Str, "ExternalINIs", &fExternalINIs, &size);
1383 size = sizeof(BOOL);
1384 PrfQueryProfileData(fmprof, FM3Str, "ExternalCollector", &fExternalCollector, &size);
1385 size = sizeof(BOOL);
1386 PrfQueryProfileData(fmprof, FM3Str, "ExternalArcboxes", &fExternalArcboxes, &size);
1387 size = sizeof(BOOL);
1388 PrfQueryProfileData(fmprof, FM3Str, "ExternalViewer", &fExternalViewer, &size);
1389 size = sizeof(BOOL);
1390 PrfQueryProfileData(fmprof, FM3Str, "UseQProcStat", &fUseQProcStat, &size);
1391 size = sizeof(BOOL);
1392 PrfQueryProfileData(fmprof, FM3Str, "UseQSysState", &fUseQSysState, &size);
1393 size = sizeof(BOOL);
1394 PrfQueryProfileData(fmprof, FM3Str, "DataMin", &fDataMin, &size);
1395 size = sizeof(BOOL);
1396 PrfQueryProfileData(fmprof, appname, "DataToFore", &fDataToFore, &size);
1397 size = sizeof(BOOL);
1398 PrfQueryProfileData(fmprof, appname, "DataShowDrives", &fDataShowDrives, &size);
1399 size = sizeof(BOOL);
1400 PrfQueryProfileData(fmprof, appname, "DataInclRemote", &fDataInclRemote, &size);
1401 size = sizeof(BOOL);
1402 PrfQueryProfileData(fmprof, FM3Str, "SplitStatus", &fSplitStatus, &size);
1403 size = sizeof(BOOL);
1404 PrfQueryProfileData(fmprof, appname, "FolderAfterExtract", &fFolderAfterExtract, &size);
1405 size = sizeof(BOOL);
1406 PrfQueryProfileData(fmprof, FM3Str, "DullDatabar", &fDullMin, &size);
1407 size = sizeof(BOOL);
1408 PrfQueryProfileData(fmprof, appname, "BlueLED", &fBlueLED, &size);
1409 size = sizeof(BOOL);
1410 PrfQueryProfileData(fmprof, appname, "ConfirmDelete", &fConfirmDelete, &size);
1411 size = sizeof(BOOL);
1412 PrfQueryProfileData(fmprof, FM3Str, "SaveState", &fSaveState, &size);
1413 size = sizeof(BOOL);
1414 PrfQueryProfileData(fmprof, appname, "SyncUpdates", &fSyncUpdates, &size);
1415 size = sizeof(BOOL);
1416 PrfQueryProfileData(fmprof, appname, "LoadSubject", &fLoadSubject, &size);
1417 size = sizeof(BOOL);
1418 PrfQueryProfileData(fmprof, appname, "UnHilite", &fUnHilite, &size);
1419 size = sizeof(BOOL);
1420 PrfQueryProfileData(fmprof, FM3Str, "TileBackwards", &fTileBackwards, &size);
1421 size = sizeof(BOOL);
1422 PrfQueryProfileData(fmprof, appname, "LoadLongname", &fLoadLongnames, &size);
1423 size = sizeof(BOOL);
1424 PrfQueryProfileData(fmprof, appname, "VerifyWrites", &fVerify, &size);
1425 DosSetVerify(fVerify);
1426 size = sizeof(BOOL);
1427 PrfQueryProfileData(fmprof, appname, "DontMoveMouse", &fDontMoveMouse, &size);
1428 size = sizeof(BOOL);
1429 PrfQueryProfileData(fmprof, appname, "NoIconsFiles", &fNoIconsFiles, &size);
1430 size = sizeof(BOOL);
1431 PrfQueryProfileData(fmprof, appname, "NoIconsDirs", &fNoIconsDirs, &size);
1432 size = sizeof(BOOL);
1433 PrfQueryProfileData(fmprof, appname, "ForceUpper", &fForceUpper, &size);
1434 size = sizeof(BOOL);
1435 PrfQueryProfileData(fmprof, appname, "ForceLower", &fForceLower, &size);
1436 size = sizeof(BOOL);
1437 PrfQueryProfileData(fmprof, FM3Str, "TextTools", &fTextTools, &size);
1438 size = sizeof(BOOL);
1439 PrfQueryProfileData(fmprof, FM3Str, "ToolTitles", &fToolTitles, &size);
1440 size = sizeof(BOOL);
1441 PrfQueryProfileData(fmprof, appname, "DoubleClickOpens", &fDCOpens, &size);
1442 size = sizeof(BOOL);
1443 PrfQueryProfileData(fmprof, appname, "LinkSetsIcon", &fLinkSetsIcon, &size);
1444 size = sizeof(INT);
1445 PrfQueryProfileData(fmprof, appname, "Sort", &sortFlags, &size);
1446 size = sizeof(INT);
1447 PrfQueryProfileData(fmprof, appname, "TreeSort", &TreesortFlags, &size);
1448 size = sizeof(INT);
1449 PrfQueryProfileData(fmprof, appname, "CollectorSort", &CollectorsortFlags, &size);
1450 PrfQueryProfileString(fmprof, appname, "Targetdir", NULL, targetdir, sizeof(targetdir));
1451 if (!IsValidDir(targetdir))
1452 *targetdir = 0;
1453 PrfQueryProfileString(fmprof, appname, "ExtractPath", NULL, extractpath, sizeof(extractpath));
1454 size = sizeof(BOOL);
1455 PrfQueryProfileData(fmprof, FM3Str, "FileNamePathCnr", &fFileNameCnrPath, &size);
1456 PrfQueryProfileString(fmprof, appname, "Printer", "PRN", printer, sizeof(printer));
1457 PrfQueryProfileString(fmprof, appname, "DirCompare", NULL, dircompare, MaxComLineStrg);
1458 PrfQueryProfileString(fmprof, appname, "Viewer", NULL, viewer, MaxComLineStrg);
1459 PrfQueryProfileString(fmprof, appname, "Editor", NULL, editor, MaxComLineStrg);
1460 PrfQueryProfileString(fmprof, appname, "BinView", NULL, binview, MaxComLineStrg);
1461 PrfQueryProfileString(fmprof, appname, "BinEd", NULL, bined, MaxComLineStrg);
1462 PrfQueryProfileString(fmprof, appname, "Compare", NULL, compare, MaxComLineStrg);
1463 PrfQueryProfileString(fmprof, appname, "Virus", NULL, virus, MaxComLineStrg);
1464 size = sizeof(BOOL);
1465 PrfQueryProfileData(fmprof, appname, "FtpRunWPSDefault", &fFtpRunWPSDefault, &size);
1466 PrfQueryProfileString(fmprof, appname, "FTPRun", NULL, ftprun, MaxComLineStrg);
1467 if (!*ftprun)
1468 fFtpRunWPSDefault = TRUE;
1469 size = sizeof(BOOL);
1470 PrfQueryProfileData(fmprof, appname, "HttpRunWPSDefault", &fHttpRunWPSDefault, &size);
1471 PrfQueryProfileString(fmprof, appname, "HTTPRun", NULL, httprun, MaxComLineStrg);
1472 if (!*httprun)
1473 fHttpRunWPSDefault = TRUE;
1474 PrfQueryProfileString(fmprof, appname, "MailRun", NULL, mailrun, MaxComLineStrg);
1475 PrfQueryProfileString(fmprof, appname, "FtpRunDir", NULL, ftprundir, sizeof(ftprundir));
1476 PrfQueryProfileString(fmprof, appname, "HttpRunDir", NULL, httprundir, sizeof(httprundir));
1477 PrfQueryProfileString(fmprof, appname, "MailRunDir", NULL, mailrundir, sizeof(mailrundir));
1478 PrfQueryProfileString(fmprof, appname, "LastToolbar", NULL, lasttoolbar, sizeof(lasttoolbar));
1479 size = sizeof(BOOL);
1480 PrfQueryProfileData(fmprof, appname, "LibPathStrictHttpRun", &fLibPathStrictHttpRun, &size);
1481 size = sizeof(BOOL);
1482 PrfQueryProfileData(fmprof, appname, "LibPathStrictFtpRun", &fLibPathStrictFtpRun, &size);
1483 size = sizeof(BOOL);
1484 PrfQueryProfileData(fmprof, appname, "LibPathStrictMailRun", &fLibPathStrictMailRun, &size);
1485 size = sizeof(BOOL);
1486 PrfQueryProfileData(fmprof, appname, "NoMailtoMailRun", &fNoMailtoMailRun, &size);
1487 size = sizeof(BOOL);
1488 PrfQueryProfileData(fmprof, appname, "FollowTree", &fFollowTree, &size);
1489 size = sizeof(BOOL);
1490 PrfQueryProfileData(fmprof, appname, "StartMaximized", &fStartMaximized, &size);
1491 if (!fStartMaximized) {
1492 size = sizeof(BOOL);
1493 PrfQueryProfileData(fmprof, appname, "StartMinimized", &fStartMinimized, &size);
1494 }
1495 size = sizeof(BOOL);
1496 PrfQueryProfileData(fmprof, appname, "DefaultCopy", &fCopyDefault, &size);
1497 size = sizeof(BOOL);
1498 PrfQueryProfileData(fmprof, appname, "IdleCopy", &fRealIdle, &size);
1499 size = sizeof(BOOL);
1500 PrfQueryProfileData(fmprof, appname, "ArcStuffVisible", &fArcStuffVisible, &size);
1501 size = sizeof(BOOL);
1502 PrfQueryProfileData(fmprof, FM3Str, "NoTreeGap", &fNoTreeGap, &size);
1503 size = sizeof(BOOL);
1504 PrfQueryProfileData(fmprof, FM3Str, "VTreeOpensWPS", &fVTreeOpensWPS, &size);
1505 size = sizeof(BOOL);
1506 PrfQueryProfileData(fmprof, appname, "RemoteBug", &fRemoteBug, &size);
1507 size = sizeof(BOOL);
1508 PrfQueryProfileData(fmprof, appname, "RScanLocal", &fRScanLocal, &size);
1509 size = sizeof(BOOL);
1510 PrfQueryProfileData(fmprof, appname, "RScanRemote", &fRScanRemote, &size);
1511 size = sizeof(BOOL);
1512 PrfQueryProfileData(fmprof, appname, "RScanVirtual", &fRScanVirtual, &size);
1513 size = sizeof(BOOL);
1514 PrfQueryProfileData(fmprof, appname, "RScanSlow", &fRScanSlow, &size);
1515 size = sizeof(BOOL);
1516 PrfQueryProfileData(fmprof, appname, "RScanNoWrite", &fRScanNoWrite, &size);
1517 size = sizeof(BOOL);
1518 PrfQueryProfileData(fmprof, appname, "EjectRemovableScan", &fEjectRemovableScan, &size);
1519 size = sizeof(BOOL);
1520 PrfQueryProfileData(fmprof, appname, "EjectCDScan", &fEjectCDScan, &size);
1521 size = sizeof(BOOL);
1522 PrfQueryProfileData(fmprof, appname, "EjectFlpyScan", &fEjectFlpyScan, &size);
1523 size = sizeof(BOOL);
1524 PrfQueryProfileData(fmprof, appname, "Drag&DropDlg", &fDragndropDlg, &size);
1525 size = sizeof(BOOL);
1526 PrfQueryProfileData(fmprof, FM3Str, "UserComboBox", &fUserComboBox, &size);
1527 size = sizeof(BOOL);
1528 PrfQueryProfileData(fmprof, FM3Str, "MinDirOnOpen", &fMinOnOpen, &size);
1529 size = sizeof(BOOL);
1530 PrfQueryProfileData(fmprof, appname, "QuickArcFind", &fQuickArcFind, &size);
1531 size = sizeof(BOOL);
1532 PrfQueryProfileData(fmprof, FM3Str, "NoRemovableScan", &fNoRemovableScan, &size);
1533 size = sizeof(ULONG);
1534 PrfQueryProfileData(fmprof, FM3Str, "NoBrokenNotify", &NoBrokenNotify, &size);
1535 size = sizeof(ULONG);
1536 PrfQueryProfileData(fmprof, appname, "ContainerType", &ulCnrType, &size);
1537 size = sizeof(ULONG);
1538 PrfQueryProfileData(fmprof, appname, "FilesToGet", &FilesToGet, &size);
1539 if (FilesToGet < FILESTOGET_MIN)
1540 FilesToGet = FILESTOGET_MIN;
1541 else if (FilesToGet > FILESTOGET_MAX)
1542 FilesToGet = FILESTOGET_MAX;
1543 size = sizeof(BOOL);
1544 PrfQueryProfileData(fmprof, FM3Str, "AutoView", &fAutoView, &size);
1545 size = sizeof(BOOL);
1546 PrfQueryProfileData(fmprof, FM3Str, "FM2Deletes", &fFM2Deletes, &size);
1547 size = sizeof(BOOL);
1548 PrfQueryProfileData(fmprof, FM3Str, "TrashCan", &fTrashCan, &size);
1549
1550 LoadDetailsSwitches(PCSZ_DIRCNR, &dsDirCnrDefault, FALSE);
1551
1552 /* load pointers and icons we use */
1553 hptrArrow = WinQuerySysPointer(HWND_DESKTOP, SPTR_ARROW, FALSE);
1554 hptrBusy = WinQuerySysPointer(HWND_DESKTOP, SPTR_WAIT, FALSE);
1555 hptrNS = WinQuerySysPointer(HWND_DESKTOP, SPTR_SIZENS, FALSE);
1556 hptrEW = WinQuerySysPointer(HWND_DESKTOP, SPTR_SIZEWE, FALSE);
1557 hptrFloppy = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, FLOPPY_ICON);
1558 hptrDrive = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, DRIVE_ICON);
1559 hptrRemovable = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, REMOVABLE_ICON);
1560 hptrCDROM = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, CDROM_ICON);
1561 hptrFile = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, FILE_ICON);
1562 hptrDir = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, DIR_FRAME);
1563 hptrArc = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, ARC_FRAME);
1564 hptrArt = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, ART_ICON);
1565 hptrSystem = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, FILE_SYSTEM_ICON);
1566 hptrHidden = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, FILE_HIDDEN_ICON);
1567 hptrReadonly = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, FILE_READONLY_ICON);
1568 hptrLast = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, LASTITEM_ICON);
1569 hptrRemote = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, REMOTE_ICON);
1570 hptrVirtual = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, VIRTUAL_ICON);
1571 hptrRamdisk = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, RAMDISK_ICON);
1572 if (!fNoDead)
1573 hptrFinger = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, FINGER_ICON);
1574 else
1575 hptrFinger = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, FINGER2_ICON);
1576 hptrApp = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, APP_ICON);
1577 hptrDunno = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, DUNNO_ICON);
1578 hptrEnv = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, ENV_ICON);
1579 hptrZipstrm = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, ZIPSTREAM_ICON);
1580
1581 // set up color array used by seeall.c and newview.c color dialog
1582
1583 standardcolors[0] = CLR_WHITE;
1584 standardcolors[1] = CLR_BLACK;
1585 standardcolors[2] = CLR_BLUE;
1586 standardcolors[3] = CLR_RED;
1587 standardcolors[4] = CLR_PINK;
1588 standardcolors[5] = CLR_GREEN;
1589 standardcolors[6] = CLR_CYAN;
1590 standardcolors[7] = CLR_YELLOW;
1591 standardcolors[8] = CLR_DARKGRAY;
1592 standardcolors[9] = CLR_DARKBLUE;
1593 standardcolors[10] = CLR_DARKRED;
1594 standardcolors[11] = CLR_DARKPINK;
1595 standardcolors[12] = CLR_DARKGREEN;
1596 standardcolors[13] = CLR_DARKCYAN;
1597 standardcolors[14] = CLR_BROWN;
1598 standardcolors[15] = CLR_PALEGRAY;
1599
1600 return TRUE;
1601}
1602
1603HWND StartFM3(HAB hab, INT argc, CHAR ** argv)
1604{
1605 HWND hwndFrame;
1606 HWND hwndClient;
1607 UINT x;
1608 ULONG FrameFlags = FCF_TITLEBAR | FCF_SYSMENU |
1609 FCF_SIZEBORDER | FCF_MINMAX |
1610 FCF_ACCELTABLE | FCF_MENU | FCF_ICON | FCF_TASKLIST | FCF_NOBYTEALIGN;
1611
1612 for (x = 1; x < argc; x++) {
1613 if (*argv[x] == '~' && !argv[x][1])
1614 fReminimize = TRUE;
1615 if (*argv[x] == '+' && !argv[x][1])
1616 fLogFile = TRUE;
1617 if (*argv[x] == '-') {
1618 if (!argv[x][1])
1619 fNoSaveState = TRUE;
1620 else
1621 strcpy(profile, &argv[x][1]);
1622 }
1623 }
1624
1625 hwndFrame = WinCreateStdWindow(HWND_DESKTOP,
1626 WS_VISIBLE,
1627 &FrameFlags,
1628 WC_MAINWND,
1629 NULL,
1630 WS_VISIBLE | WS_ANIMATE,
1631 FM3ModHandle, MAIN_FRAME, &hwndClient);
1632 if (hwndFrame) {
1633 WinSetWindowUShort(hwndFrame, QWS_ID, MAIN_FRAME);
1634 hwndMainMenu = WinWindowFromID(hwndFrame, FID_MENU);
1635 if (!WinRestoreWindowPos(FM2Str, "MainWindowPos", hwndFrame)) {
1636
1637 ULONG fl = SWP_MOVE | SWP_SIZE;
1638 RECTL rcl;
1639 ULONG icz = WinQuerySysValue(HWND_DESKTOP, SV_CYICON) * 3L;
1640 ULONG bsz = WinQuerySysValue(HWND_DESKTOP, SV_CYSIZEBORDER);
1641
1642 WinQueryWindowRect(HWND_DESKTOP, &rcl);
1643 rcl.yBottom += icz;
1644 rcl.yTop -= bsz;
1645 rcl.xLeft += bsz;
1646 rcl.xRight -= bsz;
1647 WinSetWindowPos(hwndFrame,
1648 HWND_TOP,
1649 rcl.xLeft,
1650 rcl.yBottom,
1651 rcl.xRight - rcl.xLeft, rcl.yTop - rcl.yBottom, fl);
1652 }
1653 if (fLogFile)
1654 LogFileHandle = _fsopen("FM2.LOG", "a+", SH_DENYWR);
1655 if (hwndHelp)
1656 WinAssociateHelpInstance(hwndHelp, hwndFrame);
1657 PostMsg(hwndClient, UM_SETUP, MPFROMLONG(argc), MPFROMP(argv));
1658 }
1659 return hwndFrame;
1660}
1661
1662BOOL CheckFileHeader(CHAR *filespec, CHAR *signature, LONG offset)
1663{
1664 HFILE handle;
1665 ULONG action;
1666 ULONG len = strlen(signature);
1667 ULONG l;
1668 CHAR buffer[4096]; // 06 Oct 07 SHL Protect against NTFS defect
1669 BOOL ret = FALSE;
1670
1671 DosError(FERR_DISABLEHARDERR);
1672 if (DosOpen(filespec,
1673 &handle,
1674 &action,
1675 0,
1676 0,
1677 OPEN_ACTION_FAIL_IF_NEW |
1678 OPEN_ACTION_OPEN_IF_EXISTS,
1679 OPEN_FLAGS_FAIL_ON_ERROR |
1680 OPEN_FLAGS_NOINHERIT |
1681 OPEN_FLAGS_RANDOMSEQUENTIAL |
1682 OPEN_SHARE_DENYNONE | OPEN_ACCESS_READONLY, 0))
1683 ret = FALSE;
1684 else {
1685 // Try signature match
1686 l = len;
1687 l = min(l, 79);
1688 if (!DosChgFilePtr(handle,
1689 abs(offset),
1690 (offset >= 0) ?
1691 FILE_BEGIN : FILE_END, &len)) {
1692 if (!DosRead(handle, buffer, l, &len) && len == l) {
1693 if (!memcmp(signature, buffer, l))
1694 ret = TRUE; // Matched
1695 }
1696 }
1697 }
1698 DosClose(handle); /* Either way, we're done for now */
1699 return ret; /* Return TRUE if matched */
1700}
1701
1702int CheckVersion(int vermajor, int verminor)
1703{
1704 int ok = 0;
1705
1706 // fixme to do useful check - was missing in base source
1707
1708#if 0
1709 if (vermajor && verminor) {
1710 *vermajor = VERMAJOR;
1711 *verminor = VERMINOR;
1712 ok = 1;
1713 }
1714#endif
1715
1716 ok = 1;
1717
1718 return ok;
1719}
1720
1721#ifdef __WATCOMC__
1722#pragma alloc_text(INIT,LibMain,InitFM3DLL,DeInitFM3DLL)
1723#pragma alloc_text(INIT1,StartFM3,FindSwapperDat)
1724#endif
Note: See TracBrowser for help on using the repository browser.