[41] | 1 |
|
---|
| 2 | /***********************************************************************
|
---|
| 3 |
|
---|
| 4 | $Id: autoview.c 1182 2008-09-10 21:55:47Z jbs $
|
---|
| 5 |
|
---|
| 6 | Auto view
|
---|
| 7 |
|
---|
| 8 | Copyright (c) 1993-98 M. Kimes
|
---|
[907] | 9 | Copyright (c) 2001, 2008 Steven H.Levine
|
---|
[41] | 10 |
|
---|
[130] | 11 | 12 Sep 02 SHL AutoObjProc: catch buff2 overflows
|
---|
| 12 | 25 Oct 02 SHL CreateHexDump: catch buffer overflow
|
---|
| 13 | 12 Feb 03 SHL AutoObjProc: standardize EA math
|
---|
| 14 | 23 May 05 SHL Use QWL_USER
|
---|
[291] | 15 | 29 May 06 SHL Sync with archiver.bb2 mods
|
---|
[341] | 16 | 22 Jul 06 SHL Check more run time errors
|
---|
[439] | 17 | 15 Aug 06 SHL Use Runtime_Error more
|
---|
[531] | 18 | 03 Nov 06 SHL Renames
|
---|
[689] | 19 | 30 Mar 07 GKY Remove GetPString for window class names
|
---|
[793] | 20 | 20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat
|
---|
[827] | 21 | 01 Sep 07 GKY Use xDosSetPathInfo to fix case where FS3 buffer crosses 64k boundry
|
---|
[846] | 22 | 27 Sep 07 SHL Correct ULONGLONG size formatting
|
---|
[872] | 23 | 22 Nov 07 GKY Use CopyPresParams to fix presparam inconsistencies in menus
|
---|
[897] | 24 | 30 Dec 07 GKY Use CommaFmtULL
|
---|
[985] | 25 | 29 Feb 08 GKY Use xfree where appropriate
|
---|
[41] | 26 |
|
---|
| 27 | ***********************************************************************/
|
---|
| 28 |
|
---|
[907] | 29 | #include <stdlib.h>
|
---|
| 30 | #include <string.h>
|
---|
| 31 | #include <ctype.h>
|
---|
| 32 | #include <process.h> // _beginthread
|
---|
| 33 |
|
---|
[2] | 34 | #define INCL_DOS
|
---|
| 35 | #define INCL_WIN
|
---|
| 36 | #define INCL_GPI
|
---|
[841] | 37 | #define INCL_LONGLONG
|
---|
[2] | 38 |
|
---|
[1182] | 39 | #include "fm3dll.h"
|
---|
[2] | 40 | #include "fm3dlg.h"
|
---|
| 41 | #include "fm3str.h"
|
---|
| 42 | #include "mle.h"
|
---|
[907] | 43 | #include "pathutil.h" // BldFullPathName
|
---|
| 44 | #include "errutil.h" // Dos_Error...
|
---|
| 45 | #include "strutil.h" // GetPString
|
---|
[1159] | 46 | #include "autoview.h"
|
---|
| 47 | #include "defview.h" // DefaultView
|
---|
| 48 | #include "valid.h" // IsBinary
|
---|
[1182] | 49 | #include "misc.h" // CheckMenu
|
---|
| 50 | #include "common.h" // CommonTextButton
|
---|
| 51 | #include "presparm.h" // CopyPresParams
|
---|
| 52 | #include "eas.h" // DisplayEAsProc
|
---|
| 53 | #include "chklist.h" // PopupMenu
|
---|
| 54 | #include "wrappers.h" // xDosSetPathInfo
|
---|
| 55 | #include "commafmt.h" // CommaFmtULL
|
---|
[1029] | 56 | #include "fortify.h"
|
---|
| 57 |
|
---|
[2] | 58 | #pragma data_seg(DATA1)
|
---|
[341] | 59 |
|
---|
| 60 | static PSZ pszSrcFile = __FILE__;
|
---|
| 61 |
|
---|
| 62 | static HWND hwndAutoObj;
|
---|
[2] | 63 | static CHAR stopflag;
|
---|
| 64 | static CHAR currfile[CCHMAXPATH];
|
---|
| 65 |
|
---|
[1159] | 66 | static BOOL PutComments(HWND hwnd, CHAR * filename, CHAR * comments);
|
---|
| 67 | static BOOL WriteEA(HWND hwnd, CHAR * filename, CHAR * eaname, USHORT type,
|
---|
| 68 | CHAR * data);
|
---|
| 69 |
|
---|
[551] | 70 | BOOL WriteEA(HWND hwnd, CHAR * filename, CHAR * eaname, USHORT type,
|
---|
| 71 | CHAR * data)
|
---|
[341] | 72 | {
|
---|
[2] | 73 | /* save an ea to disk */
|
---|
| 74 |
|
---|
| 75 | FEA2LIST *pfealist = NULL;
|
---|
[551] | 76 | EAOP2 eaop;
|
---|
| 77 | APIRET rc;
|
---|
| 78 | ULONG ealen;
|
---|
| 79 | USHORT len, *num, *plen, usCodepage;
|
---|
| 80 | CHAR *p, *eaval;
|
---|
| 81 | BOOL ret = FALSE;
|
---|
[2] | 82 |
|
---|
[551] | 83 | if (!filename || !eaname)
|
---|
[2] | 84 | return ret;
|
---|
[551] | 85 | usCodepage = (USHORT) WinQueryCp(WinQueryWindowULong(hwnd, QWL_HMQ));
|
---|
[2] | 86 | len = (data) ? strlen(data) : 0;
|
---|
[551] | 87 | ealen = sizeof(FEA2LIST) + 24L + strlen(eaname) + 1L + (ULONG) len + 4L;
|
---|
| 88 | switch (type) {
|
---|
| 89 | case EAT_EA:
|
---|
| 90 | case EAT_ASCII:
|
---|
| 91 | break;
|
---|
| 92 | case EAT_MVST:
|
---|
| 93 | if (data) {
|
---|
| 94 | ealen += sizeof(USHORT) * 5;
|
---|
| 95 | p = data;
|
---|
| 96 | while (*p) {
|
---|
| 97 | if (*p == '\n' && *(p + 1))
|
---|
| 98 | ealen += sizeof(USHORT);
|
---|
| 99 | p++;
|
---|
| 100 | }
|
---|
| 101 | }
|
---|
| 102 | break;
|
---|
| 103 | case EAT_MVMT:
|
---|
| 104 | if (data) {
|
---|
| 105 | ealen += sizeof(USHORT) * 5;
|
---|
| 106 | p = data;
|
---|
| 107 | while (*p) {
|
---|
| 108 | if (*p == '\n' && *(p + 1))
|
---|
| 109 | ealen += (sizeof(USHORT) * 2);
|
---|
| 110 | p++;
|
---|
| 111 | }
|
---|
| 112 | }
|
---|
| 113 | break;
|
---|
| 114 | default:
|
---|
| 115 | return ret;
|
---|
| 116 | }
|
---|
| 117 |
|
---|
| 118 | rc = DosAllocMem((PPVOID) & pfealist, ealen, PAG_COMMIT | PAG_READ |
|
---|
| 119 | PAG_WRITE | OBJ_TILE);
|
---|
| 120 | if (rc || !pfealist)
|
---|
| 121 | Dos_Error(MB_CANCEL, rc, hwnd, pszSrcFile, __LINE__,
|
---|
| 122 | GetPString(IDS_OUTOFMEMORY));
|
---|
| 123 | else {
|
---|
| 124 | memset(pfealist, 0, ealen);
|
---|
| 125 | pfealist->list[0].cbName = strlen(eaname);
|
---|
| 126 | memcpy(pfealist->list[0].szName, eaname, pfealist->list[0].cbName + 1);
|
---|
| 127 | eaval = pfealist->list[0].szName + pfealist->list[0].cbName + 1;
|
---|
| 128 | switch (type) {
|
---|
[2] | 129 | case EAT_EA:
|
---|
| 130 | case EAT_ASCII:
|
---|
[551] | 131 | if (data) {
|
---|
| 132 | *(USHORT *) eaval = (USHORT) type;
|
---|
| 133 | eaval += sizeof(USHORT);
|
---|
| 134 | *(USHORT *) eaval = (USHORT) len;
|
---|
| 135 | eaval += sizeof(USHORT);
|
---|
| 136 | memcpy(eaval, data, len);
|
---|
| 137 | eaval += len;
|
---|
| 138 | }
|
---|
[2] | 139 | break;
|
---|
| 140 | case EAT_MVST:
|
---|
[551] | 141 | if (data) {
|
---|
| 142 | *(USHORT *) eaval = (USHORT) EAT_MVST;
|
---|
| 143 | eaval += sizeof(USHORT);
|
---|
| 144 | *(USHORT *) eaval = usCodepage;
|
---|
| 145 | eaval += sizeof(USHORT);
|
---|
| 146 | num = (USHORT *) eaval;
|
---|
| 147 | *num = 0;
|
---|
| 148 | eaval += sizeof(USHORT);
|
---|
| 149 | *(USHORT *) eaval = (USHORT) EAT_ASCII;
|
---|
| 150 | eaval += sizeof(USHORT);
|
---|
| 151 | plen = (USHORT *) eaval;
|
---|
| 152 | *plen = 0;
|
---|
| 153 | eaval += sizeof(USHORT);
|
---|
| 154 | p = data;
|
---|
| 155 | while (*p) {
|
---|
| 156 | while (*p) {
|
---|
| 157 | if (*p == '\n') {
|
---|
| 158 | p++;
|
---|
| 159 | break;
|
---|
| 160 | }
|
---|
| 161 | *eaval++ = *p++;
|
---|
| 162 | (*plen)++;
|
---|
| 163 | }
|
---|
| 164 | if (*p || *plen)
|
---|
| 165 | (*num)++;
|
---|
| 166 | if (*p) {
|
---|
| 167 | plen = (USHORT *) eaval;
|
---|
| 168 | *plen = 0;
|
---|
| 169 | eaval += sizeof(USHORT);
|
---|
| 170 | }
|
---|
| 171 | }
|
---|
[2] | 172 | }
|
---|
| 173 | break;
|
---|
| 174 | case EAT_MVMT:
|
---|
[551] | 175 | if (data) {
|
---|
| 176 | *(USHORT *) eaval = (USHORT) EAT_MVMT;
|
---|
| 177 | eaval += sizeof(USHORT);
|
---|
| 178 | *(USHORT *) eaval = usCodepage;
|
---|
| 179 | eaval += sizeof(USHORT);
|
---|
| 180 | num = (USHORT *) eaval;
|
---|
| 181 | *num = 0;
|
---|
| 182 | eaval += sizeof(USHORT);
|
---|
| 183 | *(USHORT *) eaval = (USHORT) EAT_ASCII;
|
---|
| 184 | eaval += sizeof(USHORT);
|
---|
| 185 | plen = (USHORT *) eaval;
|
---|
| 186 | *plen = 0;
|
---|
| 187 | eaval += sizeof(USHORT);
|
---|
| 188 | p = data;
|
---|
| 189 | while (*p) {
|
---|
| 190 | while (*p) {
|
---|
| 191 | if (*p == '\n') {
|
---|
| 192 | p++;
|
---|
| 193 | break;
|
---|
| 194 | }
|
---|
| 195 | *eaval++ = *p++;
|
---|
| 196 | (*plen)++;
|
---|
| 197 | }
|
---|
| 198 | if (*p || *plen)
|
---|
| 199 | (*num)++;
|
---|
| 200 | if (*p) {
|
---|
| 201 | *(USHORT *) eaval = (USHORT) EAT_ASCII;
|
---|
| 202 | eaval += sizeof(USHORT);
|
---|
| 203 | plen = (USHORT *) eaval;
|
---|
| 204 | *plen = 0;
|
---|
| 205 | eaval += sizeof(USHORT);
|
---|
| 206 | }
|
---|
| 207 | }
|
---|
[2] | 208 | }
|
---|
| 209 | break;
|
---|
| 210 | }
|
---|
[1029] | 211 | pfealist->list[0].cbValue = /*(ULONG)*/ (eaval -
|
---|
[551] | 212 | (pfealist->list[0].szName +
|
---|
| 213 | pfealist->list[0].cbName + 1));
|
---|
| 214 | memset(&eaop, 0, sizeof(eaop));
|
---|
[2] | 215 | eaop.fpFEA2List = pfealist;
|
---|
[841] | 216 | pfealist->cbList = 13 + (ULONG) pfealist->list[0].cbName +
|
---|
[551] | 217 | (ULONG) pfealist->list[0].cbValue;
|
---|
[827] | 218 | rc = xDosSetPathInfo(filename, FIL_QUERYEASIZE,
|
---|
| 219 | &eaop, sizeof(eaop), DSPI_WRTTHRU);
|
---|
[2] | 220 | DosFreeMem(pfealist);
|
---|
[551] | 221 | if (!rc)
|
---|
[2] | 222 | ret = TRUE;
|
---|
| 223 | }
|
---|
| 224 | return ret;
|
---|
| 225 | }
|
---|
| 226 |
|
---|
[551] | 227 | BOOL PutComments(HWND hwnd, CHAR * filename, CHAR * comments)
|
---|
[341] | 228 | {
|
---|
[2] | 229 | register CHAR *p;
|
---|
| 230 |
|
---|
[551] | 231 | if (comments) { /* check -- is it empty? */
|
---|
[2] | 232 | p = comments;
|
---|
[551] | 233 | while (*p && isspace(*p))
|
---|
[2] | 234 | p++;
|
---|
[551] | 235 | if (!*p)
|
---|
[2] | 236 | comments = NULL;
|
---|
| 237 | }
|
---|
[551] | 238 | return WriteEA(hwnd, filename, ".COMMENTS", EAT_MVMT, comments);
|
---|
[2] | 239 | }
|
---|
| 240 |
|
---|
[439] | 241 | static PSZ pszBufOvfMsg = "Buffer overflow";
|
---|
[2] | 242 |
|
---|
[551] | 243 | ULONG CreateHexDump(CHAR * pchInBuf, ULONG cbInBuf,
|
---|
| 244 | CHAR * pchOutBuf, ULONG cbOutBuf,
|
---|
| 245 | ULONG cOffset, BOOL fLongAddr)
|
---|
[41] | 246 | {
|
---|
[551] | 247 | register CHAR *pchIn, *pchReset, *pchOut;
|
---|
| 248 | register ULONG ibIn = 0, ibIn2, ibInFill;
|
---|
[41] | 249 | ULONG cbOutLine = 6 + (fLongAddr ? 4 : 0) + 16 * 3 + 1 + 16 + 1;
|
---|
[2] | 250 |
|
---|
[551] | 251 | if (pchInBuf && cbInBuf && pchOutBuf && cbOutBuf) {
|
---|
[41] | 252 | pchIn = pchInBuf;
|
---|
| 253 | pchOut = pchOutBuf;
|
---|
[551] | 254 | if (cOffset)
|
---|
[41] | 255 | *pchOut++ = '\n';
|
---|
| 256 | while (ibIn < cbInBuf) {
|
---|
| 257 | if (pchOut - pchOutBuf + cbOutLine >= cbOutBuf) {
|
---|
[551] | 258 | Runtime_Error(pszSrcFile, __LINE__, pszBufOvfMsg);
|
---|
[41] | 259 | break;
|
---|
| 260 | }
|
---|
| 261 | pchReset = pchIn;
|
---|
| 262 | ibIn2 = ibIn;
|
---|
[551] | 263 | if (fLongAddr)
|
---|
| 264 | sprintf(pchOut, "%08lx ", ibIn + cOffset);
|
---|
[2] | 265 | else
|
---|
[551] | 266 | sprintf(pchOut, "%04lx ", ibIn + cOffset);
|
---|
[41] | 267 | pchOut += 6 + (fLongAddr ? 4 : 0);
|
---|
[2] | 268 | do {
|
---|
[870] | 269 | sprintf(pchOut, "%02x ", (UCHAR)*pchIn);
|
---|
[551] | 270 | pchOut += 3;
|
---|
| 271 | pchIn++;
|
---|
| 272 | ibIn++;
|
---|
| 273 | } while (ibIn < cbInBuf && (ibIn % 16));
|
---|
| 274 | if (ibIn % 16) {
|
---|
| 275 | ibInFill = ibIn;
|
---|
| 276 | while (ibInFill % 16) {
|
---|
| 277 | *pchOut++ = ' ';
|
---|
| 278 | *pchOut++ = ' ';
|
---|
| 279 | *pchOut++ = ' ';
|
---|
| 280 | ibInFill++;
|
---|
| 281 | }
|
---|
[2] | 282 | }
|
---|
[41] | 283 | *pchOut++ = ' ';
|
---|
| 284 | pchIn = pchReset;
|
---|
[2] | 285 | do {
|
---|
[551] | 286 | if (*pchIn && *pchIn != '\n' && *pchIn != '\r' && *pchIn != '\t'
|
---|
| 287 | && *pchIn != '\x1a')
|
---|
| 288 | *pchOut++ = *pchIn++;
|
---|
| 289 | else {
|
---|
| 290 | *pchOut++ = '.';
|
---|
| 291 | pchIn++;
|
---|
| 292 | }
|
---|
| 293 | ibIn2++;
|
---|
| 294 | } while (ibIn2 < ibIn);
|
---|
| 295 | if (ibIn < cbInBuf)
|
---|
| 296 | *pchOut++ = '\n';
|
---|
| 297 | } // while ibIn
|
---|
[41] | 298 | *pchOut = 0;
|
---|
[551] | 299 | return (ULONG) (pchOut - pchOutBuf);
|
---|
[2] | 300 | }
|
---|
| 301 | return 0L;
|
---|
| 302 | }
|
---|
| 303 |
|
---|
[551] | 304 | MRESULT EXPENTRY AutoObjProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
[51] | 305 | {
|
---|
[551] | 306 | switch (msg) {
|
---|
| 307 | case UM_LOADFILE:
|
---|
| 308 | *currfile = 0;
|
---|
| 309 | stopflag--;
|
---|
| 310 | if (fAutoView) {
|
---|
| 311 | WinSetWindowText((fComments) ? hwndAutoMLE : hwndAutoview, "");
|
---|
| 312 | MLEsetreadonly(hwndAutoMLE, TRUE);
|
---|
| 313 | MLEsetchanged(hwndAutoMLE, FALSE);
|
---|
| 314 | }
|
---|
| 315 | if (mp1) {
|
---|
| 316 | if (fAutoView) {
|
---|
[1009] | 317 | strcpy(currfile, (CHAR *)mp1);
|
---|
[551] | 318 | if (!fComments) {
|
---|
[1009] | 319 | if (IsFile((CHAR *)mp1) == 1) {
|
---|
[2] | 320 |
|
---|
[551] | 321 | HFILE handle;
|
---|
[858] | 322 | ULONG olen, ibufflen, action, obufflen, l;
|
---|
[850] | 323 | CHAR *ibuff, *obuff, *p;
|
---|
| 324 | // 06 Oct 07 SHL Protect against NTFS driver small buffer defect
|
---|
| 325 | // CHAR buffer[80];
|
---|
| 326 | CHAR buffer[4096];
|
---|
[551] | 327 | ARC_TYPE *info;
|
---|
[2] | 328 |
|
---|
[1009] | 329 | if (!DosOpen((CHAR *)mp1,
|
---|
[844] | 330 | &handle,
|
---|
| 331 | &action,
|
---|
| 332 | 0,
|
---|
| 333 | 0,
|
---|
| 334 | OPEN_ACTION_FAIL_IF_NEW | OPEN_ACTION_OPEN_IF_EXISTS,
|
---|
| 335 | OPEN_FLAGS_FAIL_ON_ERROR | OPEN_FLAGS_NOINHERIT |
|
---|
| 336 | OPEN_FLAGS_RANDOMSEQUENTIAL | OPEN_SHARE_DENYNONE |
|
---|
| 337 | OPEN_ACCESS_READONLY, 0)) {
|
---|
[850] | 338 | ibufflen = AutoviewHeight < 96 ? 512 : 3072;
|
---|
| 339 | // 06 Oct 07 SHL protect against NTFS driver small buffer defect
|
---|
[858] | 340 | // ibuff = xmalloc(ibufflen + 2, pszSrcFile, __LINE__); // 05 Nov 07 SHL
|
---|
| 341 | ibuff = xmalloc(max(ibufflen + 2, 4096), pszSrcFile, __LINE__);
|
---|
[551] | 342 | if (ibuff) {
|
---|
| 343 | // Depends on CreateHexDump line width
|
---|
| 344 | obufflen = (ibufflen / 16) * (6 + 3 * 16 + 1 + 16 + 1) + 80;
|
---|
| 345 | obuff = xmalloc(obufflen + 1, pszSrcFile, __LINE__);
|
---|
| 346 | if (obuff) {
|
---|
| 347 | *obuff = 0;
|
---|
[850] | 348 | if (!DosRead(handle, ibuff, ibufflen, &ibufflen) &&
|
---|
| 349 | ibufflen)
|
---|
| 350 | {
|
---|
[551] | 351 | ibuff[ibufflen] = 0;
|
---|
| 352 | p = obuff;
|
---|
| 353 | if (IsBinary(ibuff, ibufflen)) {
|
---|
| 354 | olen = ibufflen;
|
---|
| 355 | // Check archive
|
---|
| 356 | if (!arcsigsloaded)
|
---|
| 357 | load_archivers();
|
---|
| 358 | info = arcsighead;
|
---|
| 359 | while (info) {
|
---|
| 360 | if (info->signature && *info->signature) {
|
---|
| 361 | l = strlen(info->signature);
|
---|
| 362 | l = min(l, 79);
|
---|
| 363 | if (!DosChgFilePtr(handle, abs(info->file_offset),
|
---|
| 364 | (info->file_offset >= 0L) ?
|
---|
| 365 | FILE_BEGIN :
|
---|
| 366 | FILE_END, &ibufflen)) {
|
---|
| 367 | if (!DosRead(handle,
|
---|
| 368 | buffer,
|
---|
| 369 | l, &ibufflen) && ibufflen == l) {
|
---|
| 370 | if (!memcmp(info->signature, buffer, l))
|
---|
| 371 | break;
|
---|
| 372 | }
|
---|
| 373 | }
|
---|
| 374 | }
|
---|
| 375 | info = info->next;
|
---|
| 376 | }
|
---|
| 377 | if (info) {
|
---|
| 378 | sprintf(p, "**%s%s%s\n",
|
---|
[773] | 379 | info->id ? info->id : "",
|
---|
| 380 | info->id ? " " : "",
|
---|
[551] | 381 | GetPString(IDS_ARCHIVETEXT));
|
---|
| 382 | p += strlen(p);
|
---|
| 383 | }
|
---|
| 384 | CreateHexDump(ibuff, // Input buffer
|
---|
| 385 | olen, // Input buffer size
|
---|
| 386 | p, // Output buffer
|
---|
| 387 | obufflen - (p - obuff), // Output buffer size
|
---|
| 388 | 0, // Address offest
|
---|
| 389 | FALSE); // Short addresses
|
---|
| 390 | }
|
---|
| 391 | else {
|
---|
| 392 | // Text file
|
---|
| 393 | register CHAR *src, *dest;
|
---|
| 394 | CHAR *endsrc;
|
---|
[2] | 395 |
|
---|
[551] | 396 | src = ibuff;
|
---|
| 397 | dest = obuff;
|
---|
| 398 | endsrc = ibuff + ibufflen;
|
---|
| 399 | while (src < endsrc) {
|
---|
| 400 | if (dest == obuff && (*src == '\t' || *src == ' ' ||
|
---|
| 401 | *src == '\r' || *src == '\n')) {
|
---|
| 402 | src++;
|
---|
| 403 | }
|
---|
| 404 | else if (*src == '\t' || !*src) {
|
---|
| 405 | *dest = ' ';
|
---|
| 406 | dest++;
|
---|
| 407 | src++;
|
---|
| 408 | }
|
---|
| 409 | else if (*src == '\r' || *src == '\n') {
|
---|
| 410 | *dest = *src;
|
---|
| 411 | while (*(src + 1) == '\r' || *(src + 1) == '\n' ||
|
---|
| 412 | *(src + 1) == ' ' || *(src + 1) == '\t')
|
---|
| 413 | src++;
|
---|
| 414 | dest++;
|
---|
| 415 | src++;
|
---|
| 416 | }
|
---|
| 417 | else {
|
---|
| 418 | *dest = *src;
|
---|
| 419 | src++;
|
---|
| 420 | dest++;
|
---|
| 421 | }
|
---|
| 422 | } // while
|
---|
| 423 | *dest = 0;
|
---|
| 424 | if (dest - obuff >= obufflen)
|
---|
| 425 | Runtime_Error(pszSrcFile, __LINE__, pszBufOvfMsg);
|
---|
| 426 | }
|
---|
| 427 | if (*obuff)
|
---|
| 428 | WinSetWindowText(hwndAutoview, obuff);
|
---|
| 429 | }
|
---|
[1039] | 430 | free(obuff);
|
---|
[551] | 431 | }
|
---|
[1039] | 432 | free(ibuff);
|
---|
[551] | 433 | }
|
---|
| 434 | DosClose(handle);
|
---|
| 435 | }
|
---|
| 436 | }
|
---|
| 437 | else if (!IsFile(currfile)) {
|
---|
[2] | 438 |
|
---|
[841] | 439 | static FILEFINDBUF4L ffb[130];
|
---|
[897] | 440 | CHAR fullname[CCHMAXPATH + 4], szCmmaFmtFileSize[81];
|
---|
[551] | 441 | HDIR hdir = HDIR_CREATE;
|
---|
| 442 | ULONG x, nm, ml, mc, bufflen;
|
---|
| 443 | PBYTE fb;
|
---|
[841] | 444 | PFILEFINDBUF4L pffbFile;
|
---|
[773] | 445 | PSZ pszBuf;
|
---|
| 446 | PSZ p;
|
---|
| 447 | APIRET rc;
|
---|
[2] | 448 |
|
---|
[773] | 449 | BldFullPathName(fullname, currfile, "*");
|
---|
[763] | 450 | //sprintf(fullname,
|
---|
| 451 | // "%s%s*",
|
---|
| 452 | // currfile,
|
---|
| 453 | // (currfile[strlen(currfile) - 1] == '\\') ? "" : "\\");
|
---|
[551] | 454 | DosError(FERR_DISABLEHARDERR);
|
---|
[841] | 455 | nm = sizeof(ffb) / sizeof(FILEFINDBUF4L);
|
---|
[551] | 456 | if (AutoviewHeight < 96)
|
---|
| 457 | nm /= 2;
|
---|
[838] | 458 | rc = xDosFindFirst(fullname,
|
---|
[858] | 459 | &hdir,
|
---|
| 460 | FILE_NORMAL | FILE_DIRECTORY |
|
---|
| 461 | FILE_READONLY | FILE_ARCHIVED |
|
---|
| 462 | FILE_SYSTEM | FILE_HIDDEN,
|
---|
| 463 | &ffb, sizeof(ffb), &nm, FIL_QUERYEASIZEL);
|
---|
[551] | 464 | if (!rc && nm) {
|
---|
| 465 | fb = (PBYTE) & ffb;
|
---|
| 466 | x = ml = 0;
|
---|
| 467 | while (x < nm) {
|
---|
[841] | 468 | pffbFile = (PFILEFINDBUF4L) fb;
|
---|
[551] | 469 | mc = (ULONG) pffbFile->cchName +
|
---|
| 470 | ((pffbFile->attrFile & FILE_DIRECTORY) != 0);
|
---|
| 471 | ml = max(ml, mc);
|
---|
| 472 | if (!pffbFile->oNextEntryOffset)
|
---|
| 473 | break;
|
---|
| 474 | fb += pffbFile->oNextEntryOffset;
|
---|
| 475 | x++;
|
---|
| 476 | }
|
---|
| 477 | bufflen = (CCHMAXPATHCOMP + 42) * nm;
|
---|
[773] | 478 | pszBuf = xmalloc(bufflen, pszSrcFile, __LINE__);
|
---|
| 479 | if (pszBuf) {
|
---|
| 480 | p = pszBuf;
|
---|
[551] | 481 | *p = 0;
|
---|
| 482 | fb = (PBYTE) & ffb;
|
---|
| 483 | x = 0;
|
---|
| 484 | while (x < nm) {
|
---|
[841] | 485 | pffbFile = (PFILEFINDBUF4L) fb;
|
---|
[551] | 486 | if (!(!*pffbFile->achName ||
|
---|
| 487 | (((pffbFile->attrFile & FILE_DIRECTORY) &&
|
---|
| 488 | pffbFile->achName[0] == '.') &&
|
---|
| 489 | (!pffbFile->achName[1] ||
|
---|
| 490 | (pffbFile->achName[1] == '.' &&
|
---|
| 491 | !pffbFile->achName[2]))))) {
|
---|
[1078] | 492 | CommaFmtULL(szCmmaFmtFileSize,
|
---|
| 493 | sizeof(szCmmaFmtFileSize),
|
---|
| 494 | pffbFile->cbFile + CBLIST_TO_EASIZE(pffbFile->cbList),
|
---|
| 495 | ' ');
|
---|
[551] | 496 | sprintf(p,
|
---|
[897] | 497 | "%s%-*.*s %-8s [%s%s%s%s] %04lu/%02lu/%02lu "
|
---|
[846] | 498 | "%02lu:%02lu:%02lu\r",
|
---|
| 499 | pffbFile->attrFile & FILE_DIRECTORY ? "\\" : " ",
|
---|
[551] | 500 | ml,
|
---|
| 501 | ml,
|
---|
[1078] | 502 | pffbFile->achName,
|
---|
| 503 | szCmmaFmtFileSize,
|
---|
[846] | 504 | pffbFile->attrFile & FILE_READONLY ? "R" : "-",
|
---|
| 505 | pffbFile->attrFile & FILE_ARCHIVED ? "A" : "-",
|
---|
| 506 | pffbFile->attrFile & FILE_HIDDEN ? "H" : "-",
|
---|
| 507 | pffbFile->attrFile & FILE_SYSTEM ? "S" : "-",
|
---|
[551] | 508 | pffbFile->fdateLastWrite.year + 1980,
|
---|
| 509 | pffbFile->fdateLastWrite.month,
|
---|
| 510 | pffbFile->fdateLastWrite.day,
|
---|
| 511 | pffbFile->ftimeLastWrite.hours,
|
---|
| 512 | pffbFile->ftimeLastWrite.minutes,
|
---|
| 513 | pffbFile->ftimeLastWrite.twosecs * 2);
|
---|
| 514 | p += strlen(p);
|
---|
| 515 | }
|
---|
| 516 | if (!pffbFile->oNextEntryOffset)
|
---|
| 517 | break;
|
---|
| 518 | fb += pffbFile->oNextEntryOffset;
|
---|
| 519 | x++;
|
---|
| 520 | } // while
|
---|
[773] | 521 | if (p - pszBuf >= bufflen)
|
---|
[551] | 522 | Runtime_Error(pszSrcFile, __LINE__, pszBufOvfMsg);
|
---|
[773] | 523 | if (*pszBuf)
|
---|
| 524 | WinSetWindowText(hwndAutoview, pszBuf);
|
---|
[1039] | 525 | free(pszBuf);
|
---|
[551] | 526 | }
|
---|
| 527 | }
|
---|
| 528 | if (!rc)
|
---|
| 529 | DosFindClose(hdir);
|
---|
| 530 | }
|
---|
| 531 | }
|
---|
| 532 | else {
|
---|
[2] | 533 |
|
---|
[551] | 534 | APIRET rc;
|
---|
| 535 | EAOP2 eaop;
|
---|
| 536 | PGEA2LIST pgealist;
|
---|
| 537 | PFEA2LIST pfealist;
|
---|
| 538 | PGEA2 pgea;
|
---|
| 539 | PFEA2 pfea;
|
---|
[773] | 540 | CHAR *value, *pszBuf, *p, *data;
|
---|
[551] | 541 | USHORT len, type, plen, dlen;
|
---|
| 542 | BOOL readonly = FALSE;
|
---|
[2] | 543 |
|
---|
[551] | 544 | pgealist = xmallocz(sizeof(GEA2LIST) + 64, pszSrcFile, __LINE__);
|
---|
| 545 | if (pgealist) {
|
---|
| 546 | pgea = &pgealist->list[0];
|
---|
| 547 | strcpy(pgea->szName, ".COMMENTS");
|
---|
| 548 | pgea->cbName = strlen(pgea->szName);
|
---|
| 549 | pgea->oNextEntryOffset = 0L;
|
---|
| 550 | pgealist->cbList = (sizeof(GEA2LIST) + pgea->cbName);
|
---|
| 551 | pfealist = xmallocz(65536, pszSrcFile, __LINE__);
|
---|
| 552 | if (pfealist) {
|
---|
| 553 | pfealist->cbList = 65536;
|
---|
| 554 | eaop.fpGEA2List = pgealist;
|
---|
| 555 | eaop.fpFEA2List = pfealist;
|
---|
| 556 | eaop.oError = 0L;
|
---|
[1009] | 557 | rc = DosQueryPathInfo((CHAR *)mp1, FIL_QUERYEASFROMLIST,
|
---|
[551] | 558 | (PVOID) & eaop, (ULONG) sizeof(EAOP2));
|
---|
[1039] | 559 | free(pgealist);
|
---|
[551] | 560 | if (!rc) {
|
---|
| 561 | pfea = &eaop.fpFEA2List->list[0];
|
---|
| 562 | if (pfea->cbName && pfea->cbValue) {
|
---|
| 563 | value = pfea->szName + pfea->cbName + 1;
|
---|
| 564 | value[pfea->cbValue] = 0;
|
---|
| 565 | if (*(USHORT *) value == EAT_MVMT) {
|
---|
[773] | 566 | pszBuf = xmalloc(65536, pszSrcFile, __LINE__);
|
---|
| 567 | if (pszBuf) {
|
---|
| 568 | p = pszBuf;
|
---|
| 569 | *pszBuf = 0;
|
---|
[551] | 570 | data = value + (sizeof(USHORT) * 3);
|
---|
| 571 | type = *(USHORT *) data;
|
---|
| 572 | data += sizeof(USHORT);
|
---|
| 573 | len = *(USHORT *) data;
|
---|
| 574 | data += sizeof(USHORT);
|
---|
| 575 | while ((data - value) - len < pfea->cbValue) {
|
---|
| 576 | if (type == EAT_ASCII) {
|
---|
| 577 | dlen = plen = 0;
|
---|
| 578 | while (dlen < len) {
|
---|
| 579 | if (data[dlen] == '\r') {
|
---|
| 580 | dlen++;
|
---|
| 581 | if (dlen < len && data[dlen] != '\n')
|
---|
| 582 | p[plen++] = '\n';
|
---|
| 583 | }
|
---|
| 584 | else
|
---|
| 585 | p[plen++] = data[dlen++];
|
---|
| 586 | }
|
---|
| 587 | if ((!len || !plen || p[plen - 1] != '\n') &&
|
---|
| 588 | (data - value) + len < pfea->cbValue)
|
---|
| 589 | p[plen++] = '\n';
|
---|
| 590 | p += plen;
|
---|
| 591 | *p = 0;
|
---|
| 592 | }
|
---|
| 593 | else
|
---|
| 594 | readonly = TRUE;
|
---|
| 595 | data += len;
|
---|
| 596 | if (data - value >= pfea->cbValue)
|
---|
[41] | 597 | break;
|
---|
[551] | 598 | type = *(USHORT *) data;
|
---|
| 599 | data += sizeof(USHORT);
|
---|
| 600 | len = *(USHORT *) data;
|
---|
| 601 | data += sizeof(USHORT);
|
---|
| 602 | } // while
|
---|
[773] | 603 | if (p - pszBuf >= 65536) {
|
---|
[551] | 604 | Runtime_Error(pszSrcFile, __LINE__, pszBufOvfMsg);
|
---|
[773] | 605 | pszBuf[65535] = 0; // Try to stay alive
|
---|
[551] | 606 | break;
|
---|
| 607 | }
|
---|
[773] | 608 | WinSetWindowText(hwndAutoMLE, pszBuf);
|
---|
[1039] | 609 | free(pszBuf);
|
---|
[551] | 610 | }
|
---|
| 611 | }
|
---|
| 612 | else
|
---|
| 613 | readonly = TRUE;
|
---|
| 614 | }
|
---|
| 615 | /* else EA not present */
|
---|
| 616 | MLEsetchanged(hwndAutoMLE, FALSE);
|
---|
| 617 | MLEsetreadonly(hwndAutoMLE, readonly);
|
---|
| 618 | }
|
---|
| 619 | else {
|
---|
| 620 | MLEsetchanged(hwndAutoMLE, FALSE);
|
---|
| 621 | MLEsetreadonly(hwndAutoMLE, FALSE);
|
---|
| 622 | }
|
---|
[1039] | 623 | free(pfealist);
|
---|
[551] | 624 | }
|
---|
| 625 | }
|
---|
| 626 | }
|
---|
[2] | 627 | }
|
---|
[1039] | 628 | free((CHAR *)mp1);
|
---|
[1063] | 629 | # ifdef FORTIFY
|
---|
| 630 | Fortify_LeaveScope();
|
---|
| 631 | # endif
|
---|
[551] | 632 | }
|
---|
| 633 | return 0;
|
---|
[2] | 634 |
|
---|
[551] | 635 | case UM_CLOSE:
|
---|
| 636 | if (!PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID))
|
---|
| 637 | WinSendMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID);
|
---|
| 638 | WinDestroyWindow(hwnd);
|
---|
| 639 | return 0;
|
---|
[2] | 640 | }
|
---|
[551] | 641 | return WinDefWindowProc(hwnd, msg, mp1, mp2);
|
---|
[2] | 642 | }
|
---|
| 643 |
|
---|
[551] | 644 | static VOID MakeAutoWinThread(VOID * args)
|
---|
[341] | 645 | {
|
---|
[551] | 646 | HAB hab2;
|
---|
| 647 | HMQ hmq2;
|
---|
| 648 | HWND hwndParent = (HWND) args;
|
---|
| 649 | QMSG qmsg2;
|
---|
[2] | 650 |
|
---|
| 651 | hab2 = WinInitialize(0);
|
---|
[551] | 652 | if (hab2) {
|
---|
[1063] | 653 | # ifdef FORTIFY
|
---|
| 654 | Fortify_EnterScope();
|
---|
[1078] | 655 | # endif
|
---|
[551] | 656 | hmq2 = WinCreateMsgQueue(hab2, 128);
|
---|
| 657 | if (hmq2) {
|
---|
[2] | 658 | DosError(FERR_DISABLEHARDERR);
|
---|
| 659 | WinRegisterClass(hab2,
|
---|
[593] | 660 | WC_OBJECTWINDOW,
|
---|
[551] | 661 | AutoObjProc, 0, sizeof(PVOID));
|
---|
[2] | 662 | hwndAutoObj = WinCreateWindow(HWND_OBJECT,
|
---|
[593] | 663 | WC_OBJECTWINDOW,
|
---|
[551] | 664 | (PSZ) NULL,
|
---|
| 665 | 0,
|
---|
| 666 | 0L,
|
---|
| 667 | 0L,
|
---|
| 668 | 0L,
|
---|
| 669 | 0L, 0L, HWND_TOP, OBJ_FRAME, NULL, NULL);
|
---|
[377] | 670 | if (!hwndAutoObj) {
|
---|
[551] | 671 | Win_Error2(HWND_OBJECT, HWND_DESKTOP, pszSrcFile, __LINE__,
|
---|
| 672 | IDS_WINCREATEWINDOW);
|
---|
| 673 | if (!PostMsg(hwndParent, UM_CLOSE, MPVOID, MPVOID))
|
---|
| 674 | WinSendMsg(hwndParent, UM_CLOSE, MPVOID, MPVOID);
|
---|
[377] | 675 | }
|
---|
| 676 | else {
|
---|
[551] | 677 | WinSetWindowULong(hwndAutoObj, QWL_USER, hwndParent);
|
---|
| 678 | priority_normal();
|
---|
| 679 | while (WinGetMsg(hab2, &qmsg2, (HWND) 0, 0, 0))
|
---|
| 680 | WinDispatchMsg(hab2, &qmsg2);
|
---|
| 681 | WinDestroyWindow(hwndAutoObj);
|
---|
| 682 | hwndAutoObj = (HWND) 0;
|
---|
[2] | 683 | }
|
---|
| 684 | WinDestroyMsgQueue(hmq2);
|
---|
| 685 | }
|
---|
[1032] | 686 | // else
|
---|
| 687 | WinTerminate(hab2);
|
---|
[1063] | 688 | # ifdef FORTIFY
|
---|
[1038] | 689 | Fortify_LeaveScope();
|
---|
[1078] | 690 | # endif
|
---|
[2] | 691 | }
|
---|
| 692 | }
|
---|
| 693 |
|
---|
[551] | 694 | MRESULT EXPENTRY AutoViewProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
[341] | 695 | {
|
---|
[551] | 696 | USHORT id = WinQueryWindowUShort(hwnd, QWS_ID);
|
---|
[2] | 697 |
|
---|
[551] | 698 | switch (msg) {
|
---|
| 699 | case WM_CREATE:
|
---|
| 700 | {
|
---|
| 701 | MRESULT mr;
|
---|
[2] | 702 |
|
---|
[551] | 703 | if (!hwndAutoObj) {
|
---|
| 704 | if (_beginthread(MakeAutoWinThread, NULL, 65536, (PVOID) hwnd) == -1) {
|
---|
| 705 | Runtime_Error(pszSrcFile, __LINE__,
|
---|
| 706 | GetPString(IDS_COULDNTSTARTTHREADTEXT));
|
---|
| 707 | PostMsg(hwnd, UM_CLOSE, MPVOID, MPVOID);
|
---|
[341] | 708 | }
|
---|
[2] | 709 | }
|
---|
[551] | 710 | mr = PFNWPStatic(hwnd, msg, mp1, mp2);
|
---|
| 711 | SetPresParams(hwnd,
|
---|
| 712 | &RGBGREY,
|
---|
| 713 | &RGBBLACK, &RGBGREY, GetPString(IDS_4SYSTEMVIOTEXT));
|
---|
| 714 | stopflag = 0;
|
---|
| 715 | return mr;
|
---|
| 716 | }
|
---|
[2] | 717 |
|
---|
[551] | 718 | case UM_SETUP:
|
---|
| 719 | MLEsetlimit(hwnd, 32768);
|
---|
| 720 | MLEsetformat(hwnd, MLFIE_NOTRANS);
|
---|
| 721 | MLEsetchanged(hwnd, FALSE);
|
---|
| 722 | return 0;
|
---|
[2] | 723 |
|
---|
[551] | 724 | case WM_BUTTON1DOWN:
|
---|
| 725 | {
|
---|
| 726 | SWP swp;
|
---|
[2] | 727 |
|
---|
[551] | 728 | WinQueryWindowPos(hwnd, &swp);
|
---|
| 729 | if (SHORT2FROMMP(mp1) > swp.cy - 4) {
|
---|
[2] | 730 |
|
---|
[551] | 731 | HPS hps = WinGetPS(WinQueryWindow(hwnd, QW_PARENT));
|
---|
| 732 | SWP swpC;
|
---|
| 733 | TRACKINFO track;
|
---|
[2] | 734 |
|
---|
[551] | 735 | if (hps) {
|
---|
| 736 | WinQueryWindowPos(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
|
---|
| 737 | FID_CLIENT), &swpC);
|
---|
| 738 | track.cxBorder = 4;
|
---|
| 739 | track.cyBorder = 4;
|
---|
| 740 | track.cxGrid = 1;
|
---|
| 741 | track.cyGrid = 8;
|
---|
| 742 | track.cxKeyboard = 8;
|
---|
| 743 | track.rclTrack.yBottom = swp.y;
|
---|
| 744 | track.rclTrack.yTop = swp.y + swp.cy;
|
---|
| 745 | track.rclTrack.xLeft = swp.x;
|
---|
| 746 | track.rclTrack.xRight = swp.x + swp.cx;
|
---|
| 747 | track.rclBoundary = track.rclTrack;
|
---|
| 748 | track.rclBoundary.yTop = (swpC.cy + swp.y + swp.cy) - 116;
|
---|
| 749 | track.ptlMinTrackSize.x = swp.x + swp.cx;
|
---|
| 750 | track.ptlMinTrackSize.y = 36;
|
---|
| 751 | track.ptlMaxTrackSize.x = swp.x + swp.cx;
|
---|
| 752 | track.ptlMaxTrackSize.y = (swpC.cy + swp.cy) - 116;
|
---|
| 753 | track.fs = TF_TOP;
|
---|
| 754 | if (WinTrackRect(hwnd, hps, &track)) {
|
---|
| 755 | AutoviewHeight = track.rclTrack.yTop - track.rclTrack.yBottom;
|
---|
| 756 | PrfWriteProfileData(fmprof,
|
---|
| 757 | FM3Str,
|
---|
| 758 | "AutoviewHeight",
|
---|
| 759 | &AutoviewHeight, sizeof(ULONG));
|
---|
| 760 | WinSendMsg(WinQueryWindow(hwnd, QW_PARENT),
|
---|
| 761 | WM_UPDATEFRAME, MPFROMLONG(FCF_SIZEBORDER), MPVOID);
|
---|
| 762 | }
|
---|
| 763 | WinReleasePS(hps);
|
---|
| 764 | }
|
---|
| 765 | return (MRESULT) TRUE;
|
---|
[2] | 766 | }
|
---|
[551] | 767 | else if (id != MAIN_AUTOVIEWMLE)
|
---|
| 768 | return CommonTextButton(hwnd, msg, mp1, mp2);
|
---|
| 769 | }
|
---|
| 770 | break;
|
---|
[2] | 771 |
|
---|
[551] | 772 | case WM_BUTTON3DOWN:
|
---|
| 773 | case WM_BUTTON1UP:
|
---|
| 774 | case WM_BUTTON3UP:
|
---|
| 775 | if (id != MAIN_AUTOVIEWMLE)
|
---|
| 776 | return CommonTextButton(hwnd, msg, mp1, mp2);
|
---|
| 777 | break;
|
---|
[2] | 778 |
|
---|
[551] | 779 | case WM_MOUSEMOVE:
|
---|
| 780 | shiftstate = (SHORT2FROMMP(mp2) & (KC_ALT | KC_SHIFT | KC_CTRL));
|
---|
| 781 | {
|
---|
| 782 | SWP swp;
|
---|
[2] | 783 |
|
---|
[551] | 784 | WinQueryWindowPos(hwnd, &swp);
|
---|
| 785 | if (SHORT2FROMMP(mp1) > swp.cy - 4) {
|
---|
| 786 | WinSetPointer(HWND_DESKTOP, hptrNS);
|
---|
| 787 | return (MRESULT) TRUE;
|
---|
[2] | 788 | }
|
---|
[551] | 789 | }
|
---|
| 790 | break;
|
---|
[2] | 791 |
|
---|
[551] | 792 | case WM_PAINT:
|
---|
| 793 | PostMsg(hwnd, UM_PAINT, MPVOID, MPVOID);
|
---|
| 794 | break;
|
---|
[2] | 795 |
|
---|
[551] | 796 | case UM_PAINT:
|
---|
| 797 | PaintRecessedWindow(hwnd, (HPS) 0, TRUE, TRUE);
|
---|
| 798 | return 0;
|
---|
[2] | 799 |
|
---|
[551] | 800 | case WM_SETFOCUS:
|
---|
| 801 | switch (id) {
|
---|
| 802 | case MAIN_AUTOVIEWMLE:
|
---|
| 803 | if (!mp2 && !AutoMenu) {
|
---|
| 804 | if (*currfile) {
|
---|
| 805 | if (MLEgetchanged(hwnd)) {
|
---|
| 806 | CHAR *ea = xmalloc(32768, pszSrcFile, __LINE__);
|
---|
| 807 |
|
---|
| 808 | if (ea) {
|
---|
| 809 | *ea = 0;
|
---|
| 810 | WinQueryWindowText(hwnd, 32767, ea);
|
---|
| 811 | PutComments(hwnd, currfile, ea);
|
---|
| 812 | PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_RESCAN, 0), MPVOID);
|
---|
[1039] | 813 | free(ea);
|
---|
[1063] | 814 | # ifdef FORTIFY
|
---|
[1078] | 815 | Fortify_LeaveScope();
|
---|
[1063] | 816 | # endif
|
---|
[551] | 817 | }
|
---|
| 818 | }
|
---|
| 819 | }
|
---|
[2] | 820 | }
|
---|
| 821 | break;
|
---|
[551] | 822 | default:
|
---|
| 823 | if (mp2)
|
---|
| 824 | PostMsg(hwnd, UM_FOCUSME, mp1, mp2);
|
---|
| 825 | break;
|
---|
| 826 | }
|
---|
| 827 | break;
|
---|
[2] | 828 |
|
---|
[551] | 829 | case UM_FOCUSME:
|
---|
| 830 | if (mp2) {
|
---|
[2] | 831 |
|
---|
[551] | 832 | PID pid;
|
---|
| 833 | TID tid;
|
---|
[2] | 834 |
|
---|
[551] | 835 | if (WinQueryWindowProcess((HWND) mp1, &pid, &tid) && pid == mypid)
|
---|
| 836 | WinSetFocus(HWND_DESKTOP, (HWND) mp1);
|
---|
| 837 | else
|
---|
| 838 | WinSetFocus(HWND_DESKTOP, hwndTree);
|
---|
| 839 | }
|
---|
| 840 | return 0;
|
---|
[2] | 841 |
|
---|
[551] | 842 | case UM_CLICKED:
|
---|
| 843 | case UM_CLICKED3:
|
---|
| 844 | if (id != MAIN_AUTOVIEWMLE) {
|
---|
[2] | 845 | PostMsg(hwnd,
|
---|
[551] | 846 | WM_COMMAND,
|
---|
| 847 | MPFROM2SHORT(((msg == UM_CLICKED3) ?
|
---|
| 848 | IDM_EAS : IDM_VIEWORARC), 0), MPVOID);
|
---|
| 849 | }
|
---|
| 850 | return 0;
|
---|
[2] | 851 |
|
---|
[551] | 852 | case WM_COMMAND:
|
---|
| 853 | PostMsg(hwnd, UM_COMMAND, mp1, mp2);
|
---|
| 854 | return 0;
|
---|
[2] | 855 |
|
---|
[551] | 856 | case UM_COMMAND:
|
---|
| 857 | switch (SHORT1FROMMP(mp1)) {
|
---|
| 858 | case IDM_RESCAN:
|
---|
| 859 | if (*currfile) {
|
---|
[2] | 860 |
|
---|
[551] | 861 | CHAR *cf = xstrdup(currfile, pszSrcFile, __LINE__);
|
---|
[2] | 862 |
|
---|
[551] | 863 | if (cf) {
|
---|
| 864 | stopflag++;
|
---|
| 865 | if (!PostMsg(hwndAutoObj, UM_LOADFILE, MPFROMP(cf), MPVOID))
|
---|
[1039] | 866 | free(cf);
|
---|
[1063] | 867 | # ifdef FORTIFY
|
---|
[1078] | 868 | Fortify_LeaveScope();
|
---|
[1063] | 869 | # endif
|
---|
[551] | 870 | }
|
---|
| 871 | }
|
---|
| 872 | break;
|
---|
[2] | 873 |
|
---|
[551] | 874 | case IDM_INFO:
|
---|
| 875 | DefaultView(hwnd, (HWND) 0, hwndMain, NULL, 16, currfile);
|
---|
| 876 | break;
|
---|
[2] | 877 |
|
---|
[551] | 878 | case IDM_VIEW:
|
---|
| 879 | DefaultView(hwnd, (HWND) 0, hwndMain, NULL, 0, currfile);
|
---|
| 880 | break;
|
---|
[2] | 881 |
|
---|
[551] | 882 | case IDM_EDIT:
|
---|
| 883 | DefaultView(hwnd, (HWND) 0, hwndMain, NULL, 8, currfile);
|
---|
| 884 | break;
|
---|
[2] | 885 |
|
---|
[551] | 886 | case IDM_EAS:
|
---|
| 887 | {
|
---|
| 888 | char *list[2];
|
---|
[2] | 889 |
|
---|
[551] | 890 | list[0] = currfile;
|
---|
| 891 | list[1] = NULL;
|
---|
[2] | 892 |
|
---|
[551] | 893 | WinDlgBox(HWND_DESKTOP,
|
---|
| 894 | hwndMain,
|
---|
| 895 | DisplayEAsProc, FM3ModHandle, EA_FRAME, (PVOID) list);
|
---|
[2] | 896 | }
|
---|
| 897 | break;
|
---|
| 898 |
|
---|
[551] | 899 | default:
|
---|
| 900 | PostMsg(hwndMain, msg, mp1, mp2);
|
---|
| 901 | }
|
---|
| 902 | return 0;
|
---|
[2] | 903 |
|
---|
[551] | 904 | case WM_MENUEND:
|
---|
| 905 | if ((HWND) mp2 == AutoMenu) {
|
---|
| 906 | WinDestroyWindow(AutoMenu);
|
---|
| 907 | AutoMenu = (HWND) 0;
|
---|
| 908 | }
|
---|
| 909 | break;
|
---|
[2] | 910 |
|
---|
[551] | 911 | case WM_CONTEXTMENU:
|
---|
[872] | 912 | CheckMenu(hwnd, &AutoMenu, (id == MAIN_AUTOVIEWMLE) ?
|
---|
[551] | 913 | IDM_AUTOVIEWMLE : IDM_AUTOVIEW);
|
---|
| 914 | WinCheckMenuItem(AutoMenu, IDM_AUTOVIEWFILE, !fComments);
|
---|
| 915 | WinCheckMenuItem(AutoMenu, IDM_AUTOVIEWCOMMENTS, fComments);
|
---|
| 916 | WinEnableMenuItem(AutoMenu, IDM_VIEW, (IsFile(currfile) == 1));
|
---|
| 917 | WinEnableMenuItem(AutoMenu, IDM_EDIT, (IsFile(currfile) == 1));
|
---|
| 918 | WinEnableMenuItem(AutoMenu, IDM_INFO, (*currfile != 0));
|
---|
| 919 | PopupMenu(hwnd, hwnd, AutoMenu);
|
---|
| 920 | break;
|
---|
[2] | 921 |
|
---|
[551] | 922 | case UM_LOADFILE:
|
---|
| 923 | stopflag++;
|
---|
| 924 | if (!PostMsg(hwndAutoObj, msg, mp1, mp2)) {
|
---|
[1009] | 925 | xfree((CHAR *)mp1, pszSrcFile, __LINE__);
|
---|
[1063] | 926 | # ifdef FORTIFY
|
---|
| 927 | Fortify_LeaveScope();
|
---|
| 928 | # endif
|
---|
[551] | 929 | }
|
---|
| 930 | return 0;
|
---|
[2] | 931 |
|
---|
[551] | 932 | case UM_CLOSE:
|
---|
| 933 | if (AutoMenu) {
|
---|
| 934 | WinDestroyWindow(AutoMenu);
|
---|
| 935 | AutoMenu = (HWND) 0;
|
---|
| 936 | }
|
---|
| 937 | WinDestroyWindow(hwnd);
|
---|
| 938 | return 0;
|
---|
| 939 |
|
---|
| 940 | case WM_CLOSE:
|
---|
| 941 | WinSendMsg(hwnd, UM_CLOSE, MPVOID, MPVOID);
|
---|
| 942 | return 0;
|
---|
| 943 |
|
---|
| 944 | case WM_DESTROY:
|
---|
| 945 | if (id != MAIN_AUTOVIEWMLE) {
|
---|
| 946 | if (hwndAutoObj)
|
---|
| 947 | if (!PostMsg(hwndAutoObj, WM_CLOSE, MPVOID, MPVOID))
|
---|
| 948 | WinSendMsg(hwndAutoObj, WM_CLOSE, MPVOID, MPVOID);
|
---|
[2] | 949 | break;
|
---|
[551] | 950 | }
|
---|
| 951 | break;
|
---|
[2] | 952 | }
|
---|
| 953 |
|
---|
[551] | 954 | if (id == MAIN_AUTOVIEWMLE)
|
---|
| 955 | return PFNWPMLE(hwnd, msg, mp1, mp2);
|
---|
| 956 | return PFNWPStatic(hwnd, msg, mp1, mp2);
|
---|
[2] | 957 | }
|
---|
[793] | 958 |
|
---|
| 959 | #pragma alloc_text(AUTOVIEW,AutoViewProc,CreateHexDump,AutoObjProc)
|
---|
| 960 | #pragma alloc_text(AUTOVIEW2,MakeAutoWinThread,WriteEA,PutComments)
|
---|