source: trunk/dll/init.c@ 1045

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

One last piece of the trashcan stuff (ticket 43)

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