source: trunk/dll/init.c@ 1333

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

Added back the sizeofs for each PrfQueryProfileData call. Change the PrfQueryProfileData calls to PrfQueryProfileString for strings since MaxComLineStrg is set at run time not compile time and to eliminate the need for 2 PrfQueryProfileSize calls in RestoreDirCnrState.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 61.8 KB
RevLine 
[32]1
2/***********************************************************************
3
4 $Id: init.c 1333 2008-12-12 21:56:35Z 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
[1333]1187 if (DosCreateMutexSem(NULL, &hmtxFM2Globals, 0L, FALSE))
[1312]1188 Dos_Error(MB_CANCEL, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
1189 "DosCreateMutexSem");
[1333]1190 if (DosCreateMutexSem(NULL, &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;
[1333]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;
[1333]1252 PrfWriteProfileData(fmprof, appname, "MaxComLineChecked", &MaxComLineChecked, sizeof(BOOL));
[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
[1333]1292 size = sizeof(BOOL);
[1328]1293 PrfQueryProfileData(fmprof, appname, "ShowTarget", &fShowTarget, &size);
[1333]1294 size = sizeof(BOOL);
[1328]1295 PrfQueryProfileData(fmprof, appname, "CheckMM", &fCheckMM, &size);
[1333]1296 size = sizeof(BOOL);
[1328]1297 PrfQueryProfileData(fmprof, appname, "ChangeTarget", &fChangeTarget, &size);
[1333]1298 size = sizeof(BOOL);
[1328]1299 PrfQueryProfileData(fmprof, appname, "ConfirmTarget", &fConfirmTarget, &size);
[1333]1300 size = sizeof(BOOL);
[1328]1301 PrfQueryProfileData(fmprof, FM3Str, "CustomFileDlg", &fCustomFileDlg, &size);
[1333]1302 size = sizeof(BOOL);
[1328]1303 PrfQueryProfileData(fmprof, FM3Str, "SaveMiniCmds", &fSaveMiniCmds, &size);
[1333]1304 size = sizeof(BOOL);
[1328]1305 PrfQueryProfileData(fmprof, appname, "SaveBigCmds", &fSaveBigCmds, &size);
[1333]1306 size = sizeof(BOOL);
[1328]1307 PrfQueryProfileData(fmprof, appname, "NoFoldMenu", &fNoFoldMenu, &size);
[1333]1308 size = sizeof(BOOL);
[1328]1309 PrfQueryProfileData(fmprof, FM3Str, "ThreadNotes", &fThreadNotes, &size);
[1333]1310 size = sizeof(BOOL);
[1328]1311 PrfQueryProfileData(fmprof, FM3Str, "Prnpagenums", &prnpagenums, &size);
[1333]1312 size = sizeof(BOOL);
[1328]1313 PrfQueryProfileData(fmprof, FM3Str, "Prnalt", &prnalt, &size);
[1333]1314 size = sizeof(BOOL);
[1328]1315 PrfQueryProfileData(fmprof, FM3Str, "Prnformat", &prnformat, &size);
[1333]1316 size = sizeof(BOOL);
1317 PrfQueryProfileData(fmprof, FM3Str, "Prnformfeedbefore", &prnformfeedbefore, &size);
1318 size = sizeof(BOOL);
1319 PrfQueryProfileData(fmprof, FM3Str, "Prnformfeedafter",&prnformfeedafter, &size);
[1328]1320 size = sizeof(ULONG);
1321 PrfQueryProfileData(fmprof, FM3Str, "Prntabspaces", &prntabspaces, &size);
[1333]1322 size = sizeof(ULONG);
[1328]1323 PrfQueryProfileData(fmprof, FM3Str, "Prnwidth", &prnwidth, &size);
[1333]1324 size = sizeof(ULONG);
[1328]1325 PrfQueryProfileData(fmprof, FM3Str, "Prnlength", &prnlength, &size);
[1333]1326 size = sizeof(ULONG);
[1328]1327 PrfQueryProfileData(fmprof, FM3Str, "Prntmargin", &prntmargin, &size);
[1333]1328 size = sizeof(ULONG);
[1328]1329 PrfQueryProfileData(fmprof, FM3Str, "Prnbmargin", &prnbmargin, &size);
[1333]1330 size = sizeof(ULONG);
[1328]1331 PrfQueryProfileData(fmprof, FM3Str, "Prnlmargin", &prnlmargin, &size);
[1333]1332 size = sizeof(ULONG);
[1328]1333 PrfQueryProfileData(fmprof, FM3Str, "Prnrmargin", &prnrmargin, &size);
[1333]1334 size = sizeof(ULONG);
[1328]1335 PrfQueryProfileData(fmprof, FM3Str, "Prnspacing", &prnspacing, &size);
1336 size = sizeof(BOOL);
1337 PrfQueryProfileData(fmprof, FM3Str, "NoDead", &fNoDead, &size);
[1333]1338 size = sizeof(BOOL);
[1328]1339 PrfQueryProfileData(fmprof, FM3Str, "NoFinger", &fNoFinger, &size);
[1333]1340 size = sizeof(BOOL);
[1328]1341 PrfQueryProfileData(fmprof, appname, "SwitchTree", &fSwitchTree, &size);
[1333]1342 size = sizeof(BOOL);
1343 PrfQueryProfileData(fmprof, appname, "SwitchTreeExpand", &fSwitchTreeExpand, &size);
1344 size = sizeof(BOOL);
1345 PrfQueryProfileData(fmprof, appname, "SwitchTreeOnFocus", &fSwitchTreeOnFocus, &size);
1346 size = sizeof(BOOL);
1347 PrfQueryProfileData(fmprof, appname, "CollapseFirst", &fCollapseFirst, &size);
1348 size = sizeof(BOOL);
1349 PrfQueryProfileData(fmprof, appname, "FilesInTree", &fFilesInTree, &size);
1350 size = sizeof(BOOL);
[1328]1351 PrfQueryProfileData(fmprof, FM3Str, "TopDir", &fTopDir, &size);
[1333]1352 size = sizeof(BOOL);
[1328]1353 PrfQueryProfileData(fmprof, FM3Str, "LookInDir", &fLookInDir, &size);
[1333]1354 PrfQueryProfileString(fmprof, appname, "DefArc", NULL, szDefArc, sizeof(szDefArc));
[1328]1355 size = sizeof(ULONG);
[201]1356 PrfQueryProfileData(fmprof, FM3Str, "AutoviewHeight",
[1328]1357 &AutoviewHeight, &size);
1358 size = sizeof(BOOL);
1359 PrfQueryProfileData(fmprof, FM3Str, "KeepCmdLine", &fKeepCmdLine, &size);
[551]1360 if (strcmp(realappname, "FM/4")) {
[1333]1361 size = sizeof(BOOL);
[1328]1362 PrfQueryProfileData(fmprof, FM3Str, "MoreButtons", &fMoreButtons, &size);
[1333]1363 size = sizeof(BOOL);
[1328]1364 PrfQueryProfileData(fmprof, FM3Str, "Drivebar", &fDrivebar, &size);
[201]1365 }
1366 else
1367 fDrivebar = fMoreButtons = TRUE;
[1333]1368 size = sizeof(BOOL);
[1328]1369 PrfQueryProfileData(fmprof, appname, "NoSearch", &fNoSearch, &size);
[1333]1370 size = sizeof(BOOL);
[1328]1371 PrfQueryProfileData(fmprof, appname, "GuessType", &fGuessType, &size);
[1333]1372 size = sizeof(BOOL);
[1328]1373 PrfQueryProfileData(fmprof, appname, "ViewChild", &fViewChild, &size);
[1333]1374 size = sizeof(BOOL);
[1328]1375 PrfQueryProfileData(fmprof, appname, "ShowEnv", &fShowEnv, &size);
[1333]1376 PrfQueryProfileString(fmprof, appname, "TreeEnvVarList", "PATH;DPATH;LIBPATH;HELP;BOOKSHELF;",
1377 pszTreeEnvVarList, MaxComLineStrg);
[1328]1378 size = sizeof(BOOL);
1379 PrfQueryProfileData(fmprof, appname, "LeaveTree", &fLeaveTree, &size);
[1333]1380 size = sizeof(BOOL);
[1328]1381 PrfQueryProfileData(fmprof, FM3Str, "Comments", &fComments, &size);
1382 size = sizeof(ULONG);
1383 PrfQueryProfileData(fmprof, appname, "WS_ANIMATE", &fwsAnimate, &size);
[201]1384 if (fwsAnimate)
1385 fwsAnimate = WS_ANIMATE;
[1328]1386 size = sizeof(BOOL);
[1333]1387 PrfQueryProfileData(fmprof, appname, "SelectedAlways", &fSelectedAlways, &size);
1388 size = sizeof(BOOL);
[1328]1389 PrfQueryProfileData(fmprof, FM3Str, "ToolbarHelp", &fToolbarHelp, &size);
[1333]1390 size = sizeof(BOOL);
[1328]1391 PrfQueryProfileData(fmprof, FM3Str, "OtherHelp", &fOtherHelp, &size);
[1333]1392 size = sizeof(BOOL);
[1328]1393 PrfQueryProfileData(fmprof, FM3Str, "DrivebarHelp", &fDrivebarHelp, &size);
[1333]1394 size = sizeof(BOOL);
[1328]1395 PrfQueryProfileData(fmprof, appname, "AutoAddDirs", &fAutoAddDirs, &size);
[1333]1396 size = sizeof(BOOL);
1397 PrfQueryProfileData(fmprof, appname, "AutoAddAllDirs", &fAutoAddAllDirs, &size);
1398 size = sizeof(BOOL);
1399 PrfQueryProfileData(fmprof, FM3Str, "UserListSwitches", &fUserListSwitches, &size);
1400 size = sizeof(BOOL);
1401 PrfQueryProfileData(fmprof, appname, "UseNewViewer", &fUseNewViewer, &size);
1402 size = sizeof(BOOL);
1403 PrfQueryProfileData(fmprof, appname, "DefaultDeletePerm", &fDefaultDeletePerm, &size);
1404 size = sizeof(BOOL);
1405 PrfQueryProfileData(fmprof, FM3Str, "ExternalINIs", &fExternalINIs, &size);
1406 size = sizeof(BOOL);
1407 PrfQueryProfileData(fmprof, FM3Str, "ExternalCollector", &fExternalCollector, &size);
1408 size = sizeof(BOOL);
1409 PrfQueryProfileData(fmprof, FM3Str, "ExternalArcboxes", &fExternalArcboxes, &size);
1410 size = sizeof(BOOL);
1411 PrfQueryProfileData(fmprof, FM3Str, "ExternalViewer", &fExternalViewer, &size);
1412 size = sizeof(BOOL);
1413 PrfQueryProfileData(fmprof, FM3Str, "UseQProcStat", &fUseQProcStat, &size);
1414 size = sizeof(BOOL);
1415 PrfQueryProfileData(fmprof, FM3Str, "UseQSysState", &fUseQSysState, &size);
1416 size = sizeof(BOOL);
[1328]1417 PrfQueryProfileData(fmprof, FM3Str, "DataMin", &fDataMin, &size);
[1333]1418 size = sizeof(BOOL);
[1328]1419 PrfQueryProfileData(fmprof, appname, "DataToFore", &fDataToFore, &size);
[1333]1420 size = sizeof(BOOL);
1421 PrfQueryProfileData(fmprof, appname, "DataShowDrives", &fDataShowDrives, &size);
1422 size = sizeof(BOOL);
1423 PrfQueryProfileData(fmprof, appname, "DataInclRemote", &fDataInclRemote, &size);
1424 size = sizeof(BOOL);
[1328]1425 PrfQueryProfileData(fmprof, FM3Str, "SplitStatus", &fSplitStatus, &size);
[1333]1426 size = sizeof(BOOL);
1427 PrfQueryProfileData(fmprof, appname, "FolderAfterExtract", &fFolderAfterExtract, &size);
1428 size = sizeof(BOOL);
[1328]1429 PrfQueryProfileData(fmprof, FM3Str, "DullDatabar", &fDullMin, &size);
[1333]1430 size = sizeof(BOOL);
[1328]1431 PrfQueryProfileData(fmprof, appname, "BlueLED", &fBlueLED, &size);
[1333]1432 size = sizeof(BOOL);
1433 PrfQueryProfileData(fmprof, appname, "ConfirmDelete", &fConfirmDelete, &size);
1434 size = sizeof(BOOL);
[1328]1435 PrfQueryProfileData(fmprof, FM3Str, "SaveState", &fSaveState, &size);
[1326]1436 if (fSaveState) {
1437 ULONG numsaves = 0;
1438 CHAR szKey[STATE_NAME_MAX_BYTES + 80];
1439 CHAR szDir[CCHMAXPATH];
1440 ULONG drvNum;
1441 INT x;
1442
1443 fInitialDriveScan = TRUE;
1444 sprintf(szKey, "%s.NumDirsLastTime", GetPString(IDS_SHUTDOWNSTATE));
[1328]1445 size = sizeof(ULONG);
[1326]1446 if (PrfQueryProfileData(fmprof,
[1328]1447 FM3Str, szKey, (PVOID) &numsaves, &size)) {
[1326]1448 for (x = numsaves - 1; x >= 0; x--) {
1449 sprintf(szKey, "%s.DirCnrDir.%lu", GetPString(IDS_SHUTDOWNSTATE), x);
1450 size = sizeof(szDir);
1451 if (PrfQueryProfileData(fmprof, FM3Str, szKey, (PVOID) szDir, &size)) {
1452 drvNum = toupper(*szDir) - 'A';
1453 fDrivetoSkip[drvNum] = TRUE;
1454 }
1455 }
1456 }
1457 }
[1328]1458 size = sizeof(BOOL);
1459 PrfQueryProfileData(fmprof, appname, "SyncUpdates", &fSyncUpdates, &size);
[1333]1460 size = sizeof(BOOL);
[1328]1461 PrfQueryProfileData(fmprof, appname, "LoadSubject", &fLoadSubject, &size);
[1333]1462 size = sizeof(BOOL);
[1328]1463 PrfQueryProfileData(fmprof, appname, "UnHilite", &fUnHilite, &size);
[1333]1464 size = sizeof(BOOL);
[1328]1465 PrfQueryProfileData(fmprof, FM3Str, "TileBackwards", &fTileBackwards, &size);
[1333]1466 size = sizeof(BOOL);
[1328]1467 PrfQueryProfileData(fmprof, appname, "LoadLongname", &fLoadLongnames, &size);
[1333]1468 size = sizeof(BOOL);
[1328]1469 PrfQueryProfileData(fmprof, appname, "VerifyWrites", &fVerify, &size);
[201]1470 DosSetVerify(fVerify);
[1333]1471 size = sizeof(BOOL);
[1328]1472 PrfQueryProfileData(fmprof, appname, "DontMoveMouse", &fDontMoveMouse, &size);
[1333]1473 size = sizeof(BOOL);
[1328]1474 PrfQueryProfileData(fmprof, appname, "NoIconsFiles", &fNoIconsFiles, &size);
[1333]1475 size = sizeof(BOOL);
[1328]1476 PrfQueryProfileData(fmprof, appname, "NoIconsDirs", &fNoIconsDirs, &size);
[1333]1477 size = sizeof(BOOL);
[1328]1478 PrfQueryProfileData(fmprof, appname, "ForceUpper", &fForceUpper, &size);
[1333]1479 size = sizeof(BOOL);
[1328]1480 PrfQueryProfileData(fmprof, appname, "ForceLower", &fForceLower, &size);
[1333]1481 size = sizeof(BOOL);
[1328]1482 PrfQueryProfileData(fmprof, FM3Str, "TextTools", &fTextTools, &size);
[1333]1483 size = sizeof(BOOL);
[1328]1484 PrfQueryProfileData(fmprof, FM3Str, "ToolTitles", &fToolTitles, &size);
[1333]1485 size = sizeof(BOOL);
[1328]1486 PrfQueryProfileData(fmprof, appname, "DoubleClickOpens", &fDCOpens, &size);
[1333]1487 size = sizeof(BOOL);
[1328]1488 PrfQueryProfileData(fmprof, appname, "LinkSetsIcon", &fLinkSetsIcon, &size);
1489 size = sizeof(INT);
1490 PrfQueryProfileData(fmprof, appname, "Sort", &sortFlags, &size);
[1333]1491 size = sizeof(INT);
[1328]1492 PrfQueryProfileData(fmprof, appname, "TreeSort", &TreesortFlags, &size);
[1333]1493 size = sizeof(INT);
1494 PrfQueryProfileData(fmprof, appname, "CollectorSort", &CollectorsortFlags, &size);
1495 PrfQueryProfileString(fmprof, appname, "Targetdir", NULL, targetdir, sizeof(targetdir));
[201]1496 if (!IsValidDir(targetdir))
1497 *targetdir = 0;
[1333]1498 PrfQueryProfileString(fmprof, appname, "ExtractPath", NULL, extractpath, sizeof(extractpath));
[1328]1499 size = sizeof(BOOL);
1500 PrfQueryProfileData(fmprof, FM3Str, "FileNamePathCnr", &fFileNameCnrPath, &size);
[1333]1501 PrfQueryProfileString(fmprof, appname, "Printer", "PRN", printer, sizeof(printer));
1502 PrfQueryProfileString(fmprof, appname, "DirCompare", NULL, dircompare, MaxComLineStrg);
1503 PrfQueryProfileString(fmprof, appname, "Viewer", NULL, viewer, MaxComLineStrg);
1504 PrfQueryProfileString(fmprof, appname, "Editor", NULL, editor, MaxComLineStrg);
1505 PrfQueryProfileString(fmprof, appname, "BinView", NULL, binview, MaxComLineStrg);
1506 PrfQueryProfileString(fmprof, appname, "BinEd", NULL, bined, MaxComLineStrg);
1507 PrfQueryProfileString(fmprof, appname, "Compare", NULL, compare, MaxComLineStrg);
1508 PrfQueryProfileString(fmprof, appname, "Virus", NULL, virus, MaxComLineStrg);
[1328]1509 size = sizeof(BOOL);
1510 PrfQueryProfileData(fmprof, appname, "FtpRunWPSDefault", &fFtpRunWPSDefault, &size);
[1333]1511 PrfQueryProfileString(fmprof, appname, "FTPRun", NULL, ftprun, MaxComLineStrg);
[917]1512 if (!*ftprun)
[892]1513 fFtpRunWPSDefault = TRUE;
[1328]1514 size = sizeof(BOOL);
1515 PrfQueryProfileData(fmprof, appname, "HttpRunWPSDefault", &fHttpRunWPSDefault, &size);
[1333]1516 PrfQueryProfileString(fmprof, appname, "HTTPRun", NULL, httprun, MaxComLineStrg);
[917]1517 if (!*httprun)
[892]1518 fHttpRunWPSDefault = TRUE;
[1333]1519 PrfQueryProfileString(fmprof, appname, "MailRun", NULL, mailrun, MaxComLineStrg);
1520 PrfQueryProfileString(fmprof, appname, "FtpRunDir", NULL, ftprundir, sizeof(ftprundir));
1521 PrfQueryProfileString(fmprof, appname, "HttpRunDir", NULL, httprundir, sizeof(httprundir));
1522 PrfQueryProfileString(fmprof, appname, "MailRunDir", NULL, mailrundir, sizeof(mailrundir));
1523 PrfQueryProfileString(fmprof, appname, "LastToolbar", NULL, lasttoolbar, sizeof(lasttoolbar));
[1328]1524 size = sizeof(BOOL);
[1333]1525 PrfQueryProfileData(fmprof, appname, "LibPathStrictHttpRun", &fLibPathStrictHttpRun, &size);
1526 size = sizeof(BOOL);
1527 PrfQueryProfileData(fmprof, appname, "LibPathStrictFtpRun", &fLibPathStrictFtpRun, &size);
1528 size = sizeof(BOOL);
1529 PrfQueryProfileData(fmprof, appname, "LibPathStrictMailRun", &fLibPathStrictMailRun, &size);
1530 size = sizeof(BOOL);
1531 PrfQueryProfileData(fmprof, appname, "NoMailtoMailRun", &fNoMailtoMailRun, &size);
1532 size = sizeof(BOOL);
1533 PrfQueryProfileData(fmprof, appname, "FollowTree", &fFollowTree, &size);
1534 size = sizeof(BOOL);
1535 PrfQueryProfileData(fmprof, appname, "StartMaximized", &fStartMaximized, &size);
[551]1536 if (!fStartMaximized) {
[1333]1537 size = sizeof(BOOL);
1538 PrfQueryProfileData(fmprof, appname, "StartMinimized", &fStartMinimized, &size);
[2]1539 }
[1333]1540 size = sizeof(BOOL);
[1328]1541 PrfQueryProfileData(fmprof, appname, "DefaultCopy", &fCopyDefault, &size);
[1333]1542 size = sizeof(BOOL);
[1328]1543 PrfQueryProfileData(fmprof, appname, "IdleCopy", &fRealIdle, &size);
[1333]1544 size = sizeof(BOOL);
1545 PrfQueryProfileData(fmprof, appname, "ArcStuffVisible", &fArcStuffVisible, &size);
1546 size = sizeof(BOOL);
[1328]1547 PrfQueryProfileData(fmprof, FM3Str, "NoTreeGap", &fNoTreeGap, &size);
[1333]1548 size = sizeof(BOOL);
1549 PrfQueryProfileData(fmprof, FM3Str, "VTreeOpensWPS", &fVTreeOpensWPS, &size);
1550 size = sizeof(BOOL);
[1328]1551 PrfQueryProfileData(fmprof, appname, "RemoteBug", &fRemoteBug, &size);
[1333]1552 size = sizeof(BOOL);
1553 PrfQueryProfileData(fmprof, appname, "Drag&DropDlg", &fDragndropDlg, &size);
1554 size = sizeof(BOOL);
[1328]1555 PrfQueryProfileData(fmprof, FM3Str, "UserComboBox", &fUserComboBox, &size);
[1333]1556 size = sizeof(BOOL);
[1328]1557 PrfQueryProfileData(fmprof, FM3Str, "MinDirOnOpen", &fMinOnOpen, &size);
[1333]1558 size = sizeof(BOOL);
1559 PrfQueryProfileData(fmprof, appname, "QuickArcFind", &fQuickArcFind, &size);
1560 size = sizeof(BOOL);
1561 PrfQueryProfileData(fmprof, FM3Str, "NoRemovableScan", &fNoRemovableScan, &size);
[1328]1562 size = sizeof(ULONG);
[1333]1563 PrfQueryProfileData(fmprof, FM3Str, "NoBrokenNotify", &NoBrokenNotify, &size);
1564 size = sizeof(ULONG);
1565 PrfQueryProfileData(fmprof, appname, "ContainerType", &ulCnrType, &size);
1566 size = sizeof(ULONG);
[1328]1567 PrfQueryProfileData(fmprof, appname, "FilesToGet", &FilesToGet, &size);
[789]1568 if (FilesToGet < FILESTOGET_MIN)
1569 FilesToGet = FILESTOGET_MIN;
1570 else if (FilesToGet > FILESTOGET_MAX)
1571 FilesToGet = FILESTOGET_MAX;
[1328]1572 size = sizeof(BOOL);
1573 PrfQueryProfileData(fmprof, FM3Str, "AutoView", &fAutoView, &size);
[1333]1574 size = sizeof(BOOL);
[1328]1575 PrfQueryProfileData(fmprof, FM3Str, "FM2Deletes", &fFM2Deletes, &size);
[1333]1576 size = sizeof(BOOL);
[1328]1577 PrfQueryProfileData(fmprof, FM3Str, "TrashCan", &fTrashCan, &size);
[2]1578
[1065]1579 LoadDetailsSwitches("DirCnr", &dsDirCnrDefault);
[784]1580
[2]1581 /* load pointers and icons we use */
[189]1582 hptrArrow = WinQuerySysPointer(HWND_DESKTOP, SPTR_ARROW, FALSE);
1583 hptrBusy = WinQuerySysPointer(HWND_DESKTOP, SPTR_WAIT, FALSE);
1584 hptrNS = WinQuerySysPointer(HWND_DESKTOP, SPTR_SIZENS, FALSE);
1585 hptrEW = WinQuerySysPointer(HWND_DESKTOP, SPTR_SIZEWE, FALSE);
1586 hptrFloppy = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, FLOPPY_ICON);
1587 hptrDrive = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, DRIVE_ICON);
1588 hptrRemovable = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, REMOVABLE_ICON);
1589 hptrCDROM = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, CDROM_ICON);
1590 hptrFile = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, FILE_ICON);
1591 hptrDir = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, DIR_FRAME);
1592 hptrArc = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, ARC_FRAME);
1593 hptrArt = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, ART_ICON);
1594 hptrSystem = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, FILE_SYSTEM_ICON);
1595 hptrHidden = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, FILE_HIDDEN_ICON);
[552]1596 hptrReadonly = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, FILE_READONLY_ICON);
[189]1597 hptrLast = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, LASTITEM_ICON);
1598 hptrRemote = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, REMOTE_ICON);
[552]1599 hptrVirtual = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, VIRTUAL_ICON);
1600 hptrRamdisk = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, RAMDISK_ICON);
[189]1601 if (!fNoDead)
1602 hptrFinger = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, FINGER_ICON);
[2]1603 else
[189]1604 hptrFinger = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, FINGER2_ICON);
1605 hptrApp = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, APP_ICON);
1606 hptrDunno = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, DUNNO_ICON);
1607 hptrEnv = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, ENV_ICON);
1608 hptrZipstrm = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, ZIPSTREAM_ICON);
[2]1609
[201]1610 // set up color array used by seeall.c and newview.c color dialog
1611
[189]1612 standardcolors[0] = CLR_WHITE;
1613 standardcolors[1] = CLR_BLACK;
1614 standardcolors[2] = CLR_BLUE;
1615 standardcolors[3] = CLR_RED;
1616 standardcolors[4] = CLR_PINK;
1617 standardcolors[5] = CLR_GREEN;
1618 standardcolors[6] = CLR_CYAN;
1619 standardcolors[7] = CLR_YELLOW;
1620 standardcolors[8] = CLR_DARKGRAY;
1621 standardcolors[9] = CLR_DARKBLUE;
[2]1622 standardcolors[10] = CLR_DARKRED;
1623 standardcolors[11] = CLR_DARKPINK;
1624 standardcolors[12] = CLR_DARKGREEN;
1625 standardcolors[13] = CLR_DARKCYAN;
1626 standardcolors[14] = CLR_BROWN;
1627 standardcolors[15] = CLR_PALEGRAY;
1628
1629 return TRUE;
1630}
1631
[189]1632HWND StartFM3(HAB hab, INT argc, CHAR ** argv)
1633{
[201]1634 HWND hwndFrame;
1635 HWND hwndClient;
1636 UINT x;
[189]1637 ULONG FrameFlags = FCF_TITLEBAR | FCF_SYSMENU |
[551]1638 FCF_SIZEBORDER | FCF_MINMAX |
1639 FCF_ACCELTABLE | FCF_MENU | FCF_ICON | FCF_TASKLIST | FCF_NOBYTEALIGN;
[2]1640
[551]1641 for (x = 1; x < argc; x++) {
[201]1642 if (*argv[x] == '~' && !argv[x][1])
1643 fReminimize = TRUE;
1644 if (*argv[x] == '+' && !argv[x][1])
1645 fLogFile = TRUE;
[551]1646 if (*argv[x] == '-') {
[201]1647 if (!argv[x][1])
[1156]1648 fNoSaveState = TRUE;
[201]1649 else
[1156]1650 strcpy(profile, &argv[x][1]);
[2]1651 }
1652 }
1653
1654 hwndFrame = WinCreateStdWindow(HWND_DESKTOP,
[1156]1655 WS_VISIBLE,
1656 &FrameFlags,
1657 WC_MAINWND,
1658 NULL,
1659 WS_VISIBLE | WS_ANIMATE,
1660 FM3ModHandle, MAIN_FRAME, &hwndClient);
[551]1661 if (hwndFrame) {
1662 WinSetWindowUShort(hwndFrame, QWS_ID, MAIN_FRAME);
[875]1663 hwndMainMenu = WinWindowFromID(hwndFrame, FID_MENU);
[551]1664 if (!WinRestoreWindowPos(FM2Str, "MainWindowPos", hwndFrame)) {
[2]1665
1666 ULONG fl = SWP_MOVE | SWP_SIZE;
1667 RECTL rcl;
[189]1668 ULONG icz = WinQuerySysValue(HWND_DESKTOP, SV_CYICON) * 3L;
1669 ULONG bsz = WinQuerySysValue(HWND_DESKTOP, SV_CYSIZEBORDER);
[2]1670
[551]1671 WinQueryWindowRect(HWND_DESKTOP, &rcl);
[2]1672 rcl.yBottom += icz;
1673 rcl.yTop -= bsz;
1674 rcl.xLeft += bsz;
1675 rcl.xRight -= bsz;
1676 WinSetWindowPos(hwndFrame,
[1156]1677 HWND_TOP,
1678 rcl.xLeft,
1679 rcl.yBottom,
1680 rcl.xRight - rcl.xLeft, rcl.yTop - rcl.yBottom, fl);
[2]1681 }
[189]1682 if (fLogFile)
[551]1683 LogFileHandle = _fsopen("FM2.LOG", "a+", SH_DENYWR);
[189]1684 if (hwndHelp)
[551]1685 WinAssociateHelpInstance(hwndHelp, hwndFrame);
1686 PostMsg(hwndClient, UM_SETUP, MPFROMLONG(argc), MPFROMP(argv));
[2]1687 }
1688 return hwndFrame;
1689}
[32]1690
[985]1691BOOL CheckFileHeader(CHAR *filespec, CHAR *signature, LONG offset)
1692{
1693 HFILE handle;
1694 ULONG action;
1695 ULONG len = strlen(signature);
1696 ULONG l;
1697 // CHAR buffer[80];
[1156]1698 CHAR buffer[4096]; // 06 Oct 07 SHL Protect against NTFS defect
[985]1699 BOOL ret = FALSE;
1700
1701 DosError(FERR_DISABLEHARDERR);
1702 if (DosOpen(filespec,
[1156]1703 &handle,
1704 &action,
1705 0,
1706 0,
1707 OPEN_ACTION_FAIL_IF_NEW |
1708 OPEN_ACTION_OPEN_IF_EXISTS,
1709 OPEN_FLAGS_FAIL_ON_ERROR |
1710 OPEN_FLAGS_NOINHERIT |
1711 OPEN_FLAGS_RANDOMSEQUENTIAL |
1712 OPEN_SHARE_DENYNONE | OPEN_ACCESS_READONLY, 0))
[985]1713 ret = FALSE;
1714 else {
1715 // Try signature match
1716 l = len;
1717 l = min(l, 79);
1718 if (!DosChgFilePtr(handle,
[1156]1719 abs(offset),
1720 (offset >= 0) ?
1721 FILE_BEGIN : FILE_END, &len)) {
[985]1722 if (!DosRead(handle, buffer, l, &len) && len == l) {
[1156]1723 if (!memcmp(signature, buffer, l))
1724 ret = TRUE; // Matched
[985]1725 }
1726 }
1727 }
[1156]1728 DosClose(handle); /* Either way, we're done for now */
1729 return ret; /* Return TRUE if matched */
[985]1730}
1731
[189]1732int CheckVersion(int vermajor, int verminor)
1733{
[179]1734 int ok = 0;
[32]1735
[179]1736 // fixme to do useful check - was missing in base source
1737
[32]1738#if 0
[551]1739 if (vermajor && verminor) {
[32]1740 *vermajor = VERMAJOR;
1741 *verminor = VERMINOR;
[179]1742 ok = 1;
[32]1743 }
1744#endif
[189]1745
[179]1746 ok = 1;
[32]1747
[179]1748 return ok;
[32]1749}
[783]1750
1751#ifdef __WATCOMC__
1752#pragma alloc_text(INIT,LibMain,InitFM3DLL,DeInitFM3DLL)
1753#pragma alloc_text(INIT1,StartFM3,FindSwapperDat)
1754#endif
Note: See TracBrowser for help on using the repository browser.