source: trunk/dll/init.c@ 1074

Last change on this file since 1074 was 1074, checked in by Steven Levine, 17 years ago

Reduce code bulk in fUseTmp setup

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