[41] | 1 |
|
---|
| 2 | /***********************************************************************
|
---|
| 3 |
|
---|
| 4 | $Id: autoview.c 1878 2015-10-11 22:24:39Z gyoung $
|
---|
| 5 |
|
---|
| 6 | Auto view
|
---|
| 7 |
|
---|
| 8 | Copyright (c) 1993-98 M. Kimes
|
---|
[1498] | 9 | Copyright (c) 2001, 2010 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
|
---|
[1391] | 27 | 11 Jan 09 GKY Replace font names in the string file with global set at compile in init.c
|
---|
[1395] | 28 | 07 Feb 09 GKY Add *DateFormat functions to format dates bassed on locale
|
---|
| 29 | 07 Feb 09 GKY Eliminate Win_Error2 by moving function names to PCSZs used in Win_Error
|
---|
[1400] | 30 | 08 Mar 09 GKY Renamed commafmt.h i18nutil.h
|
---|
[1480] | 31 | 12 Jul 09 GKY Add xDosQueryAppType and xDosAlloc... to allow FM/2 to load in high memory
|
---|
[1482] | 32 | 13 Dec 09 GKY Fixed separate paramenters. Please note that appname should be used in
|
---|
| 33 | profile calls for user settings that work and are setable in more than one
|
---|
| 34 | miniapp; FM3Str should be used for setting only relavent to FM/2 or that
|
---|
| 35 | aren't user settable; realappname should be used for setting applicable to
|
---|
| 36 | one or more miniapp but not to FM/2
|
---|
[1498] | 37 | 17 JAN 10 GKY Changes to get working with Watcom 1.9 Beta (1/16/10). Mostly cast CHAR CONSTANT * as CHAR *.
|
---|
[1616] | 38 | 13 Aug 11 GKY Change to Doxygen comment format
|
---|
[1627] | 39 | 26 Aug 11 GKY Add a low mem version of xDosAlloc* wrappers; move error checking into all the
|
---|
| 40 | xDosAlloc* wrappers.
|
---|
[41] | 41 |
|
---|
| 42 | ***********************************************************************/
|
---|
| 43 |
|
---|
[907] | 44 | #include <stdlib.h>
|
---|
| 45 | #include <string.h>
|
---|
| 46 | #include <ctype.h>
|
---|
| 47 |
|
---|
[2] | 48 | #define INCL_DOS
|
---|
| 49 | #define INCL_WIN
|
---|
| 50 | #define INCL_GPI
|
---|
[841] | 51 | #define INCL_LONGLONG
|
---|
[2] | 52 |
|
---|
[1182] | 53 | #include "fm3dll.h"
|
---|
[1220] | 54 | #include "fm3dll2.h" // #define's for UM_*, control id's, etc.
|
---|
[1204] | 55 | #include "killproc.h" // Data declaration(s)
|
---|
| 56 | #include "notebook.h" // Data declaration(s)
|
---|
| 57 | #include "avl.h" // Data declaration(s)
|
---|
| 58 | #include "inis.h" // Data declaration(s)
|
---|
| 59 | #include "init.h" // Data declaration(s)
|
---|
| 60 | #include "mainwnd.h" // Data declaration(s)
|
---|
[2] | 61 | #include "fm3dlg.h"
|
---|
| 62 | #include "fm3str.h"
|
---|
| 63 | #include "mle.h"
|
---|
[907] | 64 | #include "pathutil.h" // BldFullPathName
|
---|
| 65 | #include "errutil.h" // Dos_Error...
|
---|
| 66 | #include "strutil.h" // GetPString
|
---|
[1159] | 67 | #include "autoview.h"
|
---|
| 68 | #include "defview.h" // DefaultView
|
---|
| 69 | #include "valid.h" // IsBinary
|
---|
[1182] | 70 | #include "misc.h" // CheckMenu
|
---|
| 71 | #include "common.h" // CommonTextButton
|
---|
| 72 | #include "presparm.h" // CopyPresParams
|
---|
| 73 | #include "eas.h" // DisplayEAsProc
|
---|
| 74 | #include "chklist.h" // PopupMenu
|
---|
| 75 | #include "wrappers.h" // xDosSetPathInfo
|
---|
[1400] | 76 | #include "i18nutil.h" // CommaFmtULL
|
---|
[1029] | 77 | #include "fortify.h"
|
---|
[1335] | 78 | #include "excputil.h" // 06 May 08 SHL added
|
---|
[1029] | 79 |
|
---|
[1204] | 80 | static BOOL PutComments(HWND hwnd, CHAR * filename, CHAR * comments);
|
---|
[1398] | 81 | static BOOL WriteEA(HWND hwnd, CHAR * filename, PCSZ eaname, USHORT type,
|
---|
[1204] | 82 | CHAR * data);
|
---|
| 83 |
|
---|
| 84 | // Data definitions
|
---|
| 85 | #pragma data_seg(GLOBAL1)
|
---|
| 86 | HWND hwndAutoMLE;
|
---|
| 87 |
|
---|
| 88 | #pragma data_seg(GLOBAL2)
|
---|
| 89 | ULONG AutoviewHeight;
|
---|
| 90 |
|
---|
[2] | 91 | #pragma data_seg(DATA1)
|
---|
[341] | 92 | static PSZ pszSrcFile = __FILE__;
|
---|
| 93 |
|
---|
[1204] | 94 | static HWND AutoMenu;
|
---|
[341] | 95 | static HWND hwndAutoObj;
|
---|
[2] | 96 | static CHAR stopflag;
|
---|
| 97 | static CHAR currfile[CCHMAXPATH];
|
---|
| 98 |
|
---|
[1398] | 99 | BOOL WriteEA(HWND hwnd, CHAR * filename, PCSZ eaname, USHORT type,
|
---|
[551] | 100 | CHAR * data)
|
---|
[341] | 101 | {
|
---|
[1616] | 102 | // save an ea to disk
|
---|
[2] | 103 |
|
---|
| 104 | FEA2LIST *pfealist = NULL;
|
---|
[551] | 105 | EAOP2 eaop;
|
---|
| 106 | APIRET rc;
|
---|
| 107 | ULONG ealen;
|
---|
| 108 | USHORT len, *num, *plen, usCodepage;
|
---|
| 109 | CHAR *p, *eaval;
|
---|
| 110 | BOOL ret = FALSE;
|
---|
[2] | 111 |
|
---|
[551] | 112 | if (!filename || !eaname)
|
---|
[2] | 113 | return ret;
|
---|
[551] | 114 | usCodepage = (USHORT) WinQueryCp(WinQueryWindowULong(hwnd, QWL_HMQ));
|
---|
[2] | 115 | len = (data) ? strlen(data) : 0;
|
---|
[551] | 116 | ealen = sizeof(FEA2LIST) + 24L + strlen(eaname) + 1L + (ULONG) len + 4L;
|
---|
| 117 | switch (type) {
|
---|
| 118 | case EAT_EA:
|
---|
| 119 | case EAT_ASCII:
|
---|
| 120 | break;
|
---|
| 121 | case EAT_MVST:
|
---|
| 122 | if (data) {
|
---|
| 123 | ealen += sizeof(USHORT) * 5;
|
---|
| 124 | p = data;
|
---|
| 125 | while (*p) {
|
---|
| 126 | if (*p == '\n' && *(p + 1))
|
---|
| 127 | ealen += sizeof(USHORT);
|
---|
| 128 | p++;
|
---|
| 129 | }
|
---|
| 130 | }
|
---|
| 131 | break;
|
---|
| 132 | case EAT_MVMT:
|
---|
| 133 | if (data) {
|
---|
| 134 | ealen += sizeof(USHORT) * 5;
|
---|
| 135 | p = data;
|
---|
| 136 | while (*p) {
|
---|
| 137 | if (*p == '\n' && *(p + 1))
|
---|
| 138 | ealen += (sizeof(USHORT) * 2);
|
---|
| 139 | p++;
|
---|
| 140 | }
|
---|
| 141 | }
|
---|
| 142 | break;
|
---|
| 143 | default:
|
---|
| 144 | return ret;
|
---|
| 145 | }
|
---|
| 146 |
|
---|
[1628] | 147 | if (xDosAllocMem((PPVOID) &pfealist, ealen, pszSrcFile, __LINE__))
|
---|
[1627] | 148 | ret = FALSE;
|
---|
[551] | 149 | else {
|
---|
| 150 | memset(pfealist, 0, ealen);
|
---|
| 151 | pfealist->list[0].cbName = strlen(eaname);
|
---|
| 152 | memcpy(pfealist->list[0].szName, eaname, pfealist->list[0].cbName + 1);
|
---|
| 153 | eaval = pfealist->list[0].szName + pfealist->list[0].cbName + 1;
|
---|
| 154 | switch (type) {
|
---|
[2] | 155 | case EAT_EA:
|
---|
| 156 | case EAT_ASCII:
|
---|
[551] | 157 | if (data) {
|
---|
| 158 | *(USHORT *) eaval = (USHORT) type;
|
---|
| 159 | eaval += sizeof(USHORT);
|
---|
| 160 | *(USHORT *) eaval = (USHORT) len;
|
---|
| 161 | eaval += sizeof(USHORT);
|
---|
| 162 | memcpy(eaval, data, len);
|
---|
| 163 | eaval += len;
|
---|
| 164 | }
|
---|
[2] | 165 | break;
|
---|
| 166 | case EAT_MVST:
|
---|
[551] | 167 | if (data) {
|
---|
| 168 | *(USHORT *) eaval = (USHORT) EAT_MVST;
|
---|
| 169 | eaval += sizeof(USHORT);
|
---|
| 170 | *(USHORT *) eaval = usCodepage;
|
---|
| 171 | eaval += sizeof(USHORT);
|
---|
| 172 | num = (USHORT *) eaval;
|
---|
| 173 | *num = 0;
|
---|
| 174 | eaval += sizeof(USHORT);
|
---|
| 175 | *(USHORT *) eaval = (USHORT) EAT_ASCII;
|
---|
| 176 | eaval += sizeof(USHORT);
|
---|
| 177 | plen = (USHORT *) eaval;
|
---|
| 178 | *plen = 0;
|
---|
| 179 | eaval += sizeof(USHORT);
|
---|
| 180 | p = data;
|
---|
| 181 | while (*p) {
|
---|
| 182 | while (*p) {
|
---|
| 183 | if (*p == '\n') {
|
---|
| 184 | p++;
|
---|
| 185 | break;
|
---|
| 186 | }
|
---|
| 187 | *eaval++ = *p++;
|
---|
| 188 | (*plen)++;
|
---|
| 189 | }
|
---|
| 190 | if (*p || *plen)
|
---|
| 191 | (*num)++;
|
---|
| 192 | if (*p) {
|
---|
| 193 | plen = (USHORT *) eaval;
|
---|
| 194 | *plen = 0;
|
---|
| 195 | eaval += sizeof(USHORT);
|
---|
| 196 | }
|
---|
| 197 | }
|
---|
[2] | 198 | }
|
---|
| 199 | break;
|
---|
| 200 | case EAT_MVMT:
|
---|
[551] | 201 | if (data) {
|
---|
| 202 | *(USHORT *) eaval = (USHORT) EAT_MVMT;
|
---|
| 203 | eaval += sizeof(USHORT);
|
---|
| 204 | *(USHORT *) eaval = usCodepage;
|
---|
| 205 | eaval += sizeof(USHORT);
|
---|
| 206 | num = (USHORT *) eaval;
|
---|
| 207 | *num = 0;
|
---|
| 208 | eaval += sizeof(USHORT);
|
---|
| 209 | *(USHORT *) eaval = (USHORT) EAT_ASCII;
|
---|
| 210 | eaval += sizeof(USHORT);
|
---|
| 211 | plen = (USHORT *) eaval;
|
---|
| 212 | *plen = 0;
|
---|
| 213 | eaval += sizeof(USHORT);
|
---|
| 214 | p = data;
|
---|
| 215 | while (*p) {
|
---|
| 216 | while (*p) {
|
---|
| 217 | if (*p == '\n') {
|
---|
| 218 | p++;
|
---|
| 219 | break;
|
---|
| 220 | }
|
---|
| 221 | *eaval++ = *p++;
|
---|
| 222 | (*plen)++;
|
---|
| 223 | }
|
---|
| 224 | if (*p || *plen)
|
---|
| 225 | (*num)++;
|
---|
| 226 | if (*p) {
|
---|
| 227 | *(USHORT *) eaval = (USHORT) EAT_ASCII;
|
---|
| 228 | eaval += sizeof(USHORT);
|
---|
| 229 | plen = (USHORT *) eaval;
|
---|
| 230 | *plen = 0;
|
---|
| 231 | eaval += sizeof(USHORT);
|
---|
| 232 | }
|
---|
| 233 | }
|
---|
[2] | 234 | }
|
---|
| 235 | break;
|
---|
| 236 | }
|
---|
[1616] | 237 | pfealist->list[0].cbValue = (eaval - (pfealist->list[0].szName +
|
---|
[551] | 238 | pfealist->list[0].cbName + 1));
|
---|
| 239 | memset(&eaop, 0, sizeof(eaop));
|
---|
[2] | 240 | eaop.fpFEA2List = pfealist;
|
---|
[841] | 241 | pfealist->cbList = 13 + (ULONG) pfealist->list[0].cbName +
|
---|
[551] | 242 | (ULONG) pfealist->list[0].cbValue;
|
---|
[827] | 243 | rc = xDosSetPathInfo(filename, FIL_QUERYEASIZE,
|
---|
| 244 | &eaop, sizeof(eaop), DSPI_WRTTHRU);
|
---|
[2] | 245 | DosFreeMem(pfealist);
|
---|
[551] | 246 | if (!rc)
|
---|
[2] | 247 | ret = TRUE;
|
---|
| 248 | }
|
---|
| 249 | return ret;
|
---|
| 250 | }
|
---|
| 251 |
|
---|
[551] | 252 | BOOL PutComments(HWND hwnd, CHAR * filename, CHAR * comments)
|
---|
[341] | 253 | {
|
---|
[2] | 254 | register CHAR *p;
|
---|
| 255 |
|
---|
[1616] | 256 | if (comments) { // check -- is it empty?
|
---|
[2] | 257 | p = comments;
|
---|
[551] | 258 | while (*p && isspace(*p))
|
---|
[2] | 259 | p++;
|
---|
[551] | 260 | if (!*p)
|
---|
[2] | 261 | comments = NULL;
|
---|
| 262 | }
|
---|
[1398] | 263 | return WriteEA(hwnd, filename, PCSZ_DOTCOMMENTS, EAT_MVMT, comments);
|
---|
[2] | 264 | }
|
---|
| 265 |
|
---|
[439] | 266 | static PSZ pszBufOvfMsg = "Buffer overflow";
|
---|
[2] | 267 |
|
---|
[551] | 268 | ULONG CreateHexDump(CHAR * pchInBuf, ULONG cbInBuf,
|
---|
| 269 | CHAR * pchOutBuf, ULONG cbOutBuf,
|
---|
| 270 | ULONG cOffset, BOOL fLongAddr)
|
---|
[41] | 271 | {
|
---|
[551] | 272 | register CHAR *pchIn, *pchReset, *pchOut;
|
---|
| 273 | register ULONG ibIn = 0, ibIn2, ibInFill;
|
---|
[41] | 274 | ULONG cbOutLine = 6 + (fLongAddr ? 4 : 0) + 16 * 3 + 1 + 16 + 1;
|
---|
[2] | 275 |
|
---|
[551] | 276 | if (pchInBuf && cbInBuf && pchOutBuf && cbOutBuf) {
|
---|
[41] | 277 | pchIn = pchInBuf;
|
---|
| 278 | pchOut = pchOutBuf;
|
---|
[551] | 279 | if (cOffset)
|
---|
[41] | 280 | *pchOut++ = '\n';
|
---|
| 281 | while (ibIn < cbInBuf) {
|
---|
| 282 | if (pchOut - pchOutBuf + cbOutLine >= cbOutBuf) {
|
---|
[551] | 283 | Runtime_Error(pszSrcFile, __LINE__, pszBufOvfMsg);
|
---|
[41] | 284 | break;
|
---|
| 285 | }
|
---|
| 286 | pchReset = pchIn;
|
---|
| 287 | ibIn2 = ibIn;
|
---|
[551] | 288 | if (fLongAddr)
|
---|
| 289 | sprintf(pchOut, "%08lx ", ibIn + cOffset);
|
---|
[2] | 290 | else
|
---|
[551] | 291 | sprintf(pchOut, "%04lx ", ibIn + cOffset);
|
---|
[41] | 292 | pchOut += 6 + (fLongAddr ? 4 : 0);
|
---|
[2] | 293 | do {
|
---|
[870] | 294 | sprintf(pchOut, "%02x ", (UCHAR)*pchIn);
|
---|
[551] | 295 | pchOut += 3;
|
---|
| 296 | pchIn++;
|
---|
| 297 | ibIn++;
|
---|
| 298 | } while (ibIn < cbInBuf && (ibIn % 16));
|
---|
| 299 | if (ibIn % 16) {
|
---|
| 300 | ibInFill = ibIn;
|
---|
| 301 | while (ibInFill % 16) {
|
---|
| 302 | *pchOut++ = ' ';
|
---|
| 303 | *pchOut++ = ' ';
|
---|
| 304 | *pchOut++ = ' ';
|
---|
| 305 | ibInFill++;
|
---|
| 306 | }
|
---|
[2] | 307 | }
|
---|
[41] | 308 | *pchOut++ = ' ';
|
---|
| 309 | pchIn = pchReset;
|
---|
[2] | 310 | do {
|
---|
[551] | 311 | if (*pchIn && *pchIn != '\n' && *pchIn != '\r' && *pchIn != '\t'
|
---|
| 312 | && *pchIn != '\x1a')
|
---|
| 313 | *pchOut++ = *pchIn++;
|
---|
| 314 | else {
|
---|
| 315 | *pchOut++ = '.';
|
---|
| 316 | pchIn++;
|
---|
| 317 | }
|
---|
| 318 | ibIn2++;
|
---|
| 319 | } while (ibIn2 < ibIn);
|
---|
| 320 | if (ibIn < cbInBuf)
|
---|
| 321 | *pchOut++ = '\n';
|
---|
| 322 | } // while ibIn
|
---|
[41] | 323 | *pchOut = 0;
|
---|
[551] | 324 | return (ULONG) (pchOut - pchOutBuf);
|
---|
[2] | 325 | }
|
---|
| 326 | return 0L;
|
---|
| 327 | }
|
---|
| 328 |
|
---|
[551] | 329 | MRESULT EXPENTRY AutoObjProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
[51] | 330 | {
|
---|
[551] | 331 | switch (msg) {
|
---|
| 332 | case UM_LOADFILE:
|
---|
| 333 | *currfile = 0;
|
---|
| 334 | stopflag--;
|
---|
| 335 | if (fAutoView) {
|
---|
[1438] | 336 | WinSetWindowText((fComments) ? hwndAutoMLE : hwndAutoview, NullStr);
|
---|
[551] | 337 | MLEsetreadonly(hwndAutoMLE, TRUE);
|
---|
| 338 | MLEsetchanged(hwndAutoMLE, FALSE);
|
---|
| 339 | }
|
---|
| 340 | if (mp1) {
|
---|
| 341 | if (fAutoView) {
|
---|
[1009] | 342 | strcpy(currfile, (CHAR *)mp1);
|
---|
[551] | 343 | if (!fComments) {
|
---|
[1009] | 344 | if (IsFile((CHAR *)mp1) == 1) {
|
---|
[2] | 345 |
|
---|
[551] | 346 | HFILE handle;
|
---|
[858] | 347 | ULONG olen, ibufflen, action, obufflen, l;
|
---|
[850] | 348 | CHAR *ibuff, *obuff, *p;
|
---|
| 349 | CHAR buffer[4096];
|
---|
[551] | 350 | ARC_TYPE *info;
|
---|
[2] | 351 |
|
---|
[1009] | 352 | if (!DosOpen((CHAR *)mp1,
|
---|
[844] | 353 | &handle,
|
---|
| 354 | &action,
|
---|
| 355 | 0,
|
---|
| 356 | 0,
|
---|
| 357 | OPEN_ACTION_FAIL_IF_NEW | OPEN_ACTION_OPEN_IF_EXISTS,
|
---|
| 358 | OPEN_FLAGS_FAIL_ON_ERROR | OPEN_FLAGS_NOINHERIT |
|
---|
| 359 | OPEN_FLAGS_RANDOMSEQUENTIAL | OPEN_SHARE_DENYNONE |
|
---|
| 360 | OPEN_ACCESS_READONLY, 0)) {
|
---|
[850] | 361 | ibufflen = AutoviewHeight < 96 ? 512 : 3072;
|
---|
| 362 | // 06 Oct 07 SHL protect against NTFS driver small buffer defect
|
---|
[858] | 363 | ibuff = xmalloc(max(ibufflen + 2, 4096), pszSrcFile, __LINE__);
|
---|
[551] | 364 | if (ibuff) {
|
---|
| 365 | // Depends on CreateHexDump line width
|
---|
| 366 | obufflen = (ibufflen / 16) * (6 + 3 * 16 + 1 + 16 + 1) + 80;
|
---|
| 367 | obuff = xmalloc(obufflen + 1, pszSrcFile, __LINE__);
|
---|
| 368 | if (obuff) {
|
---|
| 369 | *obuff = 0;
|
---|
[850] | 370 | if (!DosRead(handle, ibuff, ibufflen, &ibufflen) &&
|
---|
| 371 | ibufflen)
|
---|
| 372 | {
|
---|
[551] | 373 | ibuff[ibufflen] = 0;
|
---|
| 374 | p = obuff;
|
---|
| 375 | if (IsBinary(ibuff, ibufflen)) {
|
---|
| 376 | olen = ibufflen;
|
---|
| 377 | // Check archive
|
---|
| 378 | if (!arcsigsloaded)
|
---|
| 379 | load_archivers();
|
---|
| 380 | info = arcsighead;
|
---|
| 381 | while (info) {
|
---|
| 382 | if (info->signature && *info->signature) {
|
---|
| 383 | l = strlen(info->signature);
|
---|
| 384 | l = min(l, 79);
|
---|
| 385 | if (!DosChgFilePtr(handle, abs(info->file_offset),
|
---|
| 386 | (info->file_offset >= 0L) ?
|
---|
| 387 | FILE_BEGIN :
|
---|
| 388 | FILE_END, &ibufflen)) {
|
---|
| 389 | if (!DosRead(handle,
|
---|
| 390 | buffer,
|
---|
| 391 | l, &ibufflen) && ibufflen == l) {
|
---|
| 392 | if (!memcmp(info->signature, buffer, l))
|
---|
| 393 | break;
|
---|
| 394 | }
|
---|
| 395 | }
|
---|
| 396 | }
|
---|
| 397 | info = info->next;
|
---|
| 398 | }
|
---|
| 399 | if (info) {
|
---|
| 400 | sprintf(p, "**%s%s%s\n",
|
---|
[1438] | 401 | info->id ? info->id : NullStr,
|
---|
| 402 | info->id ? " " : NullStr,
|
---|
[551] | 403 | GetPString(IDS_ARCHIVETEXT));
|
---|
| 404 | p += strlen(p);
|
---|
| 405 | }
|
---|
| 406 | CreateHexDump(ibuff, // Input buffer
|
---|
| 407 | olen, // Input buffer size
|
---|
| 408 | p, // Output buffer
|
---|
| 409 | obufflen - (p - obuff), // Output buffer size
|
---|
| 410 | 0, // Address offest
|
---|
| 411 | FALSE); // Short addresses
|
---|
| 412 | }
|
---|
| 413 | else {
|
---|
| 414 | // Text file
|
---|
| 415 | register CHAR *src, *dest;
|
---|
| 416 | CHAR *endsrc;
|
---|
[2] | 417 |
|
---|
[551] | 418 | src = ibuff;
|
---|
| 419 | dest = obuff;
|
---|
| 420 | endsrc = ibuff + ibufflen;
|
---|
| 421 | while (src < endsrc) {
|
---|
| 422 | if (dest == obuff && (*src == '\t' || *src == ' ' ||
|
---|
| 423 | *src == '\r' || *src == '\n')) {
|
---|
| 424 | src++;
|
---|
| 425 | }
|
---|
| 426 | else if (*src == '\t' || !*src) {
|
---|
| 427 | *dest = ' ';
|
---|
| 428 | dest++;
|
---|
| 429 | src++;
|
---|
| 430 | }
|
---|
| 431 | else if (*src == '\r' || *src == '\n') {
|
---|
| 432 | *dest = *src;
|
---|
| 433 | while (*(src + 1) == '\r' || *(src + 1) == '\n' ||
|
---|
| 434 | *(src + 1) == ' ' || *(src + 1) == '\t')
|
---|
| 435 | src++;
|
---|
| 436 | dest++;
|
---|
| 437 | src++;
|
---|
| 438 | }
|
---|
| 439 | else {
|
---|
| 440 | *dest = *src;
|
---|
| 441 | src++;
|
---|
| 442 | dest++;
|
---|
| 443 | }
|
---|
| 444 | } // while
|
---|
| 445 | *dest = 0;
|
---|
| 446 | if (dest - obuff >= obufflen)
|
---|
| 447 | Runtime_Error(pszSrcFile, __LINE__, pszBufOvfMsg);
|
---|
| 448 | }
|
---|
| 449 | if (*obuff)
|
---|
| 450 | WinSetWindowText(hwndAutoview, obuff);
|
---|
| 451 | }
|
---|
[1039] | 452 | free(obuff);
|
---|
[551] | 453 | }
|
---|
[1039] | 454 | free(ibuff);
|
---|
[551] | 455 | }
|
---|
| 456 | DosClose(handle);
|
---|
| 457 | }
|
---|
| 458 | }
|
---|
| 459 | else if (!IsFile(currfile)) {
|
---|
[2] | 460 |
|
---|
[841] | 461 | static FILEFINDBUF4L ffb[130];
|
---|
[1397] | 462 | CHAR fullname[CCHMAXPATH + 4], szCmmaFmtFileSize[81], szDate[DATE_BUF_BYTES];
|
---|
[551] | 463 | HDIR hdir = HDIR_CREATE;
|
---|
| 464 | ULONG x, nm, ml, mc, bufflen;
|
---|
| 465 | PBYTE fb;
|
---|
[841] | 466 | PFILEFINDBUF4L pffbFile;
|
---|
[773] | 467 | PSZ pszBuf;
|
---|
| 468 | PSZ p;
|
---|
| 469 | APIRET rc;
|
---|
[2] | 470 |
|
---|
[773] | 471 | BldFullPathName(fullname, currfile, "*");
|
---|
[551] | 472 | DosError(FERR_DISABLEHARDERR);
|
---|
[841] | 473 | nm = sizeof(ffb) / sizeof(FILEFINDBUF4L);
|
---|
[551] | 474 | if (AutoviewHeight < 96)
|
---|
| 475 | nm /= 2;
|
---|
[838] | 476 | rc = xDosFindFirst(fullname,
|
---|
[858] | 477 | &hdir,
|
---|
| 478 | FILE_NORMAL | FILE_DIRECTORY |
|
---|
| 479 | FILE_READONLY | FILE_ARCHIVED |
|
---|
| 480 | FILE_SYSTEM | FILE_HIDDEN,
|
---|
| 481 | &ffb, sizeof(ffb), &nm, FIL_QUERYEASIZEL);
|
---|
[551] | 482 | if (!rc && nm) {
|
---|
| 483 | fb = (PBYTE) & ffb;
|
---|
| 484 | x = ml = 0;
|
---|
| 485 | while (x < nm) {
|
---|
[841] | 486 | pffbFile = (PFILEFINDBUF4L) fb;
|
---|
[551] | 487 | mc = (ULONG) pffbFile->cchName +
|
---|
| 488 | ((pffbFile->attrFile & FILE_DIRECTORY) != 0);
|
---|
| 489 | ml = max(ml, mc);
|
---|
| 490 | if (!pffbFile->oNextEntryOffset)
|
---|
| 491 | break;
|
---|
| 492 | fb += pffbFile->oNextEntryOffset;
|
---|
| 493 | x++;
|
---|
| 494 | }
|
---|
| 495 | bufflen = (CCHMAXPATHCOMP + 42) * nm;
|
---|
[773] | 496 | pszBuf = xmalloc(bufflen, pszSrcFile, __LINE__);
|
---|
| 497 | if (pszBuf) {
|
---|
| 498 | p = pszBuf;
|
---|
[551] | 499 | *p = 0;
|
---|
| 500 | fb = (PBYTE) & ffb;
|
---|
| 501 | x = 0;
|
---|
| 502 | while (x < nm) {
|
---|
[841] | 503 | pffbFile = (PFILEFINDBUF4L) fb;
|
---|
[551] | 504 | if (!(!*pffbFile->achName ||
|
---|
| 505 | (((pffbFile->attrFile & FILE_DIRECTORY) &&
|
---|
| 506 | pffbFile->achName[0] == '.') &&
|
---|
| 507 | (!pffbFile->achName[1] ||
|
---|
| 508 | (pffbFile->achName[1] == '.' &&
|
---|
| 509 | !pffbFile->achName[2]))))) {
|
---|
[1078] | 510 | CommaFmtULL(szCmmaFmtFileSize,
|
---|
| 511 | sizeof(szCmmaFmtFileSize),
|
---|
| 512 | pffbFile->cbFile + CBLIST_TO_EASIZE(pffbFile->cbList),
|
---|
[1395] | 513 | ' ');
|
---|
| 514 | FDateFormat(szDate, pffbFile->fdateLastWrite);
|
---|
[551] | 515 | sprintf(p,
|
---|
[1395] | 516 | "%s%-*.*s %-8s [%s%s%s%s] %s "
|
---|
| 517 | "%02lu%s%02lu%s%02lu\r",
|
---|
[1438] | 518 | pffbFile->attrFile & FILE_DIRECTORY ? PCSZ_BACKSLASH : " ",
|
---|
[551] | 519 | ml,
|
---|
| 520 | ml,
|
---|
[1078] | 521 | pffbFile->achName,
|
---|
| 522 | szCmmaFmtFileSize,
|
---|
[846] | 523 | pffbFile->attrFile & FILE_READONLY ? "R" : "-",
|
---|
| 524 | pffbFile->attrFile & FILE_ARCHIVED ? "A" : "-",
|
---|
| 525 | pffbFile->attrFile & FILE_HIDDEN ? "H" : "-",
|
---|
| 526 | pffbFile->attrFile & FILE_SYSTEM ? "S" : "-",
|
---|
[1395] | 527 | szDate,
|
---|
| 528 | pffbFile->ftimeLastWrite.hours, TimeSeparator,
|
---|
| 529 | pffbFile->ftimeLastWrite.minutes, TimeSeparator,
|
---|
[551] | 530 | pffbFile->ftimeLastWrite.twosecs * 2);
|
---|
| 531 | p += strlen(p);
|
---|
| 532 | }
|
---|
| 533 | if (!pffbFile->oNextEntryOffset)
|
---|
| 534 | break;
|
---|
| 535 | fb += pffbFile->oNextEntryOffset;
|
---|
| 536 | x++;
|
---|
| 537 | } // while
|
---|
[773] | 538 | if (p - pszBuf >= bufflen)
|
---|
[551] | 539 | Runtime_Error(pszSrcFile, __LINE__, pszBufOvfMsg);
|
---|
[773] | 540 | if (*pszBuf)
|
---|
| 541 | WinSetWindowText(hwndAutoview, pszBuf);
|
---|
[1039] | 542 | free(pszBuf);
|
---|
[551] | 543 | }
|
---|
| 544 | }
|
---|
| 545 | if (!rc)
|
---|
| 546 | DosFindClose(hdir);
|
---|
| 547 | }
|
---|
| 548 | }
|
---|
| 549 | else {
|
---|
[2] | 550 |
|
---|
[551] | 551 | APIRET rc;
|
---|
| 552 | EAOP2 eaop;
|
---|
| 553 | PGEA2LIST pgealist;
|
---|
| 554 | PFEA2LIST pfealist;
|
---|
| 555 | PGEA2 pgea;
|
---|
| 556 | PFEA2 pfea;
|
---|
[773] | 557 | CHAR *value, *pszBuf, *p, *data;
|
---|
[551] | 558 | USHORT len, type, plen, dlen;
|
---|
| 559 | BOOL readonly = FALSE;
|
---|
[2] | 560 |
|
---|
[551] | 561 | pgealist = xmallocz(sizeof(GEA2LIST) + 64, pszSrcFile, __LINE__);
|
---|
| 562 | if (pgealist) {
|
---|
| 563 | pgea = &pgealist->list[0];
|
---|
[1398] | 564 | strcpy(pgea->szName, PCSZ_DOTCOMMENTS);
|
---|
[551] | 565 | pgea->cbName = strlen(pgea->szName);
|
---|
| 566 | pgea->oNextEntryOffset = 0L;
|
---|
| 567 | pgealist->cbList = (sizeof(GEA2LIST) + pgea->cbName);
|
---|
| 568 | pfealist = xmallocz(65536, pszSrcFile, __LINE__);
|
---|
| 569 | if (pfealist) {
|
---|
| 570 | pfealist->cbList = 65536;
|
---|
| 571 | eaop.fpGEA2List = pgealist;
|
---|
| 572 | eaop.fpFEA2List = pfealist;
|
---|
| 573 | eaop.oError = 0L;
|
---|
[1009] | 574 | rc = DosQueryPathInfo((CHAR *)mp1, FIL_QUERYEASFROMLIST,
|
---|
[551] | 575 | (PVOID) & eaop, (ULONG) sizeof(EAOP2));
|
---|
[1039] | 576 | free(pgealist);
|
---|
[551] | 577 | if (!rc) {
|
---|
| 578 | pfea = &eaop.fpFEA2List->list[0];
|
---|
| 579 | if (pfea->cbName && pfea->cbValue) {
|
---|
| 580 | value = pfea->szName + pfea->cbName + 1;
|
---|
| 581 | value[pfea->cbValue] = 0;
|
---|
| 582 | if (*(USHORT *) value == EAT_MVMT) {
|
---|
[773] | 583 | pszBuf = xmalloc(65536, pszSrcFile, __LINE__);
|
---|
| 584 | if (pszBuf) {
|
---|
| 585 | p = pszBuf;
|
---|
| 586 | *pszBuf = 0;
|
---|
[551] | 587 | data = value + (sizeof(USHORT) * 3);
|
---|
| 588 | type = *(USHORT *) data;
|
---|
| 589 | data += sizeof(USHORT);
|
---|
| 590 | len = *(USHORT *) data;
|
---|
| 591 | data += sizeof(USHORT);
|
---|
| 592 | while ((data - value) - len < pfea->cbValue) {
|
---|
| 593 | if (type == EAT_ASCII) {
|
---|
| 594 | dlen = plen = 0;
|
---|
| 595 | while (dlen < len) {
|
---|
| 596 | if (data[dlen] == '\r') {
|
---|
| 597 | dlen++;
|
---|
| 598 | if (dlen < len && data[dlen] != '\n')
|
---|
| 599 | p[plen++] = '\n';
|
---|
| 600 | }
|
---|
| 601 | else
|
---|
| 602 | p[plen++] = data[dlen++];
|
---|
| 603 | }
|
---|
| 604 | if ((!len || !plen || p[plen - 1] != '\n') &&
|
---|
| 605 | (data - value) + len < pfea->cbValue)
|
---|
| 606 | p[plen++] = '\n';
|
---|
| 607 | p += plen;
|
---|
| 608 | *p = 0;
|
---|
| 609 | }
|
---|
| 610 | else
|
---|
| 611 | readonly = TRUE;
|
---|
| 612 | data += len;
|
---|
| 613 | if (data - value >= pfea->cbValue)
|
---|
[41] | 614 | break;
|
---|
[551] | 615 | type = *(USHORT *) data;
|
---|
| 616 | data += sizeof(USHORT);
|
---|
| 617 | len = *(USHORT *) data;
|
---|
| 618 | data += sizeof(USHORT);
|
---|
| 619 | } // while
|
---|
[773] | 620 | if (p - pszBuf >= 65536) {
|
---|
[551] | 621 | Runtime_Error(pszSrcFile, __LINE__, pszBufOvfMsg);
|
---|
[773] | 622 | pszBuf[65535] = 0; // Try to stay alive
|
---|
[551] | 623 | break;
|
---|
| 624 | }
|
---|
[773] | 625 | WinSetWindowText(hwndAutoMLE, pszBuf);
|
---|
[1039] | 626 | free(pszBuf);
|
---|
[551] | 627 | }
|
---|
| 628 | }
|
---|
| 629 | else
|
---|
| 630 | readonly = TRUE;
|
---|
| 631 | }
|
---|
[1616] | 632 | // else EA not present
|
---|
[551] | 633 | MLEsetchanged(hwndAutoMLE, FALSE);
|
---|
| 634 | MLEsetreadonly(hwndAutoMLE, readonly);
|
---|
| 635 | }
|
---|
| 636 | else {
|
---|
| 637 | MLEsetchanged(hwndAutoMLE, FALSE);
|
---|
| 638 | MLEsetreadonly(hwndAutoMLE, FALSE);
|
---|
| 639 | }
|
---|
[1039] | 640 | free(pfealist);
|
---|
[551] | 641 | }
|
---|
| 642 | }
|
---|
| 643 | }
|
---|
[2] | 644 | }
|
---|
[1039] | 645 | free((CHAR *)mp1);
|
---|
[1063] | 646 | # ifdef FORTIFY
|
---|
| 647 | Fortify_LeaveScope();
|
---|
| 648 | # endif
|
---|
[551] | 649 | }
|
---|
| 650 | return 0;
|
---|
[2] | 651 |
|
---|
[551] | 652 | case UM_CLOSE:
|
---|
| 653 | if (!PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID))
|
---|
| 654 | WinSendMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID);
|
---|
| 655 | WinDestroyWindow(hwnd);
|
---|
| 656 | return 0;
|
---|
[2] | 657 | }
|
---|
[551] | 658 | return WinDefWindowProc(hwnd, msg, mp1, mp2);
|
---|
[2] | 659 | }
|
---|
| 660 |
|
---|
[551] | 661 | static VOID MakeAutoWinThread(VOID * args)
|
---|
[341] | 662 | {
|
---|
[551] | 663 | HAB hab2;
|
---|
| 664 | HMQ hmq2;
|
---|
| 665 | HWND hwndParent = (HWND) args;
|
---|
| 666 | QMSG qmsg2;
|
---|
[2] | 667 |
|
---|
| 668 | hab2 = WinInitialize(0);
|
---|
[551] | 669 | if (hab2) {
|
---|
[1063] | 670 | # ifdef FORTIFY
|
---|
| 671 | Fortify_EnterScope();
|
---|
[1078] | 672 | # endif
|
---|
[551] | 673 | hmq2 = WinCreateMsgQueue(hab2, 128);
|
---|
| 674 | if (hmq2) {
|
---|
[2] | 675 | DosError(FERR_DISABLEHARDERR);
|
---|
| 676 | WinRegisterClass(hab2,
|
---|
[1498] | 677 | (CHAR *) WC_OBJECTWINDOW,
|
---|
[551] | 678 | AutoObjProc, 0, sizeof(PVOID));
|
---|
[2] | 679 | hwndAutoObj = WinCreateWindow(HWND_OBJECT,
|
---|
[1498] | 680 | (CHAR *) WC_OBJECTWINDOW,
|
---|
[551] | 681 | (PSZ) NULL,
|
---|
| 682 | 0,
|
---|
| 683 | 0L,
|
---|
| 684 | 0L,
|
---|
| 685 | 0L,
|
---|
| 686 | 0L, 0L, HWND_TOP, OBJ_FRAME, NULL, NULL);
|
---|
[377] | 687 | if (!hwndAutoObj) {
|
---|
[1395] | 688 | Win_Error(HWND_OBJECT, HWND_DESKTOP, pszSrcFile, __LINE__,
|
---|
| 689 | PCSZ_WINCREATEWINDOW);
|
---|
[551] | 690 | if (!PostMsg(hwndParent, UM_CLOSE, MPVOID, MPVOID))
|
---|
| 691 | WinSendMsg(hwndParent, UM_CLOSE, MPVOID, MPVOID);
|
---|
[377] | 692 | }
|
---|
| 693 | else {
|
---|
[551] | 694 | WinSetWindowULong(hwndAutoObj, QWL_USER, hwndParent);
|
---|
| 695 | priority_normal();
|
---|
| 696 | while (WinGetMsg(hab2, &qmsg2, (HWND) 0, 0, 0))
|
---|
| 697 | WinDispatchMsg(hab2, &qmsg2);
|
---|
| 698 | WinDestroyWindow(hwndAutoObj);
|
---|
| 699 | hwndAutoObj = (HWND) 0;
|
---|
[2] | 700 | }
|
---|
| 701 | WinDestroyMsgQueue(hmq2);
|
---|
| 702 | }
|
---|
[1032] | 703 | // else
|
---|
| 704 | WinTerminate(hab2);
|
---|
[1063] | 705 | # ifdef FORTIFY
|
---|
[1038] | 706 | Fortify_LeaveScope();
|
---|
[1078] | 707 | # endif
|
---|
[2] | 708 | }
|
---|
| 709 | }
|
---|
| 710 |
|
---|
[551] | 711 | MRESULT EXPENTRY AutoViewProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
[341] | 712 | {
|
---|
[551] | 713 | USHORT id = WinQueryWindowUShort(hwnd, QWS_ID);
|
---|
[2] | 714 |
|
---|
[551] | 715 | switch (msg) {
|
---|
| 716 | case WM_CREATE:
|
---|
| 717 | {
|
---|
| 718 | MRESULT mr;
|
---|
[2] | 719 |
|
---|
[551] | 720 | if (!hwndAutoObj) {
|
---|
[1335] | 721 | if (xbeginthread(MakeAutoWinThread,
|
---|
| 722 | 65536,
|
---|
| 723 | (PVOID)hwnd,
|
---|
| 724 | pszSrcFile,
|
---|
| 725 | __LINE__) == -1) {
|
---|
[551] | 726 | PostMsg(hwnd, UM_CLOSE, MPVOID, MPVOID);
|
---|
[341] | 727 | }
|
---|
[2] | 728 | }
|
---|
[551] | 729 | mr = PFNWPStatic(hwnd, msg, mp1, mp2);
|
---|
[1391] | 730 | //fixme to allow user to change presparams 1-10-09 GKY
|
---|
[551] | 731 | SetPresParams(hwnd,
|
---|
| 732 | &RGBGREY,
|
---|
[1391] | 733 | &RGBBLACK, &RGBGREY, FNT_4SYSTEMVIO);
|
---|
[551] | 734 | stopflag = 0;
|
---|
| 735 | return mr;
|
---|
| 736 | }
|
---|
[2] | 737 |
|
---|
[551] | 738 | case UM_SETUP:
|
---|
| 739 | MLEsetlimit(hwnd, 32768);
|
---|
| 740 | MLEsetformat(hwnd, MLFIE_NOTRANS);
|
---|
| 741 | MLEsetchanged(hwnd, FALSE);
|
---|
| 742 | return 0;
|
---|
[2] | 743 |
|
---|
[551] | 744 | case WM_BUTTON1DOWN:
|
---|
| 745 | {
|
---|
| 746 | SWP swp;
|
---|
[2] | 747 |
|
---|
[551] | 748 | WinQueryWindowPos(hwnd, &swp);
|
---|
| 749 | if (SHORT2FROMMP(mp1) > swp.cy - 4) {
|
---|
[2] | 750 |
|
---|
[551] | 751 | HPS hps = WinGetPS(WinQueryWindow(hwnd, QW_PARENT));
|
---|
| 752 | SWP swpC;
|
---|
| 753 | TRACKINFO track;
|
---|
[2] | 754 |
|
---|
[551] | 755 | if (hps) {
|
---|
| 756 | WinQueryWindowPos(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
|
---|
| 757 | FID_CLIENT), &swpC);
|
---|
| 758 | track.cxBorder = 4;
|
---|
| 759 | track.cyBorder = 4;
|
---|
| 760 | track.cxGrid = 1;
|
---|
| 761 | track.cyGrid = 8;
|
---|
| 762 | track.cxKeyboard = 8;
|
---|
| 763 | track.rclTrack.yBottom = swp.y;
|
---|
| 764 | track.rclTrack.yTop = swp.y + swp.cy;
|
---|
| 765 | track.rclTrack.xLeft = swp.x;
|
---|
| 766 | track.rclTrack.xRight = swp.x + swp.cx;
|
---|
| 767 | track.rclBoundary = track.rclTrack;
|
---|
| 768 | track.rclBoundary.yTop = (swpC.cy + swp.y + swp.cy) - 116;
|
---|
| 769 | track.ptlMinTrackSize.x = swp.x + swp.cx;
|
---|
| 770 | track.ptlMinTrackSize.y = 36;
|
---|
| 771 | track.ptlMaxTrackSize.x = swp.x + swp.cx;
|
---|
| 772 | track.ptlMaxTrackSize.y = (swpC.cy + swp.cy) - 116;
|
---|
| 773 | track.fs = TF_TOP;
|
---|
| 774 | if (WinTrackRect(hwnd, hps, &track)) {
|
---|
| 775 | AutoviewHeight = track.rclTrack.yTop - track.rclTrack.yBottom;
|
---|
[1482] | 776 | PrfWriteProfileData(fmprof, appname, "AutoviewHeight",
|
---|
[551] | 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)
|
---|