source: trunk/dll/init.c@ 849

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

Initial attempt at wrapper functions for large file support. fNoLargeFileSupport is set to TRUE in init.c for testing. The code builds but isn't functional Setting fNoLargeFileSupport FALSE will yield working code.

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