source: trunk/dll/init.c@ 1326

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

Changes to avoid duplicate directory names on scan using StubbyScanThread.

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