source: trunk/dll/init.c@ 803

Last change on this file since 803 was 803, checked in by Steven Levine, 18 years ago

InitFM3DLL: report INI file DosSetPathInfo error correctly
Use BldFullPathName
Work around DosSetPathInfo kernel defect

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