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