source: trunk/dll/init.c@ 1156

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

Ticket 187: Draft 1: Functions only

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