source: trunk/dll/init.c@ 1004

Last change on this file since 1004 was 1004, checked in by Gregg Young, 17 years ago

Change default command line length to 1024; remove additional hard coded command line lengths

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