source: trunk/dll/init.c@ 1328

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

Code cleanup replace sizeof calls for threaded drive scans

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