source: trunk/dll/init.c@ 844

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

Revert to standard APIs where large file support not required by ticket #41

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