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