source: trunk/dll/init.c@ 989

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

Refactor fm3dll.h to create command.h; broken ini is now replaced with backup or new ini as available; more variable command line ledth changes

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