source: trunk/dll/init.c@ 1224

Last change on this file since 1224 was 1224, checked in by John Small, 17 years ago

Ticket 187: Moved typedef's and some #define's from fm3dll.h

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