source: trunk/dll/init.c@ 1750

Last change on this file since 1750 was 1750, checked in by John Small, 11 years ago

Ticket #524: Made "searchapath" thread-safe. Function names and signatures were changed.

So calls to these functions, direct and indirect, had to be changed.

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