source: trunk/dll/init.c@ 1673

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

Update to Doxygen comment style Ticket 55. Also some minor code cleanup.

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