source: trunk/dll/init.c@ 1209

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

Ticket 187: Move data declarations/definitions out of fm3dll.h

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