source: trunk/dll/init.c@ 1358

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

Comments for CS 1354/55

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