source: trunk/dll/init.c@ 1303

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

Last part of remove or replace with a mutex semaphore DosEnterCriSec where appropriate. (Ticket 308) Note the partial commits for this ticket won't build without this.

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