source: trunk/dll/init.c@ 1858

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

Rework FlestWaitForWorkListEmpty to support wait for parents of path
Clean up some obsolete code

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 66.7 KB
Line 
1
2/***********************************************************************
3
4 $Id: init.c 1858 2015-08-20 05:31:14Z 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 19 Aug 15 SHL Delete obsoletes
138
139***********************************************************************/
140
141#include <stdlib.h>
142#include <string.h>
143#include <share.h>
144#include <process.h> // getpid
145#include <time.h>
146#include <ctype.h>
147
148#define INCL_DOS
149#define INCL_WIN
150#define INCL_MMIOOS2
151#define INCL_GPI
152#define INCL_DOSERRORS
153#define INCL_LONGLONG
154#define INCL_DOSNLS
155#include <os2.h>
156#include <os2me.h>
157
158#define DEFINE_GLOBALS 1
159
160#include "fm3dll.h"
161#include "fm3dll2.h" // #define's for UM_*, control id's, etc.
162#include "init.h"
163#include "mkdir.h" // Data declaration(s)
164#include "dircnrs.h" // Data declaration(s)
165#include "comp.h" // Data declaration(s)
166#include "cmdline.h" // Data declaration(s)
167#include "fm2cmd.h" // Data declaration(s)
168#include "printer.h" // Data declaration(s)
169#include "flesh.h" // Data declaration(s)
170#include "worker.h" // Data declaration(s)
171#include "filldir.h" // Data declaration(s)
172#include "defview.h" // Data declaration(s)
173#include "draglist.h" // Data declaration(s)
174#include "fm3dlg.h"
175#include "datamin.h"
176#include "tools.h"
177#include "fm3str.h"
178#include "version.h"
179#include "pathutil.h" // BldFullPathName
180#include "arccnrs.h" // ArcClientWndProc
181#include "errutil.h" // Dos_Error...
182#include "strutil.h" // GetPString
183#include "valid.h" // ArgDriveFlags
184#include "autoview.h" // AutoViewProc
185#include "mainwnd.h" // BubbleProc, ChildButtonProc, DriveBackProc,
186 // DriveProc, LEDProc, MainWndProc, StatusProc
187 // ToolBackProc
188#include "collect.h" // CollectorClientWndProc, CollectorTextProc
189#include "getnames.h" // CustomFileDlg
190#include "notify.h" // EndNote
191#include "valid.h" // FillInDriveFlags, IsValidDir
192#include "inis.h" // IniProc
193#include "viewer.h" // MLEEditorProc
194#include "mainwnd2.h" // MainWndProc2
195#include "notify.h" // NotifyWndProc
196#include "treecnr.h" // OpenButtonProc
197#include "seeall.h" // SeeAllWndProc, SeeStatusProc
198#include "timer.h" // StartTimer, StopTimer
199#include "treecnr.h" // TreeClientWndProc, TreeStatProc
200#include "newview.h" // ViewStatusProc, ViewWndProc
201#include "subj.h" // Subject
202#include "select.h" // UnHilite
203#include "dirs.h" // save_dir
204#include "copyf.h" // unlinkf
205#include "wrappers.h" // xDosSetPathInfo
206#include "misc.h" // HeapThread, LoadDetailsSwitches
207#include "notebook.h" // command line variables (editor etc)
208#include "strips.h" // bstrip
209#include "killproc.h" // GetDosPgmName
210#include "srchpath.h" // Search*Path*ForFile
211#include "fortify.h"
212#include "excputil.h" // xbeginthread
213#include "systemf.h" // runemf2
214
215#if 0
216#define __PMPRINTF__
217#include "PMPRINTF.H"
218#endif
219
220extern int _CRT_init(void);
221extern void _CRT_term(void);
222
223#ifdef __WATCOMC__
224#define a(x) #x
225#define b(x) a(x)
226// Must be global to prevent warnings
227PSZ pszBuiltWith = "Built with OpenWatcom version " b(__WATCOMC__);
228#undef b
229#undef a
230#endif
231
232static VOID FindSwapperDat(VOID);
233
234// Data definitions
235static PSZ pszSrcFile = __FILE__;
236unsigned __MaxThreads = {48};
237
238#pragma data_seg(GLOBAL1)
239HMTX hmtxFM2Delete;
240HMTX hmtxFM2Globals;
241
242HMTX hmtxFiltering;
243
244ULONG OS2ver[2];
245PFNWP PFNWPCnr;
246PFNWP PFNWPMLE;
247CHAR ThousandsSeparator[2];
248CHAR DateSeparator[2];
249CHAR TimeSeparator[2];
250ULONG ulTimeFmt;
251ULONG ulDateFmt;
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
742#if 0
743 PmPrintfDisplayInterfaceVersionInfo();
744 PmPrintfQueueNameThisProcess(NULL);
745#endif
746
747 if (!*profile)
748 strcpy(profile, PCSZ_FM3DOTINI);
749 mypid = getpid();
750 // give default appname if none set by caller
751 if (!*appname)
752 strcpy(appname, FM3Str);
753 // save appname; may be reset below
754 strcpy(realappname, appname);
755 if (!strcmp(appname, FM3Str))
756 DosSetMaxFH(100);
757 else if (!strcmp(appname, "VDir") ||
758 !strcmp(appname, "VTree") ||
759 !strcmp(appname, "VCollect") ||
760 !strcmp(appname, "SEEALL") || !strcmp(appname, "FM/4"))
761 DosSetMaxFH(60);
762 else
763 DosSetMaxFH(40);
764
765 if (DosQuerySysInfo(QSV_VERSION_MAJOR,
766 QSV_VERSION_MINOR,
767 OS2ver,
768 sizeof(OS2ver))) {
769 OS2ver[0] = 2;
770 OS2ver[1] = 1;
771 }
772
773 // Save the FM2 save directory name. This is the location of the ini, dat files etc.
774 rc = save_dir2(temp);
775 if (rc) {
776 saymsg(MB_CANCEL | MB_ICONEXCLAMATION,
777 HWND_DESKTOP,
778 GetPString(IDS_ERRORTEXT), GetPString(IDS_FM3SAVEDIRERROR1TEXT));
779 return FALSE;
780 }
781 pFM2SaveDirectory = xstrdup(temp, pszSrcFile, __LINE__);
782 if (!pFM2SaveDirectory)
783 return FALSE; // already complained
784 // set up default root names for temp file storage and archive goodies
785 env = getenv("TEMP");
786 if (env != NULL) {
787 rc = 0;
788 DosError(FERR_DISABLEHARDERR);
789 rc = DosQueryPathInfo(env, FIL_STANDARD, &fs3, sizeof(fs3));
790 }
791 if (rc || env == NULL)
792 env = getenv("TMP");
793 if (env != NULL) {
794 DosError(FERR_DISABLEHARDERR);
795 rc = DosQueryPathInfo(env, FIL_STANDARD, &fs3, sizeof(fs3));
796 if (!rc) {
797 CHAR *enddir, szTempName[CCHMAXPATH];
798 FILEFINDBUF3 ffb;
799 HDIR search_handle;
800 ULONG num_matches, ul;
801
802 strcpy(szTempName, env);
803 AddBackslashToPath(szTempName);
804 enddir = &szTempName[strlen(szTempName)];
805 strcat(szTempName, "$FM2????.");
806 strcat(szTempName, "???");
807 search_handle = HDIR_CREATE;
808 num_matches = 1;
809 if (!DosFindFirst(szTempName,
810 &search_handle,
811 FILE_NORMAL | FILE_DIRECTORY |
812 FILE_SYSTEM | FILE_READONLY | FILE_HIDDEN |
813 FILE_ARCHIVED,
814 &ffb, sizeof(ffb), &num_matches, FIL_STANDARD)) {
815 do {
816 strcpy(enddir, ffb.achName);
817 p = strrchr(szTempName, '.');
818 if (p) {
819 p++;
820 ul = strtoul(p, NULL, 16);
821 GetDosPgmName(ul, temp);
822 if (!strstr(temp, "FM/2") &&
823 !strstr(temp, "AV/2")) {
824 wipeallf(TRUE, "%s\\*", szTempName);
825 DosDeleteDir(szTempName);
826 }
827 }
828 }
829 while (!DosFindNext(search_handle,
830 &ffb, sizeof(ffb), &num_matches));
831 DosFindClose(search_handle);
832 }
833 if (fs3.attrFile & FILE_DIRECTORY) {
834 strcpy(szTempName, env);
835 MakeTempName(szTempName, NULL, 1);
836 rc = DosCreateDir(szTempName, 0);
837 if (!rc)
838 pTmpDir = xstrdup(szTempName, pszSrcFile, __LINE__); // if writable
839 else
840 pTmpDir = xstrdup(pFM2SaveDirectory, pszSrcFile, __LINE__);
841 }
842 }
843 }
844 else
845 pTmpDir = xstrdup(pFM2SaveDirectory, pszSrcFile, __LINE__);
846 // Check free space on TMP and FM2 Save drives
847 {
848 if (pTmpDir && CheckDriveSpaceAvail(pTmpDir, ullTmpSpaceNeeded, 0) == 1) {
849 if (CheckDriveSpaceAvail(pFM2SaveDirectory, ullTmpSpaceNeeded, 0) == 0){
850 ret = saymsg(MB_YESNO,
851 HWND_DESKTOP,
852 NullStr,
853 GetPString(IDS_TMPDRIVESPACELIMITED),
854 pTmpDir);
855 if (ret == MBID_YES)
856 pTmpDir = pFM2SaveDirectory;
857 }
858 else
859 saymsg(MB_OK,
860 HWND_DESKTOP,
861 NullStr,
862 GetPString(IDS_SAVETMPDRIVESPACELIMITED),
863 pTmpDir,
864 pFM2SaveDirectory);
865 }
866 else if (CheckDriveSpaceAvail(pFM2SaveDirectory, ullTmpSpaceNeeded, 0) == 1)
867 saymsg(MB_OK,
868 HWND_DESKTOP,
869 NullStr,
870 GetPString(IDS_SAVEDRIVESPACELIMITED),
871 pFM2SaveDirectory);
872 }
873 BldFullPathName(ArcTempRoot, pTmpDir, fAmAV2 ? "$AV$ARC$" : "$FM$ARC$");
874
875 // initialize random number generator
876 srand(time(NULL) + clock());
877
878 priority_bumped();
879
880 // _heapmin() is done in a separate thread -- start it
881 if (xbeginthread(HeapThread,
882 32768,
883 MPVOID,
884 pszSrcFile,
885 __LINE__) == -1) {
886 return FALSE;
887 }
888
889 if (!StartFleshWorkThread())
890 return FALSE;
891
892 // timer messages are sent from a separate thread -- start it
893 if (!StartTimer()) {
894 Runtime_Error(pszSrcFile, __LINE__,
895 GetPString(IDS_COULDNTSTARTTHREADTEXT));
896 return FALSE;
897 }
898
899 // Are we the workplace shell?
900 env = getenv("WORKPLACE_PROCESS");
901 fWorkPlace = env != NULL &&
902 (stricmp(env, "YES") == 0 || atoi(env) == 1);
903
904 if ((!strchr(profile, '\\') && !strchr(profile, ':')) ||
905 !(fmprof = PrfOpenProfile((HAB)0, profile))) {
906 // figure out where to put INI file...
907 CHAR inipath[CCHMAXPATH];
908
909 DosError(FERR_DISABLEHARDERR);
910 strcpy(HomePath, pFM2SaveDirectory);
911 DosError(FERR_DISABLEHARDERR);
912 memset(driveserial, -1, sizeof(driveserial));
913 *inipath = 0;
914 env = getenv(PCSZ_FM3INI);
915 if (env) {
916 strcpy(inipath, env);
917 DosError(FERR_DISABLEHARDERR);
918 rc = DosQueryPathInfo(inipath, FIL_STANDARD, &fs3, sizeof(fs3));
919 if (!rc) {
920 if (fs3.attrFile & FILE_DIRECTORY)
921 BldFullPathName(inipath, inipath, profile);
922 }
923 }
924 else {
925 CHAR szFullFilename[CCHMAXPATH];
926 if (!SearchMultiplePathsForFile(profile, szFullFilename)) {
927 strcpy(inipath, szFullFilename);
928 } else {
929 strcpy(inipath, profile);
930 }
931 } //fixme the DosCopies probably fail if the INI isn't in the FM2 directory GKY 06 Aug 11
932 if (!*inipath)
933 strcpy(inipath, profile);
934 DosError(FERR_DISABLEHARDERR);
935 rc = DosQueryPathInfo(inipath, FIL_STANDARD, &fs3, sizeof(fs3));
936 if (rc) {
937 if (rc == ERROR_FILE_NOT_FOUND) {
938 DosCopy(PCSZ_FM3INIDOTBAK, PCSZ_FM3DOTINI, 0);
939 }
940 rc = DosQueryPathInfo(inipath, FIL_STANDARD, &fs3, sizeof(fs3));
941 if (rc)
942 fWantFirstTimeInit = TRUE;
943 }
944 if (!fWantFirstTimeInit) { //Check the ini file header and restore from backup if corupted
945 if (!CheckFileHeader(inipath, "\xff\xff\xff\xff\x14\x00\x00\x00", 0L)) {
946 saymsg(MB_ENTER,HWND_DESKTOP, GetPString(IDS_DEBUG_STRING),
947 GetPString(IDS_INIFAILURETEXT));
948 DosCopy(PCSZ_FM3DOTINI, PCSZ_FM3INIDOTBAD, DCPY_EXISTING);
949 DosCopy(PCSZ_FM3INIDOTBAK, PCSZ_FM3DOTINI, DCPY_EXISTING);
950 if (!CheckFileHeader(inipath, "\xff\xff\xff\xff\x14\x00\x00\x00", 0L)) {
951 DosCopy(PCSZ_FM3DOTINI, PCSZ_FM3INIDOTBAD2, DCPY_EXISTING);
952 fWantFirstTimeInit = TRUE;
953 }
954 }
955 }
956 // in some odd cases the INI file can get set to readonly status
957 // here we test it and reset the readonly bit if necessary
958 if (!fWantFirstTimeInit) {
959 fIniExisted = TRUE;
960 if (fs3.attrFile & (FILE_READONLY | FILE_HIDDEN | FILE_SYSTEM)) {
961 fs3.attrFile &= ~(FILE_READONLY | FILE_HIDDEN | FILE_SYSTEM);
962 rc = xDosSetPathInfo(inipath, FIL_STANDARD, &fs3, sizeof(fs3), 0);
963 if (rc) {
964 Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
965 GetPString(IDS_INIREADONLYTEXT), inipath);
966 }
967 }
968 }
969 fmprof = PrfOpenProfile((HAB)0, inipath);
970 if (!fmprof) {
971 strcpy(inipath, PCSZ_FM3DOTINI);
972 fmprof = PrfOpenProfile((HAB)0, inipath);
973 }
974
975 // 10 Jan 08 SHL fixme to do first time if new ini
976 // 10 Jan 08 SHL post UM_FIRSTTIME to main window
977 if (!fmprof) {
978 Win_Error(NULLHANDLE, NULLHANDLE, pszSrcFile, __LINE__,
979 PCSZ_PRFOPENPROFILEFAILED, inipath);
980 return FALSE;
981 }
982 }
983
984 ArgDriveFlags(argc, argv);
985 FillInDriveFlags(NULL);
986
987 FindSwapperDat();
988
989 // start help
990 memset(&hini, 0, sizeof(HELPINIT));
991 hini.cb = sizeof(HELPINIT);
992 hini.phtHelpTable = (PHELPTABLE) MAKELONG(ID_HELPTABLE, 0xffff);
993 hini.hmodAccelActionBarModule = (HMODULE) 0;
994 hini.pszHelpWindowTitle = (PSZ)GetPString(IDS_FM2HELPTITLETEXT);
995 hini.hmodHelpTableModule = FM3ModHandle;
996 hini.fShowPanelId = CMIC_HIDE_PANEL_ID;
997 hini.pszHelpLibraryName = (CHAR *) PCSZ_FM3DOTHLP;
998 hwndHelp = WinCreateHelpInstance(hab, &hini);
999 if (!hwndHelp) {
1000 CHAR helppath[CCHMAXPATH];
1001 env = getenv(PCSZ_FM3INI);
1002 if (env) {
1003 strcpy(helppath, env);
1004 DosError(FERR_DISABLEHARDERR);
1005 rc = DosQueryPathInfo(helppath, FIL_STANDARD, &fs3, sizeof(fs3));
1006 if (!rc) {
1007 if (fs3.attrFile & FILE_DIRECTORY) {
1008 BldFullPathName(helppath, helppath, PCSZ_FM3DOTHLP);
1009 hini.pszHelpLibraryName = helppath;
1010 hwndHelp = WinCreateHelpInstance(hab, &hini);
1011 if (!hwndHelp)
1012 Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__,
1013 "WinCreateHelpInstance failed for %s with error 0x%x",
1014 hini.pszHelpLibraryName, hini.ulReturnCode);
1015 }
1016 }
1017 }
1018 }
1019 if (!hwndHelp) {
1020 saymsg(MB_ENTER | MB_ICONEXCLAMATION,
1021 HWND_DESKTOP,
1022 GetPString(IDS_FM2TROUBLETEXT),
1023 GetPString(IDS_CANTLOADHELPTEXT),
1024 GetPString(IDS_NOHELPACCEPTTEXT));
1025 }
1026
1027 // a couple of default window procs so we don't have to look them up later
1028 if (WinQueryClassInfo(hab, WC_CONTAINER, &clinfo))
1029 PFNWPCnr = clinfo.pfnWindowProc;
1030 if (WinQueryClassInfo(hab, WC_FRAME, &clinfo))
1031 PFNWPFrame = clinfo.pfnWindowProc;
1032 if (WinQueryClassInfo(hab, WC_BUTTON, &clinfo))
1033 PFNWPButton = clinfo.pfnWindowProc;
1034 if (WinQueryClassInfo(hab, WC_STATIC, &clinfo))
1035 PFNWPStatic = clinfo.pfnWindowProc;
1036 if (WinQueryClassInfo(hab, WC_MLE, &clinfo))
1037 PFNWPMLE = clinfo.pfnWindowProc;
1038 if (!PFNWPCnr || !PFNWPFrame || !PFNWPButton || !PFNWPStatic || !PFNWPMLE) {
1039 Runtime_Error(pszSrcFile, __LINE__, "WinQueryClassInfo");
1040 return FALSE;
1041 }
1042
1043 // register window classes we use
1044 WinRegisterClass(hab,
1045 (CHAR *) WC_MAINWND,
1046 MainWndProc,
1047 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 8);
1048 WinRegisterClass(hab,
1049 (CHAR *) WC_MAINWND2,
1050 MainWndProc2,
1051 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 4);
1052 WinRegisterClass(hab,
1053 (CHAR *) WC_TREECONTAINER,
1054 TreeClientWndProc,
1055 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 2);
1056 WinRegisterClass(hab,
1057 (CHAR *) WC_DIRCONTAINER,
1058 DirClientWndProc,
1059 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 2);
1060 WinRegisterClass(hab,
1061 (CHAR *) WC_COLLECTOR,
1062 CollectorClientWndProc,
1063 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 2);
1064 WinRegisterClass(hab,
1065 (CHAR *) WC_ARCCONTAINER,
1066 ArcClientWndProc,
1067 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 2);
1068 WinRegisterClass(hab,
1069 (CHAR *) WC_MLEEDITOR,
1070 MLEEditorProc,
1071 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 2);
1072 WinRegisterClass(hab,
1073 (CHAR *) WC_INIEDITOR,
1074 IniProc,
1075 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 2);
1076 WinRegisterClass(hab,
1077 (CHAR *) WC_TOOLBACK,
1078 ToolBackProc,
1079 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
1080 sizeof(PVOID));
1081 WinRegisterClass(hab,
1082 (CHAR *) WC_DRIVEBACK,
1083 DriveBackProc,
1084 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
1085 sizeof(PVOID));
1086 WinRegisterClass(hab,
1087 (CHAR *) WC_SEEALL,
1088 SeeAllWndProc,
1089 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID));
1090 WinRegisterClass(hab,
1091 (CHAR *) WC_NEWVIEW,
1092 ViewWndProc,
1093 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID));
1094 WinRegisterClass(hab,
1095 (CHAR *) WC_TOOLBUTTONS,
1096 ChildButtonProc,
1097 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
1098 sizeof(PVOID));
1099 WinRegisterClass(hab,
1100 (CHAR *) WC_DRIVEBUTTONS,
1101 DriveProc,
1102 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
1103 sizeof(PVOID));
1104 WinRegisterClass(hab,
1105 (CHAR *) WC_BUBBLE,
1106 BubbleProc,
1107 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
1108 sizeof(ULONG) * 2);
1109 WinRegisterClass(hab,
1110 (CHAR *) WC_STATUS,
1111 StatusProc,
1112 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
1113 sizeof(ULONG));
1114 WinRegisterClass(hab,
1115 (CHAR *) WC_DIRSTATUS,
1116 DirTextProc,
1117 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
1118 sizeof(ULONG));
1119 WinRegisterClass(hab,
1120 (CHAR *) WC_TREESTATUS,
1121 TreeStatProc,
1122 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
1123 sizeof(ULONG));
1124 WinRegisterClass(hab,
1125 (CHAR *) WC_ARCSTATUS,
1126 ArcTextProc,
1127 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
1128 sizeof(ULONG));
1129 WinRegisterClass(hab,
1130 (CHAR *) WC_COLSTATUS,
1131 CollectorTextProc,
1132 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
1133 sizeof(ULONG));
1134 WinRegisterClass(hab,
1135 (CHAR *) WC_SEESTATUS,
1136 SeeStatusProc,
1137 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
1138 sizeof(ULONG));
1139 WinRegisterClass(hab,
1140 (CHAR *) WC_VIEWSTATUS,
1141 ViewStatusProc,
1142 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
1143 sizeof(ULONG));
1144 WinRegisterClass(hab,
1145 (CHAR *) WC_ERRORWND,
1146 NotifyWndProc,
1147 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
1148 sizeof(PVOID));
1149 WinRegisterClass(hab,
1150 (CHAR *) WC_MINITIME,
1151 MiniTimeProc,
1152 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
1153 sizeof(PVOID) * 2);
1154 WinRegisterClass(hab,
1155 (CHAR *) WC_DATABAR,
1156 DataProc, CS_SIZEREDRAW, sizeof(PVOID));
1157 WinRegisterClass(hab,
1158 (CHAR *) WC_TREEOPENBUTTON,
1159 OpenButtonProc,
1160 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
1161 sizeof(PVOID));
1162 WinRegisterClass(hab,
1163 (CHAR *) WC_AUTOVIEW,
1164 AutoViewProc,
1165 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
1166 sizeof(PVOID));
1167 WinRegisterClass(hab,
1168 (CHAR *) WC_LED,
1169 LEDProc,
1170 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
1171 sizeof(PVOID));
1172
1173 rc = DosCreateMutexSem(NULL, &hmtxFM2Globals, 0L, FALSE);
1174 if (rc) {
1175 Dos_Error(MB_CANCEL, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
1176 PCSZ_DOSCREATEMUTEXSEM);
1177 }
1178 rc = DosCreateMutexSem(NULL, &hmtxFM2Delete, 0L, FALSE);
1179 if (rc) {
1180 Dos_Error(MB_CANCEL, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
1181 PCSZ_DOSCREATEMUTEXSEM);
1182 }
1183 rc = DosCreateMutexSem(NULL, &hmtxFiltering, 0L, FALSE);
1184 if (rc) {
1185 Dos_Error(MB_CANCEL, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
1186 PCSZ_DOSCREATEMUTEXSEM);
1187 }
1188
1189 /**
1190 * set some defaults (note: everything else automatically initialized
1191 * to 0)
1192 */
1193 dsDirCnrDefault.detailssize = dsDirCnrDefault.detailsea = dsDirCnrDefault.detailslwdate =
1194 dsDirCnrDefault.detailslwtime = dsDirCnrDefault.detailsattr = dsDirCnrDefault.detailsicon =
1195 fAutoTile = fConfirmDelete = fLoadSubject = fUnHilite =
1196 fLoadLongnames = fToolbar = fSaveState = fGuessType = fToolbarHelp =
1197 fAutoAddDirs = fUseNewViewer = fDataToFore = fDataShowDrives = fDataMin =
1198 fSplitStatus = fDragndropDlg = fQuickArcFind = fKeepCmdLine =
1199 fMoreButtons = fDrivebar = fCollapseFirst = fSwitchTreeOnDirChg =
1200 fSwitchTreeExpand = fNoSearch = fCustomFileDlg = fOtherHelp =
1201 fSaveMiniCmds = fUserComboBox = fFM2Deletes = fConfirmTarget =
1202 fShowTarget = fDrivebarHelp = fCheckMM = fInitialDriveScan =
1203 fEjectRemovableScan = fRScanLocal = TRUE;
1204 ulCnrType = CCS_EXTENDSEL;
1205 FilesToGet = FILESTOGET_MAX;
1206 MaxComLineStrg = MAXCOMLINESTRGDEFAULT;
1207 AutoviewHeight = 48;
1208 //strcpy(printer, "PRN");
1209 prnwidth = 80;
1210 prnlength = 66;
1211 prntmargin = 6;
1212 prnbmargin = 6;
1213 prnlmargin = 6;
1214 prnrmargin = 3;
1215 prnspacing = 1;
1216 prntabspaces = 8;
1217 CollectorsortFlags = sortFlags = SORT_FILENAME | SORT_DIRSFIRST;
1218 //ullDATFileSpaceNeeded = 10000;
1219
1220 //Get default Country info
1221 {
1222 COUNTRYCODE Country = {0};
1223 ULONG ulInfoLen = 0;
1224 COUNTRYINFO CtryInfo = {0};
1225
1226 if (!DosQueryCtryInfo(sizeof(CtryInfo), &Country, &CtryInfo, &ulInfoLen)) {
1227 *ThousandsSeparator = CtryInfo.szThousandsSeparator[0];
1228 strcpy(DateSeparator, CtryInfo.szDateSeparator);
1229 strcpy(TimeSeparator, CtryInfo.szTimeSeparator);
1230 ulDateFmt = CtryInfo.fsDateFmt;
1231 ulTimeFmt = CtryInfo.fsTimeFmt;
1232 //DbgMsg(pszSrcFile, __LINE__, "Date Fmt %x", ulDateFmt);
1233 }
1234 else {
1235 strcpy(ThousandsSeparator, ",");
1236 strcpy(DateSeparator, "/");
1237 strcpy(TimeSeparator, ":");
1238 ulDateFmt = 0;
1239 ulTimeFmt = 0;
1240 }
1241 }
1242 {
1243 // Check for the existance of various partitioning tools to set up menu items
1244 ULONG ulAppType;
1245
1246 if (!SearchPathForFile(PCSZ_PATH, PCSZ_LVMGUICMD, NULL))
1247 fLVMGui = TRUE;
1248 if (!xDosQueryAppType(PCSZ_DFSOS2EXE, &ulAppType))
1249 fDFSee = TRUE;
1250 if (!xDosQueryAppType(PCSZ_MINILVMEXE, &ulAppType))
1251 fMiniLVM = TRUE;
1252 if (!xDosQueryAppType(PCSZ_FDISKPMEXE, &ulAppType))
1253 fFDisk = TRUE;
1254 if (!xDosQueryAppType(PCSZ_LVMEXE, &ulAppType))
1255 fLVM = TRUE;
1256
1257 //Check for unlock.exe
1258 if (!xDosQueryAppType(PCSZ_UNLOCKEXE, &ulAppType))
1259 fUnlock = TRUE;
1260
1261 // Check to see if we are running protect only
1262 if (!xDosQueryAppType(GetCmdSpec(TRUE), &ulAppType)) {
1263 HMODULE hmod;
1264 APIRET rc;
1265
1266 rc = DosQueryModuleHandle("VKBD", &hmod);
1267 if (rc != NO_ERROR) {
1268 fProtectOnly = TRUE;
1269 //DbgMsg(pszSrcFile, __LINE__, "DosQModuleHandle VKBD returned %d fProtectOnly=%d", rc, fProtectOnly);
1270 }
1271 else {
1272 rc = DosQueryModuleHandle("VMOUSE", &hmod);
1273 if (rc != NO_ERROR) {
1274 fProtectOnly = TRUE;
1275 //DbgMsg(pszSrcFile, __LINE__, "DosQModuleHandle VMOUSE returned %d fProtectOnly=%d", rc, fProtectOnly);
1276 }
1277 }
1278 }
1279 else
1280 fProtectOnly = TRUE;
1281 }
1282
1283 // load preferences from profile (INI) file
1284 /**
1285 * Separate paramenters -- Please note that appname should be used in
1286 * profile calls for user settings that work and are setable in more than one
1287 * miniapp; FM3Str should be used for setting only relavent to FM/2 or that
1288 * aren't user settable; realappname should be used for setting applicable to
1289 * one or more miniapp but not to FM/2
1290 */
1291 size = sizeof(BOOL);
1292 PrfQueryProfileData(fmprof, realappname, "SeparateParms", &fAppSeparateSettings, &size);
1293 if (!fAppSeparateSettings)
1294 strcpy(appname, FM3Str);
1295 else
1296 strcpy(appname, realappname);
1297 size = sizeof(ULONG);
1298 PrfQueryProfileData(fmprof, appname, "MaxComLineStrg", &MaxComLineStrg, &size);
1299 // Give user one chance to reset the default command line length to 1024 (4os2's unexpanded max)
1300 if (MaxComLineStrg == 2048) {
1301 BOOL MaxComLineChecked = FALSE;
1302
1303 size = sizeof(BOOL);
1304 PrfQueryProfileData(fmprof, appname, "MaxComLineChecked", &MaxComLineChecked, &size);
1305 if (!MaxComLineChecked) {
1306 ret = saymsg(MB_YESNO,
1307 HWND_DESKTOP,
1308 NullStr,
1309 GetPString(IDS_CHANGECMDLINELENGTHDEFAULT));
1310 if (ret == MBID_YES)
1311 MaxComLineStrg = 1024;
1312 MaxComLineChecked = TRUE;
1313 PrfWriteProfileData(fmprof, appname, "MaxComLineChecked", &MaxComLineChecked, sizeof(BOOL));
1314 }
1315 }
1316 if (MaxComLineStrg < CMDLNLNGTH_MIN)
1317 MaxComLineStrg = CMDLNLNGTH_MIN;
1318 else if (MaxComLineStrg > CMDLNLNGTH_MAX)
1319 MaxComLineStrg = CMDLNLNGTH_MAX;
1320 editor = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
1321 if (!editor)
1322 return 0; //already complained
1323 viewer = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
1324 if (!viewer)
1325 return 0; //already complained
1326 virus = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
1327 if (!virus)
1328 return 0; //already complained
1329 compare = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
1330 if (!compare)
1331 return 0; //already complained
1332 binview = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
1333 if (!binview)
1334 return 0; //already complained
1335 bined = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
1336 if (!bined)
1337 return 0; //already complained
1338 dircompare = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
1339 if (!dircompare)
1340 return 0; //already complained
1341 ftprun = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
1342 if (!ftprun)
1343 return 0; //already complained
1344 httprun = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
1345 if (!httprun)
1346 return 0; //already complained
1347 mailrun = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
1348 if (!mailrun)
1349 return 0; //already complained
1350 pszTreeEnvVarList = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
1351 if (!pszTreeEnvVarList)
1352 return 0; //already complained
1353 size = sizeof(BOOL);
1354 PrfQueryProfileData(fmprof, FM3Str, "DontSuggestAgain", &fDontSuggestAgain, &size);
1355 size = sizeof(BOOL);
1356 PrfQueryProfileData(fmprof, appname, "ShowTarget", &fShowTarget, &size);
1357 size = sizeof(BOOL);
1358 PrfQueryProfileData(fmprof, appname, "CheckMM", &fCheckMM, &size);
1359 size = sizeof(BOOL);
1360 PrfQueryProfileData(fmprof, appname, "ChangeTarget", &fChangeTarget, &size);
1361 size = sizeof(BOOL);
1362 PrfQueryProfileData(fmprof, appname, "ConfirmTarget", &fConfirmTarget, &size);
1363 size = sizeof(BOOL);
1364 PrfQueryProfileData(fmprof, appname, "CustomFileDlg", &fCustomFileDlg, &size);
1365 size = sizeof(BOOL);
1366 PrfQueryProfileData(fmprof, appname, "SaveMiniCmds", &fSaveMiniCmds, &size);
1367 size = sizeof(BOOL);
1368 PrfQueryProfileData(fmprof, appname, "SaveBigCmds", &fSaveBigCmds, &size);
1369 size = sizeof(BOOL);
1370 PrfQueryProfileData(fmprof, appname, "NoFoldMenu", &fNoFoldMenu, &size);
1371 size = sizeof(BOOL);
1372 PrfQueryProfileData(fmprof, FM3Str, "Prnpagenums", &prnpagenums, &size);
1373 size = sizeof(BOOL);
1374 PrfQueryProfileData(fmprof, FM3Str, "Prnalt", &prnalt, &size);
1375 size = sizeof(BOOL);
1376 PrfQueryProfileData(fmprof, FM3Str, "Prnformat", &prnformat, &size);
1377 size = sizeof(BOOL);
1378 PrfQueryProfileData(fmprof, FM3Str, "Prnformfeedbefore", &prnformfeedbefore, &size);
1379 size = sizeof(BOOL);
1380 PrfQueryProfileData(fmprof, FM3Str, "Prnformfeedafter",&prnformfeedafter, &size);
1381 size = sizeof(ULONG);
1382 PrfQueryProfileData(fmprof, FM3Str, "Prntabspaces", &prntabspaces, &size);
1383 size = sizeof(ULONG);
1384 PrfQueryProfileData(fmprof, FM3Str, "Prnwidth", &prnwidth, &size);
1385 size = sizeof(ULONG);
1386 PrfQueryProfileData(fmprof, FM3Str, "Prnlength", &prnlength, &size);
1387 size = sizeof(ULONG);
1388 PrfQueryProfileData(fmprof, FM3Str, "Prntmargin", &prntmargin, &size);
1389 size = sizeof(ULONG);
1390 PrfQueryProfileData(fmprof, FM3Str, "Prnbmargin", &prnbmargin, &size);
1391 size = sizeof(ULONG);
1392 PrfQueryProfileData(fmprof, FM3Str, "Prnlmargin", &prnlmargin, &size);
1393 size = sizeof(ULONG);
1394 PrfQueryProfileData(fmprof, FM3Str, "Prnrmargin", &prnrmargin, &size);
1395 size = sizeof(ULONG);
1396 PrfQueryProfileData(fmprof, FM3Str, "Prnspacing", &prnspacing, &size);
1397 size = sizeof(BOOL);
1398 PrfQueryProfileData(fmprof, appname, "NoDead", &fNoDead, &size);
1399 size = sizeof(BOOL);
1400 PrfQueryProfileData(fmprof, appname, "NoFinger", &fNoFinger, &size);
1401 size = sizeof(BOOL);
1402 PrfQueryProfileData(fmprof, appname, "AlertBeepOff", &fAlertBeepOff, &size);
1403 size = sizeof(BOOL);
1404 PrfQueryProfileData(fmprof, appname, "ErrorBeepOff", &fErrorBeepOff, &size);
1405 size = sizeof(BOOL);
1406 PrfQueryProfileData(fmprof, appname, "SwitchTree", &fSwitchTreeOnDirChg, &size);
1407 size = sizeof(BOOL);
1408 PrfQueryProfileData(fmprof, appname, "SwitchTreeExpand", &fSwitchTreeExpand, &size);
1409 size = sizeof(BOOL);
1410 PrfQueryProfileData(fmprof, appname, "SwitchTreeOnFocus", &fSwitchTreeOnFocus, &size);
1411 size = sizeof(BOOL);
1412 PrfQueryProfileData(fmprof, appname, "CollapseFirst", &fCollapseFirst, &size);
1413 size = sizeof(BOOL);
1414 PrfQueryProfileData(fmprof, appname, "FilesInTree", &fFilesInTree, &size);
1415 size = sizeof(BOOL);
1416 PrfQueryProfileData(fmprof, appname, "TopDir", &fTopDir, &size);
1417 size = sizeof(BOOL);
1418 PrfQueryProfileData(fmprof, appname, "LookInDir", &fLookInDir, &size);
1419 PrfQueryProfileString(fmprof, appname, "DefArc", NULL, szDefArc, sizeof(szDefArc));
1420 size = sizeof(ULONG);
1421 PrfQueryProfileData(fmprof, appname, "AutoviewHeight",
1422 &AutoviewHeight, &size);
1423 size = sizeof(BOOL);
1424 PrfQueryProfileData(fmprof, appname, "KeepCmdLine", &fKeepCmdLine, &size);
1425 if (strcmp(realappname, "FM/4")) {
1426 size = sizeof(BOOL);
1427 PrfQueryProfileData(fmprof, FM3Str, "MoreButtons", &fMoreButtons, &size);
1428 size = sizeof(BOOL);
1429 PrfQueryProfileData(fmprof, FM3Str, "Drivebar", &fDrivebar, &size);
1430 }
1431 size = sizeof(BOOL);
1432 PrfQueryProfileData(fmprof, appname, "NoSearch", &fNoSearch, &size);
1433 size = sizeof(BOOL);
1434 PrfQueryProfileData(fmprof, appname, "GuessType", &fGuessType, &size);
1435 size = sizeof(BOOL);
1436 PrfQueryProfileData(fmprof, appname, "ViewChild", &fViewChild, &size);
1437 size = sizeof(BOOL);
1438 PrfQueryProfileData(fmprof, appname, "ShowEnv", &fShowEnv, &size);
1439 PrfQueryProfileString(fmprof, appname, "TreeEnvVarList", "PATH;DPATH;LIBPATH;HELP;BOOKSHELF;",
1440 pszTreeEnvVarList, MaxComLineStrg);
1441 size = sizeof(BOOL);
1442 PrfQueryProfileData(fmprof, appname, "ShowDriveOnly", &fShowDriveOnly, &size);
1443 size = sizeof(BOOL);
1444 PrfQueryProfileData(fmprof, appname, "ShowFSTypeInTree", &fShowFSTypeInTree, &size);
1445 size = sizeof(BOOL);
1446 PrfQueryProfileData(fmprof, appname, "ShowDriveLabelInTree", &fShowDriveLabelInTree, &size);
1447 if (!fShowDriveOnly && !fShowFSTypeInTree && !fShowDriveLabelInTree)
1448 fShowDriveOnly = TRUE;
1449 size = sizeof(BOOL);
1450 PrfQueryProfileData(fmprof, appname, "LeaveTree", &fLeaveTree, &size);
1451 size = sizeof(BOOL);
1452 PrfQueryProfileData(fmprof, appname, "Comments", &fComments, &size);
1453 size = sizeof(ULONG);
1454 PrfQueryProfileData(fmprof, appname, "WS_ANIMATE", &fwsAnimate, &size);
1455 if (fwsAnimate)
1456 fwsAnimate = WS_ANIMATE;
1457 size = sizeof(BOOL);
1458 PrfQueryProfileData(fmprof, appname, "SelectedAlways", &fSelectedAlways, &size);
1459 size = sizeof(BOOL);
1460 PrfQueryProfileData(fmprof, appname, "ToolbarHelp", &fToolbarHelp, &size);
1461 size = sizeof(BOOL);
1462 PrfQueryProfileData(fmprof, appname, "OtherHelp", &fOtherHelp, &size);
1463 size = sizeof(BOOL);
1464 PrfQueryProfileData(fmprof, appname, "DrivebarHelp", &fDrivebarHelp, &size);
1465 size = sizeof(BOOL);
1466 PrfQueryProfileData(fmprof, appname, "AutoAddDirs", &fAutoAddDirs, &size);
1467 size = sizeof(BOOL);
1468 PrfQueryProfileData(fmprof, appname, "AutoAddAllDirs", &fAutoAddAllDirs, &size);
1469 size = sizeof(BOOL);
1470 PrfQueryProfileData(fmprof, FM3Str, "UserListSwitches", &fUserListSwitches, &size);
1471 size = sizeof(BOOL);
1472 PrfQueryProfileData(fmprof, appname, "UseNewViewer", &fUseNewViewer, &size);
1473 size = sizeof(BOOL);
1474 PrfQueryProfileData(fmprof, appname, "DefaultDeletePerm", &fDefaultDeletePerm, &size);
1475 size = sizeof(BOOL);
1476 PrfQueryProfileData(fmprof, FM3Str, "ExternalINIs", &fExternalINIs, &size);
1477 size = sizeof(BOOL);
1478 PrfQueryProfileData(fmprof, FM3Str, "ExternalCollector", &fExternalCollector, &size);
1479 size = sizeof(BOOL);
1480 PrfQueryProfileData(fmprof, FM3Str, "ExternalArcboxes", &fExternalArcboxes, &size);
1481 size = sizeof(BOOL);
1482 PrfQueryProfileData(fmprof, FM3Str, "ExternalViewer", &fExternalViewer, &size);
1483 size = sizeof(BOOL);
1484 PrfQueryProfileData(fmprof, FM3Str, "UseQProcStat", &fUseQProcStat, &size);
1485 size = sizeof(BOOL);
1486 PrfQueryProfileData(fmprof, FM3Str, "UseQSysState", &fUseQSysState, &size);
1487 size = sizeof(BOOL);
1488 PrfQueryProfileData(fmprof, appname, "DataMin", &fDataMin, &size);
1489 size = sizeof(BOOL);
1490 PrfQueryProfileData(fmprof, appname, "DataToFore", &fDataToFore, &size);
1491 size = sizeof(BOOL);
1492 PrfQueryProfileData(fmprof, appname, "DataShowDrives", &fDataShowDrives, &size);
1493 size = sizeof(BOOL);
1494 PrfQueryProfileData(fmprof, appname, "DataInclRemote", &fDataInclRemote, &size);
1495 size = sizeof(BOOL);
1496 PrfQueryProfileData(fmprof, FM3Str, "SplitStatus", &fSplitStatus, &size);
1497 size = sizeof(BOOL);
1498 PrfQueryProfileData(fmprof, appname, "FolderAfterExtract", &fFolderAfterExtract, &size);
1499 size = sizeof(BOOL);
1500 PrfQueryProfileData(fmprof, appname, "DullDatabar", &fDullMin, &size);
1501 size = sizeof(BOOL);
1502 PrfQueryProfileData(fmprof, appname, "BlueLED", &fBlueLED, &size);
1503 size = sizeof(BOOL);
1504 PrfQueryProfileData(fmprof, appname, "ConfirmDelete", &fConfirmDelete, &size);
1505 size = sizeof(BOOL);
1506 PrfQueryProfileData(fmprof, FM3Str, "SaveState", &fSaveState, &size);
1507 size = sizeof(BOOL);
1508 PrfQueryProfileData(fmprof, appname, "SyncUpdates", &fSyncUpdates, &size);
1509 size = sizeof(BOOL);
1510 PrfQueryProfileData(fmprof, appname, "LoadSubject", &fLoadSubject, &size);
1511 size = sizeof(BOOL);
1512 PrfQueryProfileData(fmprof, appname, "UnHilite", &fUnHilite, &size);
1513 size = sizeof(BOOL);
1514 PrfQueryProfileData(fmprof, FM3Str, "TileBackwards", &fTileBackwards, &size);
1515 size = sizeof(BOOL);
1516 PrfQueryProfileData(fmprof, appname, "LoadLongname", &fLoadLongnames, &size);
1517 size = sizeof(BOOL);
1518 PrfQueryProfileData(fmprof, appname, "VerifyWrites", &fVerify, &size);
1519 DosSetVerify(fVerify);
1520 size = sizeof(BOOL);
1521 PrfQueryProfileData(fmprof, appname, "DontMoveMouse", &fDontMoveMouse, &size);
1522 size = sizeof(BOOL);
1523 PrfQueryProfileData(fmprof, appname, "NoIconsFiles", &fNoIconsFiles, &size);
1524 size = sizeof(BOOL);
1525 PrfQueryProfileData(fmprof, appname, "NoIconsDirs", &fNoIconsDirs, &size);
1526 size = sizeof(BOOL);
1527 PrfQueryProfileData(fmprof, appname, "ForceUpper", &fForceUpper, &size);
1528 size = sizeof(BOOL);
1529 PrfQueryProfileData(fmprof, appname, "ForceLower", &fForceLower, &size);
1530 size = sizeof(BOOL);
1531 PrfQueryProfileData(fmprof, appname, "TextTools", &fTextTools, &size);
1532 size = sizeof(BOOL);
1533 PrfQueryProfileData(fmprof, appname, "ToolTitles", &fToolTitles, &size);
1534 size = sizeof(BOOL);
1535 PrfQueryProfileData(fmprof, appname, "DoubleClickOpens", &fDCOpens, &size);
1536 size = sizeof(BOOL);
1537 PrfQueryProfileData(fmprof, appname, "LinkSetsIcon", &fLinkSetsIcon, &size);
1538 size = sizeof(BOOL);
1539 PrfQueryProfileData(fmprof, appname, "WarnReadOnly", &fWarnReadOnly, &size);
1540 size = sizeof(INT);
1541 PrfQueryProfileData(fmprof, appname, "Sort", &sortFlags, &size);
1542 size = sizeof(INT);
1543 PrfQueryProfileData(fmprof, appname, "TreeSort", &TreesortFlags, &size);
1544 size = sizeof(INT);
1545 PrfQueryProfileData(fmprof, appname, "CollectorSort", &CollectorsortFlags, &size);
1546 PrfQueryProfileString(fmprof, appname, "Targetdir", NULL, targetdir, sizeof(targetdir));
1547 if (!IsValidDir(targetdir))
1548 *targetdir = 0;
1549 PrfQueryProfileString(fmprof, appname, "ExtractPath", NULL, extractpath, sizeof(extractpath));
1550 size = sizeof(BOOL);
1551 PrfQueryProfileData(fmprof, appname, "FileNamePathCnr", &fFileNameCnrPath, &size);
1552 PrfQueryProfileString(fmprof, appname, "Printer", "PRN", printer, sizeof(printer));
1553 PrfQueryProfileString(fmprof, appname, "DirCompare", NULL, dircompare, MaxComLineStrg);
1554 PrfQueryProfileString(fmprof, appname, "Viewer", NULL, viewer, MaxComLineStrg);
1555 PrfQueryProfileString(fmprof, appname, "Editor", NULL, editor, MaxComLineStrg);
1556 PrfQueryProfileString(fmprof, appname, "BinView", NULL, binview, MaxComLineStrg);
1557 PrfQueryProfileString(fmprof, appname, "BinEd", NULL, bined, MaxComLineStrg);
1558 PrfQueryProfileString(fmprof, appname, "Compare", NULL, compare, MaxComLineStrg);
1559 PrfQueryProfileString(fmprof, appname, "Virus", NULL, virus, MaxComLineStrg);
1560 size = sizeof(BOOL);
1561 PrfQueryProfileData(fmprof, appname, "FtpRunWPSDefault", &fFtpRunWPSDefault, &size);
1562 PrfQueryProfileString(fmprof, appname, "FTPRun", NULL, ftprun, MaxComLineStrg);
1563 if (!*ftprun)
1564 fFtpRunWPSDefault = TRUE;
1565 size = sizeof(BOOL);
1566 PrfQueryProfileData(fmprof, appname, "HttpRunWPSDefault", &fHttpRunWPSDefault, &size);
1567 PrfQueryProfileString(fmprof, appname, "HTTPRun", NULL, httprun, MaxComLineStrg);
1568 if (!*httprun)
1569 fHttpRunWPSDefault = TRUE;
1570 PrfQueryProfileString(fmprof, appname, "MailRun", NULL, mailrun, MaxComLineStrg);
1571 PrfQueryProfileString(fmprof, appname, "FtpRunDir", NULL, ftprundir, sizeof(ftprundir));
1572 PrfQueryProfileString(fmprof, appname, "HttpRunDir", NULL, httprundir, sizeof(httprundir));
1573 PrfQueryProfileString(fmprof, appname, "MailRunDir", NULL, mailrundir, sizeof(mailrundir));
1574 PrfQueryProfileString(fmprof, appname, "LastToolbar", NULL, lasttoolbar, sizeof(lasttoolbar));
1575 size = sizeof(BOOL);
1576 PrfQueryProfileData(fmprof, appname, "LibPathStrictHttpRun", &fLibPathStrictHttpRun, &size);
1577 size = sizeof(BOOL);
1578 PrfQueryProfileData(fmprof, appname, "LibPathStrictFtpRun", &fLibPathStrictFtpRun, &size);
1579 size = sizeof(BOOL);
1580 PrfQueryProfileData(fmprof, appname, "LibPathStrictMailRun", &fLibPathStrictMailRun, &size);
1581 size = sizeof(BOOL);
1582 PrfQueryProfileData(fmprof, appname, "NoMailtoMailRun", &fNoMailtoMailRun, &size);
1583 size = sizeof(BOOL);
1584 PrfQueryProfileData(fmprof, appname, "FollowTree", &fFollowTree, &size);
1585 size = sizeof(BOOL);
1586 PrfQueryProfileData(fmprof, appname, "StartMaximized", &fStartMaximized, &size);
1587 if (!fStartMaximized) {
1588 size = sizeof(BOOL);
1589 PrfQueryProfileData(fmprof, appname, "StartMinimized", &fStartMinimized, &size);
1590 }
1591 size = sizeof(BOOL);
1592 PrfQueryProfileData(fmprof, appname, "DefaultCopy", &fCopyDefault, &size);
1593 size = sizeof(BOOL);
1594 PrfQueryProfileData(fmprof, appname, "IdleCopy", &fRealIdle, &size);
1595 size = sizeof(BOOL);
1596 PrfQueryProfileData(fmprof, appname, "ArcStuffVisible", &fArcStuffVisible, &size);
1597 size = sizeof(BOOL);
1598 PrfQueryProfileData(fmprof, appname, "NoTreeGap", &fNoTreeGap, &size);
1599 size = sizeof(BOOL);
1600 PrfQueryProfileData(fmprof, FM3Str, "VTreeOpensWPS", &fVTreeOpensWPS, &size);
1601 size = sizeof(BOOL);
1602 PrfQueryProfileData(fmprof, appname, "RemoteBug", &fRemoteBug, &size);
1603 size = sizeof(BOOL);
1604 PrfQueryProfileData(fmprof, appname, "RScanLocal", &fRScanLocal, &size);
1605 size = sizeof(BOOL);
1606 PrfQueryProfileData(fmprof, appname, "RScanRemote", &fRScanRemote, &size);
1607 size = sizeof(BOOL);
1608 PrfQueryProfileData(fmprof, appname, "RScanVirtual", &fRScanVirtual, &size);
1609 size = sizeof(BOOL);
1610 PrfQueryProfileData(fmprof, appname, "RScanSlow", &fRScanSlow, &size);
1611 size = sizeof(BOOL);
1612 PrfQueryProfileData(fmprof, appname, "RScanNoWrite", &fRScanNoWrite, &size);
1613 size = sizeof(BOOL);
1614 PrfQueryProfileData(fmprof, appname, "EjectRemovableScan", &fEjectRemovableScan, &size);
1615 size = sizeof(BOOL);
1616 PrfQueryProfileData(fmprof, appname, "EjectCDScan", &fEjectCDScan, &size);
1617 size = sizeof(BOOL);
1618 PrfQueryProfileData(fmprof, appname, "EjectFlpyScan", &fEjectFlpyScan, &size);
1619 size = sizeof(BOOL);
1620 PrfQueryProfileData(fmprof, appname, "Drag&DropDlg", &fDragndropDlg, &size);
1621 size = sizeof(BOOL);
1622 PrfQueryProfileData(fmprof, FM3Str, "UserComboBox", &fUserComboBox, &size);
1623 size = sizeof(BOOL);
1624 PrfQueryProfileData(fmprof, FM3Str, "MinDirOnOpen", &fMinOnOpen, &size);
1625 size = sizeof(BOOL);
1626 PrfQueryProfileData(fmprof, appname, "QuickArcFind", &fQuickArcFind, &size);
1627 size = sizeof(BOOL);
1628 PrfQueryProfileData(fmprof, appname, "NoRemovableScan", &fNoRemovableScan, &size);
1629 size = sizeof(ULONG);
1630 PrfQueryProfileData(fmprof, FM3Str, "NoBrokenNotify", &NoBrokenNotify, &size);
1631 size = sizeof(ULONG);
1632 PrfQueryProfileData(fmprof, appname, "ContainerType", &ulCnrType, &size);
1633 size = sizeof(ULONG);
1634 PrfQueryProfileData(fmprof, appname, "FilesToGet", &FilesToGet, &size);
1635 if (FilesToGet < FILESTOGET_MIN)
1636 FilesToGet = FILESTOGET_MIN;
1637 else if (FilesToGet > FILESTOGET_MAX)
1638 FilesToGet = FILESTOGET_MAX;
1639 size = sizeof(BOOL);
1640 PrfQueryProfileData(fmprof, appname, "AutoView", &fAutoView, &size);
1641 size = sizeof(BOOL);
1642 PrfQueryProfileData(fmprof, appname, "FM2Deletes", &fFM2Deletes, &size);
1643 size = sizeof(BOOL);
1644 PrfQueryProfileData(fmprof, appname, "TrashCan", &fTrashCan, &size);
1645 size = sizeof(BOOL);
1646 PrfQueryProfileData(fmprof, appname, "ThreadNotes", &fThreadNotes, &size);
1647 if (fThreadNotes)
1648 ShowNote();
1649 size = sizeof(BOOL);
1650 PrfQueryProfileData(fmprof, FM3Str, "DontAskBzip", &fDontAskBzip, &size);
1651 size = sizeof(BOOL);
1652 PrfQueryProfileData(fmprof, FM3Str, "DontAskGzip", &fDontAskGzip, &size);
1653
1654 // 2015-08-11 SHL FIXME debug
1655 DbgMsg(pszSrcFile, __LINE__, "ShowEnv %u SwitchTree %u SwitchTreeExpand %u SwitchTreeOnFocus %u CollapseFirst %u", fShowEnv, fSwitchTreeOnDirChg, fSwitchTreeExpand, fSwitchTreeOnFocus, fCollapseFirst);
1656 DbgMsg(pszSrcFile, __LINE__, "RScanLocal %u RScanRemote %u RScanVirtual %u RScanSlow RScanNoWrite %u", fRScanLocal, fRScanRemote, fRScanVirtual, fRScanSlow, fRScanNoWrite);
1657
1658 LoadDetailsSwitches(PCSZ_DIRCNR, &dsDirCnrDefault, FALSE);
1659
1660 // load pointers and icons we use
1661 hptrArrow = WinQuerySysPointer(HWND_DESKTOP, SPTR_ARROW, FALSE);
1662 hptrBusy = WinQuerySysPointer(HWND_DESKTOP, SPTR_WAIT, FALSE);
1663 hptrNS = WinQuerySysPointer(HWND_DESKTOP, SPTR_SIZENS, FALSE);
1664 hptrEW = WinQuerySysPointer(HWND_DESKTOP, SPTR_SIZEWE, FALSE);
1665 hptrFloppy = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, FLOPPY_ICON);
1666 hptrDrive = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, DRIVE_ICON);
1667 hptrRemovable = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, REMOVABLE_ICON);
1668 hptrCDROM = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, CDROM_ICON);
1669 hptrFile = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, FILE_ICON);
1670 hptrDir = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, DIR_FRAME);
1671 hptrArc = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, ARC_FRAME);
1672 hptrArt = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, ART_ICON);
1673 hptrSystem = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, FILE_SYSTEM_ICON);
1674 hptrHidden = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, FILE_HIDDEN_ICON);
1675 hptrReadonly = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, FILE_READONLY_ICON);
1676 hptrLast = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, LASTITEM_ICON);
1677 hptrRemote = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, REMOTE_ICON);
1678 hptrVirtual = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, VIRTUAL_ICON);
1679 hptrRamdisk = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, RAMDISK_ICON);
1680 if (!fNoDead)
1681 hptrFinger = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, FINGER_ICON);
1682 else
1683 hptrFinger = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, FINGER2_ICON);
1684 hptrApp = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, APP_ICON);
1685 hptrDunno = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, DUNNO_ICON);
1686 hptrEnv = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, ENV_ICON);
1687 hptrZipstrm = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, ZIPSTREAM_ICON);
1688
1689 // set up color array used by seeall.c and newview.c color dialog
1690
1691 standardcolors[0] = CLR_WHITE;
1692 standardcolors[1] = CLR_BLACK;
1693 standardcolors[2] = CLR_BLUE;
1694 standardcolors[3] = CLR_RED;
1695 standardcolors[4] = CLR_PINK;
1696 standardcolors[5] = CLR_GREEN;
1697 standardcolors[6] = CLR_CYAN;
1698 standardcolors[7] = CLR_YELLOW;
1699 standardcolors[8] = CLR_DARKGRAY;
1700 standardcolors[9] = CLR_DARKBLUE;
1701 standardcolors[10] = CLR_DARKRED;
1702 standardcolors[11] = CLR_DARKPINK;
1703 standardcolors[12] = CLR_DARKGREEN;
1704 standardcolors[13] = CLR_DARKCYAN;
1705 standardcolors[14] = CLR_BROWN;
1706 standardcolors[15] = CLR_PALEGRAY;
1707
1708 return TRUE;
1709}
1710
1711HWND StartFM3(HAB hab, INT argc, CHAR ** argv)
1712{
1713 HWND hwndFrame;
1714 HWND hwndClient;
1715 UINT x;
1716 ULONG FrameFlags = FCF_TITLEBAR | FCF_SYSMENU |
1717 FCF_SIZEBORDER | FCF_MINMAX |
1718 FCF_ACCELTABLE | FCF_MENU | FCF_ICON | FCF_TASKLIST | FCF_NOBYTEALIGN;
1719
1720 for (x = 1; x < argc; x++) {
1721 if (*argv[x] == '~' && !argv[x][1])
1722 fReminimize = TRUE;
1723 if (*argv[x] == '+' && !argv[x][1])
1724 fLogFile = TRUE;
1725 if (*argv[x] == '-') {
1726 if (!argv[x][1])
1727 fNoSaveState = TRUE;
1728 else
1729 strcpy(profile, &argv[x][1]);
1730 }
1731 if (*argv[x] == '#' && !argv[x][1])
1732 fUseShellEnv = TRUE;
1733 }
1734
1735 hwndFrame = WinCreateStdWindow(HWND_DESKTOP,
1736 WS_VISIBLE,
1737 &FrameFlags,
1738 (CHAR *) WC_MAINWND,
1739 NULL,
1740 WS_VISIBLE | WS_ANIMATE,
1741 FM3ModHandle, MAIN_FRAME, &hwndClient);
1742 if (hwndFrame) {
1743 WinSetWindowUShort(hwndFrame, QWS_ID, MAIN_FRAME);
1744 hwndMainMenu = WinWindowFromID(hwndFrame, FID_MENU);
1745 if (!WinRestoreWindowPos((CHAR *) FM2Str, "MainWindowPos", hwndFrame)) {
1746
1747 ULONG fl = SWP_MOVE | SWP_SIZE;
1748 RECTL rcl;
1749 ULONG icz = WinQuerySysValue(HWND_DESKTOP, SV_CYICON) * 3L;
1750 ULONG bsz = WinQuerySysValue(HWND_DESKTOP, SV_CYSIZEBORDER);
1751
1752 WinQueryWindowRect(HWND_DESKTOP, &rcl);
1753 rcl.yBottom += icz;
1754 rcl.yTop -= bsz;
1755 rcl.xLeft += bsz;
1756 rcl.xRight -= bsz;
1757 WinSetWindowPos(hwndFrame,
1758 HWND_TOP,
1759 rcl.xLeft,
1760 rcl.yBottom,
1761 rcl.xRight - rcl.xLeft, rcl.yTop - rcl.yBottom, fl);
1762 }
1763 if (fLogFile) {
1764 CHAR *modea = "a+";
1765
1766 LogFileHandle = xfsopen("FM2.LOG", modea, SH_DENYWR, pszSrcFile, __LINE__, TRUE);
1767 }
1768 if (hwndHelp)
1769 WinAssociateHelpInstance(hwndHelp, hwndFrame);
1770 PostMsg(hwndClient, UM_SETUP, MPFROMLONG(argc), MPFROMP(argv));
1771 }
1772 return hwndFrame;
1773}
1774
1775BOOL CheckFileHeader(CHAR *filespec, CHAR *signature, LONG offset)
1776{
1777 HFILE handle;
1778 ULONG action;
1779 ULONG len = strlen(signature);
1780 ULONG l;
1781 CHAR buffer[4096]; // 06 Oct 07 SHL Protect against NTFS defect
1782 BOOL ret = FALSE;
1783
1784 DosError(FERR_DISABLEHARDERR);
1785 if (DosOpen(filespec,
1786 &handle,
1787 &action,
1788 0,
1789 0,
1790 OPEN_ACTION_FAIL_IF_NEW |
1791 OPEN_ACTION_OPEN_IF_EXISTS,
1792 OPEN_FLAGS_FAIL_ON_ERROR |
1793 OPEN_FLAGS_NOINHERIT |
1794 OPEN_FLAGS_RANDOMSEQUENTIAL |
1795 OPEN_SHARE_DENYNONE | OPEN_ACCESS_READONLY, 0))
1796 ret = FALSE;
1797 else {
1798 // Try signature match
1799 l = len;
1800 l = min(l, 79);
1801 if (!DosChgFilePtr(handle,
1802 abs(offset),
1803 (offset >= 0) ?
1804 FILE_BEGIN : FILE_END, &len)) {
1805 if (!DosRead(handle, buffer, l, &len) && len == l) {
1806 if (!memcmp(signature, buffer, l))
1807 ret = TRUE; // Matched
1808 }
1809 }
1810 }
1811 DosClose(handle); // Either way, we're done for now
1812 return ret; // Return TRUE if matched
1813}
1814
1815int CheckVersion(int vermajor, int verminor)
1816{
1817 int ok = 0;
1818
1819 // fixme to do useful check - was missing in base source
1820
1821#if 0
1822 if (vermajor && verminor) {
1823 *vermajor = VERMAJOR;
1824 *verminor = VERMINOR;
1825 ok = 1;
1826 }
1827#endif
1828
1829 ok = 1;
1830
1831 return ok;
1832}
1833
1834#ifdef __WATCOMC__
1835#pragma alloc_text(INIT,LibMain,InitFM3DLL,DeInitFM3DLL)
1836#pragma alloc_text(INIT1,StartFM3,FindSwapperDat)
1837#endif
Note: See TracBrowser for help on using the repository browser.