source: trunk/dll/init.c@ 1351

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

Additional code cleanup

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