[41] | 1 |
|
---|
| 2 | /***********************************************************************
|
---|
| 3 |
|
---|
| 4 | $Id: autoview.c 1032 2008-06-30 02:55:36Z 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__);
|
---|
[1029] | 420 | # ifdef FORTIFY
|
---|
| 421 | Fortify_LeaveScope();
|
---|
| 422 | # endif
|
---|
[551] | 423 | }
|
---|
| 424 | DosClose(handle);
|
---|
| 425 | }
|
---|
| 426 | }
|
---|
| 427 | else if (!IsFile(currfile)) {
|
---|
[2] | 428 |
|
---|
[841] | 429 | static FILEFINDBUF4L ffb[130];
|
---|
[897] | 430 | CHAR fullname[CCHMAXPATH + 4], szCmmaFmtFileSize[81];
|
---|
[551] | 431 | HDIR hdir = HDIR_CREATE;
|
---|
| 432 | ULONG x, nm, ml, mc, bufflen;
|
---|
| 433 | PBYTE fb;
|
---|
[841] | 434 | PFILEFINDBUF4L pffbFile;
|
---|
[773] | 435 | PSZ pszBuf;
|
---|
| 436 | PSZ p;
|
---|
| 437 | APIRET rc;
|
---|
[2] | 438 |
|
---|
[773] | 439 | BldFullPathName(fullname, currfile, "*");
|
---|
[763] | 440 | //sprintf(fullname,
|
---|
| 441 | // "%s%s*",
|
---|
| 442 | // currfile,
|
---|
| 443 | // (currfile[strlen(currfile) - 1] == '\\') ? "" : "\\");
|
---|
[551] | 444 | DosError(FERR_DISABLEHARDERR);
|
---|
[841] | 445 | nm = sizeof(ffb) / sizeof(FILEFINDBUF4L);
|
---|
[551] | 446 | if (AutoviewHeight < 96)
|
---|
| 447 | nm /= 2;
|
---|
[838] | 448 | rc = xDosFindFirst(fullname,
|
---|
[858] | 449 | &hdir,
|
---|
| 450 | FILE_NORMAL | FILE_DIRECTORY |
|
---|
| 451 | FILE_READONLY | FILE_ARCHIVED |
|
---|
| 452 | FILE_SYSTEM | FILE_HIDDEN,
|
---|
| 453 | &ffb, sizeof(ffb), &nm, FIL_QUERYEASIZEL);
|
---|
[551] | 454 | if (!rc && nm) {
|
---|
| 455 | fb = (PBYTE) & ffb;
|
---|
| 456 | x = ml = 0;
|
---|
| 457 | while (x < nm) {
|
---|
[841] | 458 | pffbFile = (PFILEFINDBUF4L) fb;
|
---|
[551] | 459 | mc = (ULONG) pffbFile->cchName +
|
---|
| 460 | ((pffbFile->attrFile & FILE_DIRECTORY) != 0);
|
---|
| 461 | ml = max(ml, mc);
|
---|
| 462 | if (!pffbFile->oNextEntryOffset)
|
---|
| 463 | break;
|
---|
| 464 | fb += pffbFile->oNextEntryOffset;
|
---|
| 465 | x++;
|
---|
| 466 | }
|
---|
| 467 | bufflen = (CCHMAXPATHCOMP + 42) * nm;
|
---|
[773] | 468 | pszBuf = xmalloc(bufflen, pszSrcFile, __LINE__);
|
---|
| 469 | if (pszBuf) {
|
---|
| 470 | p = pszBuf;
|
---|
[551] | 471 | *p = 0;
|
---|
| 472 | fb = (PBYTE) & ffb;
|
---|
| 473 | x = 0;
|
---|
| 474 | while (x < nm) {
|
---|
[841] | 475 | pffbFile = (PFILEFINDBUF4L) fb;
|
---|
[551] | 476 | if (!(!*pffbFile->achName ||
|
---|
| 477 | (((pffbFile->attrFile & FILE_DIRECTORY) &&
|
---|
| 478 | pffbFile->achName[0] == '.') &&
|
---|
| 479 | (!pffbFile->achName[1] ||
|
---|
| 480 | (pffbFile->achName[1] == '.' &&
|
---|
| 481 | !pffbFile->achName[2]))))) {
|
---|
[897] | 482 | CommaFmtULL(szCmmaFmtFileSize,
|
---|
| 483 | sizeof(szCmmaFmtFileSize),
|
---|
| 484 | pffbFile->cbFile + CBLIST_TO_EASIZE(pffbFile->cbList),
|
---|
| 485 | ' ');
|
---|
[551] | 486 | sprintf(p,
|
---|
[897] | 487 | "%s%-*.*s %-8s [%s%s%s%s] %04lu/%02lu/%02lu "
|
---|
[846] | 488 | "%02lu:%02lu:%02lu\r",
|
---|
| 489 | pffbFile->attrFile & FILE_DIRECTORY ? "\\" : " ",
|
---|
[551] | 490 | ml,
|
---|
| 491 | ml,
|
---|
[897] | 492 | pffbFile->achName,
|
---|
| 493 | szCmmaFmtFileSize,
|
---|
[846] | 494 | pffbFile->attrFile & FILE_READONLY ? "R" : "-",
|
---|
| 495 | pffbFile->attrFile & FILE_ARCHIVED ? "A" : "-",
|
---|
| 496 | pffbFile->attrFile & FILE_HIDDEN ? "H" : "-",
|
---|
| 497 | pffbFile->attrFile & FILE_SYSTEM ? "S" : "-",
|
---|
[551] | 498 | pffbFile->fdateLastWrite.year + 1980,
|
---|
| 499 | pffbFile->fdateLastWrite.month,
|
---|
| 500 | pffbFile->fdateLastWrite.day,
|
---|
| 501 | pffbFile->ftimeLastWrite.hours,
|
---|
| 502 | pffbFile->ftimeLastWrite.minutes,
|
---|
| 503 | pffbFile->ftimeLastWrite.twosecs * 2);
|
---|
| 504 | p += strlen(p);
|
---|
| 505 | }
|
---|
| 506 | if (!pffbFile->oNextEntryOffset)
|
---|
| 507 | break;
|
---|
| 508 | fb += pffbFile->oNextEntryOffset;
|
---|
| 509 | x++;
|
---|
| 510 | } // while
|
---|
[773] | 511 | if (p - pszBuf >= bufflen)
|
---|
[551] | 512 | Runtime_Error(pszSrcFile, __LINE__, pszBufOvfMsg);
|
---|
[773] | 513 | if (*pszBuf)
|
---|
| 514 | WinSetWindowText(hwndAutoview, pszBuf);
|
---|
[1009] | 515 | xfree(pszBuf, pszSrcFile, __LINE__);
|
---|
[1029] | 516 | # ifdef FORTIFY
|
---|
| 517 | Fortify_LeaveScope();
|
---|
| 518 | # endif
|
---|
[551] | 519 | }
|
---|
| 520 | }
|
---|
| 521 | if (!rc)
|
---|
| 522 | DosFindClose(hdir);
|
---|
| 523 | }
|
---|
| 524 | }
|
---|
| 525 | else {
|
---|
[2] | 526 |
|
---|
[551] | 527 | APIRET rc;
|
---|
| 528 | EAOP2 eaop;
|
---|
| 529 | PGEA2LIST pgealist;
|
---|
| 530 | PFEA2LIST pfealist;
|
---|
| 531 | PGEA2 pgea;
|
---|
| 532 | PFEA2 pfea;
|
---|
[773] | 533 | CHAR *value, *pszBuf, *p, *data;
|
---|
[551] | 534 | USHORT len, type, plen, dlen;
|
---|
| 535 | BOOL readonly = FALSE;
|
---|
[2] | 536 |
|
---|
[551] | 537 | pgealist = xmallocz(sizeof(GEA2LIST) + 64, pszSrcFile, __LINE__);
|
---|
| 538 | if (pgealist) {
|
---|
| 539 | pgea = &pgealist->list[0];
|
---|
| 540 | strcpy(pgea->szName, ".COMMENTS");
|
---|
| 541 | pgea->cbName = strlen(pgea->szName);
|
---|
| 542 | pgea->oNextEntryOffset = 0L;
|
---|
| 543 | pgealist->cbList = (sizeof(GEA2LIST) + pgea->cbName);
|
---|
| 544 | pfealist = xmallocz(65536, pszSrcFile, __LINE__);
|
---|
| 545 | if (pfealist) {
|
---|
| 546 | pfealist->cbList = 65536;
|
---|
| 547 | eaop.fpGEA2List = pgealist;
|
---|
| 548 | eaop.fpFEA2List = pfealist;
|
---|
| 549 | eaop.oError = 0L;
|
---|
[1009] | 550 | rc = DosQueryPathInfo((CHAR *)mp1, FIL_QUERYEASFROMLIST,
|
---|
[551] | 551 | (PVOID) & eaop, (ULONG) sizeof(EAOP2));
|
---|
[1009] | 552 | xfree(pgealist, pszSrcFile, __LINE__);
|
---|
[1029] | 553 | # ifdef FORTIFY
|
---|
| 554 | Fortify_LeaveScope();
|
---|
| 555 | # endif
|
---|
[551] | 556 | if (!rc) {
|
---|
| 557 | pfea = &eaop.fpFEA2List->list[0];
|
---|
| 558 | if (pfea->cbName && pfea->cbValue) {
|
---|
| 559 | value = pfea->szName + pfea->cbName + 1;
|
---|
| 560 | value[pfea->cbValue] = 0;
|
---|
| 561 | if (*(USHORT *) value == EAT_MVMT) {
|
---|
[773] | 562 | pszBuf = xmalloc(65536, pszSrcFile, __LINE__);
|
---|
| 563 | if (pszBuf) {
|
---|
| 564 | p = pszBuf;
|
---|
| 565 | *pszBuf = 0;
|
---|
[551] | 566 | data = value + (sizeof(USHORT) * 3);
|
---|
| 567 | type = *(USHORT *) data;
|
---|
| 568 | data += sizeof(USHORT);
|
---|
| 569 | len = *(USHORT *) data;
|
---|
| 570 | data += sizeof(USHORT);
|
---|
| 571 | while ((data - value) - len < pfea->cbValue) {
|
---|
| 572 | if (type == EAT_ASCII) {
|
---|
| 573 | dlen = plen = 0;
|
---|
| 574 | while (dlen < len) {
|
---|
| 575 | if (data[dlen] == '\r') {
|
---|
| 576 | dlen++;
|
---|
| 577 | if (dlen < len && data[dlen] != '\n')
|
---|
| 578 | p[plen++] = '\n';
|
---|
| 579 | }
|
---|
| 580 | else
|
---|
| 581 | p[plen++] = data[dlen++];
|
---|
| 582 | }
|
---|
| 583 | if ((!len || !plen || p[plen - 1] != '\n') &&
|
---|
| 584 | (data - value) + len < pfea->cbValue)
|
---|
| 585 | p[plen++] = '\n';
|
---|
| 586 | p += plen;
|
---|
| 587 | *p = 0;
|
---|
| 588 | }
|
---|
| 589 | else
|
---|
| 590 | readonly = TRUE;
|
---|
| 591 | data += len;
|
---|
| 592 | if (data - value >= pfea->cbValue)
|
---|
[41] | 593 | break;
|
---|
[551] | 594 | type = *(USHORT *) data;
|
---|
| 595 | data += sizeof(USHORT);
|
---|
| 596 | len = *(USHORT *) data;
|
---|
| 597 | data += sizeof(USHORT);
|
---|
| 598 | } // while
|
---|
[773] | 599 | if (p - pszBuf >= 65536) {
|
---|
[551] | 600 | Runtime_Error(pszSrcFile, __LINE__, pszBufOvfMsg);
|
---|
[773] | 601 | pszBuf[65535] = 0; // Try to stay alive
|
---|
[551] | 602 | break;
|
---|
| 603 | }
|
---|
[773] | 604 | WinSetWindowText(hwndAutoMLE, pszBuf);
|
---|
[1009] | 605 | xfree(pszBuf, pszSrcFile, __LINE__);
|
---|
[551] | 606 | }
|
---|
| 607 | }
|
---|
| 608 | else
|
---|
| 609 | readonly = TRUE;
|
---|
| 610 | }
|
---|
| 611 | /* else EA not present */
|
---|
| 612 | MLEsetchanged(hwndAutoMLE, FALSE);
|
---|
| 613 | MLEsetreadonly(hwndAutoMLE, readonly);
|
---|
| 614 | }
|
---|
| 615 | else {
|
---|
| 616 | MLEsetchanged(hwndAutoMLE, FALSE);
|
---|
| 617 | MLEsetreadonly(hwndAutoMLE, FALSE);
|
---|
| 618 | }
|
---|
[1009] | 619 | xfree(pfealist, pszSrcFile, __LINE__);
|
---|
[551] | 620 | }
|
---|
| 621 | }
|
---|
| 622 | }
|
---|
[2] | 623 | }
|
---|
[1009] | 624 | xfree((CHAR *)mp1, pszSrcFile, __LINE__);
|
---|
[1029] | 625 | # ifdef FORTIFY
|
---|
| 626 | Fortify_LeaveScope();
|
---|
| 627 | # endif
|
---|
[551] | 628 | }
|
---|
| 629 | return 0;
|
---|
[2] | 630 |
|
---|
[551] | 631 | case UM_CLOSE:
|
---|
| 632 | if (!PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID))
|
---|
| 633 | WinSendMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID);
|
---|
| 634 | WinDestroyWindow(hwnd);
|
---|
| 635 | return 0;
|
---|
[2] | 636 | }
|
---|
[551] | 637 | return WinDefWindowProc(hwnd, msg, mp1, mp2);
|
---|
[2] | 638 | }
|
---|
| 639 |
|
---|
[551] | 640 | static VOID MakeAutoWinThread(VOID * args)
|
---|
[341] | 641 | {
|
---|
[551] | 642 | HAB hab2;
|
---|
| 643 | HMQ hmq2;
|
---|
| 644 | HWND hwndParent = (HWND) args;
|
---|
| 645 | QMSG qmsg2;
|
---|
[2] | 646 |
|
---|
| 647 | hab2 = WinInitialize(0);
|
---|
[551] | 648 | if (hab2) {
|
---|
| 649 | hmq2 = WinCreateMsgQueue(hab2, 128);
|
---|
| 650 | if (hmq2) {
|
---|
[2] | 651 | DosError(FERR_DISABLEHARDERR);
|
---|
| 652 | WinRegisterClass(hab2,
|
---|
[593] | 653 | WC_OBJECTWINDOW,
|
---|
[551] | 654 | AutoObjProc, 0, sizeof(PVOID));
|
---|
[2] | 655 | hwndAutoObj = WinCreateWindow(HWND_OBJECT,
|
---|
[593] | 656 | WC_OBJECTWINDOW,
|
---|
[551] | 657 | (PSZ) NULL,
|
---|
| 658 | 0,
|
---|
| 659 | 0L,
|
---|
| 660 | 0L,
|
---|
| 661 | 0L,
|
---|
| 662 | 0L, 0L, HWND_TOP, OBJ_FRAME, NULL, NULL);
|
---|
[377] | 663 | if (!hwndAutoObj) {
|
---|
[551] | 664 | Win_Error2(HWND_OBJECT, HWND_DESKTOP, pszSrcFile, __LINE__,
|
---|
| 665 | IDS_WINCREATEWINDOW);
|
---|
| 666 | if (!PostMsg(hwndParent, UM_CLOSE, MPVOID, MPVOID))
|
---|
| 667 | WinSendMsg(hwndParent, UM_CLOSE, MPVOID, MPVOID);
|
---|
[377] | 668 | }
|
---|
| 669 | else {
|
---|
[1032] | 670 | # ifdef FORTIFY
|
---|
| 671 | Fortify_EnterScope();
|
---|
| 672 | # endif
|
---|
[551] | 673 | WinSetWindowULong(hwndAutoObj, QWL_USER, hwndParent);
|
---|
| 674 | priority_normal();
|
---|
| 675 | while (WinGetMsg(hab2, &qmsg2, (HWND) 0, 0, 0))
|
---|
| 676 | WinDispatchMsg(hab2, &qmsg2);
|
---|
| 677 | WinDestroyWindow(hwndAutoObj);
|
---|
| 678 | hwndAutoObj = (HWND) 0;
|
---|
[2] | 679 | }
|
---|
| 680 | WinDestroyMsgQueue(hmq2);
|
---|
| 681 | }
|
---|
[1032] | 682 | // else
|
---|
| 683 | WinTerminate(hab2);
|
---|
| 684 | # ifdef FORTIFY
|
---|
| 685 | xFortify_LeaveScope(pszSrcFile, __LINE__);
|
---|
| 686 | # endif
|
---|
[2] | 687 | }
|
---|
| 688 | }
|
---|
| 689 |
|
---|
[551] | 690 | MRESULT EXPENTRY AutoViewProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
[341] | 691 | {
|
---|
[551] | 692 | USHORT id = WinQueryWindowUShort(hwnd, QWS_ID);
|
---|
[2] | 693 |
|
---|
[551] | 694 | switch (msg) {
|
---|
| 695 | case WM_CREATE:
|
---|
| 696 | {
|
---|
| 697 | MRESULT mr;
|
---|
[2] | 698 |
|
---|
[551] | 699 | if (!hwndAutoObj) {
|
---|
| 700 | if (_beginthread(MakeAutoWinThread, NULL, 65536, (PVOID) hwnd) == -1) {
|
---|
| 701 | Runtime_Error(pszSrcFile, __LINE__,
|
---|
| 702 | GetPString(IDS_COULDNTSTARTTHREADTEXT));
|
---|
| 703 | PostMsg(hwnd, UM_CLOSE, MPVOID, MPVOID);
|
---|
[341] | 704 | }
|
---|
[2] | 705 | }
|
---|
[551] | 706 | mr = PFNWPStatic(hwnd, msg, mp1, mp2);
|
---|
| 707 | SetPresParams(hwnd,
|
---|
| 708 | &RGBGREY,
|
---|
| 709 | &RGBBLACK, &RGBGREY, GetPString(IDS_4SYSTEMVIOTEXT));
|
---|
| 710 | stopflag = 0;
|
---|
| 711 | return mr;
|
---|
| 712 | }
|
---|
[2] | 713 |
|
---|
[551] | 714 | case UM_SETUP:
|
---|
| 715 | MLEsetlimit(hwnd, 32768);
|
---|
| 716 | MLEsetformat(hwnd, MLFIE_NOTRANS);
|
---|
| 717 | MLEsetchanged(hwnd, FALSE);
|
---|
| 718 | return 0;
|
---|
[2] | 719 |
|
---|
[551] | 720 | case WM_BUTTON1DOWN:
|
---|
| 721 | {
|
---|
| 722 | SWP swp;
|
---|
[2] | 723 |
|
---|
[551] | 724 | WinQueryWindowPos(hwnd, &swp);
|
---|
| 725 | if (SHORT2FROMMP(mp1) > swp.cy - 4) {
|
---|
[2] | 726 |
|
---|
[551] | 727 | HPS hps = WinGetPS(WinQueryWindow(hwnd, QW_PARENT));
|
---|
| 728 | SWP swpC;
|
---|
| 729 | TRACKINFO track;
|
---|
[2] | 730 |
|
---|
[551] | 731 | if (hps) {
|
---|
| 732 | WinQueryWindowPos(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
|
---|
| 733 | FID_CLIENT), &swpC);
|
---|
| 734 | track.cxBorder = 4;
|
---|
| 735 | track.cyBorder = 4;
|
---|
| 736 | track.cxGrid = 1;
|
---|
| 737 | track.cyGrid = 8;
|
---|
| 738 | track.cxKeyboard = 8;
|
---|
| 739 | track.rclTrack.yBottom = swp.y;
|
---|
| 740 | track.rclTrack.yTop = swp.y + swp.cy;
|
---|
| 741 | track.rclTrack.xLeft = swp.x;
|
---|
| 742 | track.rclTrack.xRight = swp.x + swp.cx;
|
---|
| 743 | track.rclBoundary = track.rclTrack;
|
---|
| 744 | track.rclBoundary.yTop = (swpC.cy + swp.y + swp.cy) - 116;
|
---|
| 745 | track.ptlMinTrackSize.x = swp.x + swp.cx;
|
---|
| 746 | track.ptlMinTrackSize.y = 36;
|
---|
| 747 | track.ptlMaxTrackSize.x = swp.x + swp.cx;
|
---|
| 748 | track.ptlMaxTrackSize.y = (swpC.cy + swp.cy) - 116;
|
---|
| 749 | track.fs = TF_TOP;
|
---|
| 750 | if (WinTrackRect(hwnd, hps, &track)) {
|
---|
| 751 | AutoviewHeight = track.rclTrack.yTop - track.rclTrack.yBottom;
|
---|
| 752 | PrfWriteProfileData(fmprof,
|
---|
| 753 | FM3Str,
|
---|
| 754 | "AutoviewHeight",
|
---|
| 755 | &AutoviewHeight, sizeof(ULONG));
|
---|
| 756 | WinSendMsg(WinQueryWindow(hwnd, QW_PARENT),
|
---|
| 757 | WM_UPDATEFRAME, MPFROMLONG(FCF_SIZEBORDER), MPVOID);
|
---|
| 758 | }
|
---|
| 759 | WinReleasePS(hps);
|
---|
| 760 | }
|
---|
| 761 | return (MRESULT) TRUE;
|
---|
[2] | 762 | }
|
---|
[551] | 763 | else if (id != MAIN_AUTOVIEWMLE)
|
---|
| 764 | return CommonTextButton(hwnd, msg, mp1, mp2);
|
---|
| 765 | }
|
---|
| 766 | break;
|
---|
[2] | 767 |
|
---|
[551] | 768 | case WM_BUTTON3DOWN:
|
---|
| 769 | case WM_BUTTON1UP:
|
---|
| 770 | case WM_BUTTON3UP:
|
---|
| 771 | if (id != MAIN_AUTOVIEWMLE)
|
---|
| 772 | return CommonTextButton(hwnd, msg, mp1, mp2);
|
---|
| 773 | break;
|
---|
[2] | 774 |
|
---|
[551] | 775 | case WM_MOUSEMOVE:
|
---|
| 776 | shiftstate = (SHORT2FROMMP(mp2) & (KC_ALT | KC_SHIFT | KC_CTRL));
|
---|
| 777 | {
|
---|
| 778 | SWP swp;
|
---|
[2] | 779 |
|
---|
[551] | 780 | WinQueryWindowPos(hwnd, &swp);
|
---|
| 781 | if (SHORT2FROMMP(mp1) > swp.cy - 4) {
|
---|
| 782 | WinSetPointer(HWND_DESKTOP, hptrNS);
|
---|
| 783 | return (MRESULT) TRUE;
|
---|
[2] | 784 | }
|
---|
[551] | 785 | }
|
---|
| 786 | break;
|
---|
[2] | 787 |
|
---|
[551] | 788 | case WM_PAINT:
|
---|
| 789 | PostMsg(hwnd, UM_PAINT, MPVOID, MPVOID);
|
---|
| 790 | break;
|
---|
[2] | 791 |
|
---|
[551] | 792 | case UM_PAINT:
|
---|
| 793 | PaintRecessedWindow(hwnd, (HPS) 0, TRUE, TRUE);
|
---|
| 794 | return 0;
|
---|
[2] | 795 |
|
---|
[551] | 796 | case WM_SETFOCUS:
|
---|
| 797 | switch (id) {
|
---|
| 798 | case MAIN_AUTOVIEWMLE:
|
---|
| 799 | if (!mp2 && !AutoMenu) {
|
---|
| 800 | if (*currfile) {
|
---|
| 801 | if (MLEgetchanged(hwnd)) {
|
---|
| 802 | CHAR *ea = xmalloc(32768, pszSrcFile, __LINE__);
|
---|
| 803 |
|
---|
| 804 | if (ea) {
|
---|
| 805 | *ea = 0;
|
---|
| 806 | WinQueryWindowText(hwnd, 32767, ea);
|
---|
| 807 | PutComments(hwnd, currfile, ea);
|
---|
| 808 | PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_RESCAN, 0), MPVOID);
|
---|
[1009] | 809 | xfree(ea, pszSrcFile, __LINE__);
|
---|
[1029] | 810 | # ifdef FORTIFY
|
---|
| 811 | Fortify_LeaveScope();
|
---|
| 812 | # endif
|
---|
[551] | 813 | }
|
---|
| 814 | }
|
---|
| 815 | }
|
---|
[2] | 816 | }
|
---|
| 817 | break;
|
---|
[551] | 818 | default:
|
---|
| 819 | if (mp2)
|
---|
| 820 | PostMsg(hwnd, UM_FOCUSME, mp1, mp2);
|
---|
| 821 | break;
|
---|
| 822 | }
|
---|
| 823 | break;
|
---|
[2] | 824 |
|
---|
[551] | 825 | case UM_FOCUSME:
|
---|
| 826 | if (mp2) {
|
---|
[2] | 827 |
|
---|
[551] | 828 | PID pid;
|
---|
| 829 | TID tid;
|
---|
[2] | 830 |
|
---|
[551] | 831 | if (WinQueryWindowProcess((HWND) mp1, &pid, &tid) && pid == mypid)
|
---|
| 832 | WinSetFocus(HWND_DESKTOP, (HWND) mp1);
|
---|
| 833 | else
|
---|
| 834 | WinSetFocus(HWND_DESKTOP, hwndTree);
|
---|
| 835 | }
|
---|
| 836 | return 0;
|
---|
[2] | 837 |
|
---|
[551] | 838 | case UM_CLICKED:
|
---|
| 839 | case UM_CLICKED3:
|
---|
| 840 | if (id != MAIN_AUTOVIEWMLE) {
|
---|
[2] | 841 | PostMsg(hwnd,
|
---|
[551] | 842 | WM_COMMAND,
|
---|
| 843 | MPFROM2SHORT(((msg == UM_CLICKED3) ?
|
---|
| 844 | IDM_EAS : IDM_VIEWORARC), 0), MPVOID);
|
---|
| 845 | }
|
---|
| 846 | return 0;
|
---|
[2] | 847 |
|
---|
[551] | 848 | case WM_COMMAND:
|
---|
| 849 | PostMsg(hwnd, UM_COMMAND, mp1, mp2);
|
---|
| 850 | return 0;
|
---|
[2] | 851 |
|
---|
[551] | 852 | case UM_COMMAND:
|
---|
| 853 | switch (SHORT1FROMMP(mp1)) {
|
---|
| 854 | case IDM_RESCAN:
|
---|
| 855 | if (*currfile) {
|
---|
[2] | 856 |
|
---|
[551] | 857 | CHAR *cf = xstrdup(currfile, pszSrcFile, __LINE__);
|
---|
[2] | 858 |
|
---|
[551] | 859 | if (cf) {
|
---|
| 860 | stopflag++;
|
---|
| 861 | if (!PostMsg(hwndAutoObj, UM_LOADFILE, MPFROMP(cf), MPVOID))
|
---|
[1009] | 862 | xfree(cf, pszSrcFile, __LINE__);
|
---|
[1029] | 863 | # ifdef FORTIFY
|
---|
| 864 | Fortify_LeaveScope();
|
---|
| 865 | # endif
|
---|
[551] | 866 | }
|
---|
| 867 | }
|
---|
| 868 | break;
|
---|
[2] | 869 |
|
---|
[551] | 870 | case IDM_INFO:
|
---|
| 871 | DefaultView(hwnd, (HWND) 0, hwndMain, NULL, 16, currfile);
|
---|
| 872 | break;
|
---|
[2] | 873 |
|
---|
[551] | 874 | case IDM_VIEW:
|
---|
| 875 | DefaultView(hwnd, (HWND) 0, hwndMain, NULL, 0, currfile);
|
---|
| 876 | break;
|
---|
[2] | 877 |
|
---|
[551] | 878 | case IDM_EDIT:
|
---|
| 879 | DefaultView(hwnd, (HWND) 0, hwndMain, NULL, 8, currfile);
|
---|
| 880 | break;
|
---|
[2] | 881 |
|
---|
[551] | 882 | case IDM_EAS:
|
---|
| 883 | {
|
---|
| 884 | char *list[2];
|
---|
[2] | 885 |
|
---|
[551] | 886 | list[0] = currfile;
|
---|
| 887 | list[1] = NULL;
|
---|
[2] | 888 |
|
---|
[551] | 889 | WinDlgBox(HWND_DESKTOP,
|
---|
| 890 | hwndMain,
|
---|
| 891 | DisplayEAsProc, FM3ModHandle, EA_FRAME, (PVOID) list);
|
---|
[2] | 892 | }
|
---|
| 893 | break;
|
---|
| 894 |
|
---|
[551] | 895 | default:
|
---|
| 896 | PostMsg(hwndMain, msg, mp1, mp2);
|
---|
| 897 | }
|
---|
| 898 | return 0;
|
---|
[2] | 899 |
|
---|
[551] | 900 | case WM_MENUEND:
|
---|
| 901 | if ((HWND) mp2 == AutoMenu) {
|
---|
| 902 | WinDestroyWindow(AutoMenu);
|
---|
| 903 | AutoMenu = (HWND) 0;
|
---|
| 904 | }
|
---|
| 905 | break;
|
---|
[2] | 906 |
|
---|
[551] | 907 | case WM_CONTEXTMENU:
|
---|
[872] | 908 | CheckMenu(hwnd, &AutoMenu, (id == MAIN_AUTOVIEWMLE) ?
|
---|
[551] | 909 | IDM_AUTOVIEWMLE : IDM_AUTOVIEW);
|
---|
| 910 | WinCheckMenuItem(AutoMenu, IDM_AUTOVIEWFILE, !fComments);
|
---|
| 911 | WinCheckMenuItem(AutoMenu, IDM_AUTOVIEWCOMMENTS, fComments);
|
---|
| 912 | WinEnableMenuItem(AutoMenu, IDM_VIEW, (IsFile(currfile) == 1));
|
---|
| 913 | WinEnableMenuItem(AutoMenu, IDM_EDIT, (IsFile(currfile) == 1));
|
---|
| 914 | WinEnableMenuItem(AutoMenu, IDM_INFO, (*currfile != 0));
|
---|
| 915 | PopupMenu(hwnd, hwnd, AutoMenu);
|
---|
| 916 | break;
|
---|
[2] | 917 |
|
---|
[551] | 918 | case UM_LOADFILE:
|
---|
| 919 | stopflag++;
|
---|
| 920 | if (!PostMsg(hwndAutoObj, msg, mp1, mp2)) {
|
---|
[1009] | 921 | xfree((CHAR *)mp1, pszSrcFile, __LINE__);
|
---|
[1029] | 922 | # ifdef FORTIFY
|
---|
| 923 | Fortify_LeaveScope();
|
---|
| 924 | # endif
|
---|
[551] | 925 | }
|
---|
| 926 | return 0;
|
---|
[2] | 927 |
|
---|
[551] | 928 | case UM_CLOSE:
|
---|
| 929 | if (AutoMenu) {
|
---|
| 930 | WinDestroyWindow(AutoMenu);
|
---|
| 931 | AutoMenu = (HWND) 0;
|
---|
| 932 | }
|
---|
| 933 | WinDestroyWindow(hwnd);
|
---|
| 934 | return 0;
|
---|
| 935 |
|
---|
| 936 | case WM_CLOSE:
|
---|
| 937 | WinSendMsg(hwnd, UM_CLOSE, MPVOID, MPVOID);
|
---|
| 938 | return 0;
|
---|
| 939 |
|
---|
| 940 | case WM_DESTROY:
|
---|
| 941 | if (id != MAIN_AUTOVIEWMLE) {
|
---|
| 942 | if (hwndAutoObj)
|
---|
| 943 | if (!PostMsg(hwndAutoObj, WM_CLOSE, MPVOID, MPVOID))
|
---|
| 944 | WinSendMsg(hwndAutoObj, WM_CLOSE, MPVOID, MPVOID);
|
---|
[2] | 945 | break;
|
---|
[551] | 946 | }
|
---|
| 947 | break;
|
---|
[2] | 948 | }
|
---|
| 949 |
|
---|
[551] | 950 | if (id == MAIN_AUTOVIEWMLE)
|
---|
| 951 | return PFNWPMLE(hwnd, msg, mp1, mp2);
|
---|
| 952 | return PFNWPStatic(hwnd, msg, mp1, mp2);
|
---|
[2] | 953 | }
|
---|
[793] | 954 |
|
---|
| 955 | #pragma alloc_text(AUTOVIEW,AutoViewProc,CreateHexDump,AutoObjProc)
|
---|
| 956 | #pragma alloc_text(AUTOVIEW2,MakeAutoWinThread,WriteEA,PutComments)
|
---|