source: trunk/dll/init.c@ 1607

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

Cleanup of ini load code with PCSZ replacing hard coded names like FM3INI.

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