source: trunk/dll/init.c@ 1654

Last change on this file since 1654 was 1654, checked in by Gregg Young, 14 years ago

Add support for changing PresParams in the notify status window.

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