source: trunk/dll/init.c@ 888

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

runemf2 now quotes executable strings if needed (Ticket 180); it also reports where it was called from on errors

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