source: trunk/dll/init.c@ 926

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

Background color on toolbar now can be change with drag drop; ticket 161. Set command line string length to 2048

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