source: trunk/dll/init.c@ 1546

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

Add menu item to allow opening of directory container from the collector based on the path of the selected item. (Ticket 362) Add open file button to EAs dialog to allow opening of a new file's eas (Ticket 439). Initial work on populating the help table (It provides F1 help a few more places) (Ticket 95). Some minor code cleanup and help file updates.

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