source: trunk/dll/init.c@ 1063

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

Fortify ifdef reformat

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 49.0 KB
RevLine 
[32]1
2/***********************************************************************
3
4 $Id: init.c 1063 2008-07-11 03:33:36Z gyoung $
5
6 Initialization
7
8 Copyright (c) 1993-98 M. Kimes
[907]9 Copyright (c) 2001, 2008 Steven H. Levine
[32]10
[133]11 11 Jun 02 SHL Add CheckVersion
12 11 Jun 03 SHL Add JFS and FAT32 support
13 25 Nov 03 SHL InitFM3DLL: correct strings error mesage
14 23 May 05 SHL Use datamin.h
[179]15 26 May 05 SHL Comments
[189]16 06 Jun 05 SHL indent -i2
[201]17 06 Jun 05 SHL Rework FindSwapperDat for VAC3.65 compat
[339]18 13 Jul 06 SHL Use Runtime_Error
19 13 Jul 06 SHL Sync with current style
[404]20 29 Jul 06 SHL Use xfgets
[526]21 22 Oct 06 GKY Add NDFS32 support
[552]22 18 Feb 07 GKY Add ISOFS, RAMFS support
[593]23 30 Mar 07 GKY Defined golbals for removing GetPString for window class names
[627]24 21 Apr 07 GKY Find FM2Utils by path or utils directory eleminate fAddUtils global
[690]25 15 Jun 07 SHL Make OpenWatcom compatible
[705]26 23 Jun 07 GKY Fix WORPLACE_PROCESS enviroment check logic
[718]27 28 Jun 07 SHL Rework WORKPLACE_PROCESS check to match reality
[756]28 03 Aug 07 GKY Enlarged and made setable everywhere Findbuf (speed file loading)
[775]29 06 Aug 07 GKY Reduce DosSleep times (ticket 148)
[783]30 13 Aug 07 SHL Move #pragma alloc_text to end for OpenWatcom compat
[784]31 18 Aug 07 JBS Added code to read Details* keys from the INI file (Ticket 118)
[789]32 19 Aug 07 SHL Ensure FilesToGet in valid range
[796]33 21 Aug 07 GKY Make Subject column in dircnr sizable and movable from the rigth to the left pane
[803]34 23 Aug 07 SHL InitFM3DLL: report INI file DosSetPathInfo error correctly
35 23 Aug 07 SHL Use BldFullPathName
36 25 Aug 07 SHL Work around DosSetPathInfo kernel defect
[827]37 01 Sep 07 GKY Use xDosSetPathInfo to fix case where FS3 buffer crosses 64k boundry
[860]38 10 Nov 07 GKY Get thousands separator from country info for file sizes.
[878]39 26 Nov 07 GKY Eliminate check of ext path on start up
[888]40 17 Dec 07 GKY Make WPURLDEFAULTSETTINGS the fall back for ftp/httprun
[940]41 13 Jan 08 GKY Get Subjectwidth/Subjectleft working in the collector.
[952]42 12 Feb 08 SHL Compile OpenWatcom version into binary
[985]43 29 Feb 08 GKY Changes to enable user settable command line length
44 29 Feb 08 GKY Refactor global command line variables to notebook.h
[998]45 08 Mar 08 JBS Ticket 230: Replace prefixless INI keys for default directory containers with
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();
[189]540 if (FM3ModHandle)
[2]541 DosFreeModule(FM3ModHandle);
542
[551]543 DosExitList(EXLST_REMOVE, DeInitFM3DLL);
[2]544}
545
[189]546BOOL InitFM3DLL(HAB hab, int argc, char **argv)
547{
[2]548 /*
549 * this function should be called by any application using this DLL right
550 * after setting up a message queue
551 */
552
553 CLASSINFO clinfo;
[201]554 APIRET rc;
555 APIRET rcl = 1;
556 APIRET rcq = 1;
[803]557 PFN pfnResVersion = (PFN)NULL;
[201]558 ULONG RVMajor = 0;
559 ULONG RVMinor = 0;
560 ULONG ret = 0;
[849]561 FILESTATUS3 fs3; // 25 Aug 07 SHL
[803]562 PSZ env;
[201]563 CHAR dllfile[CCHMAXPATH];
564 ULONG size;
[2]565
[551]566 if (!StringsLoaded()) {
[2]567 saymsg(MB_ENTER,
[189]568 HWND_DESKTOP,
569 "Error",
570 "FM3RES.STR isn't in right format, at least "
571 "for this version of FM/2.");
[2]572 return FALSE;
573 }
574
[201]575 strcpy(dllfile, "FM3RES");
576 env = getenv("FM3INI");
[551]577 if (env) {
[201]578 DosError(FERR_DISABLEHARDERR);
[849]579 rc = DosQueryPathInfo(env, FIL_STANDARD, &fs3, sizeof(fs3));
[551]580 if (!rc) {
[803]581 if (fs3.attrFile & FILE_DIRECTORY) {
582 BldFullPathName(dllfile, env, "FM3RES"); // 23 Aug 07 SHL
[201]583 DosError(FERR_DISABLEHARDERR);
[849]584 if (DosQueryPathInfo(dllfile, FIL_STANDARD, &fs3, sizeof(fs3)))
[201]585 strcpy(dllfile, "FM3RES");
[2]586 }
587 }
[201]588 }
[551]589 rcl = DosLoadModule(NULL, 0, dllfile, &FM3ModHandle);
590 if (rcl) {
[339]591 saymsg(MB_CANCEL | MB_ICONEXCLAMATION,
592 HWND_DESKTOP,
[551]593 GetPString(IDS_ERRORTEXT), GetPString(IDS_FM3RESERROR1TEXT));
[339]594 return FALSE;
595 }
596 else {
597 rc = DosExitList(EXLST_ADD, DeInitFM3DLL);
[551]598 if (rc) {
[803]599 Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
600 "DosExitList");
[339]601 }
[551]602 rcq = DosQueryProcAddr(FM3ModHandle, 1, "ResVersion", &pfnResVersion);
[201]603 if (!rcq)
604 ret = pfnResVersion(&RVMajor, &RVMinor);
605 }
[551]606 if (RVMajor < VERMAJOR || (RVMajor == VERMAJOR && RVMinor < VERMINOR)) {
[201]607 saymsg(MB_ENTER,
608 HWND_DESKTOP,
609 GetPString(IDS_ERRORTEXT),
610 GetPString(IDS_FM3RESERROR2TEXT),
611 !rcq ?
[551]612 GetPString(IDS_FM3RESERROR3TEXT) :
613 !rcl ?
614 GetPString(IDS_FM3RESERROR4TEXT) :
615 GetPString(IDS_FM3RESERROR5TEXT), RVMajor, RVMinor, rcl, rcq, ret);
[201]616 return FALSE;
[2]617 }
618
[189]619 ArgDriveFlags(argc, argv);
[2]620 FillInDriveFlags(NULL);
621
[189]622 if (!*profile)
623 strcpy(profile, "FM3.INI");
[2]624 mypid = getpid();
625 /* give default appname if none set by caller */
[189]626 if (!*appname)
627 strcpy(appname, FM3Str);
[2]628 /* save appname; may be reset below */
[189]629 strcpy(realappname, appname);
630 if (!strcmp(appname, FM3Str))
[803]631 DosSetMaxFH(100);
[189]632 else if (!strcmp(appname, "VDir") ||
633 !strcmp(appname, "VTree") ||
634 !strcmp(appname, "VCollect") ||
[551]635 !strcmp(appname, "SEEALL") || !strcmp(appname, "FM/4"))
[803]636 DosSetMaxFH(60);
[2]637 else
[803]638 DosSetMaxFH(40);
[2]639
[189]640 if (DosQuerySysInfo(QSV_VERSION_MAJOR,
641 QSV_VERSION_MINOR,
[803]642 OS2ver,
643 sizeof(OS2ver))) {
[2]644 OS2ver[0] = 2;
645 OS2ver[1] = 1;
646 }
647
648 /* set up default root names for temp archive goodies */
[189]649 if (!fAmAV2)
650 strcpy(ArcTempRoot, "$FM$ARC$");
[2]651 else
[189]652 strcpy(ArcTempRoot, "$AV$ARC$");
[2]653
654 /* initialize random number generator */
655 srand(time(NULL) + clock());
656
657 priority_bumped();
658
659 /* _heapmin() is done in a separate thread -- start it */
[551]660 if (_beginthread(HeapThread, NULL, 32768, NULL) == -1) {
661 Runtime_Error(pszSrcFile, __LINE__,
662 GetPString(IDS_COULDNTSTARTTHREADTEXT));
[339]663 return FALSE;
664 }
[917]665
[189]666 /* timer messages are sent from a separate thread -- start it */
[803]667 if (!StartTimer()) {
668 Runtime_Error(pszSrcFile, __LINE__,
669 GetPString(IDS_COULDNTSTARTTHREADTEXT));
[2]670 return FALSE;
[803]671 }
[2]672
[718]673 /* Are we the workplace shell? */
[705]674 env = getenv("WORKPLACE_PROCESS");
[718]675 fWorkPlace = env != NULL &&
676 (stricmp(env, "YES") == 0 || atoi(env) == 1);
677
[189]678 if ((!strchr(profile, '\\') && !strchr(profile, ':')) ||
[803]679 !(fmprof = PrfOpenProfile((HAB)0, profile)))
680 {
[2]681 /* figure out where to put INI file... */
[803]682 CHAR inipath[CCHMAXPATH];
[2]683
684 DosError(FERR_DISABLEHARDERR);
685 save_dir2(HomePath);
686 DosError(FERR_DISABLEHARDERR);
[189]687 memset(driveserial, -1, sizeof(driveserial));
[2]688 *inipath = 0;
689 env = getenv("FM3INI");
[551]690 if (env) {
[189]691 strcpy(inipath, env);
[2]692 DosError(FERR_DISABLEHARDERR);
[849]693 rc = DosQueryPathInfo(inipath, FIL_STANDARD, &fs3, sizeof(fs3));
[551]694 if (!rc) {
[803]695 if (fs3.attrFile & FILE_DIRECTORY)
696 BldFullPathName(inipath, inipath, profile);
[2]697 }
698 }
[551]699 if (!env) {
[2]700 env = searchpath(profile);
[189]701 if (!env)
702 env = profile;
703 strcpy(inipath, env);
[2]704 }
[201]705
[2]706 /* in some odd cases the INI file can get set to readonly status */
707 /* here we test it and reset the readonly bit if necessary */
[201]708 if (!*inipath)
709 strcpy(inipath, profile);
710 DosError(FERR_DISABLEHARDERR);
[803]711
[917]712 rc = DosQueryPathInfo(inipath, FIL_STANDARD, &fs3, sizeof(fs3));
713 if (rc) {
714 if (rc == ERROR_FILE_NOT_FOUND)
715 fWantFirstTimeInit = TRUE;
716 }
717 else {
[989]718 if (!CheckFileHeader(inipath, "\xff\xff\xff\xff\x14\x00\x00\x00", 0L)) {
719 saymsg(MB_ENTER,HWND_DESKTOP,DEBUG_STRING,
720 "Check INI header failed will attempt to replace with backup \\
721 if backup fails or not found will open with new ini");
722 DosCopy("FM3.INI", "FM3INI.BAD", DCPY_EXISTING);
723 DosCopy("FM3INI.BAK", "FM3.INI", DCPY_EXISTING);
724 if (!CheckFileHeader(inipath, "\xff\xff\xff\xff\x14\x00\x00\x00", 0L)) {
725 DosCopy("FM3.INI", "FM3INI2.BAD", DCPY_EXISTING);
726 fWantFirstTimeInit = TRUE;
727 }
[2]728 }
[989]729 if (!fWantFirstTimeInit) {
730 fIniExisted = TRUE;
731 if (fs3.attrFile & (FILE_READONLY | FILE_HIDDEN | FILE_SYSTEM)) {
732 fs3.attrFile &= ~(FILE_READONLY | FILE_HIDDEN | FILE_SYSTEM);
733 rc = xDosSetPathInfo(inipath, FIL_STANDARD, &fs3, sizeof(fs3), 0);
734 if (rc) {
735 Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
736 GetPString(IDS_INIREADONLYTEXT), inipath);
737 }
738 }
739 }
[2]740 }
[803]741 fmprof = PrfOpenProfile((HAB)0, inipath);
[551]742 if (!fmprof) {
[189]743 strcpy(inipath, "FM3.INI");
[803]744 fmprof = PrfOpenProfile((HAB)0, inipath);
[2]745 }
[201]746
[917]747 // 10 Jan 08 SHL fixme to do first time if new ini
748 // 10 Jan 08 SHL post UM_FIRSTTIME to main window
[551]749 if (!fmprof) {
750 Win_Error(NULLHANDLE, NULLHANDLE, pszSrcFile, __LINE__,
[989]751 "PrfOpenProfile");
[2]752 return FALSE;
753 }
754 }
755
756 FindSwapperDat();
757
[201]758 size = sizeof(BOOL);
759 PrfQueryProfileData(fmprof,
760 FM3Str,
[803]761 "SeparateParms",
762 &fSeparateParms,
763 &size);
[201]764 if (!fSeparateParms)
765 strcpy(appname, FM3Str);
[2]766
767 /* start help */
[189]768 memset(&hini, 0, sizeof(HELPINIT));
[2]769 hini.cb = sizeof(HELPINIT);
[849]770 hini.ulReturnCode = 0;
[2]771 hini.pszTutorialName = NULL;
[189]772 hini.phtHelpTable = (PHELPTABLE) MAKELONG(ID_HELPTABLE, 0xffff);
773 hini.hmodAccelActionBarModule = (HMODULE) 0;
[2]774 hini.idAccelTable = 0;
775 hini.idActionBar = 0;
776 hini.pszHelpWindowTitle = GetPString(IDS_FM2HELPTITLETEXT);
777 hini.fShowPanelId = CMIC_HIDE_PANEL_ID;
778 hini.pszHelpLibraryName = "FM3.HLP";
[189]779 hwndHelp = WinCreateHelpInstance(hab, &hini);
[551]780 if (!hwndHelp) {
[201]781 static CHAR helppath[CCHMAXPATH]; // fixme to be local?
[2]782
783 env = getenv("FM3INI");
[551]784 if (env) {
[189]785 strcpy(helppath, env);
[2]786 DosError(FERR_DISABLEHARDERR);
[849]787 rc = DosQueryPathInfo(helppath, FIL_STANDARD, &fs3, sizeof(fs3));
[551]788 if (!rc) {
[803]789 if (fs3.attrFile & FILE_DIRECTORY) {
790 BldFullPathName(helppath, helppath, "FM3.HLP");
[189]791 hini.pszHelpLibraryName = helppath;
792 hwndHelp = WinCreateHelpInstance(hab, &hini);
793 }
[2]794 }
795 }
796 }
[551]797 if (!hwndHelp) {
[2]798 saymsg(MB_ENTER | MB_ICONEXCLAMATION,
[189]799 HWND_DESKTOP,
800 GetPString(IDS_FM2TROUBLETEXT),
801 GetPString(IDS_CANTLOADHELPTEXT),
802 GetPString(IDS_NOHELPACCEPTTEXT));
[2]803 }
804
805 /* a couple of default window procs so we don't have to look them up later */
[189]806 if (WinQueryClassInfo(hab, WC_CONTAINER, &clinfo))
[2]807 PFNWPCnr = clinfo.pfnWindowProc;
[179]808 // saymsg(MB_ENTER,HWND_DESKTOP,"Container flags:","%08lx",clinfo.flClassStyle);
[189]809 if (WinQueryClassInfo(hab, WC_FRAME, &clinfo))
[2]810 PFNWPFrame = clinfo.pfnWindowProc;
[179]811 // saymsg(MB_ENTER,HWND_DESKTOP,"Frame flags:","%08lx",clinfo.flClassStyle);
[189]812 if (WinQueryClassInfo(hab, WC_BUTTON, &clinfo))
[2]813 PFNWPButton = clinfo.pfnWindowProc;
[179]814 // saymsg(MB_ENTER,HWND_DESKTOP,"Button flags:","%08lx",clinfo.flClassStyle);
[189]815 if (WinQueryClassInfo(hab, WC_STATIC, &clinfo))
[2]816 PFNWPStatic = clinfo.pfnWindowProc;
[179]817 // saymsg(MB_ENTER,HWND_DESKTOP,"Static flags:","%08lx",clinfo.flClassStyle);
[189]818 if (WinQueryClassInfo(hab, WC_MLE, &clinfo))
[2]819 PFNWPMLE = clinfo.pfnWindowProc;
[179]820 // saymsg(MB_ENTER,HWND_DESKTOP,"MLE flags:","%08lx",clinfo.flClassStyle);
[551]821 if (!PFNWPCnr || !PFNWPFrame || !PFNWPButton || !PFNWPStatic || !PFNWPMLE) {
[339]822 Runtime_Error(pszSrcFile, __LINE__, "WinQueryClassInfo");
[2]823 return FALSE;
824 }
825
826 /* register window classes we use */
827 WinRegisterClass(hab,
[593]828 WC_MAINWND,
[189]829 MainWndProc,
[551]830 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 8);
[2]831 WinRegisterClass(hab,
[593]832 WC_MAINWND2,
[189]833 MainWndProc2,
[551]834 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 4);
[2]835 WinRegisterClass(hab,
[593]836 WC_TREECONTAINER,
[189]837 TreeClientWndProc,
[551]838 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 2);
[2]839 WinRegisterClass(hab,
[593]840 WC_DIRCONTAINER,
[189]841 DirClientWndProc,
[551]842 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 2);
[2]843 WinRegisterClass(hab,
[593]844 WC_COLLECTOR,
[189]845 CollectorClientWndProc,
[551]846 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 2);
[2]847 WinRegisterClass(hab,
[593]848 WC_ARCCONTAINER,
[189]849 ArcClientWndProc,
[551]850 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 2);
[2]851 WinRegisterClass(hab,
[593]852 WC_MLEEDITOR,
[189]853 MLEEditorProc,
[551]854 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 2);
[2]855 WinRegisterClass(hab,
[593]856 WC_INIEDITOR,
[189]857 IniProc,
[551]858 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 2);
[2]859 WinRegisterClass(hab,
[593]860 WC_TOOLBACK,
[952]861 ToolBackProc,
862 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
863 sizeof(PVOID));
[2]864 WinRegisterClass(hab,
[593]865 WC_DRIVEBACK,
[189]866 DriveBackProc,
867 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
868 sizeof(PVOID));
[2]869 WinRegisterClass(hab,
[593]870 WC_SEEALL,
[189]871 SeeAllWndProc,
[551]872 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID));
[2]873 WinRegisterClass(hab,
[593]874 WC_NEWVIEW,
[189]875 ViewWndProc,
[551]876 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID));
[2]877 WinRegisterClass(hab,
[593]878 WC_TOOLBUTTONS,
[189]879 ChildButtonProc,
880 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
881 sizeof(PVOID));
[2]882 WinRegisterClass(hab,
[593]883 WC_DRIVEBUTTONS,
[189]884 DriveProc,
885 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
886 sizeof(PVOID));
[2]887 WinRegisterClass(hab,
[593]888 WC_BUBBLE,
[189]889 BubbleProc,
890 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
891 sizeof(ULONG) * 2);
[2]892 WinRegisterClass(hab,
[593]893 WC_STATUS,
[189]894 StatusProc,
895 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
896 sizeof(ULONG));
[2]897 WinRegisterClass(hab,
[593]898 WC_DIRSTATUS,
[189]899 DirTextProc,
900 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
901 sizeof(ULONG));
[2]902 WinRegisterClass(hab,
[593]903 WC_TREESTATUS,
[189]904 TreeStatProc,
905 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
906 sizeof(ULONG));
[2]907 WinRegisterClass(hab,
[593]908 WC_ARCSTATUS,
[189]909 ArcTextProc,
910 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
911 sizeof(ULONG));
[2]912 WinRegisterClass(hab,
[593]913 WC_COLSTATUS,
[189]914 CollectorTextProc,
915 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
916 sizeof(ULONG));
[2]917 WinRegisterClass(hab,
[593]918 WC_SEESTATUS,
[189]919 SeeStatusProc,
920 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
921 sizeof(ULONG));
[2]922 WinRegisterClass(hab,
[593]923 WC_VIEWSTATUS,
[189]924 ViewStatusProc,
925 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
926 sizeof(ULONG));
[2]927 WinRegisterClass(hab,
[593]928 WC_ERRORWND,
[189]929 NotifyWndProc,
930 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
931 sizeof(PVOID));
[2]932 WinRegisterClass(hab,
[593]933 WC_MINITIME,
[189]934 MiniTimeProc,
935 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
936 sizeof(PVOID) * 2);
[2]937 WinRegisterClass(hab,
[593]938 WC_DATABAR,
[551]939 DataProc, CS_SIZEREDRAW, sizeof(PVOID));
[2]940 WinRegisterClass(hab,
[593]941 WC_TREEOPENBUTTON,
[189]942 OpenButtonProc,
943 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
944 sizeof(PVOID));
[2]945 WinRegisterClass(hab,
[593]946 WC_AUTOVIEW,
[189]947 AutoViewProc,
948 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
949 sizeof(PVOID));
[2]950 WinRegisterClass(hab,
[593]951 WC_LED,
[189]952 LEDProc,
953 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
954 sizeof(PVOID));
[2]955
956 /*
[201]957 * set some defaults (note: everything else automatically initialized
[2]958 * to 0)
959 */
960 detailssize = detailsea = detailslwdate = detailslwtime = detailsattr =
[189]961 detailsicon = fAutoTile = fConfirmDelete = fLoadSubject = fUnHilite =
962 fLoadLongnames = fToolbar = fSaveState = fGuessType = fToolbarHelp =
963 fAutoAddDirs = fUseNewViewer = fDataToFore = fDataShowDrives =
964 fSplitStatus = fDragndropDlg = fQuickArcFind = fKeepCmdLine =
965 fMoreButtons = fDrivebar = fCollapseFirst = fSwitchTree =
966 fSwitchTreeExpand = fNoSearch = fCustomFileDlg = fOtherHelp =
967 fSaveMiniCmds = fUserComboBox = fFM2Deletes = fConfirmTarget =
[850]968 fShowTarget = fDrivebarHelp = fCheckMM = TRUE;
[2]969 ulCnrType = CCS_EXTENDSEL;
[789]970 FilesToGet = FILESTOGET_MIN;
[985]971 MaxComLineStrg = MAXCOMLINESTRGDEFAULT;
[752]972 AutoviewHeight = 48;
[189]973 strcpy(printer, "PRN");
[2]974 prnwidth = 80;
975 prnlength = 66;
976 prntmargin = 6;
977 prnbmargin = 6;
978 prnlmargin = 6;
979 prnrmargin = 3;
980 prnspacing = 1;
981 prntabspaces = 8;
982 CollectorsortFlags = sortFlags = SORT_DIRSFIRST;
983
[860]984 //Get default Country info
985 {
986 COUNTRYCODE Country = {0};
987 ULONG ulInfoLen = 0;
988 COUNTRYINFO CtryInfo = {0};
989
990 DosQueryCtryInfo(sizeof(CtryInfo), &Country,
[917]991 &CtryInfo, &ulInfoLen);
[860]992 *ThousandsSeparator = CtryInfo.szThousandsSeparator[0];
993 }
994
[201]995 // load preferences from profile (INI) file
[985]996 size = sizeof(ULONG);
997 PrfQueryProfileData(fmprof, appname, "MaxComLineStrg", &MaxComLineStrg, &size);
[1004]998 // Give user one chance to reset the default command line length to 1024 (4os2's unexpanded max)
999 if (MaxComLineStrg == 2048) {
1000 BOOL MaxComLineChecked = FALSE;
1001
1002 size = sizeof(BOOL);
1003 PrfQueryProfileData(fmprof, appname, "MaxComLineChecked", &MaxComLineChecked, &size);
1004 if (!MaxComLineChecked) {
1005 ret = saymsg(MB_YESNO,
1006 HWND_DESKTOP,
1007 NullStr,
1008 GetPString(IDS_CHANGECMDLINELENGTHDEFAULT));
1009 if (ret == MBID_YES)
1010 MaxComLineStrg = 1024;
1011 MaxComLineChecked = TRUE;
1012 PrfWriteProfileData(fmprof, appname, "MaxComLineChecked", &MaxComLineChecked, sizeof(BOOL));
1013 }
1014 }
[985]1015 if (MaxComLineStrg < CMDLNLNGTH_MIN)
1016 MaxComLineStrg = CMDLNLNGTH_MIN;
1017 else if (MaxComLineStrg > CMDLNLNGTH_MAX)
1018 MaxComLineStrg = CMDLNLNGTH_MAX;
1019 editor = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
1020 if (!editor)
1021 return 0; //already complained
1022 viewer = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
1023 if (!viewer)
1024 return 0; //already complained
1025 virus = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
1026 if (!virus)
1027 return 0; //already complained
1028 compare = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
1029 if (!compare)
1030 return 0; //already complained
1031 binview = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
1032 if (!binview)
1033 return 0; //already complained
1034 bined = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
1035 if (!bined)
1036 return 0; //already complained
1037 dircompare = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
1038 if (!dircompare)
1039 return 0; //already complained
1040 ftprun = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
1041 if (!ftprun)
1042 return 0; //already complained
1043 httprun = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
1044 if (!httprun)
1045 return 0; //already complained
1046 mailrun = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
1047 if (!mailrun)
1048 return 0; //already complained
[201]1049 size = sizeof(BOOL);
[803]1050 PrfQueryProfileData(fmprof, appname, "ShowTarget", &fShowTarget, &size);
[201]1051 size = sizeof(BOOL);
[803]1052 PrfQueryProfileData(fmprof, appname, "CheckMM", &fCheckMM, &size);
[201]1053 size = sizeof(BOOL);
[803]1054 PrfQueryProfileData(fmprof, appname, "ChangeTarget", &fChangeTarget, &size);
[201]1055 size = sizeof(BOOL);
[803]1056 PrfQueryProfileData(fmprof, appname, "ConfirmTarget", &fConfirmTarget, &size);
[201]1057 size = sizeof(BOOL);
[803]1058 PrfQueryProfileData(fmprof, FM3Str, "CustomFileDlg", &fCustomFileDlg, &size);
[201]1059 size = sizeof(BOOL);
[803]1060 PrfQueryProfileData(fmprof, FM3Str, "SaveMiniCmds", &fSaveMiniCmds, &size);
[201]1061 size = sizeof(BOOL);
[803]1062 PrfQueryProfileData(fmprof, appname, "SaveBigCmds", &fSaveBigCmds, &size);
[201]1063 size = sizeof(BOOL);
[803]1064 PrfQueryProfileData(fmprof, appname, "NoFoldMenu", &fNoFoldMenu, &size);
[201]1065 size = sizeof(BOOL);
[803]1066 PrfQueryProfileData(fmprof, FM3Str, "ThreadNotes", &fThreadNotes, &size);
[551]1067 size = sizeof(BOOL);
[803]1068 PrfQueryProfileData(fmprof, FM3Str, "Prnpagenums", &prnpagenums, &size);
[201]1069 size = sizeof(BOOL);
[803]1070 PrfQueryProfileData(fmprof, FM3Str, "Prnalt", &prnalt, &size);
[201]1071 size = sizeof(BOOL);
[803]1072 PrfQueryProfileData(fmprof, FM3Str, "Prnformat", &prnformat, &size);
[201]1073 size = sizeof(BOOL);
1074 PrfQueryProfileData(fmprof, FM3Str, "Prnformfeedbefore",
[803]1075 &prnformfeedbefore, &size);
[201]1076 size = sizeof(BOOL);
[803]1077 PrfQueryProfileData(fmprof, FM3Str,
1078 "Prnformfeedafter",&prnformfeedafter, &size);
[201]1079 size = sizeof(ULONG);
[803]1080 PrfQueryProfileData(fmprof, FM3Str, "Prntabspaces", &prntabspaces, &size);
[201]1081 size = sizeof(ULONG);
[803]1082 PrfQueryProfileData(fmprof, FM3Str, "Prnwidth", &prnwidth, &size);
[201]1083 size = sizeof(ULONG);
[803]1084 PrfQueryProfileData(fmprof, FM3Str, "Prnlength", &prnlength, &size);
[201]1085 size = sizeof(ULONG);
[803]1086 PrfQueryProfileData(fmprof, FM3Str, "Prntmargin", &prntmargin, &size);
[201]1087 size = sizeof(ULONG);
[803]1088 PrfQueryProfileData(fmprof, FM3Str, "Prnbmargin", &prnbmargin, &size);
[201]1089 size = sizeof(ULONG);
[803]1090 PrfQueryProfileData(fmprof, FM3Str, "Prnlmargin", &prnlmargin, &size);
[201]1091 size = sizeof(ULONG);
[803]1092 PrfQueryProfileData(fmprof, FM3Str, "Prnrmargin", &prnrmargin, &size);
[201]1093 size = sizeof(ULONG);
[803]1094 PrfQueryProfileData(fmprof, FM3Str, "Prnspacing", &prnspacing, &size);
[201]1095 size = sizeof(BOOL);
[803]1096 PrfQueryProfileData(fmprof, FM3Str, "NoDead", &fNoDead, &size);
[201]1097 size = sizeof(BOOL);
[803]1098 PrfQueryProfileData(fmprof, FM3Str, "NoFinger", &fNoFinger, &size);
[201]1099 size = sizeof(BOOL);
[803]1100 PrfQueryProfileData(fmprof, appname, "SwitchTree", &fSwitchTree, &size);
[201]1101 size = sizeof(BOOL);
1102 PrfQueryProfileData(fmprof, appname, "SwitchTreeExpand",
[803]1103 &fSwitchTreeExpand, &size);
[201]1104 size = sizeof(BOOL);
1105 PrfQueryProfileData(fmprof, appname, "SwitchTreeOnFocus",
[803]1106 &fSwitchTreeOnFocus, &size);
[201]1107 size = sizeof(BOOL);
1108 PrfQueryProfileData(fmprof, appname, "CollapseFirst",
[803]1109 &fCollapseFirst, &size);
[201]1110 size = sizeof(BOOL);
1111 PrfQueryProfileData(fmprof, appname, "FilesInTree",
[803]1112 &fFilesInTree, &size);
[201]1113 size = sizeof(BOOL);
[803]1114 PrfQueryProfileData(fmprof, FM3Str, "TopDir", &fTopDir, &size);
[201]1115 size = sizeof(BOOL);
[803]1116 PrfQueryProfileData(fmprof, FM3Str, "LookInDir", &fLookInDir, &size);
[551]1117 PrfQueryProfileString(fmprof, appname, "DefArc", NULL, szDefArc,
1118 sizeof(szDefArc));
[201]1119 size = sizeof(ULONG);
1120 PrfQueryProfileData(fmprof, FM3Str, "AutoviewHeight",
[803]1121 &AutoviewHeight, &size);
[201]1122 size = sizeof(BOOL);
[803]1123 PrfQueryProfileData(fmprof, FM3Str, "KeepCmdLine", &fKeepCmdLine, &size);
[551]1124 if (strcmp(realappname, "FM/4")) {
[2]1125 size = sizeof(BOOL);
[803]1126 PrfQueryProfileData(fmprof, FM3Str, "MoreButtons", &fMoreButtons, &size);
[2]1127 size = sizeof(BOOL);
[803]1128 PrfQueryProfileData(fmprof, FM3Str, "Drivebar", &fDrivebar, &size);
[201]1129 }
1130 else
1131 fDrivebar = fMoreButtons = TRUE;
1132 size = sizeof(BOOL);
[803]1133 PrfQueryProfileData(fmprof, appname, "NoSearch", &fNoSearch, &size);
[201]1134 size = sizeof(BOOL);
[803]1135 PrfQueryProfileData(fmprof, appname, "GuessType", &fGuessType, &size);
[201]1136 size = sizeof(BOOL);
[803]1137 PrfQueryProfileData(fmprof, appname, "ViewChild", &fViewChild, &size);
[201]1138 size = sizeof(BOOL);
[803]1139 PrfQueryProfileData(fmprof, appname, "ShowEnv", &fShowEnv, &size);
[201]1140 size = sizeof(BOOL);
[803]1141 PrfQueryProfileData(fmprof, appname, "LeaveTree", &fLeaveTree, &size);
[201]1142 size = sizeof(BOOL);
[803]1143 PrfQueryProfileData(fmprof, FM3Str, "Comments", &fComments, &size);
[201]1144 size = sizeof(ULONG);
[803]1145 PrfQueryProfileData(fmprof, appname, "WS_ANIMATE", &fwsAnimate, &size);
[201]1146 if (fwsAnimate)
1147 fwsAnimate = WS_ANIMATE;
1148 size = sizeof(ULONG);
1149 size = sizeof(BOOL);
1150 PrfQueryProfileData(fmprof, appname, "SelectedAlways",
[803]1151 &fSelectedAlways, &size);
[201]1152 size = sizeof(BOOL);
[803]1153 PrfQueryProfileData(fmprof, FM3Str, "ToolbarHelp", &fToolbarHelp, &size);
[201]1154 size = sizeof(BOOL);
[803]1155 PrfQueryProfileData(fmprof, FM3Str, "OtherHelp", &fOtherHelp, &size);
[201]1156 size = sizeof(BOOL);
[803]1157 PrfQueryProfileData(fmprof, FM3Str, "DrivebarHelp", &fDrivebarHelp, &size);
[201]1158 size = sizeof(BOOL);
[803]1159 PrfQueryProfileData(fmprof, appname, "AutoAddDirs", &fAutoAddDirs, &size);
[201]1160 size = sizeof(BOOL);
[803]1161 PrfQueryProfileData(fmprof, appname,
1162 "AutoAddAllDirs", &fAutoAddAllDirs, &size);
[201]1163 size = sizeof(BOOL);
1164 PrfQueryProfileData(fmprof, FM3Str, "UserListSwitches",
[803]1165 &fUserListSwitches, &size);
[201]1166 size = sizeof(BOOL);
1167 PrfQueryProfileData(fmprof, appname, "UseNewViewer",
[803]1168 &fUseNewViewer, &size);
[201]1169 size = sizeof(BOOL);
1170 PrfQueryProfileData(fmprof, appname, "DefaultDeletePerm",
[803]1171 &fDefaultDeletePerm, &size);
[201]1172 size = sizeof(BOOL);
1173 PrfQueryProfileData(fmprof, FM3Str, "ExternalINIs",
[803]1174 &fExternalINIs, &size);
[201]1175 size = sizeof(BOOL);
1176 PrfQueryProfileData(fmprof, FM3Str, "ExternalCollector",
[803]1177 &fExternalCollector, &size);
[201]1178 size = sizeof(BOOL);
1179 PrfQueryProfileData(fmprof, FM3Str, "ExternalArcboxes",
[803]1180 &fExternalArcboxes, &size);
[201]1181 size = sizeof(BOOL);
1182 PrfQueryProfileData(fmprof, FM3Str, "ExternalViewer",
[803]1183 &fExternalViewer, &size);
[201]1184 size = sizeof(BOOL);
1185 PrfQueryProfileData(fmprof, FM3Str, "UseQProcStat",
[850]1186 &fUseQProcStat, &size);
[201]1187 size = sizeof(BOOL);
[828]1188 PrfQueryProfileData(fmprof, FM3Str, "UseQSysState",
1189 &fUseQSysState, &size);
1190 size = sizeof(BOOL);
[803]1191 PrfQueryProfileData(fmprof, FM3Str, "DataMin", &fDataMin, &size);
[201]1192 size = sizeof(BOOL);
[803]1193 PrfQueryProfileData(fmprof, appname, "DataToFore", &fDataToFore, &size);
[201]1194 size = sizeof(BOOL);
1195 PrfQueryProfileData(fmprof, appname, "DataShowDrives",
[803]1196 &fDataShowDrives, &size);
[201]1197 size = sizeof(BOOL);
1198 PrfQueryProfileData(fmprof, appname, "DataInclRemote",
[803]1199 &fDataInclRemote, &size);
[201]1200 size = sizeof(BOOL);
[803]1201 PrfQueryProfileData(fmprof, FM3Str, "SplitStatus", &fSplitStatus, &size);
[201]1202 size = sizeof(BOOL);
1203 PrfQueryProfileData(fmprof, appname, "FolderAfterExtract",
[803]1204 &fFolderAfterExtract, &size);
[201]1205 size = sizeof(BOOL);
[803]1206 PrfQueryProfileData(fmprof, FM3Str, "DullDatabar", &fDullMin, &size);
[201]1207 size = sizeof(BOOL);
[803]1208 PrfQueryProfileData(fmprof, appname, "BlueLED", &fBlueLED, &size);
[201]1209 size = sizeof(BOOL);
[551]1210 PrfQueryProfileData(fmprof, appname, "ConfirmDelete",
[803]1211 &fConfirmDelete, &size);
[201]1212 size = sizeof(BOOL);
[803]1213 PrfQueryProfileData(fmprof, FM3Str, "SaveState", &fSaveState, &size);
[201]1214 size = sizeof(BOOL);
[803]1215 PrfQueryProfileData(fmprof, appname, "SyncUpdates", &fSyncUpdates, &size);
[201]1216 size = sizeof(BOOL);
[803]1217 PrfQueryProfileData(fmprof, appname, "LoadSubject", &fLoadSubject, &size);
[201]1218 size = sizeof(BOOL);
[803]1219 PrfQueryProfileData(fmprof, appname, "UnHilite", &fUnHilite, &size);
[201]1220 size = sizeof(BOOL);
[803]1221 PrfQueryProfileData(fmprof, FM3Str, "TileBackwards", &fTileBackwards, &size);
[201]1222 size = sizeof(BOOL);
[803]1223 PrfQueryProfileData(fmprof, appname, "LoadLongname", &fLoadLongnames, &size);
[551]1224 size = sizeof(BOOL);
[803]1225 PrfQueryProfileData(fmprof, appname, "VerifyWrites", &fVerify, &size);
[201]1226 DosSetVerify(fVerify);
1227 size = sizeof(BOOL);
[803]1228 PrfQueryProfileData(fmprof, appname, "DontMoveMouse", &fDontMoveMouse, &size);
[201]1229 size = sizeof(BOOL);
[803]1230 PrfQueryProfileData(fmprof, appname, "NoIconsFiles", &fNoIconsFiles, &size);
[201]1231 size = sizeof(BOOL);
[803]1232 PrfQueryProfileData(fmprof, appname, "NoIconsDirs", &fNoIconsDirs, &size);
[201]1233 size = sizeof(BOOL);
[803]1234 PrfQueryProfileData(fmprof, appname, "ForceUpper", &fForceUpper, &size);
[201]1235 size = sizeof(BOOL);
[803]1236 PrfQueryProfileData(fmprof, appname, "ForceLower", &fForceLower, &size);
[201]1237 size = sizeof(BOOL);
[803]1238 PrfQueryProfileData(fmprof, FM3Str, "TextTools", &fTextTools, &size);
[201]1239 size = sizeof(BOOL);
[803]1240 PrfQueryProfileData(fmprof, FM3Str, "ToolTitles", &fToolTitles, &size);
[201]1241 size = sizeof(BOOL);
[803]1242 PrfQueryProfileData(fmprof, appname, "DoubleClickOpens", &fDCOpens, &size);
[201]1243 size = sizeof(BOOL);
[803]1244 PrfQueryProfileData(fmprof, appname, "LinkSetsIcon", &fLinkSetsIcon, &size);
[201]1245 size = sizeof(INT);
[803]1246 PrfQueryProfileData(fmprof, appname, "Sort", &sortFlags, &size);
[201]1247 size = sizeof(INT);
[803]1248 PrfQueryProfileData(fmprof, appname, "TreeSort", &TreesortFlags, &size);
[201]1249 size = sizeof(INT);
[803]1250 PrfQueryProfileData(fmprof, appname,
1251 "CollectorSort", &CollectorsortFlags, &size);
[201]1252 size = sizeof(targetdir);
[803]1253 PrfQueryProfileData(fmprof, appname, "Targetdir", targetdir, &size);
[201]1254 if (!IsValidDir(targetdir))
1255 *targetdir = 0;
1256 size = sizeof(extractpath);
[803]1257 PrfQueryProfileData(fmprof, appname, "ExtractPath", extractpath, &size);
[201]1258 size = sizeof(printer);
[803]1259 PrfQueryProfileData(fmprof, appname, "Printer", printer, &size);
[985]1260 size = MaxComLineStrg;
[803]1261 PrfQueryProfileData(fmprof, appname, "DirCompare", dircompare,
[551]1262 &size);
[985]1263 size = MaxComLineStrg;
[803]1264 PrfQueryProfileData(fmprof, appname, "Viewer", viewer, &size);
[985]1265 size = MaxComLineStrg;
[803]1266 PrfQueryProfileData(fmprof, appname, "Editor", editor, &size);
[985]1267 size = MaxComLineStrg;
[803]1268 PrfQueryProfileData(fmprof, appname, "BinView", binview, &size);
[985]1269 size = MaxComLineStrg;
[803]1270 PrfQueryProfileData(fmprof, appname, "BinEd", bined, &size);
[985]1271 size = MaxComLineStrg;
[803]1272 PrfQueryProfileData(fmprof, appname, "Compare", compare, &size);
[985]1273 size = MaxComLineStrg;
[803]1274 PrfQueryProfileData(fmprof, appname, "Virus", virus, &size);
[892]1275 size = sizeof(BOOL);
1276 PrfQueryProfileData(fmprof, appname, "FtpRunWPSDefault", &fFtpRunWPSDefault, &size);
[985]1277 size = MaxComLineStrg;
[803]1278 PrfQueryProfileData(fmprof, appname, "FTPRun", ftprun, &size);
[917]1279 if (!*ftprun)
[892]1280 fFtpRunWPSDefault = TRUE;
1281 size = sizeof(BOOL);
1282 PrfQueryProfileData(fmprof, appname, "HttpRunWPSDefault", &fHttpRunWPSDefault, &size);
[985]1283 size = MaxComLineStrg;
[803]1284 PrfQueryProfileData(fmprof, appname, "HTTPRun", httprun, &size);
[917]1285 if (!*httprun)
[892]1286 fHttpRunWPSDefault = TRUE;
[985]1287 size = MaxComLineStrg;
[892]1288 PrfQueryProfileData(fmprof, appname, "MailRun", mailrun, &size);
1289 size = sizeof(ftprundir);
1290 PrfQueryProfileData(fmprof, appname, "FtpRunDir", ftprundir, &size);
1291 size = sizeof(httprundir);
1292 PrfQueryProfileData(fmprof, appname, "HttpRunDir", httprundir, &size);
1293 size = sizeof(mailrundir);
[898]1294 PrfQueryProfileData(fmprof, appname, "MailRunDir", mailrundir, &size);
[201]1295 size = sizeof(lasttoolbox);
[803]1296 PrfQueryProfileData(fmprof, FM3Str, "LastToolBox", lasttoolbox,
[917]1297 &size);
[892]1298 size = sizeof(BOOL);
1299 PrfQueryProfileData(fmprof, appname, "LibPathStrictHttpRun", &fLibPathStrictHttpRun,
[917]1300 &size);
[892]1301 size = sizeof(BOOL);
1302 PrfQueryProfileData(fmprof, appname, "LibPathStrictFtpRun", &fLibPathStrictFtpRun,
[917]1303 &size);
[896]1304 size = sizeof(BOOL);
1305 PrfQueryProfileData(fmprof, appname, "LibPathStrictMailRun", &fLibPathStrictMailRun,
[917]1306 &size);
[898]1307 size = sizeof(BOOL);
1308 PrfQueryProfileData(fmprof, appname, "NoMailtoMailRun", &fNoMailtoMailRun,
[551]1309 &size);
[201]1310 size = sizeof(BOOL);
[803]1311 PrfQueryProfileData(fmprof, appname, "FollowTree", &fFollowTree,
[551]1312 &size);
[201]1313 size = sizeof(BOOL);
[551]1314 PrfQueryProfileData(fmprof, appname, "StartMaximized",
[803]1315 &fStartMaximized, &size);
[551]1316 if (!fStartMaximized) {
[2]1317 size = sizeof(BOOL);
[551]1318 PrfQueryProfileData(fmprof, appname, "StartMinimized",
[803]1319 &fStartMinimized, &size);
[2]1320 }
[201]1321 size = sizeof(BOOL);
[803]1322 PrfQueryProfileData(fmprof, appname, "DefaultCopy", &fCopyDefault, &size);
[201]1323 size = sizeof(BOOL);
[803]1324 PrfQueryProfileData(fmprof, appname, "IdleCopy", &fRealIdle, &size);
[201]1325 size = sizeof(BOOL);
1326 PrfQueryProfileData(fmprof, appname, "ArcStuffVisible",
[803]1327 &fArcStuffVisible, &size);
[201]1328 size = sizeof(BOOL);
[803]1329 PrfQueryProfileData(fmprof, FM3Str, "NoTreeGap", &fNoTreeGap, &size);
[201]1330 size = sizeof(BOOL);
[551]1331 PrfQueryProfileData(fmprof, FM3Str, "VTreeOpensWPS",
[803]1332 &fVTreeOpensWPS, &size);
[201]1333 size = sizeof(BOOL);
[803]1334 PrfQueryProfileData(fmprof, appname, "RemoteBug", &fRemoteBug, &size);
[201]1335 size = sizeof(BOOL);
[551]1336 PrfQueryProfileData(fmprof, appname, "Drag&DropDlg",
[803]1337 &fDragndropDlg, &size);
[551]1338 size = sizeof(BOOL);
[803]1339 PrfQueryProfileData(fmprof, FM3Str, "UserComboBox", &fUserComboBox, &size);
[201]1340 size = sizeof(BOOL);
[803]1341 PrfQueryProfileData(fmprof, FM3Str, "MinDirOnOpen", &fMinOnOpen, &size);
[201]1342 size = sizeof(BOOL);
[551]1343 PrfQueryProfileData(fmprof, appname, "QuickArcFind",
[803]1344 &fQuickArcFind, &size);
[201]1345 size = sizeof(BOOL);
[551]1346 PrfQueryProfileData(fmprof, FM3Str, "NoRemovableScan",
[803]1347 &fNoRemovableScan, &size);
[551]1348 size = sizeof(ULONG);
1349 PrfQueryProfileData(fmprof, FM3Str, "NoBrokenNotify",
[803]1350 &NoBrokenNotify, &size);
[551]1351 size = sizeof(ULONG);
[803]1352 PrfQueryProfileData(fmprof, appname, "ContainerType", &ulCnrType,
[201]1353 &size);
1354 size = sizeof(ULONG);
[803]1355 PrfQueryProfileData(fmprof, appname, "FilesToGet", &FilesToGet, &size);
[789]1356 if (FilesToGet < FILESTOGET_MIN)
1357 FilesToGet = FILESTOGET_MIN;
1358 else if (FilesToGet > FILESTOGET_MAX)
1359 FilesToGet = FILESTOGET_MAX;
[201]1360 size = sizeof(BOOL);
[803]1361 PrfQueryProfileData(fmprof, FM3Str, "AutoView", &fAutoView, &size);
[201]1362 size = sizeof(BOOL);
[803]1363 PrfQueryProfileData(fmprof, FM3Str, "FM2Deletes", &fFM2Deletes, &size);
[1045]1364 size = sizeof(BOOL);
1365 PrfQueryProfileData(fmprof, FM3Str, "TrashCan", &fTrashCan, &size);
[2]1366
[997]1367 LoadDetailsSwitches("DirCnr", NULL);
[784]1368
[2]1369 /* load pointers and icons we use */
[189]1370 hptrArrow = WinQuerySysPointer(HWND_DESKTOP, SPTR_ARROW, FALSE);
1371 hptrBusy = WinQuerySysPointer(HWND_DESKTOP, SPTR_WAIT, FALSE);
1372 hptrNS = WinQuerySysPointer(HWND_DESKTOP, SPTR_SIZENS, FALSE);
1373 hptrEW = WinQuerySysPointer(HWND_DESKTOP, SPTR_SIZEWE, FALSE);
1374 hptrFloppy = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, FLOPPY_ICON);
1375 hptrDrive = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, DRIVE_ICON);
1376 hptrRemovable = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, REMOVABLE_ICON);
1377 hptrCDROM = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, CDROM_ICON);
1378 hptrFile = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, FILE_ICON);
1379 hptrDir = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, DIR_FRAME);
1380 hptrArc = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, ARC_FRAME);
1381 hptrArt = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, ART_ICON);
1382 hptrSystem = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, FILE_SYSTEM_ICON);
1383 hptrHidden = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, FILE_HIDDEN_ICON);
[552]1384 hptrReadonly = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, FILE_READONLY_ICON);
[189]1385 hptrLast = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, LASTITEM_ICON);
1386 hptrRemote = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, REMOTE_ICON);
[552]1387 hptrVirtual = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, VIRTUAL_ICON);
1388 hptrRamdisk = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, RAMDISK_ICON);
[189]1389 if (!fNoDead)
1390 hptrFinger = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, FINGER_ICON);
[2]1391 else
[189]1392 hptrFinger = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, FINGER2_ICON);
1393 hptrApp = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, APP_ICON);
1394 hptrDunno = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, DUNNO_ICON);
1395 hptrEnv = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, ENV_ICON);
1396 hptrZipstrm = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, ZIPSTREAM_ICON);
[2]1397
[201]1398 // set up color array used by seeall.c and newview.c color dialog
1399
[189]1400 standardcolors[0] = CLR_WHITE;
1401 standardcolors[1] = CLR_BLACK;
1402 standardcolors[2] = CLR_BLUE;
1403 standardcolors[3] = CLR_RED;
1404 standardcolors[4] = CLR_PINK;
1405 standardcolors[5] = CLR_GREEN;
1406 standardcolors[6] = CLR_CYAN;
1407 standardcolors[7] = CLR_YELLOW;
1408 standardcolors[8] = CLR_DARKGRAY;
1409 standardcolors[9] = CLR_DARKBLUE;
[2]1410 standardcolors[10] = CLR_DARKRED;
1411 standardcolors[11] = CLR_DARKPINK;
1412 standardcolors[12] = CLR_DARKGREEN;
1413 standardcolors[13] = CLR_DARKCYAN;
1414 standardcolors[14] = CLR_BROWN;
1415 standardcolors[15] = CLR_PALEGRAY;
1416
1417 return TRUE;
1418}
1419
[189]1420HWND StartFM3(HAB hab, INT argc, CHAR ** argv)
1421{
[201]1422 HWND hwndFrame;
1423 HWND hwndClient;
1424 UINT x;
[189]1425 ULONG FrameFlags = FCF_TITLEBAR | FCF_SYSMENU |
[551]1426 FCF_SIZEBORDER | FCF_MINMAX |
1427 FCF_ACCELTABLE | FCF_MENU | FCF_ICON | FCF_TASKLIST | FCF_NOBYTEALIGN;
[2]1428
[551]1429 for (x = 1; x < argc; x++) {
[201]1430 if (*argv[x] == '~' && !argv[x][1])
1431 fReminimize = TRUE;
1432 if (*argv[x] == '+' && !argv[x][1])
1433 fLogFile = TRUE;
[551]1434 if (*argv[x] == '-') {
[201]1435 if (!argv[x][1])
1436 fNoSaveState = TRUE;
1437 else
1438 strcpy(profile, &argv[x][1]);
[2]1439 }
1440 }
1441
1442 hwndFrame = WinCreateStdWindow(HWND_DESKTOP,
[189]1443 WS_VISIBLE,
1444 &FrameFlags,
[593]1445 WC_MAINWND,
[189]1446 NULL,
1447 WS_VISIBLE | WS_ANIMATE,
[551]1448 FM3ModHandle, MAIN_FRAME, &hwndClient);
1449 if (hwndFrame) {
1450 WinSetWindowUShort(hwndFrame, QWS_ID, MAIN_FRAME);
[875]1451 hwndMainMenu = WinWindowFromID(hwndFrame, FID_MENU);
[551]1452 if (!WinRestoreWindowPos(FM2Str, "MainWindowPos", hwndFrame)) {
[2]1453
1454 ULONG fl = SWP_MOVE | SWP_SIZE;
1455 RECTL rcl;
[189]1456 ULONG icz = WinQuerySysValue(HWND_DESKTOP, SV_CYICON) * 3L;
1457 ULONG bsz = WinQuerySysValue(HWND_DESKTOP, SV_CYSIZEBORDER);
[2]1458
[551]1459 WinQueryWindowRect(HWND_DESKTOP, &rcl);
[2]1460 rcl.yBottom += icz;
1461 rcl.yTop -= bsz;
1462 rcl.xLeft += bsz;
1463 rcl.xRight -= bsz;
1464 WinSetWindowPos(hwndFrame,
[189]1465 HWND_TOP,
1466 rcl.xLeft,
1467 rcl.yBottom,
[551]1468 rcl.xRight - rcl.xLeft, rcl.yTop - rcl.yBottom, fl);
[2]1469 }
[189]1470 if (fLogFile)
[551]1471 LogFileHandle = _fsopen("FM2.LOG", "a+", SH_DENYWR);
[189]1472 if (hwndHelp)
[551]1473 WinAssociateHelpInstance(hwndHelp, hwndFrame);
1474 PostMsg(hwndClient, UM_SETUP, MPFROMLONG(argc), MPFROMP(argv));
[2]1475 }
1476 return hwndFrame;
1477}
[32]1478
[985]1479BOOL CheckFileHeader(CHAR *filespec, CHAR *signature, LONG offset)
1480{
1481 HFILE handle;
1482 ULONG action;
1483 ULONG len = strlen(signature);
1484 ULONG l;
1485 // CHAR buffer[80];
1486 CHAR buffer[4096]; // 06 Oct 07 SHL Protect against NTFS defect
1487 BOOL ret = FALSE;
1488
1489 DosError(FERR_DISABLEHARDERR);
1490 if (DosOpen(filespec,
1491 &handle,
1492 &action,
1493 0,
1494 0,
1495 OPEN_ACTION_FAIL_IF_NEW |
1496 OPEN_ACTION_OPEN_IF_EXISTS,
1497 OPEN_FLAGS_FAIL_ON_ERROR |
1498 OPEN_FLAGS_NOINHERIT |
1499 OPEN_FLAGS_RANDOMSEQUENTIAL |
1500 OPEN_SHARE_DENYNONE | OPEN_ACCESS_READONLY, 0))
1501 ret = FALSE;
1502 else {
1503 // Try signature match
1504 l = len;
1505 l = min(l, 79);
1506 if (!DosChgFilePtr(handle,
1507 abs(offset),
1508 (offset >= 0) ?
1509 FILE_BEGIN : FILE_END, &len)) {
1510 if (!DosRead(handle, buffer, l, &len) && len == l) {
1511 if (!memcmp(signature, buffer, l))
1512 ret = TRUE; // Matched
1513 }
1514 }
1515 }
1516 DosClose(handle); /* Either way, we're done for now */
1517 return ret; /* Return TRUE if matched */
1518}
1519
[189]1520int CheckVersion(int vermajor, int verminor)
1521{
[179]1522 int ok = 0;
[32]1523
[179]1524 // fixme to do useful check - was missing in base source
1525
[32]1526#if 0
[551]1527 if (vermajor && verminor) {
[32]1528 *vermajor = VERMAJOR;
1529 *verminor = VERMINOR;
[179]1530 ok = 1;
[32]1531 }
1532#endif
[189]1533
[179]1534 ok = 1;
[32]1535
[179]1536 return ok;
[32]1537}
[783]1538
1539#ifdef __WATCOMC__
1540#pragma alloc_text(INIT,LibMain,InitFM3DLL,DeInitFM3DLL)
1541#pragma alloc_text(INIT1,StartFM3,FindSwapperDat)
1542#endif
Note: See TracBrowser for help on using the repository browser.