source: trunk/dll/init.c@ 710

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

yet another fix of WORKPLACE_PROCESS (yes & no should always mean the same thing)

  • 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 710 2007-06-25 00:16:38Z 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");
[707]632 if (!env){
633 env = getenv("WORKPLACE__PROCESS");
[710]634 if (!env || stricmp(env, "NO"))
[707]635 fWorkPlace = TRUE;
636 }
637 else{
638 if (stricmp(env, "YES"))
639 fWorkPlace = TRUE;
640 }
[189]641 if ((!strchr(profile, '\\') && !strchr(profile, ':')) ||
[551]642 !(fmprof = PrfOpenProfile((HAB) 0, profile))) {
[2]643 /* figure out where to put INI file... */
[189]644 CHAR *env, inipath[CCHMAXPATH];
[2]645
646 DosError(FERR_DISABLEHARDERR);
647 save_dir2(HomePath);
648 DosError(FERR_DISABLEHARDERR);
[189]649 memset(driveserial, -1, sizeof(driveserial));
[2]650 *inipath = 0;
651 env = getenv("FM3INI");
[551]652 if (env) {
[189]653 strcpy(inipath, env);
[2]654 DosError(FERR_DISABLEHARDERR);
[551]655 rc = DosQueryPathInfo(inipath, FIL_STANDARD, &fsa, (ULONG) sizeof(fsa));
656 if (!rc) {
657 if (fsa.attrFile & FILE_DIRECTORY) {
[189]658 if (inipath[strlen(inipath) - 1] != '\\')
659 strcat(inipath, "\\");
660 strcat(inipath, profile);
661 }
[2]662 }
663 }
[551]664 if (!env) {
[2]665 env = searchpath(profile);
[189]666 if (!env)
667 env = profile;
668 strcpy(inipath, env);
[2]669 }
[201]670
[2]671 /* in some odd cases the INI file can get set to readonly status */
672 /* here we test it and reset the readonly bit if necessary */
[201]673 if (!*inipath)
674 strcpy(inipath, profile);
675 DosError(FERR_DISABLEHARDERR);
[551]676 if (!DosQueryPathInfo(inipath, FIL_STANDARD, &fsa, (ULONG) sizeof(fsa))) {
[201]677 fIniExisted = TRUE;
[551]678 if (fsa.attrFile & (FILE_READONLY | FILE_HIDDEN | FILE_SYSTEM)) {
[201]679 fsa.attrFile &= (~(FILE_READONLY | FILE_HIDDEN | FILE_SYSTEM));
680 if (DosSetPathInfo(inipath, FIL_STANDARD, (PVOID) & fsa,
681 (ULONG) sizeof(fsa), 0L))
682 saymsg(MB_ENTER,
683 HWND_DESKTOP,
684 GetPString(IDS_ERRORTEXT),
[551]685 GetPString(IDS_INIREADONLYTEXT), inipath);
[2]686 }
687 }
[201]688
[189]689 fmprof = PrfOpenProfile((HAB) 0, inipath);
[551]690 if (!fmprof) {
[189]691 strcpy(inipath, "FM3.INI");
692 fmprof = PrfOpenProfile((HAB) 0, inipath);
[2]693 }
[201]694
[551]695 if (!fmprof) {
696 Win_Error(NULLHANDLE, NULLHANDLE, pszSrcFile, __LINE__,
697 "PrfOpenProfile failed");
[2]698 return FALSE;
699 }
700 }
701
702 FindSwapperDat();
703
[201]704 size = sizeof(BOOL);
705 PrfQueryProfileData(fmprof,
706 FM3Str,
[551]707 "SeparateParms", (PVOID) & fSeparateParms, &size);
[201]708 if (!fSeparateParms)
709 strcpy(appname, FM3Str);
[2]710
711 /* start help */
[189]712 memset(&hini, 0, sizeof(HELPINIT));
[2]713 hini.cb = sizeof(HELPINIT);
714 hini.ulReturnCode = 0L;
715 hini.pszTutorialName = NULL;
[189]716 hini.phtHelpTable = (PHELPTABLE) MAKELONG(ID_HELPTABLE, 0xffff);
717 hini.hmodAccelActionBarModule = (HMODULE) 0;
[2]718 hini.idAccelTable = 0;
719 hini.idActionBar = 0;
720 hini.pszHelpWindowTitle = GetPString(IDS_FM2HELPTITLETEXT);
721 hini.fShowPanelId = CMIC_HIDE_PANEL_ID;
722 hini.pszHelpLibraryName = "FM3.HLP";
[189]723 hwndHelp = WinCreateHelpInstance(hab, &hini);
[551]724 if (!hwndHelp) {
[201]725 static CHAR helppath[CCHMAXPATH]; // fixme to be local?
[2]726
727 env = getenv("FM3INI");
[551]728 if (env) {
[2]729 FILESTATUS3 fsa;
[189]730 APIRET rc;
[2]731
[189]732 strcpy(helppath, env);
[2]733 DosError(FERR_DISABLEHARDERR);
[551]734 rc =
735 DosQueryPathInfo(helppath, FIL_STANDARD, &fsa, (ULONG) sizeof(fsa));
736 if (!rc) {
737 if (fsa.attrFile & FILE_DIRECTORY) {
[189]738 if (helppath[strlen(helppath) - 1] != '\\')
739 strcat(helppath, "\\");
740 strcat(helppath, "FM3.HLP");
741 hini.pszHelpLibraryName = helppath;
742 hwndHelp = WinCreateHelpInstance(hab, &hini);
743 }
[2]744 }
745 }
746 }
[551]747 if (!hwndHelp) {
[2]748 saymsg(MB_ENTER | MB_ICONEXCLAMATION,
[189]749 HWND_DESKTOP,
750 GetPString(IDS_FM2TROUBLETEXT),
751 GetPString(IDS_CANTLOADHELPTEXT),
752 GetPString(IDS_NOHELPACCEPTTEXT));
[2]753 }
754
755 /* a couple of default window procs so we don't have to look them up later */
[189]756 if (WinQueryClassInfo(hab, WC_CONTAINER, &clinfo))
[2]757 PFNWPCnr = clinfo.pfnWindowProc;
[179]758 // saymsg(MB_ENTER,HWND_DESKTOP,"Container flags:","%08lx",clinfo.flClassStyle);
[189]759 if (WinQueryClassInfo(hab, WC_FRAME, &clinfo))
[2]760 PFNWPFrame = clinfo.pfnWindowProc;
[179]761 // saymsg(MB_ENTER,HWND_DESKTOP,"Frame flags:","%08lx",clinfo.flClassStyle);
[189]762 if (WinQueryClassInfo(hab, WC_BUTTON, &clinfo))
[2]763 PFNWPButton = clinfo.pfnWindowProc;
[179]764 // saymsg(MB_ENTER,HWND_DESKTOP,"Button flags:","%08lx",clinfo.flClassStyle);
[189]765 if (WinQueryClassInfo(hab, WC_STATIC, &clinfo))
[2]766 PFNWPStatic = clinfo.pfnWindowProc;
[179]767 // saymsg(MB_ENTER,HWND_DESKTOP,"Static flags:","%08lx",clinfo.flClassStyle);
[189]768 if (WinQueryClassInfo(hab, WC_MLE, &clinfo))
[2]769 PFNWPMLE = clinfo.pfnWindowProc;
[179]770 // saymsg(MB_ENTER,HWND_DESKTOP,"MLE flags:","%08lx",clinfo.flClassStyle);
[551]771 if (!PFNWPCnr || !PFNWPFrame || !PFNWPButton || !PFNWPStatic || !PFNWPMLE) {
[339]772 Runtime_Error(pszSrcFile, __LINE__, "WinQueryClassInfo");
[2]773 return FALSE;
774 }
775
776 /* register window classes we use */
777 WinRegisterClass(hab,
[593]778 WC_MAINWND,
[189]779 MainWndProc,
[551]780 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 8);
[2]781 WinRegisterClass(hab,
[593]782 WC_MAINWND2,
[189]783 MainWndProc2,
[551]784 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 4);
[2]785 WinRegisterClass(hab,
[593]786 WC_TREECONTAINER,
[189]787 TreeClientWndProc,
[551]788 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 2);
[2]789 WinRegisterClass(hab,
[593]790 WC_DIRCONTAINER,
[189]791 DirClientWndProc,
[551]792 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 2);
[2]793 WinRegisterClass(hab,
[593]794 WC_COLLECTOR,
[189]795 CollectorClientWndProc,
[551]796 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 2);
[2]797 WinRegisterClass(hab,
[593]798 WC_ARCCONTAINER,
[189]799 ArcClientWndProc,
[551]800 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 2);
[2]801 WinRegisterClass(hab,
[593]802 WC_MLEEDITOR,
[189]803 MLEEditorProc,
[551]804 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 2);
[2]805 WinRegisterClass(hab,
[593]806 WC_INIEDITOR,
[189]807 IniProc,
[551]808 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 2);
[2]809 WinRegisterClass(hab,
[593]810 WC_TOOLBACK,
[551]811 ToolBackProc, CS_SIZEREDRAW, sizeof(PVOID));
[2]812 WinRegisterClass(hab,
[593]813 WC_DRIVEBACK,
[189]814 DriveBackProc,
815 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
816 sizeof(PVOID));
[2]817 WinRegisterClass(hab,
[593]818 WC_SEEALL,
[189]819 SeeAllWndProc,
[551]820 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID));
[2]821 WinRegisterClass(hab,
[593]822 WC_NEWVIEW,
[189]823 ViewWndProc,
[551]824 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID));
[2]825 WinRegisterClass(hab,
[593]826 WC_TOOLBUTTONS,
[189]827 ChildButtonProc,
828 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
829 sizeof(PVOID));
[2]830 WinRegisterClass(hab,
[593]831 WC_DRIVEBUTTONS,
[189]832 DriveProc,
833 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
834 sizeof(PVOID));
[2]835 WinRegisterClass(hab,
[593]836 WC_BUBBLE,
[189]837 BubbleProc,
838 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
839 sizeof(ULONG) * 2);
[2]840 WinRegisterClass(hab,
[593]841 WC_STATUS,
[189]842 StatusProc,
843 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
844 sizeof(ULONG));
[2]845 WinRegisterClass(hab,
[593]846 WC_DIRSTATUS,
[189]847 DirTextProc,
848 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
849 sizeof(ULONG));
[2]850 WinRegisterClass(hab,
[593]851 WC_TREESTATUS,
[189]852 TreeStatProc,
853 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
854 sizeof(ULONG));
[2]855 WinRegisterClass(hab,
[593]856 WC_ARCSTATUS,
[189]857 ArcTextProc,
858 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
859 sizeof(ULONG));
[2]860 WinRegisterClass(hab,
[593]861 WC_COLSTATUS,
[189]862 CollectorTextProc,
863 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
864 sizeof(ULONG));
[2]865 WinRegisterClass(hab,
[593]866 WC_SEESTATUS,
[189]867 SeeStatusProc,
868 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
869 sizeof(ULONG));
[2]870 WinRegisterClass(hab,
[593]871 WC_VIEWSTATUS,
[189]872 ViewStatusProc,
873 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
874 sizeof(ULONG));
[2]875 WinRegisterClass(hab,
[593]876 WC_ERRORWND,
[189]877 NotifyWndProc,
878 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
879 sizeof(PVOID));
[2]880 WinRegisterClass(hab,
[593]881 WC_MINITIME,
[189]882 MiniTimeProc,
883 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
884 sizeof(PVOID) * 2);
[2]885 WinRegisterClass(hab,
[593]886 WC_DATABAR,
[551]887 DataProc, CS_SIZEREDRAW, sizeof(PVOID));
[2]888 WinRegisterClass(hab,
[593]889 WC_TREEOPENBUTTON,
[189]890 OpenButtonProc,
891 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
892 sizeof(PVOID));
[2]893 WinRegisterClass(hab,
[593]894 WC_AUTOVIEW,
[189]895 AutoViewProc,
896 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
897 sizeof(PVOID));
[2]898 WinRegisterClass(hab,
[593]899 WC_LED,
[189]900 LEDProc,
901 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
902 sizeof(PVOID));
[2]903
904 /*
[201]905 * set some defaults (note: everything else automatically initialized
[2]906 * to 0)
907 */
908 detailssize = detailsea = detailslwdate = detailslwtime = detailsattr =
[189]909 detailsicon = fAutoTile = fConfirmDelete = fLoadSubject = fUnHilite =
910 fLoadLongnames = fToolbar = fSaveState = fGuessType = fToolbarHelp =
911 fAutoAddDirs = fUseNewViewer = fDataToFore = fDataShowDrives =
912 fSplitStatus = fDragndropDlg = fQuickArcFind = fKeepCmdLine =
913 fMoreButtons = fDrivebar = fCollapseFirst = fSwitchTree =
914 fSwitchTreeExpand = fNoSearch = fCustomFileDlg = fOtherHelp =
915 fSaveMiniCmds = fUserComboBox = fFM2Deletes = fConfirmTarget =
916 fShowTarget = fDrivebarHelp = fCheckMM = TRUE;
[2]917 ulCnrType = CCS_EXTENDSEL;
918 FilesToGet = 128L;
919 AutoviewHeight = 48L;
[189]920 strcpy(printer, "PRN");
[2]921 prnwidth = 80;
922 prnlength = 66;
923 prntmargin = 6;
924 prnbmargin = 6;
925 prnlmargin = 6;
926 prnrmargin = 3;
927 prnspacing = 1;
928 prntabspaces = 8;
929 CollectorsortFlags = sortFlags = SORT_DIRSFIRST;
930
[201]931 // load preferences from profile (INI) file
932 size = sizeof(BOOL);
933 PrfQueryProfileData(fmprof,
[551]934 appname, "ShowTarget", (PVOID) & fShowTarget, &size);
[201]935 size = sizeof(BOOL);
[551]936 PrfQueryProfileData(fmprof, appname, "CheckMM", (PVOID) & fCheckMM, &size);
[201]937 size = sizeof(BOOL);
938 PrfQueryProfileData(fmprof,
939 appname,
[551]940 "ChangeTarget", (PVOID) & fChangeTarget, &size);
[201]941 size = sizeof(BOOL);
942 PrfQueryProfileData(fmprof,
943 appname,
[551]944 "ConfirmTarget", (PVOID) & fConfirmTarget, &size);
[201]945 size = sizeof(BOOL);
946 PrfQueryProfileData(fmprof,
947 FM3Str,
[551]948 "CustomFileDlg", (PVOID) & fCustomFileDlg, &size);
[201]949 size = sizeof(BOOL);
950 PrfQueryProfileData(fmprof,
[551]951 FM3Str, "SaveMiniCmds", (PVOID) & fSaveMiniCmds, &size);
[201]952 size = sizeof(BOOL);
953 PrfQueryProfileData(fmprof,
[551]954 appname, "SaveBigCmds", (PVOID) & fSaveBigCmds, &size);
[201]955 size = sizeof(BOOL);
956 PrfQueryProfileData(fmprof,
[551]957 appname, "NoFoldMenu", (PVOID) & fNoFoldMenu, &size);
[201]958 size = sizeof(BOOL);
959 PrfQueryProfileData(fmprof,
[551]960 FM3Str, "ThreadNotes", (PVOID) & fThreadNotes, &size);
961 size = sizeof(BOOL);
962 PrfQueryProfileData(fmprof, FM3Str, "Prnpagenums", (PVOID) & prnpagenums,
[201]963 &size);
964 size = sizeof(BOOL);
965 PrfQueryProfileData(fmprof, FM3Str, "Prnalt", (PVOID) & prnalt, &size);
966 size = sizeof(BOOL);
[551]967 PrfQueryProfileData(fmprof, FM3Str, "Prnformat", (PVOID) & prnformat,
968 &size);
[201]969 size = sizeof(BOOL);
970 PrfQueryProfileData(fmprof, FM3Str, "Prnformfeedbefore",
971 (PVOID) & prnformfeedbefore, &size);
972 size = sizeof(BOOL);
973 PrfQueryProfileData(fmprof,
974 FM3Str,
[551]975 "Prnformfeedafter", (PVOID) & prnformfeedafter, &size);
[201]976 size = sizeof(ULONG);
977 PrfQueryProfileData(fmprof, FM3Str, "Prntabspaces",
978 (PVOID) & prntabspaces, &size);
979 size = sizeof(ULONG);
980 PrfQueryProfileData(fmprof, FM3Str, "Prnwidth", (PVOID) & prnwidth, &size);
981 size = sizeof(ULONG);
[551]982 PrfQueryProfileData(fmprof, FM3Str, "Prnlength", (PVOID) & prnlength,
983 &size);
[201]984 size = sizeof(ULONG);
[551]985 PrfQueryProfileData(fmprof, FM3Str, "Prntmargin", (PVOID) & prntmargin,
986 &size);
[201]987 size = sizeof(ULONG);
[551]988 PrfQueryProfileData(fmprof, FM3Str, "Prnbmargin", (PVOID) & prnbmargin,
989 &size);
[201]990 size = sizeof(ULONG);
[551]991 PrfQueryProfileData(fmprof, FM3Str, "Prnlmargin", (PVOID) & prnlmargin,
992 &size);
[201]993 size = sizeof(ULONG);
[551]994 PrfQueryProfileData(fmprof, FM3Str, "Prnrmargin", (PVOID) & prnrmargin,
995 &size);
[201]996 size = sizeof(ULONG);
[551]997 PrfQueryProfileData(fmprof, FM3Str, "Prnspacing", (PVOID) & prnspacing,
998 &size);
[201]999 size = sizeof(BOOL);
1000 PrfQueryProfileData(fmprof, FM3Str, "NoDead", (PVOID) & fNoDead, &size);
1001 size = sizeof(BOOL);
1002 PrfQueryProfileData(fmprof, FM3Str, "NoFinger", (PVOID) & fNoFinger, &size);
1003 size = sizeof(BOOL);
1004 PrfQueryProfileData(fmprof, appname, "SwitchTree", (PVOID) & fSwitchTree,
1005 &size);
1006 size = sizeof(BOOL);
1007 PrfQueryProfileData(fmprof, appname, "SwitchTreeExpand",
1008 (PVOID) & fSwitchTreeExpand, &size);
1009 size = sizeof(BOOL);
1010 PrfQueryProfileData(fmprof, appname, "SwitchTreeOnFocus",
1011 (PVOID) & fSwitchTreeOnFocus, &size);
1012 size = sizeof(BOOL);
1013 PrfQueryProfileData(fmprof, appname, "CollapseFirst",
1014 (PVOID) & fCollapseFirst, &size);
1015 size = sizeof(BOOL);
1016 PrfQueryProfileData(fmprof, appname, "FilesInTree",
1017 (PVOID) & fFilesInTree, &size);
1018 size = sizeof(BOOL);
1019 PrfQueryProfileData(fmprof, FM3Str, "TopDir", (PVOID) & fTopDir, &size);
1020 size = sizeof(BOOL);
[551]1021 PrfQueryProfileData(fmprof, FM3Str, "LookInDir", (PVOID) & fLookInDir,
1022 &size);
1023 PrfQueryProfileString(fmprof, appname, "DefArc", NULL, szDefArc,
1024 sizeof(szDefArc));
[201]1025 size = sizeof(ULONG);
1026 PrfQueryProfileData(fmprof, FM3Str, "AutoviewHeight",
1027 (PVOID) & AutoviewHeight, &size);
1028 size = sizeof(BOOL);
[551]1029 PrfQueryProfileData(fmprof, FM3Str, "KeepCmdLine", (PVOID) & fKeepCmdLine,
1030 &size);
1031 if (strcmp(realappname, "FM/4")) {
[2]1032 size = sizeof(BOOL);
1033 PrfQueryProfileData(fmprof,
[551]1034 FM3Str, "MoreButtons", (PVOID) & fMoreButtons, &size);
[2]1035 size = sizeof(BOOL);
1036 PrfQueryProfileData(fmprof,
[551]1037 FM3Str, "Drivebar", (PVOID) & fDrivebar, &size);
[201]1038 }
1039 else
1040 fDrivebar = fMoreButtons = TRUE;
1041 size = sizeof(BOOL);
1042 PrfQueryProfileData(fmprof,
[551]1043 appname, "NoSearch", (PVOID) & fNoSearch, &size);
[201]1044 size = sizeof(BOOL);
1045 PrfQueryProfileData(fmprof,
[551]1046 appname, "GuessType", (PVOID) & fGuessType, &size);
[201]1047 size = sizeof(BOOL);
1048 PrfQueryProfileData(fmprof,
[551]1049 appname, "ViewChild", (PVOID) & fViewChild, &size);
[201]1050 size = sizeof(BOOL);
[551]1051 PrfQueryProfileData(fmprof, appname, "ShowEnv", (PVOID) & fShowEnv, &size);
[201]1052 size = sizeof(BOOL);
1053 PrfQueryProfileData(fmprof,
[551]1054 appname, "LeaveTree", (PVOID) & fLeaveTree, &size);
[201]1055 size = sizeof(BOOL);
1056 PrfQueryProfileData(fmprof, FM3Str, "Comments", (PVOID) & fComments, &size);
1057 size = sizeof(ULONG);
[551]1058 PrfQueryProfileData(fmprof, appname, "WS_ANIMATE", (PVOID) & fwsAnimate,
1059 &size);
[201]1060 if (fwsAnimate)
1061 fwsAnimate = WS_ANIMATE;
1062 size = sizeof(ULONG);
1063 size = sizeof(BOOL);
1064 PrfQueryProfileData(fmprof, appname, "SelectedAlways",
1065 (PVOID) & fSelectedAlways, &size);
1066 size = sizeof(BOOL);
[551]1067 PrfQueryProfileData(fmprof, FM3Str, "ToolbarHelp", (PVOID) & fToolbarHelp,
1068 &size);
[201]1069 size = sizeof(BOOL);
[551]1070 PrfQueryProfileData(fmprof, FM3Str, "OtherHelp", (PVOID) & fOtherHelp,
1071 &size);
[201]1072 size = sizeof(BOOL);
[551]1073 PrfQueryProfileData(fmprof, FM3Str, "DrivebarHelp", (PVOID) & fDrivebarHelp,
1074 &size);
[201]1075 size = sizeof(BOOL);
1076 PrfQueryProfileData(fmprof,
[551]1077 appname, "AutoAddDirs", (PVOID) & fAutoAddDirs, &size);
[201]1078 size = sizeof(BOOL);
1079 PrfQueryProfileData(fmprof,
1080 appname,
[551]1081 "AutoAddAllDirs", (PVOID) & fAutoAddAllDirs, &size);
[201]1082 size = sizeof(BOOL);
1083 PrfQueryProfileData(fmprof, FM3Str, "UserListSwitches",
1084 (PVOID) & fUserListSwitches, &size);
1085 size = sizeof(BOOL);
1086 PrfQueryProfileData(fmprof, appname, "UseNewViewer",
1087 (PVOID) & fUseNewViewer, &size);
1088 size = sizeof(BOOL);
1089 PrfQueryProfileData(fmprof, appname, "DefaultDeletePerm",
1090 (PVOID) & fDefaultDeletePerm, &size);
1091 size = sizeof(BOOL);
1092 PrfQueryProfileData(fmprof, FM3Str, "ExternalINIs",
1093 (PVOID) & fExternalINIs, &size);
1094 size = sizeof(BOOL);
1095 PrfQueryProfileData(fmprof, FM3Str, "ExternalCollector",
1096 (PVOID) & fExternalCollector, &size);
1097 size = sizeof(BOOL);
1098 PrfQueryProfileData(fmprof, FM3Str, "ExternalArcboxes",
1099 (PVOID) & fExternalArcboxes, &size);
1100 size = sizeof(BOOL);
1101 PrfQueryProfileData(fmprof, FM3Str, "ExternalViewer",
1102 (PVOID) & fExternalViewer, &size);
1103 size = sizeof(BOOL);
1104 PrfQueryProfileData(fmprof, FM3Str, "UseQProcStat",
1105 (PVOID) & fUseQProcStat, &size);
1106 size = sizeof(BOOL);
1107 PrfQueryProfileData(fmprof, FM3Str, "DataMin", (PVOID) & fDataMin, &size);
1108 size = sizeof(BOOL);
[551]1109 PrfQueryProfileData(fmprof, appname, "DataToFore", (PVOID) & fDataToFore,
1110 &size);
[201]1111 size = sizeof(BOOL);
1112 PrfQueryProfileData(fmprof, appname, "DataShowDrives",
1113 (PVOID) & fDataShowDrives, &size);
1114 size = sizeof(BOOL);
1115 PrfQueryProfileData(fmprof, appname, "DataInclRemote",
1116 (PVOID) & fDataInclRemote, &size);
1117 size = sizeof(BOOL);
[551]1118 PrfQueryProfileData(fmprof, FM3Str, "SplitStatus", (PVOID) & fSplitStatus,
1119 &size);
[201]1120 size = sizeof(BOOL);
1121 PrfQueryProfileData(fmprof, appname, "FolderAfterExtract",
1122 (PVOID) & fFolderAfterExtract, &size);
1123 size = sizeof(BOOL);
[551]1124 PrfQueryProfileData(fmprof, FM3Str, "DullDatabar", (PVOID) & fDullMin,
1125 &size);
[201]1126 size = sizeof(BOOL);
1127 PrfQueryProfileData(fmprof, appname, "BlueLED", (PVOID) & fBlueLED, &size);
1128 size = sizeof(BOOL);
[551]1129 PrfQueryProfileData(fmprof, appname, "ConfirmDelete",
1130 (PVOID) & fConfirmDelete, &size);
[201]1131 size = sizeof(BOOL);
[551]1132 PrfQueryProfileData(fmprof, FM3Str, "SaveState", (PVOID) & fSaveState,
1133 &size);
[201]1134 size = sizeof(BOOL);
[551]1135 PrfQueryProfileData(fmprof, appname, "SyncUpdates", (PVOID) & fSyncUpdates,
1136 &size);
[201]1137 size = sizeof(BOOL);
[551]1138 PrfQueryProfileData(fmprof, appname, "LoadSubject", (PVOID) & fLoadSubject,
1139 &size);
[201]1140 size = sizeof(BOOL);
[551]1141 PrfQueryProfileData(fmprof, appname, "UnHilite", (PVOID) & fUnHilite,
[201]1142 &size);
1143 size = sizeof(BOOL);
[551]1144 PrfQueryProfileData(fmprof, FM3Str, "TileBackwards",
1145 (PVOID) & fTileBackwards, &size);
[201]1146 size = sizeof(BOOL);
[551]1147 PrfQueryProfileData(fmprof, appname, "LoadLongname",
1148 (PVOID) & fLoadLongnames, &size);
1149 size = sizeof(BOOL);
1150 PrfQueryProfileData(fmprof, appname, "VerifyWrites", (PVOID) & fVerify,
1151 &size);
[201]1152 DosSetVerify(fVerify);
1153 size = sizeof(BOOL);
[551]1154 PrfQueryProfileData(fmprof, appname, "DontMoveMouse",
1155 (PVOID) & fDontMoveMouse, &size);
[201]1156 size = sizeof(BOOL);
[551]1157 PrfQueryProfileData(fmprof, appname, "NoIconsFiles",
1158 (PVOID) & fNoIconsFiles, &size);
[201]1159 size = sizeof(BOOL);
[551]1160 PrfQueryProfileData(fmprof, appname, "NoIconsDirs", (PVOID) & fNoIconsDirs,
1161 &size);
[201]1162 size = sizeof(BOOL);
[551]1163 PrfQueryProfileData(fmprof, appname, "ForceUpper", (PVOID) & fForceUpper,
1164 &size);
[201]1165 size = sizeof(BOOL);
[551]1166 PrfQueryProfileData(fmprof, appname, "ForceLower", (PVOID) & fForceLower,
1167 &size);
[201]1168 size = sizeof(BOOL);
[551]1169 PrfQueryProfileData(fmprof, FM3Str, "TextTools", (PVOID) & fTextTools,
1170 &size);
[201]1171 size = sizeof(BOOL);
[551]1172 PrfQueryProfileData(fmprof, FM3Str, "ToolTitles", (PVOID) & fToolTitles,
1173 &size);
[201]1174 size = sizeof(BOOL);
[551]1175 PrfQueryProfileData(fmprof, appname, "DoubleClickOpens", (PVOID) & fDCOpens,
1176 &size);
[201]1177 size = sizeof(BOOL);
[551]1178 PrfQueryProfileData(fmprof, appname, "LinkSetsIcon",
1179 (PVOID) & fLinkSetsIcon, &size);
[201]1180 size = sizeof(INT);
1181 PrfQueryProfileData(fmprof, appname, "Sort", (PVOID) & sortFlags, &size);
1182 size = sizeof(INT);
[551]1183 PrfQueryProfileData(fmprof, appname, "TreeSort", (PVOID) & TreesortFlags,
1184 &size);
[201]1185 size = sizeof(INT);
1186 PrfQueryProfileData(fmprof,
1187 appname,
[551]1188 "CollectorSort", (PVOID) & CollectorsortFlags, &size);
[201]1189 size = sizeof(targetdir);
[551]1190 PrfQueryProfileData(fmprof, appname, "Targetdir", (PVOID) targetdir, &size);
[201]1191 if (!IsValidDir(targetdir))
1192 *targetdir = 0;
1193 size = sizeof(extractpath);
1194 PrfQueryProfileData(fmprof,
[551]1195 appname, "ExtractPath", (PVOID) extractpath, &size);
[201]1196 if (!IsValidDir(extractpath))
1197 *extractpath = 0;
1198 size = sizeof(printer);
1199 PrfQueryProfileData(fmprof, appname, "Printer", (PVOID) printer, &size);
1200 size = sizeof(dircompare);
[551]1201 PrfQueryProfileData(fmprof, appname, "DirCompare", (PVOID) dircompare,
1202 &size);
[201]1203 size = sizeof(viewer);
1204 PrfQueryProfileData(fmprof, appname, "Viewer", (PVOID) viewer, &size);
1205 size = sizeof(editor);
1206 PrfQueryProfileData(fmprof, appname, "Editor", (PVOID) editor, &size);
1207 size = sizeof(binview);
1208 PrfQueryProfileData(fmprof, appname, "BinView", (PVOID) binview, &size);
1209 size = sizeof(bined);
1210 PrfQueryProfileData(fmprof, appname, "BinEd", (PVOID) bined, &size);
1211 size = sizeof(compare);
1212 PrfQueryProfileData(fmprof, appname, "Compare", (PVOID) compare, &size);
1213 size = sizeof(virus);
1214 PrfQueryProfileData(fmprof, appname, "Virus", (PVOID) virus, &size);
1215 size = sizeof(ftprun);
1216 PrfQueryProfileData(fmprof, appname, "FTPRun", (PVOID) ftprun, &size);
1217 if (!*ftprun && !size)
1218 strcpy(ftprun, "ftppm.exe");
1219 size = sizeof(httprun);
1220 PrfQueryProfileData(fmprof, appname, "HTTPRun", (PVOID) httprun, &size);
1221 if (!*httprun && !size)
1222 strcpy(httprun, "explore.exe -q");
1223 size = sizeof(lasttoolbox);
[551]1224 PrfQueryProfileData(fmprof, FM3Str, "LastToolBox", (PVOID) lasttoolbox,
1225 &size);
[201]1226 size = sizeof(BOOL);
[551]1227 PrfQueryProfileData(fmprof, appname, "FollowTree", (PVOID) & fFollowTree,
1228 &size);
[201]1229 size = sizeof(BOOL);
[551]1230 PrfQueryProfileData(fmprof, appname, "StartMaximized",
1231 (PVOID) & fStartMaximized, &size);
1232 if (!fStartMaximized) {
[2]1233 size = sizeof(BOOL);
[551]1234 PrfQueryProfileData(fmprof, appname, "StartMinimized",
1235 (PVOID) & fStartMinimized, &size);
[2]1236 }
[201]1237 size = sizeof(BOOL);
[551]1238 PrfQueryProfileData(fmprof, appname, "DefaultCopy", (PVOID) & fCopyDefault,
1239 &size);
[201]1240 size = sizeof(BOOL);
[551]1241 PrfQueryProfileData(fmprof, appname, "IdleCopy", (PVOID) & fRealIdle,
1242 &size);
[201]1243 size = sizeof(BOOL);
1244 PrfQueryProfileData(fmprof, appname, "ArcStuffVisible",
1245 (PVOID) & fArcStuffVisible, &size);
1246 size = sizeof(BOOL);
[551]1247 PrfQueryProfileData(fmprof, FM3Str, "NoTreeGap", (PVOID) & fNoTreeGap,
[201]1248 &size);
1249 size = sizeof(BOOL);
[551]1250 PrfQueryProfileData(fmprof, FM3Str, "VTreeOpensWPS",
1251 (PVOID) & fVTreeOpensWPS, &size);
[201]1252 size = sizeof(BOOL);
[551]1253 PrfQueryProfileData(fmprof, appname, "RemoteBug", (PVOID) & fRemoteBug,
[201]1254 &size);
1255 size = sizeof(BOOL);
[551]1256 PrfQueryProfileData(fmprof, appname, "Drag&DropDlg",
1257 (PVOID) & fDragndropDlg, &size);
1258 size = sizeof(BOOL);
[201]1259 PrfQueryProfileData(fmprof, FM3Str, "UserComboBox", (PVOID) & fUserComboBox,
1260 &size);
1261 size = sizeof(BOOL);
1262 PrfQueryProfileData(fmprof, FM3Str, "MinDirOnOpen", (PVOID) & fMinOnOpen,
1263 &size);
1264 size = sizeof(BOOL);
[551]1265 PrfQueryProfileData(fmprof, appname, "QuickArcFind",
1266 (PVOID) & fQuickArcFind, &size);
[201]1267 size = sizeof(BOOL);
[551]1268 PrfQueryProfileData(fmprof, FM3Str, "NoRemovableScan",
1269 (PVOID) & fNoRemovableScan, &size);
1270 size = sizeof(ULONG);
1271 PrfQueryProfileData(fmprof, FM3Str, "NoBrokenNotify",
1272 (PVOID) & NoBrokenNotify, &size);
1273 size = sizeof(ULONG);
1274 PrfQueryProfileData(fmprof, appname, "ContainerType", (PVOID) & ulCnrType,
[201]1275 &size);
1276 size = sizeof(ULONG);
[551]1277 PrfQueryProfileData(fmprof, appname, "FilesToGet", (PVOID) & FilesToGet,
[201]1278 &size);
1279 size = sizeof(BOOL);
1280 PrfQueryProfileData(fmprof, FM3Str, "AutoView", (PVOID) & fAutoView, &size);
1281 size = sizeof(BOOL);
[551]1282 PrfQueryProfileData(fmprof, FM3Str, "FM2Deletes", (PVOID) & fFM2Deletes,
1283 &size);
[2]1284
1285 /* load pointers and icons we use */
[189]1286 hptrArrow = WinQuerySysPointer(HWND_DESKTOP, SPTR_ARROW, FALSE);
1287 hptrBusy = WinQuerySysPointer(HWND_DESKTOP, SPTR_WAIT, FALSE);
1288 hptrNS = WinQuerySysPointer(HWND_DESKTOP, SPTR_SIZENS, FALSE);
1289 hptrEW = WinQuerySysPointer(HWND_DESKTOP, SPTR_SIZEWE, FALSE);
1290 hptrFloppy = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, FLOPPY_ICON);
1291 hptrDrive = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, DRIVE_ICON);
1292 hptrRemovable = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, REMOVABLE_ICON);
1293 hptrCDROM = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, CDROM_ICON);
1294 hptrFile = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, FILE_ICON);
1295 hptrDir = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, DIR_FRAME);
1296 hptrArc = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, ARC_FRAME);
1297 hptrArt = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, ART_ICON);
1298 hptrSystem = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, FILE_SYSTEM_ICON);
1299 hptrHidden = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, FILE_HIDDEN_ICON);
[552]1300 hptrReadonly = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, FILE_READONLY_ICON);
[189]1301 hptrLast = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, LASTITEM_ICON);
1302 hptrRemote = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, REMOTE_ICON);
[552]1303 hptrVirtual = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, VIRTUAL_ICON);
1304 hptrRamdisk = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, RAMDISK_ICON);
[189]1305 if (!fNoDead)
1306 hptrFinger = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, FINGER_ICON);
[2]1307 else
[189]1308 hptrFinger = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, FINGER2_ICON);
1309 hptrApp = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, APP_ICON);
1310 hptrDunno = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, DUNNO_ICON);
1311 hptrEnv = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, ENV_ICON);
1312 hptrZipstrm = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, ZIPSTREAM_ICON);
[2]1313
[201]1314 // set up color array used by seeall.c and newview.c color dialog
1315
[189]1316 standardcolors[0] = CLR_WHITE;
1317 standardcolors[1] = CLR_BLACK;
1318 standardcolors[2] = CLR_BLUE;
1319 standardcolors[3] = CLR_RED;
1320 standardcolors[4] = CLR_PINK;
1321 standardcolors[5] = CLR_GREEN;
1322 standardcolors[6] = CLR_CYAN;
1323 standardcolors[7] = CLR_YELLOW;
1324 standardcolors[8] = CLR_DARKGRAY;
1325 standardcolors[9] = CLR_DARKBLUE;
[2]1326 standardcolors[10] = CLR_DARKRED;
1327 standardcolors[11] = CLR_DARKPINK;
1328 standardcolors[12] = CLR_DARKGREEN;
1329 standardcolors[13] = CLR_DARKCYAN;
1330 standardcolors[14] = CLR_BROWN;
1331 standardcolors[15] = CLR_PALEGRAY;
1332
1333 return TRUE;
1334}
1335
[189]1336HWND StartFM3(HAB hab, INT argc, CHAR ** argv)
1337{
[201]1338 HWND hwndFrame;
1339 HWND hwndClient;
1340 UINT x;
[189]1341 ULONG FrameFlags = FCF_TITLEBAR | FCF_SYSMENU |
[551]1342 FCF_SIZEBORDER | FCF_MINMAX |
1343 FCF_ACCELTABLE | FCF_MENU | FCF_ICON | FCF_TASKLIST | FCF_NOBYTEALIGN;
[2]1344
[551]1345 for (x = 1; x < argc; x++) {
[201]1346 if (*argv[x] == '~' && !argv[x][1])
1347 fReminimize = TRUE;
1348 if (*argv[x] == '+' && !argv[x][1])
1349 fLogFile = TRUE;
[551]1350 if (*argv[x] == '-') {
[201]1351 if (!argv[x][1])
1352 fNoSaveState = TRUE;
1353 else
1354 strcpy(profile, &argv[x][1]);
[2]1355 }
1356 }
1357
1358 hwndFrame = WinCreateStdWindow(HWND_DESKTOP,
[189]1359 WS_VISIBLE,
1360 &FrameFlags,
[593]1361 WC_MAINWND,
[189]1362 NULL,
1363 WS_VISIBLE | WS_ANIMATE,
[551]1364 FM3ModHandle, MAIN_FRAME, &hwndClient);
1365 if (hwndFrame) {
1366 WinSetWindowUShort(hwndFrame, QWS_ID, MAIN_FRAME);
1367 if (!WinRestoreWindowPos(FM2Str, "MainWindowPos", hwndFrame)) {
[2]1368
1369 ULONG fl = SWP_MOVE | SWP_SIZE;
1370 RECTL rcl;
[189]1371 ULONG icz = WinQuerySysValue(HWND_DESKTOP, SV_CYICON) * 3L;
1372 ULONG bsz = WinQuerySysValue(HWND_DESKTOP, SV_CYSIZEBORDER);
[2]1373
[551]1374 WinQueryWindowRect(HWND_DESKTOP, &rcl);
[2]1375 rcl.yBottom += icz;
1376 rcl.yTop -= bsz;
1377 rcl.xLeft += bsz;
1378 rcl.xRight -= bsz;
1379 WinSetWindowPos(hwndFrame,
[189]1380 HWND_TOP,
1381 rcl.xLeft,
1382 rcl.yBottom,
[551]1383 rcl.xRight - rcl.xLeft, rcl.yTop - rcl.yBottom, fl);
[2]1384 }
[189]1385 if (fLogFile)
[551]1386 LogFileHandle = _fsopen("FM2.LOG", "a+", SH_DENYWR);
[189]1387 if (hwndHelp)
[551]1388 WinAssociateHelpInstance(hwndHelp, hwndFrame);
1389 PostMsg(hwndClient, UM_SETUP, MPFROMLONG(argc), MPFROMP(argv));
[2]1390 }
1391 return hwndFrame;
1392}
[32]1393
[189]1394int CheckVersion(int vermajor, int verminor)
1395{
[179]1396 int ok = 0;
[32]1397
[179]1398 // fixme to do useful check - was missing in base source
1399
[32]1400#if 0
[551]1401 if (vermajor && verminor) {
[32]1402 *vermajor = VERMAJOR;
1403 *verminor = VERMINOR;
[179]1404 ok = 1;
[32]1405 }
1406#endif
[189]1407
[179]1408 ok = 1;
[32]1409
[179]1410 return ok;
[32]1411}
Note: See TracBrowser for help on using the repository browser.