source: trunk/dll/init.c@ 1786

Last change on this file since 1786 was 1786, checked in by Gregg Young, 11 years ago

Add semaphore hmtxFiltering to prevent freeing dcd while filtering. Prevents a trap when FM2 is shutdown while directory containers are still populating (Ticket 535)

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