source: trunk/dll/init.c@ 1076

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

Remove fUseTmp

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