source: trunk/dll/init.c@ 1082

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

Changes so FM2 will use TMP/TEMP directory for all temp files; Replaced save_dir2 with global variable so BldFullPathName could easily replace code that performed the same function; Added #ifdef FORTIFY to free_ function that are only used when fortified.

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