source: trunk/dll/init.c@ 1335

Last change on this file since 1335 was 1335, checked in by Steven Levine, 17 years ago

Ticket 26: Add exception handlers to all threads using xbeginthread

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