source: trunk/dll/init.c@ 1312

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

Fix for traps caused by race condition on directory deletes. This disables immediate updates for deleted directory and set a semaphore to allow the delete to complete before update. It also quotes the * on the extract command line which appears to allow tar 1.15 and higher to work. (Ticket 304)

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