source: trunk/dll/init.c@ 826

Last change on this file since 826 was 826, checked in by Gregg Young, 18 years ago

Add xDosSetPathInfo to work around FILESTATUSx buffer crossing 64k boundry

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