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