source: trunk/dll/init.c@ 940

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

Minor cleanup, added comments and History for recent changes

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