source: trunk/dll/init.c@ 1375

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

Updated history; comments minor code cleanup for recent changes

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