source: trunk/dll/init.c@ 998

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

Added comments and removed dead code.

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