source: trunk/dll/init.c@ 1065

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

Ticket 230: Simplified code and eliminated some local variables by incorporating
all the details view settings (both the global variables and those in the
DIRCNRDATA struct) into a new struct: DETAILS_SETTINGS.

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