source: trunk/dll/init.c@ 690

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

Commit more OpenWatcom compatibility updates

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