source: trunk/dll/init.c@ 1544

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

Changes to fopen and _fsopen to allow FM2 to be loaded in high memory

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