source: trunk/dll/init.c@ 1711

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

Fix separate parameters. Moved to general page renamed separate settings for apps. Ticket 497

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