source: trunk/dll/init.c@ 952

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

Compile OpenWatcom version into binary

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