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