source: trunk/dll/init.c@ 1391

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

Move nontranslated strings to init.c and codepage.c; use those strings in place of GetPString calls. Move other strings to a StringTable; minor cleanup and code changes to codepage.c to use a string array instead of GetPString calls. Ticket 340

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