source: trunk/dll/init.c@ 1224

Last change on this file since 1224 was 1224, checked in by John Small, 17 years ago

Ticket 187: Moved typedef's and some #define's from fm3dll.h

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