source: trunk/dll/init.c@ 1522

Last change on this file since 1522 was 1522, checked in by John Small, 15 years ago

Ticket 434: Startup parameter suggestion improvements and bug fixes.

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