source: trunk/dll/init.c@ 1073

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

Fm2 uses TMP/TEMP directory if set for temporary files and directories. Ticket 20

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