source: trunk/dll/init.c@ 1554

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

Check that pTmpDir IsValid and recreate if not found; Fixes hangs caused by temp file creation failures. (Ticket 440)

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