source: trunk/dll/init.c@ 705

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

Minor code cleanup fix ramdisk on states list & WORPLACE_PROCESS logic

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