source: trunk/dll/init.c@ 1871

Last change on this file since 1871 was 1871, checked in by Gregg Young, 10 years ago

Create CollapseAll and modify ExpandAll to reduce code overhead both to try and speed drive expansion. Change ExpandAll to allow it to loop in UM_EXPAND until until drive is completely expanded. Changes were need to work with Flesh, Stubby and UnFlesh being moved to a thread. Add code for Flesh to skip the directory entry added by Stubby (eliminate use of NULL/Nullstr pszFileNames by Stubby). Add code in Stubby to insert a complete container item. Add a flag to indicate when a directory needed to be Fleshed. Get expand and switch code to work with Flesh, UnFlesh and Stubby running on a thread. Loop and idle ExpandAll; Move tree expand to a thread; Have ShowTreeRec wait for the Flesh thread. Add a correction factor so directories don't get placed above the top of the tree container when a large drive has been expanded. Debug is mostly still in but all turned off.

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