source: trunk/dll/init.c@ 1306

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

Added option to use subdirectory based on the archive name for extraction from the arc container; it is set in the notebook and separate from the extract dialog setting; includes help file update, comments and cleanup (Ticket 22)

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