source: trunk/dll/init.c@ 1479

Last change on this file since 1479 was 1479, checked in by Gregg Young, 16 years ago

Work around MMIO's failure to recognize MPG files as media. Reorder file type checks to eliminate problem with MMIO identifying exes etc as media. Check for zero byte file and let user decide to open in an editor or abort (also prevents MMIO misidentification). Tickets 70, 405, 409, 410

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