source: trunk/dll/init.c@ 1444

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

Rework of drivebar to rescan all drives and refresh media buttons and menu items grey out inappropriate menu items. Streamline Tree scan code and use semaphores to serialize access. Add NOEASUPPORT and LOCALHD driveflag; .LONGNAME usage fixes; (Tickets 377-386)

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