source: trunk/dll/init.c@ 1395

Last change on this file since 1395 was 1395, checked in by Gregg Young, 17 years ago

Allow user to turn off alert and/or error beeps in settings notebook. Ticket 341 Move repeated strings to PCSZs. Ticket 6 Add *DateFormat functions to format dates based on locale Ticket 28 Eliminate Win_Error2 by moving function names to PCSZs used in Win_Error Ticket 6

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