source: trunk/dll/init.c@ 1846

Last change on this file since 1846 was 1846, checked in by John Small, 10 years ago

Ticket #524: Ensure no "highmem-unsafe" functions are called directly
Calls to unsafe Dos... functions have been changed to call the wrapped xDos... functions.

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