source: trunk/dll/init.c@ 1317

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

Add an event semaphore to prevent duplicate directory names in tree caused by RestoreDirCnrState running concurrently with the StubbyThread for the same drive. (Ticket 25)

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