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