source: trunk/dll/init.c@ 1393

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

Added Archiver.bb2 string back after removal from string table. Fixes archiver failure.

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