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