source: trunk/dll/init.c@ 756

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

Cleanup for ticket 138 & 24

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