source: trunk/dll/init.c@ 1642

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

Fixed thread notes dialog to reopen on startup if it was open on shutdown.

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