source: trunk/dll/init.c@ 1326

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

Changes to avoid duplicate directory names on scan using StubbyScanThread.

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