source: trunk/dll/init.c@ 1209

Last change on this file since 1209 was 1209, checked in by John Small, 17 years ago

Ticket 187: Move data declarations/definitions out of fm3dll.h

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