source: trunk/dll/init.c@ 783

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

Rework DosFindFirst/Next loops to optimize memory allocation and code paths
Adjust FilesToGet limits
Update configuration notebook scanning page
Start updating #pragma alloc_text positioning for OpenWatcom compatibility

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