source: trunk/dll/init.c@ 1604

Last change on this file since 1604 was 1604, checked in by Gregg Young, 14 years ago

Cleanup of INI load code; added error checking to save directory load; improve code format.

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