source: trunk/dll/init.c@ 1217

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

init.c: moved a misplaced function declaration.

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