source: trunk/dll/init.c@ 1450

Last change on this file since 1450 was 1450, checked in by Gregg Young, 16 years ago

Add a PCSZ srting for error messages; prevent error popup for locked text file on directory scan (scan works as expected anyway); Pass file names on stack which is in low mem for DosGetMessage.

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