source: trunk/dll/init.c@ 1664

Last change on this file since 1664 was 1664, checked in by Gregg Young, 13 years ago

Changes to use Unlock to unlock files if Unlock.exe is in path both from menu/toolbar and as part of copy, move and delete operations. Changes to allow copy and move over readonly files with a warning dialog; also added a warning dialog for delete of readonly files

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