source: trunk/dll/init.c@ 1720

Last change on this file since 1720 was 1720, checked in by Gregg Young, 12 years ago

Add "#" command line switch to workaround problem with blank command shell started from fm2 after fm2 has been started with stdout and stderr redirected to a file. Fixes it by using the system environment instead of fm2's when starting command shells.

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