source: trunk/dll/init.c@ 1407

Last change on this file since 1407 was 1403, checked in by Gregg Young, 17 years ago

Remove all IBMC specific code (ifdefs) including the removal of fsopen.c (obj reference removed from makefile).

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