source: trunk/dll/init.c@ 886

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

Make WPURLDEFAULTSETTINGS the fall back for ftprun Ticket 182

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