source: trunk/dll/init.c@ 1320

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

Use event semaphore to prevent rescan of drives while StubbySacnTreads are still running; code cleanup.

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