source: trunk/dll/init.c@ 838

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

Remainder of changes for xDosFindFirst/Next wrapper performance test

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