source: trunk/dll/init.c@ 1743

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

Ticket #515L Corrected a mis-coded call to strtol (can changed it to strtoul).

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