source: trunk/dll/init.c@ 1303

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

Last part of remove or replace with a mutex semaphore DosEnterCriSec where appropriate. (Ticket 308) Note the partial commits for this ticket won't build without this.

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