source: trunk/dll/init.c@ 1358

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

Comments for CS 1354/55

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