source: trunk/dll/init.c@ 1551

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

This code adds the semaphores to prevent a rescan from starting before the current one is finished; it fixes the double directory listing in the tree container and streamlines scanning. It update mapsym.pl to the latest version. Some code cleanup is included

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