source: trunk/dll/init.c@ 1553

Last change on this file since 1553 was 1553, checked in by Gregg Young, 15 years ago

Rework scanning code to remove redundant scans, prevent double directory entries in the tree container, fix related semaphore performance using combination of event and mutex semaphores

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