source: trunk/dll/init.c@ 1856

Last change on this file since 1856 was 1856, checked in by Steven Levine, 10 years ago

Rework Flesh/Stubby etc. to avoid running on thread 1
Should be ready for release after spurious traps resolved
DbgMsg calls retained - delete/disable before release

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