source: trunk/dll/init.c@ 1363

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

Move the FillInDriveFlags call in init.c to after the ini file is fully initiated since it accesses it; Fix the black toolbar on new install issue (I think I removed the right ini entry to test this) Ticket 328

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