source: trunk/dll/init.c@ 1360

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

Conditionally enable Refresh removable media and individual partition menu items based on availability of required tool in PATH. (Tickets 36 & 54)

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