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
RevLine 
[32]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
[907]9 Copyright (c) 2001, 2008 Steven H. Levine
[32]10
[133]11 11 Jun 02 SHL Add CheckVersion
12 11 Jun 03 SHL Add JFS and FAT32 support
13 25 Nov 03 SHL InitFM3DLL: correct strings error mesage
14 23 May 05 SHL Use datamin.h
[179]15 26 May 05 SHL Comments
[189]16 06 Jun 05 SHL indent -i2
[201]17 06 Jun 05 SHL Rework FindSwapperDat for VAC3.65 compat
[339]18 13 Jul 06 SHL Use Runtime_Error
19 13 Jul 06 SHL Sync with current style
[404]20 29 Jul 06 SHL Use xfgets
[526]21 22 Oct 06 GKY Add NDFS32 support
[552]22 18 Feb 07 GKY Add ISOFS, RAMFS support
[593]23 30 Mar 07 GKY Defined golbals for removing GetPString for window class names
[627]24 21 Apr 07 GKY Find FM2Utils by path or utils directory eleminate fAddUtils global
[690]25 15 Jun 07 SHL Make OpenWatcom compatible
[705]26 23 Jun 07 GKY Fix WORPLACE_PROCESS enviroment check logic
[718]27 28 Jun 07 SHL Rework WORKPLACE_PROCESS check to match reality
[756]28 03 Aug 07 GKY Enlarged and made setable everywhere Findbuf (speed file loading)
[775]29 06 Aug 07 GKY Reduce DosSleep times (ticket 148)
[783]30 13 Aug 07 SHL Move #pragma alloc_text to end for OpenWatcom compat
[784]31 18 Aug 07 JBS Added code to read Details* keys from the INI file (Ticket 118)
[789]32 19 Aug 07 SHL Ensure FilesToGet in valid range
[796]33 21 Aug 07 GKY Make Subject column in dircnr sizable and movable from the rigth to the left pane
[803]34 23 Aug 07 SHL InitFM3DLL: report INI file DosSetPathInfo error correctly
35 23 Aug 07 SHL Use BldFullPathName
36 25 Aug 07 SHL Work around DosSetPathInfo kernel defect
[827]37 01 Sep 07 GKY Use xDosSetPathInfo to fix case where FS3 buffer crosses 64k boundry
[860]38 10 Nov 07 GKY Get thousands separator from country info for file sizes.
[878]39 26 Nov 07 GKY Eliminate check of ext path on start up
[888]40 17 Dec 07 GKY Make WPURLDEFAULTSETTINGS the fall back for ftp/httprun
[940]41 13 Jan 08 GKY Get Subjectwidth/Subjectleft working in the collector.
[952]42 12 Feb 08 SHL Compile OpenWatcom version into binary
[985]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
[998]45 08 Mar 08 JBS Ticket 230: Replace prefixless INI keys for default directory containers with
46 keys using a "DirCnr." prefix
[1004]47 20 Apr 08 GKY Change default cmd line length to 1024 Ask once if user wants to reset it.
[32]48
49***********************************************************************/
50
[2]51#include <stdlib.h>
52#include <string.h>
53#include <share.h>
54#include <process.h>
[133]55
[803]56#define INCL_DOS
57#define INCL_WIN
58#define INCL_MMIOOS2
59#define INCL_GPI
60#define INCL_DOSERRORS
[841]61#define INCL_LONGLONG
[860]62#define INCL_DOSNLS
[803]63#include <os2.h>
64#include <os2me.h>
65
66#define DEFINE_GLOBALS 1
67
[2]68#include "fm3dlg.h"
[133]69#include "datamin.h"
[2]70#include "tools.h"
71#include "fm3str.h"
72#include "version.h"
[907]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"
[985]78#include "notebook.h" // command line variables (editor etc)
[2]79
[783]80#ifdef __IBMC__
[690]81#pragma alloc_text(INIT,LibMain,InitFM3DLL,DeInitFM3DLL)
[783]82#pragma alloc_text(INIT1,StartFM3,FindSwapperDat)
[690]83#endif
84
[189]85extern int _CRT_init(void);
[2]86extern void _CRT_term(void);
87
[952]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
[339]97static PSZ pszSrcFile = __FILE__;
[2]98
[985]99BOOL CheckFileHeader(CHAR *filespec, CHAR *signature, LONG offset);
100
[189]101VOID FindSwapperDat(VOID)
102{
[201]103 CHAR filename[] = "C:\\CONFIG.SYS";
104 CHAR input[8192];
105 CHAR *p;
106 CHAR *pp;
[189]107 FILE *fp;
[849]108 FILEFINDBUF3L ffb;
[201]109 ULONG nm;
110 ULONG size = sizeof(SwapperDat);
[189]111 HDIR hdir = HDIR_CREATE;
[201]112 APIRET rc = 1;
[2]113
114 *SwapperDat = 0;
[201]115 // Check already known
[803]116 PrfQueryProfileData(fmprof, FM3Str, "SwapperDat", SwapperDat, &size);
[551]117 if (*SwapperDat) {
[201]118 nm = 1;
[843]119 rc = DosFindFirst(SwapperDat,
120 &hdir,
121 FILE_NORMAL | FILE_ARCHIVED |
122 FILE_HIDDEN | FILE_SYSTEM | FILE_READONLY,
[850]123 &ffb, sizeof(ffb), &nm, FIL_STANDARDL);
124 if (rc && rc != ERROR_FILE_NOT_FOUND && rc != ERROR_PATH_NOT_FOUND) {
[849]125 FILEFINDBUF3 ffb;
126 rc = DosFindFirst(SwapperDat,
[850]127 &hdir,
128 FILE_NORMAL | FILE_ARCHIVED |
129 FILE_HIDDEN | FILE_SYSTEM | FILE_READONLY,
130 &ffb, sizeof(ffb), &nm, FIL_STANDARD);
[849]131 fNoLargeFileSupport = TRUE;
132 }
[551]133 if (!rc) {
[2]134 DosFindClose(hdir);
[189]135 fp = fopen(SwapperDat, "r");
[551]136 if (fp) {
[189]137 fclose(fp);
138 *SwapperDat = 0;
[551]139 rc = 1; // Force config.sys scan
[2]140 }
141 }
142 else
143 *SwapperDat = 0;
144 }
[201]145 // If not defined in INI or INI wrong, scan config.sys for SWAPPATH statement
[551]146 if (rc) {
[189]147 if (DosQuerySysInfo(QSV_BOOT_DRIVE,
148 QSV_BOOT_DRIVE,
[803]149 &nm,
150 sizeof(ULONG))) {
[551]151 nm = 3; // Assume drive C:
[201]152 }
[551]153 *filename = (CHAR) nm + '@';
[404]154 fp = xfsopen(filename, "r", SH_DENYNO, pszSrcFile, __LINE__);
[551]155 if (fp) {
[404]156 while (!feof(fp)) {
[551]157 if (!xfgets(input, sizeof(input), fp, pszSrcFile, __LINE__))
[189]158 break;
159 lstrip(input);
[551]160 if (!strnicmp(input, "SWAPPATH", 8)) {
[189]161 p = input + 8;
162 while (*p == ' ')
163 p++;
[551]164 if (*p == '=') {
[189]165 p++;
166 stripcr(p);
167 rstrip(p);
168 while (*p == ' ')
169 p++;
[551]170 if (*p == '\"') {
[189]171 p++;
172 pp = p;
173 while (*pp && *pp != '\"')
[689]174 *pp += 1;
[189]175 if (*pp)
176 *pp = 0;
177 }
[551]178 else {
[189]179 pp = strchr(p, ' ');
180 if (pp)
181 *pp = 0;
182 }
[551]183 if (*p) {
[189]184 strncpy(SwapperDat, p, CCHMAXPATH);
185 SwapperDat[CCHMAXPATH - 1] = 0;
[803]186 BldFullPathName(SwapperDat, SwapperDat, "SWAPPER.DAT");
[189]187 hdir = HDIR_CREATE;
[201]188 nm = 1;
[849]189 rc = DosFindFirst(SwapperDat,
[843]190 &hdir,
191 FILE_NORMAL | FILE_ARCHIVED |
192 FILE_HIDDEN | FILE_SYSTEM | FILE_READONLY,
[850]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) {
[189]204 DosFindClose(hdir);
205 PrfWriteProfileString(fmprof,
[551]206 FM3Str, "SwapperDat", SwapperDat);
[189]207 }
208 else
209 *SwapperDat = 0;
210 break;
211 }
212 }
[551]213 } // if SWAPPATH
214 } // while
[2]215 fclose(fp);
216 }
217 }
218}
219
[690]220#ifdef __WATCOMC__
221
222unsigned APIENTRY LibMain(unsigned hModule,
[783]223 unsigned ulFlag)
[690]224{
225 CHAR *env;
226 CHAR stringfile[CCHMAXPATH];
[849]227 FILESTATUS3 fsa;
[690]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);
[849]240 rc = DosQueryPathInfo(env, FIL_STANDARD, &fsa, sizeof(fsa));
[690]241 if (!rc) {
242 if (fsa.attrFile & FILE_DIRECTORY) {
[803]243 BldFullPathName(stringfile, env, "FM3RES.STR");
[690]244 DosError(FERR_DISABLEHARDERR);
[849]245 if (DosQueryPathInfo(stringfile, FIL_STANDARD, &fsa, sizeof(fsa)))
[690]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;
[803]317 FM3UL = *(ULONG *)FM3Str;
[690]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
[189]336unsigned long _System _DLL_InitTerm(unsigned long hModule,
337 unsigned long ulFlag)
338{
[201]339 CHAR *env;
340 CHAR stringfile[CCHMAXPATH];
[849]341 FILESTATUS3 fsa;
[201]342 APIRET rc;
[2]343
[551]344 switch (ulFlag) {
[189]345 case 0:
346 if (_CRT_init() == -1)
347 return 0UL;
348 FM3DllHandle = hModule;
[201]349 strcpy(stringfile, "FM3RES.STR");
350 env = getenv("FM3INI");
[551]351 if (env) {
[201]352 DosError(FERR_DISABLEHARDERR);
[849]353 rc = DosQueryPathInfo(env, FIL_STANDARD, &fsa, sizeof(fsa));
[551]354 if (!rc) {
355 if (fsa.attrFile & FILE_DIRECTORY) {
[803]356 BldFullPathName(stringfile, env, "FM3RES.STR");
[201]357 DosError(FERR_DISABLEHARDERR);
[849]358 if (DosQueryPathInfo(stringfile, FIL_STANDARD, &fsa, sizeof(fsa)))
[201]359 strcpy(stringfile, "FM3RES.STR");
[189]360 }
[2]361 }
[189]362 }
[201]363 LoadStrings(stringfile);
364
[189]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>,"
[551]379 "<DRM_DISCARD,DRF_UNKNOWN>," "<DRM_PRINT,DRF_UNKNOWN>";
[189]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";
[552]389 ISOFS = "ISOFS";
[189]390 FAT32 = "FAT32";
391 HPFS386 = "HPFS386";
392 CBSIFS = "CBSIFS";
[526]393 NDFS32 = "NDFS32";
[552]394 RAMFS = "RAMFS";
[555]395 NTFS = "NTFS";
[593]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
[189]426 /* end of strings */
427 memset(&RGBBLACK, 0, sizeof(RGB2));
[689]428 RGBGREY.bRed = RGBGREY.bGreen = RGBGREY.bBlue = (BYTE)204;
[189]429 RGBGREY.fcOptions = 0;
[803]430 FM3UL = *(ULONG *)FM3Str;
[189]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;
[2]442 }
443 return 1UL;
444}
445
[690]446#endif // __IBMC__
447
[189]448VOID APIENTRY DeInitFM3DLL(ULONG why)
449{
[2]450 /* cleanup */
[189]451 static CHAR s[CCHMAXPATH];
452 CHAR *enddir;
453 HDIR search_handle;
454 ULONG num_matches;
[843]455 FILEFINDBUF3 ffb;
[2]456
457 StopTimer();
458 StopPrinting = 1;
459
[189]460 if (LogFileHandle)
[2]461 fclose(LogFileHandle);
462
[551]463 if (fmprof) {
[2]464 PrfCloseProfile(fmprof);
[189]465 fmprof = (HINI) 0;
[551]466 if (fIniExisted) {
[2]467 DosError(FERR_DISABLEHARDERR);
[551]468 DosCopy("FM3.INI", "FM3INI.BAK", DCPY_EXISTING);
[2]469 }
470 }
471
[189]472 if (fToolsChanged)
[2]473 save_tools(NULL);
474
[689]475# ifdef __IBMC__
[2]476 _fcloseall();
[689]477# else // __WATCOMC__
478 fcloseall();
479# endif
[2]480
481 save_dir(s);
[189]482 if (s[strlen(s) - 1] != '\\')
483 strcat(s, "\\");
[2]484 enddir = &s[strlen(s)];
[551]485 if (*ArcTempRoot) {
[189]486 strcat(s, ArcTempRoot);
487 strcat(s, "*");
[2]488 search_handle = HDIR_CREATE;
489 num_matches = 1L;
[843]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)) {
[551]496 do {
[843]497 strcpy(enddir, ffb.achName);
498 if (ffb.attrFile & FILE_DIRECTORY) {
[189]499 wipeallf("%s\\*", s);
500 DosDeleteDir(s);
501 }
502 else
503 unlinkf("%s", s);
504 }
[843]505 while (!DosFindNext(search_handle,
506 &ffb, sizeof(ffb), &num_matches));
[2]507 DosFindClose(search_handle);
508 }
509 }
510
511 save_dir(s);
[189]512 if (s[strlen(s) - 1] != '\\')
513 strcat(s, "\\");
[2]514 enddir = &s[strlen(s)];
[189]515 strcat(s, LISTTEMPROOT);
516 strcat(s, "???");
[2]517 search_handle = HDIR_CREATE;
[838]518 num_matches = 1;
[843]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)) {
[551]525 do {
[843]526 if (!(ffb.attrFile & FILE_DIRECTORY)) {
527 strcpy(enddir, ffb.achName);
[189]528 unlinkf("%s", s);
[2]529 }
[189]530 }
[843]531 while (!DosFindNext(search_handle,
532 &ffb, sizeof(ffb), &num_matches));
[2]533 DosFindClose(search_handle);
534 }
535
536 DosForceDelete("$FM2PLAY.$$$");
537
538 EndNote();
539
[189]540 if (FM3ModHandle)
[2]541 DosFreeModule(FM3ModHandle);
542
[551]543 DosExitList(EXLST_REMOVE, DeInitFM3DLL);
[2]544}
545
[189]546BOOL InitFM3DLL(HAB hab, int argc, char **argv)
547{
[2]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;
[201]554 APIRET rc;
555 APIRET rcl = 1;
556 APIRET rcq = 1;
[803]557 PFN pfnResVersion = (PFN)NULL;
[201]558 ULONG RVMajor = 0;
559 ULONG RVMinor = 0;
560 ULONG ret = 0;
[849]561 FILESTATUS3 fs3; // 25 Aug 07 SHL
[803]562 PSZ env;
[201]563 CHAR dllfile[CCHMAXPATH];
564 ULONG size;
[2]565
[551]566 if (!StringsLoaded()) {
[2]567 saymsg(MB_ENTER,
[189]568 HWND_DESKTOP,
569 "Error",
570 "FM3RES.STR isn't in right format, at least "
571 "for this version of FM/2.");
[2]572 return FALSE;
573 }
574
[201]575 strcpy(dllfile, "FM3RES");
576 env = getenv("FM3INI");
[551]577 if (env) {
[201]578 DosError(FERR_DISABLEHARDERR);
[849]579 rc = DosQueryPathInfo(env, FIL_STANDARD, &fs3, sizeof(fs3));
[551]580 if (!rc) {
[803]581 if (fs3.attrFile & FILE_DIRECTORY) {
582 BldFullPathName(dllfile, env, "FM3RES"); // 23 Aug 07 SHL
[201]583 DosError(FERR_DISABLEHARDERR);
[849]584 if (DosQueryPathInfo(dllfile, FIL_STANDARD, &fs3, sizeof(fs3)))
[201]585 strcpy(dllfile, "FM3RES");
[2]586 }
587 }
[201]588 }
[551]589 rcl = DosLoadModule(NULL, 0, dllfile, &FM3ModHandle);
590 if (rcl) {
[339]591 saymsg(MB_CANCEL | MB_ICONEXCLAMATION,
592 HWND_DESKTOP,
[551]593 GetPString(IDS_ERRORTEXT), GetPString(IDS_FM3RESERROR1TEXT));
[339]594 return FALSE;
595 }
596 else {
597 rc = DosExitList(EXLST_ADD, DeInitFM3DLL);
[551]598 if (rc) {
[803]599 Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
600 "DosExitList");
[339]601 }
[551]602 rcq = DosQueryProcAddr(FM3ModHandle, 1, "ResVersion", &pfnResVersion);
[201]603 if (!rcq)
604 ret = pfnResVersion(&RVMajor, &RVMinor);
605 }
[339]606
[551]607 if (RVMajor < VERMAJOR || (RVMajor == VERMAJOR && RVMinor < VERMINOR)) {
[201]608 saymsg(MB_ENTER,
609 HWND_DESKTOP,
610 GetPString(IDS_ERRORTEXT),
611 GetPString(IDS_FM3RESERROR2TEXT),
612 !rcq ?
[551]613 GetPString(IDS_FM3RESERROR3TEXT) :
614 !rcl ?
615 GetPString(IDS_FM3RESERROR4TEXT) :
616 GetPString(IDS_FM3RESERROR5TEXT), RVMajor, RVMinor, rcl, rcq, ret);
[201]617 return FALSE;
[2]618 }
619
[189]620 ArgDriveFlags(argc, argv);
[2]621 FillInDriveFlags(NULL);
622
[189]623 if (!*profile)
624 strcpy(profile, "FM3.INI");
[2]625 mypid = getpid();
626 /* give default appname if none set by caller */
[189]627 if (!*appname)
628 strcpy(appname, FM3Str);
[2]629 /* save appname; may be reset below */
[189]630 strcpy(realappname, appname);
631 if (!strcmp(appname, FM3Str))
[803]632 DosSetMaxFH(100);
[189]633 else if (!strcmp(appname, "VDir") ||
634 !strcmp(appname, "VTree") ||
635 !strcmp(appname, "VCollect") ||
[551]636 !strcmp(appname, "SEEALL") || !strcmp(appname, "FM/4"))
[803]637 DosSetMaxFH(60);
[2]638 else
[803]639 DosSetMaxFH(40);
[2]640
[189]641 if (DosQuerySysInfo(QSV_VERSION_MAJOR,
642 QSV_VERSION_MINOR,
[803]643 OS2ver,
644 sizeof(OS2ver))) {
[2]645 OS2ver[0] = 2;
646 OS2ver[1] = 1;
647 }
648
649 /* set up default root names for temp archive goodies */
[189]650 if (!fAmAV2)
651 strcpy(ArcTempRoot, "$FM$ARC$");
[2]652 else
[189]653 strcpy(ArcTempRoot, "$AV$ARC$");
[2]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 */
[551]661 if (_beginthread(HeapThread, NULL, 32768, NULL) == -1) {
662 Runtime_Error(pszSrcFile, __LINE__,
663 GetPString(IDS_COULDNTSTARTTHREADTEXT));
[339]664 return FALSE;
665 }
[917]666
[189]667 /* timer messages are sent from a separate thread -- start it */
[803]668 if (!StartTimer()) {
669 Runtime_Error(pszSrcFile, __LINE__,
670 GetPString(IDS_COULDNTSTARTTHREADTEXT));
[2]671 return FALSE;
[803]672 }
[2]673
[718]674 /* Are we the workplace shell? */
[705]675 env = getenv("WORKPLACE_PROCESS");
[718]676 fWorkPlace = env != NULL &&
677 (stricmp(env, "YES") == 0 || atoi(env) == 1);
678
[189]679 if ((!strchr(profile, '\\') && !strchr(profile, ':')) ||
[803]680 !(fmprof = PrfOpenProfile((HAB)0, profile)))
681 {
[2]682 /* figure out where to put INI file... */
[803]683 CHAR inipath[CCHMAXPATH];
[2]684
685 DosError(FERR_DISABLEHARDERR);
686 save_dir2(HomePath);
687 DosError(FERR_DISABLEHARDERR);
[189]688 memset(driveserial, -1, sizeof(driveserial));
[2]689 *inipath = 0;
690 env = getenv("FM3INI");
[551]691 if (env) {
[189]692 strcpy(inipath, env);
[2]693 DosError(FERR_DISABLEHARDERR);
[849]694 rc = DosQueryPathInfo(inipath, FIL_STANDARD, &fs3, sizeof(fs3));
[551]695 if (!rc) {
[803]696 if (fs3.attrFile & FILE_DIRECTORY)
697 BldFullPathName(inipath, inipath, profile);
[2]698 }
699 }
[551]700 if (!env) {
[2]701 env = searchpath(profile);
[189]702 if (!env)
703 env = profile;
704 strcpy(inipath, env);
[2]705 }
[201]706
[2]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 */
[201]709 if (!*inipath)
710 strcpy(inipath, profile);
711 DosError(FERR_DISABLEHARDERR);
[803]712
[917]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 {
[989]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 }
[2]729 }
[989]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 }
[2]741 }
[803]742 fmprof = PrfOpenProfile((HAB)0, inipath);
[551]743 if (!fmprof) {
[189]744 strcpy(inipath, "FM3.INI");
[803]745 fmprof = PrfOpenProfile((HAB)0, inipath);
[2]746 }
[201]747
[917]748 // 10 Jan 08 SHL fixme to do first time if new ini
749 // 10 Jan 08 SHL post UM_FIRSTTIME to main window
[551]750 if (!fmprof) {
751 Win_Error(NULLHANDLE, NULLHANDLE, pszSrcFile, __LINE__,
[989]752 "PrfOpenProfile");
[2]753 return FALSE;
754 }
755 }
756
757 FindSwapperDat();
758
[201]759 size = sizeof(BOOL);
760 PrfQueryProfileData(fmprof,
761 FM3Str,
[803]762 "SeparateParms",
763 &fSeparateParms,
764 &size);
[201]765 if (!fSeparateParms)
766 strcpy(appname, FM3Str);
[2]767
768 /* start help */
[189]769 memset(&hini, 0, sizeof(HELPINIT));
[2]770 hini.cb = sizeof(HELPINIT);
[849]771 hini.ulReturnCode = 0;
[2]772 hini.pszTutorialName = NULL;
[189]773 hini.phtHelpTable = (PHELPTABLE) MAKELONG(ID_HELPTABLE, 0xffff);
774 hini.hmodAccelActionBarModule = (HMODULE) 0;
[2]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";
[189]780 hwndHelp = WinCreateHelpInstance(hab, &hini);
[551]781 if (!hwndHelp) {
[201]782 static CHAR helppath[CCHMAXPATH]; // fixme to be local?
[2]783
784 env = getenv("FM3INI");
[551]785 if (env) {
[189]786 strcpy(helppath, env);
[2]787 DosError(FERR_DISABLEHARDERR);
[849]788 rc = DosQueryPathInfo(helppath, FIL_STANDARD, &fs3, sizeof(fs3));
[551]789 if (!rc) {
[803]790 if (fs3.attrFile & FILE_DIRECTORY) {
791 BldFullPathName(helppath, helppath, "FM3.HLP");
[189]792 hini.pszHelpLibraryName = helppath;
793 hwndHelp = WinCreateHelpInstance(hab, &hini);
794 }
[2]795 }
796 }
797 }
[551]798 if (!hwndHelp) {
[2]799 saymsg(MB_ENTER | MB_ICONEXCLAMATION,
[189]800 HWND_DESKTOP,
801 GetPString(IDS_FM2TROUBLETEXT),
802 GetPString(IDS_CANTLOADHELPTEXT),
803 GetPString(IDS_NOHELPACCEPTTEXT));
[2]804 }
805
806 /* a couple of default window procs so we don't have to look them up later */
[189]807 if (WinQueryClassInfo(hab, WC_CONTAINER, &clinfo))
[2]808 PFNWPCnr = clinfo.pfnWindowProc;
[179]809 // saymsg(MB_ENTER,HWND_DESKTOP,"Container flags:","%08lx",clinfo.flClassStyle);
[189]810 if (WinQueryClassInfo(hab, WC_FRAME, &clinfo))
[2]811 PFNWPFrame = clinfo.pfnWindowProc;
[179]812 // saymsg(MB_ENTER,HWND_DESKTOP,"Frame flags:","%08lx",clinfo.flClassStyle);
[189]813 if (WinQueryClassInfo(hab, WC_BUTTON, &clinfo))
[2]814 PFNWPButton = clinfo.pfnWindowProc;
[179]815 // saymsg(MB_ENTER,HWND_DESKTOP,"Button flags:","%08lx",clinfo.flClassStyle);
[189]816 if (WinQueryClassInfo(hab, WC_STATIC, &clinfo))
[2]817 PFNWPStatic = clinfo.pfnWindowProc;
[179]818 // saymsg(MB_ENTER,HWND_DESKTOP,"Static flags:","%08lx",clinfo.flClassStyle);
[189]819 if (WinQueryClassInfo(hab, WC_MLE, &clinfo))
[2]820 PFNWPMLE = clinfo.pfnWindowProc;
[179]821 // saymsg(MB_ENTER,HWND_DESKTOP,"MLE flags:","%08lx",clinfo.flClassStyle);
[551]822 if (!PFNWPCnr || !PFNWPFrame || !PFNWPButton || !PFNWPStatic || !PFNWPMLE) {
[339]823 Runtime_Error(pszSrcFile, __LINE__, "WinQueryClassInfo");
[2]824 return FALSE;
825 }
826
827 /* register window classes we use */
828 WinRegisterClass(hab,
[593]829 WC_MAINWND,
[189]830 MainWndProc,
[551]831 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 8);
[2]832 WinRegisterClass(hab,
[593]833 WC_MAINWND2,
[189]834 MainWndProc2,
[551]835 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 4);
[2]836 WinRegisterClass(hab,
[593]837 WC_TREECONTAINER,
[189]838 TreeClientWndProc,
[551]839 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 2);
[2]840 WinRegisterClass(hab,
[593]841 WC_DIRCONTAINER,
[189]842 DirClientWndProc,
[551]843 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 2);
[2]844 WinRegisterClass(hab,
[593]845 WC_COLLECTOR,
[189]846 CollectorClientWndProc,
[551]847 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 2);
[2]848 WinRegisterClass(hab,
[593]849 WC_ARCCONTAINER,
[189]850 ArcClientWndProc,
[551]851 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 2);
[2]852 WinRegisterClass(hab,
[593]853 WC_MLEEDITOR,
[189]854 MLEEditorProc,
[551]855 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 2);
[2]856 WinRegisterClass(hab,
[593]857 WC_INIEDITOR,
[189]858 IniProc,
[551]859 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 2);
[2]860 WinRegisterClass(hab,
[593]861 WC_TOOLBACK,
[952]862 ToolBackProc,
863 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
864 sizeof(PVOID));
[2]865 WinRegisterClass(hab,
[593]866 WC_DRIVEBACK,
[189]867 DriveBackProc,
868 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
869 sizeof(PVOID));
[2]870 WinRegisterClass(hab,
[593]871 WC_SEEALL,
[189]872 SeeAllWndProc,
[551]873 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID));
[2]874 WinRegisterClass(hab,
[593]875 WC_NEWVIEW,
[189]876 ViewWndProc,
[551]877 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID));
[2]878 WinRegisterClass(hab,
[593]879 WC_TOOLBUTTONS,
[189]880 ChildButtonProc,
881 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
882 sizeof(PVOID));
[2]883 WinRegisterClass(hab,
[593]884 WC_DRIVEBUTTONS,
[189]885 DriveProc,
886 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
887 sizeof(PVOID));
[2]888 WinRegisterClass(hab,
[593]889 WC_BUBBLE,
[189]890 BubbleProc,
891 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
892 sizeof(ULONG) * 2);
[2]893 WinRegisterClass(hab,
[593]894 WC_STATUS,
[189]895 StatusProc,
896 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
897 sizeof(ULONG));
[2]898 WinRegisterClass(hab,
[593]899 WC_DIRSTATUS,
[189]900 DirTextProc,
901 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
902 sizeof(ULONG));
[2]903 WinRegisterClass(hab,
[593]904 WC_TREESTATUS,
[189]905 TreeStatProc,
906 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
907 sizeof(ULONG));
[2]908 WinRegisterClass(hab,
[593]909 WC_ARCSTATUS,
[189]910 ArcTextProc,
911 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
912 sizeof(ULONG));
[2]913 WinRegisterClass(hab,
[593]914 WC_COLSTATUS,
[189]915 CollectorTextProc,
916 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
917 sizeof(ULONG));
[2]918 WinRegisterClass(hab,
[593]919 WC_SEESTATUS,
[189]920 SeeStatusProc,
921 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
922 sizeof(ULONG));
[2]923 WinRegisterClass(hab,
[593]924 WC_VIEWSTATUS,
[189]925 ViewStatusProc,
926 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
927 sizeof(ULONG));
[2]928 WinRegisterClass(hab,
[593]929 WC_ERRORWND,
[189]930 NotifyWndProc,
931 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
932 sizeof(PVOID));
[2]933 WinRegisterClass(hab,
[593]934 WC_MINITIME,
[189]935 MiniTimeProc,
936 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
937 sizeof(PVOID) * 2);
[2]938 WinRegisterClass(hab,
[593]939 WC_DATABAR,
[551]940 DataProc, CS_SIZEREDRAW, sizeof(PVOID));
[2]941 WinRegisterClass(hab,
[593]942 WC_TREEOPENBUTTON,
[189]943 OpenButtonProc,
944 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
945 sizeof(PVOID));
[2]946 WinRegisterClass(hab,
[593]947 WC_AUTOVIEW,
[189]948 AutoViewProc,
949 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
950 sizeof(PVOID));
[2]951 WinRegisterClass(hab,
[593]952 WC_LED,
[189]953 LEDProc,
954 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
955 sizeof(PVOID));
[2]956
957 /*
[201]958 * set some defaults (note: everything else automatically initialized
[2]959 * to 0)
960 */
961 detailssize = detailsea = detailslwdate = detailslwtime = detailsattr =
[189]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 =
[850]969 fShowTarget = fDrivebarHelp = fCheckMM = TRUE;
[2]970 ulCnrType = CCS_EXTENDSEL;
[789]971 FilesToGet = FILESTOGET_MIN;
[985]972 MaxComLineStrg = MAXCOMLINESTRGDEFAULT;
[752]973 AutoviewHeight = 48;
[189]974 strcpy(printer, "PRN");
[2]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
[860]985 //Get default Country info
986 {
987 COUNTRYCODE Country = {0};
988 ULONG ulInfoLen = 0;
989 COUNTRYINFO CtryInfo = {0};
990
991 DosQueryCtryInfo(sizeof(CtryInfo), &Country,
[917]992 &CtryInfo, &ulInfoLen);
[860]993 *ThousandsSeparator = CtryInfo.szThousandsSeparator[0];
994 }
995
[201]996 // load preferences from profile (INI) file
[985]997 size = sizeof(ULONG);
998 PrfQueryProfileData(fmprof, appname, "MaxComLineStrg", &MaxComLineStrg, &size);
[1004]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 }
[985]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
[201]1050 size = sizeof(BOOL);
[803]1051 PrfQueryProfileData(fmprof, appname, "ShowTarget", &fShowTarget, &size);
[201]1052 size = sizeof(BOOL);
[803]1053 PrfQueryProfileData(fmprof, appname, "CheckMM", &fCheckMM, &size);
[201]1054 size = sizeof(BOOL);
[803]1055 PrfQueryProfileData(fmprof, appname, "ChangeTarget", &fChangeTarget, &size);
[201]1056 size = sizeof(BOOL);
[803]1057 PrfQueryProfileData(fmprof, appname, "ConfirmTarget", &fConfirmTarget, &size);
[201]1058 size = sizeof(BOOL);
[803]1059 PrfQueryProfileData(fmprof, FM3Str, "CustomFileDlg", &fCustomFileDlg, &size);
[201]1060 size = sizeof(BOOL);
[803]1061 PrfQueryProfileData(fmprof, FM3Str, "SaveMiniCmds", &fSaveMiniCmds, &size);
[201]1062 size = sizeof(BOOL);
[803]1063 PrfQueryProfileData(fmprof, appname, "SaveBigCmds", &fSaveBigCmds, &size);
[201]1064 size = sizeof(BOOL);
[803]1065 PrfQueryProfileData(fmprof, appname, "NoFoldMenu", &fNoFoldMenu, &size);
[201]1066 size = sizeof(BOOL);
[803]1067 PrfQueryProfileData(fmprof, FM3Str, "ThreadNotes", &fThreadNotes, &size);
[551]1068 size = sizeof(BOOL);
[803]1069 PrfQueryProfileData(fmprof, FM3Str, "Prnpagenums", &prnpagenums, &size);
[201]1070 size = sizeof(BOOL);
[803]1071 PrfQueryProfileData(fmprof, FM3Str, "Prnalt", &prnalt, &size);
[201]1072 size = sizeof(BOOL);
[803]1073 PrfQueryProfileData(fmprof, FM3Str, "Prnformat", &prnformat, &size);
[201]1074 size = sizeof(BOOL);
1075 PrfQueryProfileData(fmprof, FM3Str, "Prnformfeedbefore",
[803]1076 &prnformfeedbefore, &size);
[201]1077 size = sizeof(BOOL);
[803]1078 PrfQueryProfileData(fmprof, FM3Str,
1079 "Prnformfeedafter",&prnformfeedafter, &size);
[201]1080 size = sizeof(ULONG);
[803]1081 PrfQueryProfileData(fmprof, FM3Str, "Prntabspaces", &prntabspaces, &size);
[201]1082 size = sizeof(ULONG);
[803]1083 PrfQueryProfileData(fmprof, FM3Str, "Prnwidth", &prnwidth, &size);
[201]1084 size = sizeof(ULONG);
[803]1085 PrfQueryProfileData(fmprof, FM3Str, "Prnlength", &prnlength, &size);
[201]1086 size = sizeof(ULONG);
[803]1087 PrfQueryProfileData(fmprof, FM3Str, "Prntmargin", &prntmargin, &size);
[201]1088 size = sizeof(ULONG);
[803]1089 PrfQueryProfileData(fmprof, FM3Str, "Prnbmargin", &prnbmargin, &size);
[201]1090 size = sizeof(ULONG);
[803]1091 PrfQueryProfileData(fmprof, FM3Str, "Prnlmargin", &prnlmargin, &size);
[201]1092 size = sizeof(ULONG);
[803]1093 PrfQueryProfileData(fmprof, FM3Str, "Prnrmargin", &prnrmargin, &size);
[201]1094 size = sizeof(ULONG);
[803]1095 PrfQueryProfileData(fmprof, FM3Str, "Prnspacing", &prnspacing, &size);
[201]1096 size = sizeof(BOOL);
[803]1097 PrfQueryProfileData(fmprof, FM3Str, "NoDead", &fNoDead, &size);
[201]1098 size = sizeof(BOOL);
[803]1099 PrfQueryProfileData(fmprof, FM3Str, "NoFinger", &fNoFinger, &size);
[201]1100 size = sizeof(BOOL);
[803]1101 PrfQueryProfileData(fmprof, appname, "SwitchTree", &fSwitchTree, &size);
[201]1102 size = sizeof(BOOL);
1103 PrfQueryProfileData(fmprof, appname, "SwitchTreeExpand",
[803]1104 &fSwitchTreeExpand, &size);
[201]1105 size = sizeof(BOOL);
1106 PrfQueryProfileData(fmprof, appname, "SwitchTreeOnFocus",
[803]1107 &fSwitchTreeOnFocus, &size);
[201]1108 size = sizeof(BOOL);
1109 PrfQueryProfileData(fmprof, appname, "CollapseFirst",
[803]1110 &fCollapseFirst, &size);
[201]1111 size = sizeof(BOOL);
1112 PrfQueryProfileData(fmprof, appname, "FilesInTree",
[803]1113 &fFilesInTree, &size);
[201]1114 size = sizeof(BOOL);
[803]1115 PrfQueryProfileData(fmprof, FM3Str, "TopDir", &fTopDir, &size);
[201]1116 size = sizeof(BOOL);
[803]1117 PrfQueryProfileData(fmprof, FM3Str, "LookInDir", &fLookInDir, &size);
[551]1118 PrfQueryProfileString(fmprof, appname, "DefArc", NULL, szDefArc,
1119 sizeof(szDefArc));
[201]1120 size = sizeof(ULONG);
1121 PrfQueryProfileData(fmprof, FM3Str, "AutoviewHeight",
[803]1122 &AutoviewHeight, &size);
[201]1123 size = sizeof(BOOL);
[803]1124 PrfQueryProfileData(fmprof, FM3Str, "KeepCmdLine", &fKeepCmdLine, &size);
[551]1125 if (strcmp(realappname, "FM/4")) {
[2]1126 size = sizeof(BOOL);
[803]1127 PrfQueryProfileData(fmprof, FM3Str, "MoreButtons", &fMoreButtons, &size);
[2]1128 size = sizeof(BOOL);
[803]1129 PrfQueryProfileData(fmprof, FM3Str, "Drivebar", &fDrivebar, &size);
[201]1130 }
1131 else
1132 fDrivebar = fMoreButtons = TRUE;
1133 size = sizeof(BOOL);
[803]1134 PrfQueryProfileData(fmprof, appname, "NoSearch", &fNoSearch, &size);
[201]1135 size = sizeof(BOOL);
[803]1136 PrfQueryProfileData(fmprof, appname, "GuessType", &fGuessType, &size);
[201]1137 size = sizeof(BOOL);
[803]1138 PrfQueryProfileData(fmprof, appname, "ViewChild", &fViewChild, &size);
[201]1139 size = sizeof(BOOL);
[803]1140 PrfQueryProfileData(fmprof, appname, "ShowEnv", &fShowEnv, &size);
[201]1141 size = sizeof(BOOL);
[803]1142 PrfQueryProfileData(fmprof, appname, "LeaveTree", &fLeaveTree, &size);
[201]1143 size = sizeof(BOOL);
[803]1144 PrfQueryProfileData(fmprof, FM3Str, "Comments", &fComments, &size);
[201]1145 size = sizeof(ULONG);
[803]1146 PrfQueryProfileData(fmprof, appname, "WS_ANIMATE", &fwsAnimate, &size);
[201]1147 if (fwsAnimate)
1148 fwsAnimate = WS_ANIMATE;
1149 size = sizeof(ULONG);
1150 size = sizeof(BOOL);
1151 PrfQueryProfileData(fmprof, appname, "SelectedAlways",
[803]1152 &fSelectedAlways, &size);
[201]1153 size = sizeof(BOOL);
[803]1154 PrfQueryProfileData(fmprof, FM3Str, "ToolbarHelp", &fToolbarHelp, &size);
[201]1155 size = sizeof(BOOL);
[803]1156 PrfQueryProfileData(fmprof, FM3Str, "OtherHelp", &fOtherHelp, &size);
[201]1157 size = sizeof(BOOL);
[803]1158 PrfQueryProfileData(fmprof, FM3Str, "DrivebarHelp", &fDrivebarHelp, &size);
[201]1159 size = sizeof(BOOL);
[803]1160 PrfQueryProfileData(fmprof, appname, "AutoAddDirs", &fAutoAddDirs, &size);
[201]1161 size = sizeof(BOOL);
[803]1162 PrfQueryProfileData(fmprof, appname,
1163 "AutoAddAllDirs", &fAutoAddAllDirs, &size);
[201]1164 size = sizeof(BOOL);
1165 PrfQueryProfileData(fmprof, FM3Str, "UserListSwitches",
[803]1166 &fUserListSwitches, &size);
[201]1167 size = sizeof(BOOL);
1168 PrfQueryProfileData(fmprof, appname, "UseNewViewer",
[803]1169 &fUseNewViewer, &size);
[201]1170 size = sizeof(BOOL);
1171 PrfQueryProfileData(fmprof, appname, "DefaultDeletePerm",
[803]1172 &fDefaultDeletePerm, &size);
[201]1173 size = sizeof(BOOL);
1174 PrfQueryProfileData(fmprof, FM3Str, "ExternalINIs",
[803]1175 &fExternalINIs, &size);
[201]1176 size = sizeof(BOOL);
1177 PrfQueryProfileData(fmprof, FM3Str, "ExternalCollector",
[803]1178 &fExternalCollector, &size);
[201]1179 size = sizeof(BOOL);
1180 PrfQueryProfileData(fmprof, FM3Str, "ExternalArcboxes",
[803]1181 &fExternalArcboxes, &size);
[201]1182 size = sizeof(BOOL);
1183 PrfQueryProfileData(fmprof, FM3Str, "ExternalViewer",
[803]1184 &fExternalViewer, &size);
[201]1185 size = sizeof(BOOL);
1186 PrfQueryProfileData(fmprof, FM3Str, "UseQProcStat",
[850]1187 &fUseQProcStat, &size);
[201]1188 size = sizeof(BOOL);
[828]1189 PrfQueryProfileData(fmprof, FM3Str, "UseQSysState",
1190 &fUseQSysState, &size);
1191 size = sizeof(BOOL);
[803]1192 PrfQueryProfileData(fmprof, FM3Str, "DataMin", &fDataMin, &size);
[201]1193 size = sizeof(BOOL);
[803]1194 PrfQueryProfileData(fmprof, appname, "DataToFore", &fDataToFore, &size);
[201]1195 size = sizeof(BOOL);
1196 PrfQueryProfileData(fmprof, appname, "DataShowDrives",
[803]1197 &fDataShowDrives, &size);
[201]1198 size = sizeof(BOOL);
1199 PrfQueryProfileData(fmprof, appname, "DataInclRemote",
[803]1200 &fDataInclRemote, &size);
[201]1201 size = sizeof(BOOL);
[803]1202 PrfQueryProfileData(fmprof, FM3Str, "SplitStatus", &fSplitStatus, &size);
[201]1203 size = sizeof(BOOL);
1204 PrfQueryProfileData(fmprof, appname, "FolderAfterExtract",
[803]1205 &fFolderAfterExtract, &size);
[201]1206 size = sizeof(BOOL);
[803]1207 PrfQueryProfileData(fmprof, FM3Str, "DullDatabar", &fDullMin, &size);
[201]1208 size = sizeof(BOOL);
[803]1209 PrfQueryProfileData(fmprof, appname, "BlueLED", &fBlueLED, &size);
[201]1210 size = sizeof(BOOL);
[551]1211 PrfQueryProfileData(fmprof, appname, "ConfirmDelete",
[803]1212 &fConfirmDelete, &size);
[201]1213 size = sizeof(BOOL);
[803]1214 PrfQueryProfileData(fmprof, FM3Str, "SaveState", &fSaveState, &size);
[201]1215 size = sizeof(BOOL);
[803]1216 PrfQueryProfileData(fmprof, appname, "SyncUpdates", &fSyncUpdates, &size);
[201]1217 size = sizeof(BOOL);
[803]1218 PrfQueryProfileData(fmprof, appname, "LoadSubject", &fLoadSubject, &size);
[201]1219 size = sizeof(BOOL);
[803]1220 PrfQueryProfileData(fmprof, appname, "UnHilite", &fUnHilite, &size);
[201]1221 size = sizeof(BOOL);
[803]1222 PrfQueryProfileData(fmprof, FM3Str, "TileBackwards", &fTileBackwards, &size);
[201]1223 size = sizeof(BOOL);
[803]1224 PrfQueryProfileData(fmprof, appname, "LoadLongname", &fLoadLongnames, &size);
[551]1225 size = sizeof(BOOL);
[803]1226 PrfQueryProfileData(fmprof, appname, "VerifyWrites", &fVerify, &size);
[201]1227 DosSetVerify(fVerify);
1228 size = sizeof(BOOL);
[803]1229 PrfQueryProfileData(fmprof, appname, "DontMoveMouse", &fDontMoveMouse, &size);
[201]1230 size = sizeof(BOOL);
[803]1231 PrfQueryProfileData(fmprof, appname, "NoIconsFiles", &fNoIconsFiles, &size);
[201]1232 size = sizeof(BOOL);
[803]1233 PrfQueryProfileData(fmprof, appname, "NoIconsDirs", &fNoIconsDirs, &size);
[201]1234 size = sizeof(BOOL);
[803]1235 PrfQueryProfileData(fmprof, appname, "ForceUpper", &fForceUpper, &size);
[201]1236 size = sizeof(BOOL);
[803]1237 PrfQueryProfileData(fmprof, appname, "ForceLower", &fForceLower, &size);
[201]1238 size = sizeof(BOOL);
[803]1239 PrfQueryProfileData(fmprof, FM3Str, "TextTools", &fTextTools, &size);
[201]1240 size = sizeof(BOOL);
[803]1241 PrfQueryProfileData(fmprof, FM3Str, "ToolTitles", &fToolTitles, &size);
[201]1242 size = sizeof(BOOL);
[803]1243 PrfQueryProfileData(fmprof, appname, "DoubleClickOpens", &fDCOpens, &size);
[201]1244 size = sizeof(BOOL);
[803]1245 PrfQueryProfileData(fmprof, appname, "LinkSetsIcon", &fLinkSetsIcon, &size);
[201]1246 size = sizeof(INT);
[803]1247 PrfQueryProfileData(fmprof, appname, "Sort", &sortFlags, &size);
[201]1248 size = sizeof(INT);
[803]1249 PrfQueryProfileData(fmprof, appname, "TreeSort", &TreesortFlags, &size);
[201]1250 size = sizeof(INT);
[803]1251 PrfQueryProfileData(fmprof, appname,
1252 "CollectorSort", &CollectorsortFlags, &size);
[201]1253 size = sizeof(targetdir);
[803]1254 PrfQueryProfileData(fmprof, appname, "Targetdir", targetdir, &size);
[201]1255 if (!IsValidDir(targetdir))
1256 *targetdir = 0;
1257 size = sizeof(extractpath);
[803]1258 PrfQueryProfileData(fmprof, appname, "ExtractPath", extractpath, &size);
[201]1259 size = sizeof(printer);
[803]1260 PrfQueryProfileData(fmprof, appname, "Printer", printer, &size);
[985]1261 size = MaxComLineStrg;
[803]1262 PrfQueryProfileData(fmprof, appname, "DirCompare", dircompare,
[551]1263 &size);
[985]1264 size = MaxComLineStrg;
[803]1265 PrfQueryProfileData(fmprof, appname, "Viewer", viewer, &size);
[985]1266 size = MaxComLineStrg;
[803]1267 PrfQueryProfileData(fmprof, appname, "Editor", editor, &size);
[985]1268 size = MaxComLineStrg;
[803]1269 PrfQueryProfileData(fmprof, appname, "BinView", binview, &size);
[985]1270 size = MaxComLineStrg;
[803]1271 PrfQueryProfileData(fmprof, appname, "BinEd", bined, &size);
[985]1272 size = MaxComLineStrg;
[803]1273 PrfQueryProfileData(fmprof, appname, "Compare", compare, &size);
[985]1274 size = MaxComLineStrg;
[803]1275 PrfQueryProfileData(fmprof, appname, "Virus", virus, &size);
[892]1276 size = sizeof(BOOL);
1277 PrfQueryProfileData(fmprof, appname, "FtpRunWPSDefault", &fFtpRunWPSDefault, &size);
[985]1278 size = MaxComLineStrg;
[803]1279 PrfQueryProfileData(fmprof, appname, "FTPRun", ftprun, &size);
[917]1280 if (!*ftprun)
[892]1281 fFtpRunWPSDefault = TRUE;
1282 size = sizeof(BOOL);
1283 PrfQueryProfileData(fmprof, appname, "HttpRunWPSDefault", &fHttpRunWPSDefault, &size);
[985]1284 size = MaxComLineStrg;
[803]1285 PrfQueryProfileData(fmprof, appname, "HTTPRun", httprun, &size);
[917]1286 if (!*httprun)
[892]1287 fHttpRunWPSDefault = TRUE;
[985]1288 size = MaxComLineStrg;
[892]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);
[898]1295 PrfQueryProfileData(fmprof, appname, "MailRunDir", mailrundir, &size);
[201]1296 size = sizeof(lasttoolbox);
[803]1297 PrfQueryProfileData(fmprof, FM3Str, "LastToolBox", lasttoolbox,
[917]1298 &size);
[892]1299 size = sizeof(BOOL);
1300 PrfQueryProfileData(fmprof, appname, "LibPathStrictHttpRun", &fLibPathStrictHttpRun,
[917]1301 &size);
[892]1302 size = sizeof(BOOL);
1303 PrfQueryProfileData(fmprof, appname, "LibPathStrictFtpRun", &fLibPathStrictFtpRun,
[917]1304 &size);
[896]1305 size = sizeof(BOOL);
1306 PrfQueryProfileData(fmprof, appname, "LibPathStrictMailRun", &fLibPathStrictMailRun,
[917]1307 &size);
[898]1308 size = sizeof(BOOL);
1309 PrfQueryProfileData(fmprof, appname, "NoMailtoMailRun", &fNoMailtoMailRun,
[551]1310 &size);
[201]1311 size = sizeof(BOOL);
[803]1312 PrfQueryProfileData(fmprof, appname, "FollowTree", &fFollowTree,
[551]1313 &size);
[201]1314 size = sizeof(BOOL);
[551]1315 PrfQueryProfileData(fmprof, appname, "StartMaximized",
[803]1316 &fStartMaximized, &size);
[551]1317 if (!fStartMaximized) {
[2]1318 size = sizeof(BOOL);
[551]1319 PrfQueryProfileData(fmprof, appname, "StartMinimized",
[803]1320 &fStartMinimized, &size);
[2]1321 }
[201]1322 size = sizeof(BOOL);
[803]1323 PrfQueryProfileData(fmprof, appname, "DefaultCopy", &fCopyDefault, &size);
[201]1324 size = sizeof(BOOL);
[803]1325 PrfQueryProfileData(fmprof, appname, "IdleCopy", &fRealIdle, &size);
[201]1326 size = sizeof(BOOL);
1327 PrfQueryProfileData(fmprof, appname, "ArcStuffVisible",
[803]1328 &fArcStuffVisible, &size);
[201]1329 size = sizeof(BOOL);
[803]1330 PrfQueryProfileData(fmprof, FM3Str, "NoTreeGap", &fNoTreeGap, &size);
[201]1331 size = sizeof(BOOL);
[551]1332 PrfQueryProfileData(fmprof, FM3Str, "VTreeOpensWPS",
[803]1333 &fVTreeOpensWPS, &size);
[201]1334 size = sizeof(BOOL);
[803]1335 PrfQueryProfileData(fmprof, appname, "RemoteBug", &fRemoteBug, &size);
[201]1336 size = sizeof(BOOL);
[551]1337 PrfQueryProfileData(fmprof, appname, "Drag&DropDlg",
[803]1338 &fDragndropDlg, &size);
[551]1339 size = sizeof(BOOL);
[803]1340 PrfQueryProfileData(fmprof, FM3Str, "UserComboBox", &fUserComboBox, &size);
[201]1341 size = sizeof(BOOL);
[803]1342 PrfQueryProfileData(fmprof, FM3Str, "MinDirOnOpen", &fMinOnOpen, &size);
[201]1343 size = sizeof(BOOL);
[551]1344 PrfQueryProfileData(fmprof, appname, "QuickArcFind",
[803]1345 &fQuickArcFind, &size);
[201]1346 size = sizeof(BOOL);
[551]1347 PrfQueryProfileData(fmprof, FM3Str, "NoRemovableScan",
[803]1348 &fNoRemovableScan, &size);
[551]1349 size = sizeof(ULONG);
1350 PrfQueryProfileData(fmprof, FM3Str, "NoBrokenNotify",
[803]1351 &NoBrokenNotify, &size);
[551]1352 size = sizeof(ULONG);
[803]1353 PrfQueryProfileData(fmprof, appname, "ContainerType", &ulCnrType,
[201]1354 &size);
1355 size = sizeof(ULONG);
[803]1356 PrfQueryProfileData(fmprof, appname, "FilesToGet", &FilesToGet, &size);
[789]1357 if (FilesToGet < FILESTOGET_MIN)
1358 FilesToGet = FILESTOGET_MIN;
1359 else if (FilesToGet > FILESTOGET_MAX)
1360 FilesToGet = FILESTOGET_MAX;
[201]1361 size = sizeof(BOOL);
[803]1362 PrfQueryProfileData(fmprof, FM3Str, "AutoView", &fAutoView, &size);
[201]1363 size = sizeof(BOOL);
[803]1364 PrfQueryProfileData(fmprof, FM3Str, "FM2Deletes", &fFM2Deletes, &size);
[2]1365
[997]1366 LoadDetailsSwitches("DirCnr", NULL);
[784]1367
[2]1368 /* load pointers and icons we use */
[189]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);
[552]1383 hptrReadonly = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, FILE_READONLY_ICON);
[189]1384 hptrLast = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, LASTITEM_ICON);
1385 hptrRemote = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, REMOTE_ICON);
[552]1386 hptrVirtual = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, VIRTUAL_ICON);
1387 hptrRamdisk = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, RAMDISK_ICON);
[189]1388 if (!fNoDead)
1389 hptrFinger = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, FINGER_ICON);
[2]1390 else
[189]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);
[2]1396
[201]1397 // set up color array used by seeall.c and newview.c color dialog
1398
[189]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;
[2]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
[189]1419HWND StartFM3(HAB hab, INT argc, CHAR ** argv)
1420{
[201]1421 HWND hwndFrame;
1422 HWND hwndClient;
1423 UINT x;
[189]1424 ULONG FrameFlags = FCF_TITLEBAR | FCF_SYSMENU |
[551]1425 FCF_SIZEBORDER | FCF_MINMAX |
1426 FCF_ACCELTABLE | FCF_MENU | FCF_ICON | FCF_TASKLIST | FCF_NOBYTEALIGN;
[2]1427
[551]1428 for (x = 1; x < argc; x++) {
[201]1429 if (*argv[x] == '~' && !argv[x][1])
1430 fReminimize = TRUE;
1431 if (*argv[x] == '+' && !argv[x][1])
1432 fLogFile = TRUE;
[551]1433 if (*argv[x] == '-') {
[201]1434 if (!argv[x][1])
1435 fNoSaveState = TRUE;
1436 else
1437 strcpy(profile, &argv[x][1]);
[2]1438 }
1439 }
1440
1441 hwndFrame = WinCreateStdWindow(HWND_DESKTOP,
[189]1442 WS_VISIBLE,
1443 &FrameFlags,
[593]1444 WC_MAINWND,
[189]1445 NULL,
1446 WS_VISIBLE | WS_ANIMATE,
[551]1447 FM3ModHandle, MAIN_FRAME, &hwndClient);
1448 if (hwndFrame) {
1449 WinSetWindowUShort(hwndFrame, QWS_ID, MAIN_FRAME);
[875]1450 hwndMainMenu = WinWindowFromID(hwndFrame, FID_MENU);
[551]1451 if (!WinRestoreWindowPos(FM2Str, "MainWindowPos", hwndFrame)) {
[2]1452
1453 ULONG fl = SWP_MOVE | SWP_SIZE;
1454 RECTL rcl;
[189]1455 ULONG icz = WinQuerySysValue(HWND_DESKTOP, SV_CYICON) * 3L;
1456 ULONG bsz = WinQuerySysValue(HWND_DESKTOP, SV_CYSIZEBORDER);
[2]1457
[551]1458 WinQueryWindowRect(HWND_DESKTOP, &rcl);
[2]1459 rcl.yBottom += icz;
1460 rcl.yTop -= bsz;
1461 rcl.xLeft += bsz;
1462 rcl.xRight -= bsz;
1463 WinSetWindowPos(hwndFrame,
[189]1464 HWND_TOP,
1465 rcl.xLeft,
1466 rcl.yBottom,
[551]1467 rcl.xRight - rcl.xLeft, rcl.yTop - rcl.yBottom, fl);
[2]1468 }
[189]1469 if (fLogFile)
[551]1470 LogFileHandle = _fsopen("FM2.LOG", "a+", SH_DENYWR);
[189]1471 if (hwndHelp)
[551]1472 WinAssociateHelpInstance(hwndHelp, hwndFrame);
1473 PostMsg(hwndClient, UM_SETUP, MPFROMLONG(argc), MPFROMP(argv));
[2]1474 }
1475 return hwndFrame;
1476}
[32]1477
[985]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
[189]1519int CheckVersion(int vermajor, int verminor)
1520{
[179]1521 int ok = 0;
[32]1522
[179]1523 // fixme to do useful check - was missing in base source
1524
[32]1525#if 0
[551]1526 if (vermajor && verminor) {
[32]1527 *vermajor = VERMAJOR;
1528 *verminor = VERMINOR;
[179]1529 ok = 1;
[32]1530 }
1531#endif
[189]1532
[179]1533 ok = 1;
[32]1534
[179]1535 return ok;
[32]1536}
[783]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.