source: trunk/dll/init.c@ 1177

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

Ticket 187: Draft 2: Move remaining function declarations

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