source: trunk/dll/init.c@ 875

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

Used global variable to link presparams to main menu window for both drop down and pop up menus

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