source: trunk/dll/init.c@ 1328

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

Code cleanup replace sizeof calls for threaded drive scans

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