source: trunk/dll/init.c@ 1083

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

Ticket 114: Support user-selectable env. strings in Tree container.

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