source: trunk/dll/init.c@ 1351

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

Additional code cleanup

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