source: trunk/dll/init.c@ 827

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

Future proof xDosSetPathInfo
Clean up callers

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 43.5 KB
RevLine 
[32]1
2/***********************************************************************
3
4 $Id: init.c 827 2007-09-02 18:32:14Z 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
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;
[2]94 rc = DosFindFirst(SwapperDat,
[189]95 &hdir,
96 FILE_NORMAL | FILE_ARCHIVED |
97 FILE_HIDDEN | FILE_SYSTEM | FILE_READONLY,
[551]98 &ffb, sizeof(ffb), &nm, FIL_STANDARD);
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;
[189]155 if (!DosFindFirst(SwapperDat,
156 &hdir,
157 FILE_NORMAL | FILE_ARCHIVED |
158 FILE_HIDDEN | FILE_SYSTEM | FILE_READONLY,
[551]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;
[189]446 if (!DosFindFirst(s,
447 &search_handle,
448 FILE_NORMAL | FILE_DIRECTORY |
449 FILE_SYSTEM | FILE_READONLY | FILE_HIDDEN |
450 FILE_ARCHIVED,
[551]451 &f, sizeof(FILEFINDBUF3), &num_matches, FIL_STANDARD)) {
452 do {
[189]453 strcpy(enddir, f.achName);
[551]454 if (f.attrFile & FILE_DIRECTORY) {
[189]455 wipeallf("%s\\*", s);
456 DosDeleteDir(s);
457 }
458 else
459 unlinkf("%s", s);
460 }
461 while (!DosFindNext(search_handle,
[551]462 &f, sizeof(FILEFINDBUF3), &num_matches));
[2]463 DosFindClose(search_handle);
464 }
465 }
466
467 save_dir(s);
[189]468 if (s[strlen(s) - 1] != '\\')
469 strcat(s, "\\");
[2]470 enddir = &s[strlen(s)];
[189]471 strcat(s, LISTTEMPROOT);
472 strcat(s, "???");
[2]473 search_handle = HDIR_CREATE;
474 num_matches = 1L;
[189]475 if (!DosFindFirst(s,
476 &search_handle,
477 FILE_NORMAL | FILE_DIRECTORY |
478 FILE_SYSTEM | FILE_READONLY | FILE_HIDDEN |
479 FILE_ARCHIVED,
[551]480 &f, sizeof(FILEFINDBUF3), &num_matches, FIL_STANDARD)) {
481 do {
482 if (!(f.attrFile & FILE_DIRECTORY)) {
[189]483 strcpy(enddir, f.achName);
484 unlinkf("%s", s);
[2]485 }
[189]486 }
487 while (!DosFindNext(search_handle,
[551]488 &f, sizeof(FILEFINDBUF3), &num_matches));
[2]489 DosFindClose(search_handle);
490 }
491
492 DosForceDelete("$FM2PLAY.$$$");
493
494 EndNote();
495
[189]496 if (FM3ModHandle)
[2]497 DosFreeModule(FM3ModHandle);
498
[551]499 DosExitList(EXLST_REMOVE, DeInitFM3DLL);
[2]500}
501
[189]502BOOL InitFM3DLL(HAB hab, int argc, char **argv)
503{
[2]504 /*
505 * this function should be called by any application using this DLL right
506 * after setting up a message queue
507 */
508
509 CLASSINFO clinfo;
[201]510 APIRET rc;
511 APIRET rcl = 1;
512 APIRET rcq = 1;
[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",
[803]1058 &fUseQProcStat, &size);
[201]1059 size = sizeof(BOOL);
[803]1060 PrfQueryProfileData(fmprof, FM3Str, "DataMin", &fDataMin, &size);
[201]1061 size = sizeof(BOOL);
[803]1062 PrfQueryProfileData(fmprof, appname, "DataToFore", &fDataToFore, &size);
[201]1063 size = sizeof(BOOL);
1064 PrfQueryProfileData(fmprof, appname, "DataShowDrives",
[803]1065 &fDataShowDrives, &size);
[201]1066 size = sizeof(BOOL);
1067 PrfQueryProfileData(fmprof, appname, "DataInclRemote",
[803]1068 &fDataInclRemote, &size);
[201]1069 size = sizeof(BOOL);
[803]1070 PrfQueryProfileData(fmprof, FM3Str, "SplitStatus", &fSplitStatus, &size);
[201]1071 size = sizeof(BOOL);
1072 PrfQueryProfileData(fmprof, appname, "FolderAfterExtract",
[803]1073 &fFolderAfterExtract, &size);
[201]1074 size = sizeof(BOOL);
[803]1075 PrfQueryProfileData(fmprof, FM3Str, "DullDatabar", &fDullMin, &size);
[201]1076 size = sizeof(BOOL);
[803]1077 PrfQueryProfileData(fmprof, appname, "BlueLED", &fBlueLED, &size);
[201]1078 size = sizeof(BOOL);
[551]1079 PrfQueryProfileData(fmprof, appname, "ConfirmDelete",
[803]1080 &fConfirmDelete, &size);
[201]1081 size = sizeof(BOOL);
[803]1082 PrfQueryProfileData(fmprof, FM3Str, "SaveState", &fSaveState, &size);
[201]1083 size = sizeof(BOOL);
[803]1084 PrfQueryProfileData(fmprof, appname, "SyncUpdates", &fSyncUpdates, &size);
[201]1085 size = sizeof(BOOL);
[803]1086 PrfQueryProfileData(fmprof, appname, "LoadSubject", &fLoadSubject, &size);
[201]1087 size = sizeof(BOOL);
[803]1088 PrfQueryProfileData(fmprof, appname, "UnHilite", &fUnHilite, &size);
[201]1089 size = sizeof(BOOL);
[803]1090 PrfQueryProfileData(fmprof, FM3Str, "TileBackwards", &fTileBackwards, &size);
[201]1091 size = sizeof(BOOL);
[803]1092 PrfQueryProfileData(fmprof, appname, "LoadLongname", &fLoadLongnames, &size);
[551]1093 size = sizeof(BOOL);
[803]1094 PrfQueryProfileData(fmprof, appname, "VerifyWrites", &fVerify, &size);
[201]1095 DosSetVerify(fVerify);
1096 size = sizeof(BOOL);
[803]1097 PrfQueryProfileData(fmprof, appname, "DontMoveMouse", &fDontMoveMouse, &size);
[201]1098 size = sizeof(BOOL);
[803]1099 PrfQueryProfileData(fmprof, appname, "NoIconsFiles", &fNoIconsFiles, &size);
[201]1100 size = sizeof(BOOL);
[803]1101 PrfQueryProfileData(fmprof, appname, "NoIconsDirs", &fNoIconsDirs, &size);
[201]1102 size = sizeof(BOOL);
[803]1103 PrfQueryProfileData(fmprof, appname, "ForceUpper", &fForceUpper, &size);
[201]1104 size = sizeof(BOOL);
[803]1105 PrfQueryProfileData(fmprof, appname, "ForceLower", &fForceLower, &size);
[201]1106 size = sizeof(BOOL);
[803]1107 PrfQueryProfileData(fmprof, FM3Str, "TextTools", &fTextTools, &size);
[201]1108 size = sizeof(BOOL);
[803]1109 PrfQueryProfileData(fmprof, FM3Str, "ToolTitles", &fToolTitles, &size);
[201]1110 size = sizeof(BOOL);
[803]1111 PrfQueryProfileData(fmprof, appname, "DoubleClickOpens", &fDCOpens, &size);
[201]1112 size = sizeof(BOOL);
[803]1113 PrfQueryProfileData(fmprof, appname, "LinkSetsIcon", &fLinkSetsIcon, &size);
[201]1114 size = sizeof(INT);
[803]1115 PrfQueryProfileData(fmprof, appname, "Sort", &sortFlags, &size);
[201]1116 size = sizeof(INT);
[803]1117 PrfQueryProfileData(fmprof, appname, "TreeSort", &TreesortFlags, &size);
[201]1118 size = sizeof(INT);
[803]1119 PrfQueryProfileData(fmprof, appname,
1120 "CollectorSort", &CollectorsortFlags, &size);
[201]1121 size = sizeof(targetdir);
[803]1122 PrfQueryProfileData(fmprof, appname, "Targetdir", targetdir, &size);
[201]1123 if (!IsValidDir(targetdir))
1124 *targetdir = 0;
1125 size = sizeof(extractpath);
[803]1126 PrfQueryProfileData(fmprof, appname, "ExtractPath", extractpath, &size);
[201]1127 if (!IsValidDir(extractpath))
1128 *extractpath = 0;
1129 size = sizeof(printer);
[803]1130 PrfQueryProfileData(fmprof, appname, "Printer", printer, &size);
[201]1131 size = sizeof(dircompare);
[803]1132 PrfQueryProfileData(fmprof, appname, "DirCompare", dircompare,
[551]1133 &size);
[201]1134 size = sizeof(viewer);
[803]1135 PrfQueryProfileData(fmprof, appname, "Viewer", viewer, &size);
[201]1136 size = sizeof(editor);
[803]1137 PrfQueryProfileData(fmprof, appname, "Editor", editor, &size);
[201]1138 size = sizeof(binview);
[803]1139 PrfQueryProfileData(fmprof, appname, "BinView", binview, &size);
[201]1140 size = sizeof(bined);
[803]1141 PrfQueryProfileData(fmprof, appname, "BinEd", bined, &size);
[201]1142 size = sizeof(compare);
[803]1143 PrfQueryProfileData(fmprof, appname, "Compare", compare, &size);
[201]1144 size = sizeof(virus);
[803]1145 PrfQueryProfileData(fmprof, appname, "Virus", virus, &size);
[201]1146 size = sizeof(ftprun);
[803]1147 PrfQueryProfileData(fmprof, appname, "FTPRun", ftprun, &size);
[201]1148 if (!*ftprun && !size)
1149 strcpy(ftprun, "ftppm.exe");
1150 size = sizeof(httprun);
[803]1151 PrfQueryProfileData(fmprof, appname, "HTTPRun", httprun, &size);
[201]1152 if (!*httprun && !size)
1153 strcpy(httprun, "explore.exe -q");
1154 size = sizeof(lasttoolbox);
[803]1155 PrfQueryProfileData(fmprof, FM3Str, "LastToolBox", lasttoolbox,
[551]1156 &size);
[201]1157 size = sizeof(BOOL);
[803]1158 PrfQueryProfileData(fmprof, appname, "FollowTree", &fFollowTree,
[551]1159 &size);
[201]1160 size = sizeof(BOOL);
[551]1161 PrfQueryProfileData(fmprof, appname, "StartMaximized",
[803]1162 &fStartMaximized, &size);
[551]1163 if (!fStartMaximized) {
[2]1164 size = sizeof(BOOL);
[551]1165 PrfQueryProfileData(fmprof, appname, "StartMinimized",
[803]1166 &fStartMinimized, &size);
[2]1167 }
[201]1168 size = sizeof(BOOL);
[803]1169 PrfQueryProfileData(fmprof, appname, "DefaultCopy", &fCopyDefault, &size);
[201]1170 size = sizeof(BOOL);
[803]1171 PrfQueryProfileData(fmprof, appname, "IdleCopy", &fRealIdle, &size);
[201]1172 size = sizeof(BOOL);
1173 PrfQueryProfileData(fmprof, appname, "ArcStuffVisible",
[803]1174 &fArcStuffVisible, &size);
[201]1175 size = sizeof(BOOL);
[803]1176 PrfQueryProfileData(fmprof, FM3Str, "NoTreeGap", &fNoTreeGap, &size);
[201]1177 size = sizeof(BOOL);
[551]1178 PrfQueryProfileData(fmprof, FM3Str, "VTreeOpensWPS",
[803]1179 &fVTreeOpensWPS, &size);
[201]1180 size = sizeof(BOOL);
[803]1181 PrfQueryProfileData(fmprof, appname, "RemoteBug", &fRemoteBug, &size);
[201]1182 size = sizeof(BOOL);
[551]1183 PrfQueryProfileData(fmprof, appname, "Drag&DropDlg",
[803]1184 &fDragndropDlg, &size);
[551]1185 size = sizeof(BOOL);
[803]1186 PrfQueryProfileData(fmprof, FM3Str, "UserComboBox", &fUserComboBox, &size);
[201]1187 size = sizeof(BOOL);
[803]1188 PrfQueryProfileData(fmprof, FM3Str, "MinDirOnOpen", &fMinOnOpen, &size);
[201]1189 size = sizeof(BOOL);
[551]1190 PrfQueryProfileData(fmprof, appname, "QuickArcFind",
[803]1191 &fQuickArcFind, &size);
[201]1192 size = sizeof(BOOL);
[551]1193 PrfQueryProfileData(fmprof, FM3Str, "NoRemovableScan",
[803]1194 &fNoRemovableScan, &size);
[551]1195 size = sizeof(ULONG);
1196 PrfQueryProfileData(fmprof, FM3Str, "NoBrokenNotify",
[803]1197 &NoBrokenNotify, &size);
[551]1198 size = sizeof(ULONG);
[803]1199 PrfQueryProfileData(fmprof, appname, "ContainerType", &ulCnrType,
[201]1200 &size);
1201 size = sizeof(ULONG);
[803]1202 PrfQueryProfileData(fmprof, appname, "FilesToGet", &FilesToGet, &size);
[789]1203 if (FilesToGet < FILESTOGET_MIN)
1204 FilesToGet = FILESTOGET_MIN;
1205 else if (FilesToGet > FILESTOGET_MAX)
1206 FilesToGet = FILESTOGET_MAX;
[201]1207 size = sizeof(BOOL);
[803]1208 PrfQueryProfileData(fmprof, FM3Str, "AutoView", &fAutoView, &size);
[201]1209 size = sizeof(BOOL);
[803]1210 PrfQueryProfileData(fmprof, FM3Str, "FM2Deletes", &fFM2Deletes, &size);
[2]1211
[784]1212 size = sizeof(BOOL);
[803]1213 PrfQueryProfileData(fmprof, appname, "DetailsLWDate", &detailslwdate, &size);
[784]1214 size = sizeof(BOOL);
[803]1215 PrfQueryProfileData(fmprof, appname, "DetailsLWTime", &detailslwtime, &size);
[784]1216 size = sizeof(BOOL);
[803]1217 PrfQueryProfileData(fmprof, appname, "DetailsLADate", &detailsladate, &size);
[784]1218 size = sizeof(BOOL);
[803]1219 PrfQueryProfileData(fmprof, appname, "DetailsLATime", &detailslatime, &size);
[784]1220 size = sizeof(BOOL);
[803]1221 PrfQueryProfileData(fmprof, appname, "DetailsCRDate", &detailscrdate, &size);
[784]1222 size = sizeof(BOOL);
[803]1223 PrfQueryProfileData(fmprof, appname, "DetailsCRTime", &detailscrtime, &size);
[784]1224 size = sizeof(BOOL);
[803]1225 PrfQueryProfileData(fmprof, appname, "DetailsLongname", &detailslongname, &size);
[784]1226 size = sizeof(BOOL);
[803]1227 PrfQueryProfileData(fmprof, appname, "DetailsEA", &detailsea, &size);
[784]1228 size = sizeof(BOOL);
[803]1229 PrfQueryProfileData(fmprof, appname, "DetailsSize", &detailssize, &size);
[784]1230 size = sizeof(BOOL);
[803]1231 PrfQueryProfileData(fmprof, appname, "DetailsSubject", &detailssubject, &size);
[784]1232 size = sizeof(BOOL);
[803]1233 PrfQueryProfileData(fmprof, appname, "DetailsAttr", &detailsattr, &size);
[784]1234 size = sizeof(BOOL);
[803]1235 PrfQueryProfileData(fmprof, appname, "DetailsIcon", &detailsicon, &size);
[796]1236 size = sizeof(BOOL);
[803]1237 PrfQueryProfileData(fmprof, appname, "SubjectInLeftPane", &fSubjectInLeftPane,
1238 &size);
[796]1239 size = sizeof(ULONG);
[803]1240 PrfQueryProfileData(fmprof, appname, "SubjectDisplayWidth",
1241 &SubjectDisplayWidth, &size);
[796]1242 if (SubjectDisplayWidth < 50)
1243 SubjectDisplayWidth = 0;
1244 else if (SubjectDisplayWidth > 1000)
1245 SubjectDisplayWidth = 1000;
1246 size = sizeof(BOOL);
[803]1247 PrfQueryProfileData(fmprof, appname, "SubjectLengthMax", &fSubjectLengthMax,
1248 &size);
[784]1249
[2]1250 /* load pointers and icons we use */
[189]1251 hptrArrow = WinQuerySysPointer(HWND_DESKTOP, SPTR_ARROW, FALSE);
1252 hptrBusy = WinQuerySysPointer(HWND_DESKTOP, SPTR_WAIT, FALSE);
1253 hptrNS = WinQuerySysPointer(HWND_DESKTOP, SPTR_SIZENS, FALSE);
1254 hptrEW = WinQuerySysPointer(HWND_DESKTOP, SPTR_SIZEWE, FALSE);
1255 hptrFloppy = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, FLOPPY_ICON);
1256 hptrDrive = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, DRIVE_ICON);
1257 hptrRemovable = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, REMOVABLE_ICON);
1258 hptrCDROM = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, CDROM_ICON);
1259 hptrFile = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, FILE_ICON);
1260 hptrDir = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, DIR_FRAME);
1261 hptrArc = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, ARC_FRAME);
1262 hptrArt = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, ART_ICON);
1263 hptrSystem = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, FILE_SYSTEM_ICON);
1264 hptrHidden = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, FILE_HIDDEN_ICON);
[552]1265 hptrReadonly = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, FILE_READONLY_ICON);
[189]1266 hptrLast = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, LASTITEM_ICON);
1267 hptrRemote = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, REMOTE_ICON);
[552]1268 hptrVirtual = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, VIRTUAL_ICON);
1269 hptrRamdisk = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, RAMDISK_ICON);
[189]1270 if (!fNoDead)
1271 hptrFinger = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, FINGER_ICON);
[2]1272 else
[189]1273 hptrFinger = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, FINGER2_ICON);
1274 hptrApp = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, APP_ICON);
1275 hptrDunno = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, DUNNO_ICON);
1276 hptrEnv = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, ENV_ICON);
1277 hptrZipstrm = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, ZIPSTREAM_ICON);
[2]1278
[201]1279 // set up color array used by seeall.c and newview.c color dialog
1280
[189]1281 standardcolors[0] = CLR_WHITE;
1282 standardcolors[1] = CLR_BLACK;
1283 standardcolors[2] = CLR_BLUE;
1284 standardcolors[3] = CLR_RED;
1285 standardcolors[4] = CLR_PINK;
1286 standardcolors[5] = CLR_GREEN;
1287 standardcolors[6] = CLR_CYAN;
1288 standardcolors[7] = CLR_YELLOW;
1289 standardcolors[8] = CLR_DARKGRAY;
1290 standardcolors[9] = CLR_DARKBLUE;
[2]1291 standardcolors[10] = CLR_DARKRED;
1292 standardcolors[11] = CLR_DARKPINK;
1293 standardcolors[12] = CLR_DARKGREEN;
1294 standardcolors[13] = CLR_DARKCYAN;
1295 standardcolors[14] = CLR_BROWN;
1296 standardcolors[15] = CLR_PALEGRAY;
1297
1298 return TRUE;
1299}
1300
[189]1301HWND StartFM3(HAB hab, INT argc, CHAR ** argv)
1302{
[201]1303 HWND hwndFrame;
1304 HWND hwndClient;
1305 UINT x;
[189]1306 ULONG FrameFlags = FCF_TITLEBAR | FCF_SYSMENU |
[551]1307 FCF_SIZEBORDER | FCF_MINMAX |
1308 FCF_ACCELTABLE | FCF_MENU | FCF_ICON | FCF_TASKLIST | FCF_NOBYTEALIGN;
[2]1309
[551]1310 for (x = 1; x < argc; x++) {
[201]1311 if (*argv[x] == '~' && !argv[x][1])
1312 fReminimize = TRUE;
1313 if (*argv[x] == '+' && !argv[x][1])
1314 fLogFile = TRUE;
[551]1315 if (*argv[x] == '-') {
[201]1316 if (!argv[x][1])
1317 fNoSaveState = TRUE;
1318 else
1319 strcpy(profile, &argv[x][1]);
[2]1320 }
1321 }
1322
1323 hwndFrame = WinCreateStdWindow(HWND_DESKTOP,
[189]1324 WS_VISIBLE,
1325 &FrameFlags,
[593]1326 WC_MAINWND,
[189]1327 NULL,
1328 WS_VISIBLE | WS_ANIMATE,
[551]1329 FM3ModHandle, MAIN_FRAME, &hwndClient);
1330 if (hwndFrame) {
1331 WinSetWindowUShort(hwndFrame, QWS_ID, MAIN_FRAME);
1332 if (!WinRestoreWindowPos(FM2Str, "MainWindowPos", hwndFrame)) {
[2]1333
1334 ULONG fl = SWP_MOVE | SWP_SIZE;
1335 RECTL rcl;
[189]1336 ULONG icz = WinQuerySysValue(HWND_DESKTOP, SV_CYICON) * 3L;
1337 ULONG bsz = WinQuerySysValue(HWND_DESKTOP, SV_CYSIZEBORDER);
[2]1338
[551]1339 WinQueryWindowRect(HWND_DESKTOP, &rcl);
[2]1340 rcl.yBottom += icz;
1341 rcl.yTop -= bsz;
1342 rcl.xLeft += bsz;
1343 rcl.xRight -= bsz;
1344 WinSetWindowPos(hwndFrame,
[189]1345 HWND_TOP,
1346 rcl.xLeft,
1347 rcl.yBottom,
[551]1348 rcl.xRight - rcl.xLeft, rcl.yTop - rcl.yBottom, fl);
[2]1349 }
[189]1350 if (fLogFile)
[551]1351 LogFileHandle = _fsopen("FM2.LOG", "a+", SH_DENYWR);
[189]1352 if (hwndHelp)
[551]1353 WinAssociateHelpInstance(hwndHelp, hwndFrame);
1354 PostMsg(hwndClient, UM_SETUP, MPFROMLONG(argc), MPFROMP(argv));
[2]1355 }
1356 return hwndFrame;
1357}
[32]1358
[189]1359int CheckVersion(int vermajor, int verminor)
1360{
[179]1361 int ok = 0;
[32]1362
[179]1363 // fixme to do useful check - was missing in base source
1364
[32]1365#if 0
[551]1366 if (vermajor && verminor) {
[32]1367 *vermajor = VERMAJOR;
1368 *verminor = VERMINOR;
[179]1369 ok = 1;
[32]1370 }
1371#endif
[189]1372
[179]1373 ok = 1;
[32]1374
[179]1375 return ok;
[32]1376}
[783]1377
1378#ifdef __WATCOMC__
1379#pragma alloc_text(INIT,LibMain,InitFM3DLL,DeInitFM3DLL)
1380#pragma alloc_text(INIT1,StartFM3,FindSwapperDat)
1381#endif
Note: See TracBrowser for help on using the repository browser.