source: trunk/dll/init.c@ 1156

Last change on this file since 1156 was 1156, checked in by John Small, 17 years ago

Ticket 187: Draft 1: Functions only

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