source: trunk/dll/init.c@ 1863

Last change on this file since 1863 was 1863, checked in by Gregg Young, 10 years ago

Remove recurse scan code; fix A:\ drive not ready error caused by not moving the cursor from drive A:\ fast enough. Have Flesh remove pcis that have NullStr FileNames.

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