source: trunk/dll/init.c@ 1505

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

Remove unnecessary type casts; minor formating cleanup.

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