source: trunk/dll/init.c@ 1424

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

Show either file system type or drive label beside dirve letter in tree. (tickets 47 & 339)

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