source: trunk/dll/init.c@ 1313

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

Improved fix to delete race condition with container updates (Ticket 304)

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