source: trunk/dll/init.c@ 1177

Last change on this file since 1177 was 1177, checked in by John Small, 17 years ago

Ticket 187: Draft 2: Move remaining function declarations

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