source: trunk/dll/init.c@ 718

Last change on this file since 718 was 718, checked in by Steven Levine, 18 years ago

Rework WORKPLACE_PROCESS check to match reality

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