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