source: trunk/dll/init.c@ 1370

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

This should completely fix the drives not getting scanned issue

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