source: trunk/dll/init.c@ 1394

Last change on this file since 1394 was 1394, checked in by Steven Levine, 17 years ago

Ticket 340: Convert GetPString to use STRINGTABLE.

Drop fm3dll.str and mkstr.exe from makefiles and wpi builders

Convert many functions to expect PCSZ arguments.
Correct walk, compare and dirsizes dialog setups to ignore saved dialog size
Drop copyright.c logic from makefile

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