source: trunk/dll/init.c@ 1603

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

If both TEMP and TMP environment variables are missing or point to invalid directories the FM2SaveDirectory doesn't get set. This fixes it and probably the trap in Ticket 468

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