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