source: trunk/dll/init.c@ 1104

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

Replace save_dir2(dir) with strcpy(dir, pFM2SaveDirectory)

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