1 |
|
---|
2 | /***********************************************************************
|
---|
3 |
|
---|
4 | $Id: autoview.c 1498 2010-01-18 00:57:01Z gyoung $
|
---|
5 |
|
---|
6 | Auto view
|
---|
7 |
|
---|
8 | Copyright (c) 1993-98 M. Kimes
|
---|
9 | Copyright (c) 2001, 2010 Steven H.Levine
|
---|
10 |
|
---|
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
|
---|
15 | 29 May 06 SHL Sync with archiver.bb2 mods
|
---|
16 | 22 Jul 06 SHL Check more run time errors
|
---|
17 | 15 Aug 06 SHL Use Runtime_Error more
|
---|
18 | 03 Nov 06 SHL Renames
|
---|
19 | 30 Mar 07 GKY Remove GetPString for window class names
|
---|
20 | 20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat
|
---|
21 | 01 Sep 07 GKY Use xDosSetPathInfo to fix case where FS3 buffer crosses 64k boundry
|
---|
22 | 27 Sep 07 SHL Correct ULONGLONG size formatting
|
---|
23 | 22 Nov 07 GKY Use CopyPresParams to fix presparam inconsistencies in menus
|
---|
24 | 30 Dec 07 GKY Use CommaFmtULL
|
---|
25 | 29 Feb 08 GKY Use xfree where appropriate
|
---|
26 | 10 Dec 08 SHL Integrate exception handler support
|
---|
27 | 11 Jan 09 GKY Replace font names in the string file with global set at compile in init.c
|
---|
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
|
---|
30 | 08 Mar 09 GKY Renamed commafmt.h i18nutil.h
|
---|
31 | 12 Jul 09 GKY Add xDosQueryAppType and xDosAlloc... to allow FM/2 to load in high memory
|
---|
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
|
---|
37 | 17 JAN 10 GKY Changes to get working with Watcom 1.9 Beta (1/16/10). Mostly cast CHAR CONSTANT * as CHAR *.
|
---|
38 |
|
---|
39 | ***********************************************************************/
|
---|
40 |
|
---|
41 | #include <stdlib.h>
|
---|
42 | #include <string.h>
|
---|
43 | #include <ctype.h>
|
---|
44 | // #include <process.h> // _beginthread
|
---|
45 |
|
---|
46 | #define INCL_DOS
|
---|
47 | #define INCL_WIN
|
---|
48 | #define INCL_GPI
|
---|
49 | #define INCL_LONGLONG
|
---|
50 |
|
---|
51 | #include "fm3dll.h"
|
---|
52 | #include "fm3dll2.h" // #define's for UM_*, control id's, etc.
|
---|
53 | #include "killproc.h" // Data declaration(s)
|
---|
54 | #include "notebook.h" // Data declaration(s)
|
---|
55 | #include "avl.h" // Data declaration(s)
|
---|
56 | #include "inis.h" // Data declaration(s)
|
---|
57 | #include "init.h" // Data declaration(s)
|
---|
58 | #include "mainwnd.h" // Data declaration(s)
|
---|
59 | #include "fm3dlg.h"
|
---|
60 | #include "fm3str.h"
|
---|
61 | #include "mle.h"
|
---|
62 | #include "pathutil.h" // BldFullPathName
|
---|
63 | #include "errutil.h" // Dos_Error...
|
---|
64 | #include "strutil.h" // GetPString
|
---|
65 | #include "autoview.h"
|
---|
66 | #include "defview.h" // DefaultView
|
---|
67 | #include "valid.h" // IsBinary
|
---|
68 | #include "misc.h" // CheckMenu
|
---|
69 | #include "common.h" // CommonTextButton
|
---|
70 | #include "presparm.h" // CopyPresParams
|
---|
71 | #include "eas.h" // DisplayEAsProc
|
---|
72 | #include "chklist.h" // PopupMenu
|
---|
73 | #include "wrappers.h" // xDosSetPathInfo
|
---|
74 | #include "i18nutil.h" // CommaFmtULL
|
---|
75 | #include "fortify.h"
|
---|
76 | #include "excputil.h" // 06 May 08 SHL added
|
---|
77 |
|
---|
78 | static BOOL PutComments(HWND hwnd, CHAR * filename, CHAR * comments);
|
---|
79 | static BOOL WriteEA(HWND hwnd, CHAR * filename, PCSZ eaname, USHORT type,
|
---|
80 | CHAR * data);
|
---|
81 |
|
---|
82 | // Data definitions
|
---|
83 | #pragma data_seg(GLOBAL1)
|
---|
84 | HWND hwndAutoMLE;
|
---|
85 |
|
---|
86 | #pragma data_seg(GLOBAL2)
|
---|
87 | ULONG AutoviewHeight;
|
---|
88 |
|
---|
89 | #pragma data_seg(DATA1)
|
---|
90 | static PSZ pszSrcFile = __FILE__;
|
---|
91 |
|
---|
92 | static HWND AutoMenu;
|
---|
93 | static HWND hwndAutoObj;
|
---|
94 | static CHAR stopflag;
|
---|
95 | static CHAR currfile[CCHMAXPATH];
|
---|
96 |
|
---|
97 | BOOL WriteEA(HWND hwnd, CHAR * filename, PCSZ eaname, USHORT type,
|
---|
98 | CHAR * data)
|
---|
99 | {
|
---|
100 | /* save an ea to disk */
|
---|
101 |
|
---|
102 | FEA2LIST *pfealist = NULL;
|
---|
103 | EAOP2 eaop;
|
---|
104 | APIRET rc;
|
---|
105 | ULONG ealen;
|
---|
106 | USHORT len, *num, *plen, usCodepage;
|
---|
107 | CHAR *p, *eaval;
|
---|
108 | BOOL ret = FALSE;
|
---|
109 |
|
---|
110 | if (!filename || !eaname)
|
---|
111 | return ret;
|
---|
112 | usCodepage = (USHORT) WinQueryCp(WinQueryWindowULong(hwnd, QWL_HMQ));
|
---|
113 | len = (data) ? strlen(data) : 0;
|
---|
114 | ealen = sizeof(FEA2LIST) + 24L + strlen(eaname) + 1L + (ULONG) len + 4L;
|
---|
115 | switch (type) {
|
---|
116 | case EAT_EA:
|
---|
117 | case EAT_ASCII:
|
---|
118 | break;
|
---|
119 | case EAT_MVST:
|
---|
120 | if (data) {
|
---|
121 | ealen += sizeof(USHORT) * 5;
|
---|
122 | p = data;
|
---|
123 | while (*p) {
|
---|
124 | if (*p == '\n' && *(p + 1))
|
---|
125 | ealen += sizeof(USHORT);
|
---|
126 | p++;
|
---|
127 | }
|
---|
128 | }
|
---|
129 | break;
|
---|
130 | case EAT_MVMT:
|
---|
131 | if (data) {
|
---|
132 | ealen += sizeof(USHORT) * 5;
|
---|
133 | p = data;
|
---|
134 | while (*p) {
|
---|
135 | if (*p == '\n' && *(p + 1))
|
---|
136 | ealen += (sizeof(USHORT) * 2);
|
---|
137 | p++;
|
---|
138 | }
|
---|
139 | }
|
---|
140 | break;
|
---|
141 | default:
|
---|
142 | return ret;
|
---|
143 | }
|
---|
144 |
|
---|
145 | rc = xDosAllocMem((PPVOID) & pfealist, ealen, PAG_COMMIT | PAG_READ |
|
---|
146 | PAG_WRITE, pszSrcFile, __LINE__);
|
---|
147 | if (rc || !pfealist)
|
---|
148 | Dos_Error(MB_CANCEL, rc, hwnd, pszSrcFile, __LINE__,
|
---|
149 | GetPString(IDS_OUTOFMEMORY));
|
---|
150 | else {
|
---|
151 | memset(pfealist, 0, ealen);
|
---|
152 | pfealist->list[0].cbName = strlen(eaname);
|
---|
153 | memcpy(pfealist->list[0].szName, eaname, pfealist->list[0].cbName + 1);
|
---|
154 | eaval = pfealist->list[0].szName + pfealist->list[0].cbName + 1;
|
---|
155 | switch (type) {
|
---|
156 | case EAT_EA:
|
---|
157 | case EAT_ASCII:
|
---|
158 | if (data) {
|
---|
159 | *(USHORT *) eaval = (USHORT) type;
|
---|
160 | eaval += sizeof(USHORT);
|
---|
161 | *(USHORT *) eaval = (USHORT) len;
|
---|
162 | eaval += sizeof(USHORT);
|
---|
163 | memcpy(eaval, data, len);
|
---|
164 | eaval += len;
|
---|
165 | }
|
---|
166 | break;
|
---|
167 | case EAT_MVST:
|
---|
168 | if (data) {
|
---|
169 | *(USHORT *) eaval = (USHORT) EAT_MVST;
|
---|
170 | eaval += sizeof(USHORT);
|
---|
171 | *(USHORT *) eaval = usCodepage;
|
---|
172 | eaval += sizeof(USHORT);
|
---|
173 | num = (USHORT *) eaval;
|
---|
174 | *num = 0;
|
---|
175 | eaval += sizeof(USHORT);
|
---|
176 | *(USHORT *) eaval = (USHORT) EAT_ASCII;
|
---|
177 | eaval += sizeof(USHORT);
|
---|
178 | plen = (USHORT *) eaval;
|
---|
179 | *plen = 0;
|
---|
180 | eaval += sizeof(USHORT);
|
---|
181 | p = data;
|
---|
182 | while (*p) {
|
---|
183 | while (*p) {
|
---|
184 | if (*p == '\n') {
|
---|
185 | p++;
|
---|
186 | break;
|
---|
187 | }
|
---|
188 | *eaval++ = *p++;
|
---|
189 | (*plen)++;
|
---|
190 | }
|
---|
191 | if (*p || *plen)
|
---|
192 | (*num)++;
|
---|
193 | if (*p) {
|
---|
194 | plen = (USHORT *) eaval;
|
---|
195 | *plen = 0;
|
---|
196 | eaval += sizeof(USHORT);
|
---|
197 | }
|
---|
198 | }
|
---|
199 | }
|
---|
200 | break;
|
---|
201 | case EAT_MVMT:
|
---|
202 | if (data) {
|
---|
203 | *(USHORT *) eaval = (USHORT) EAT_MVMT;
|
---|
204 | eaval += sizeof(USHORT);
|
---|
205 | *(USHORT *) eaval = usCodepage;
|
---|
206 | eaval += sizeof(USHORT);
|
---|
207 | num = (USHORT *) eaval;
|
---|
208 | *num = 0;
|
---|
209 | eaval += sizeof(USHORT);
|
---|
210 | *(USHORT *) eaval = (USHORT) EAT_ASCII;
|
---|
211 | eaval += sizeof(USHORT);
|
---|
212 | plen = (USHORT *) eaval;
|
---|
213 | *plen = 0;
|
---|
214 | eaval += sizeof(USHORT);
|
---|
215 | p = data;
|
---|
216 | while (*p) {
|
---|
217 | while (*p) {
|
---|
218 | if (*p == '\n') {
|
---|
219 | p++;
|
---|
220 | break;
|
---|
221 | }
|
---|
222 | *eaval++ = *p++;
|
---|
223 | (*plen)++;
|
---|
224 | }
|
---|
225 | if (*p || *plen)
|
---|
226 | (*num)++;
|
---|
227 | if (*p) {
|
---|
228 | *(USHORT *) eaval = (USHORT) EAT_ASCII;
|
---|
229 | eaval += sizeof(USHORT);
|
---|
230 | plen = (USHORT *) eaval;
|
---|
231 | *plen = 0;
|
---|
232 | eaval += sizeof(USHORT);
|
---|
233 | }
|
---|
234 | }
|
---|
235 | }
|
---|
236 | break;
|
---|
237 | }
|
---|
238 | pfealist->list[0].cbValue = /*(ULONG)*/ (eaval -
|
---|
239 | (pfealist->list[0].szName +
|
---|
240 | pfealist->list[0].cbName + 1));
|
---|
241 | memset(&eaop, 0, sizeof(eaop));
|
---|
242 | eaop.fpFEA2List = pfealist;
|
---|
243 | pfealist->cbList = 13 + (ULONG) pfealist->list[0].cbName +
|
---|
244 | (ULONG) pfealist->list[0].cbValue;
|
---|
245 | rc = xDosSetPathInfo(filename, FIL_QUERYEASIZE,
|
---|
246 | &eaop, sizeof(eaop), DSPI_WRTTHRU);
|
---|
247 | DosFreeMem(pfealist);
|
---|
248 | if (!rc)
|
---|
249 | ret = TRUE;
|
---|
250 | }
|
---|
251 | return ret;
|
---|
252 | }
|
---|
253 |
|
---|
254 | BOOL PutComments(HWND hwnd, CHAR * filename, CHAR * comments)
|
---|
255 | {
|
---|
256 | register CHAR *p;
|
---|
257 |
|
---|
258 | if (comments) { /* check -- is it empty? */
|
---|
259 | p = comments;
|
---|
260 | while (*p && isspace(*p))
|
---|
261 | p++;
|
---|
262 | if (!*p)
|
---|
263 | comments = NULL;
|
---|
264 | }
|
---|
265 | return WriteEA(hwnd, filename, PCSZ_DOTCOMMENTS, EAT_MVMT, comments);
|
---|
266 | }
|
---|
267 |
|
---|
268 | static PSZ pszBufOvfMsg = "Buffer overflow";
|
---|
269 |
|
---|
270 | ULONG CreateHexDump(CHAR * pchInBuf, ULONG cbInBuf,
|
---|
271 | CHAR * pchOutBuf, ULONG cbOutBuf,
|
---|
272 | ULONG cOffset, BOOL fLongAddr)
|
---|
273 | {
|
---|
274 | register CHAR *pchIn, *pchReset, *pchOut;
|
---|
275 | register ULONG ibIn = 0, ibIn2, ibInFill;
|
---|
276 | ULONG cbOutLine = 6 + (fLongAddr ? 4 : 0) + 16 * 3 + 1 + 16 + 1;
|
---|
277 |
|
---|
278 | if (pchInBuf && cbInBuf && pchOutBuf && cbOutBuf) {
|
---|
279 | pchIn = pchInBuf;
|
---|
280 | pchOut = pchOutBuf;
|
---|
281 | if (cOffset)
|
---|
282 | *pchOut++ = '\n';
|
---|
283 | while (ibIn < cbInBuf) {
|
---|
284 | if (pchOut - pchOutBuf + cbOutLine >= cbOutBuf) {
|
---|
285 | Runtime_Error(pszSrcFile, __LINE__, pszBufOvfMsg);
|
---|
286 | break;
|
---|
287 | }
|
---|
288 | pchReset = pchIn;
|
---|
289 | ibIn2 = ibIn;
|
---|
290 | if (fLongAddr)
|
---|
291 | sprintf(pchOut, "%08lx ", ibIn + cOffset);
|
---|
292 | else
|
---|
293 | sprintf(pchOut, "%04lx ", ibIn + cOffset);
|
---|
294 | pchOut += 6 + (fLongAddr ? 4 : 0);
|
---|
295 | do {
|
---|
296 | sprintf(pchOut, "%02x ", (UCHAR)*pchIn);
|
---|
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 | }
|
---|
309 | }
|
---|
310 | *pchOut++ = ' ';
|
---|
311 | pchIn = pchReset;
|
---|
312 | do {
|
---|
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
|
---|
325 | *pchOut = 0;
|
---|
326 | return (ULONG) (pchOut - pchOutBuf);
|
---|
327 | }
|
---|
328 | return 0L;
|
---|
329 | }
|
---|
330 |
|
---|
331 | MRESULT EXPENTRY AutoObjProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
332 | {
|
---|
333 | switch (msg) {
|
---|
334 | case UM_LOADFILE:
|
---|
335 | *currfile = 0;
|
---|
336 | stopflag--;
|
---|
337 | if (fAutoView) {
|
---|
338 | WinSetWindowText((fComments) ? hwndAutoMLE : hwndAutoview, NullStr);
|
---|
339 | MLEsetreadonly(hwndAutoMLE, TRUE);
|
---|
340 | MLEsetchanged(hwndAutoMLE, FALSE);
|
---|
341 | }
|
---|
342 | if (mp1) {
|
---|
343 | if (fAutoView) {
|
---|
344 | strcpy(currfile, (CHAR *)mp1);
|
---|
345 | if (!fComments) {
|
---|
346 | if (IsFile((CHAR *)mp1) == 1) {
|
---|
347 |
|
---|
348 | HFILE handle;
|
---|
349 | ULONG olen, ibufflen, action, obufflen, l;
|
---|
350 | CHAR *ibuff, *obuff, *p;
|
---|
351 | CHAR buffer[4096];
|
---|
352 | ARC_TYPE *info;
|
---|
353 |
|
---|
354 | if (!DosOpen((CHAR *)mp1,
|
---|
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)) {
|
---|
363 | ibufflen = AutoviewHeight < 96 ? 512 : 3072;
|
---|
364 | // 06 Oct 07 SHL protect against NTFS driver small buffer defect
|
---|
365 | ibuff = xmalloc(max(ibufflen + 2, 4096), pszSrcFile, __LINE__);
|
---|
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;
|
---|
372 | if (!DosRead(handle, ibuff, ibufflen, &ibufflen) &&
|
---|
373 | ibufflen)
|
---|
374 | {
|
---|
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",
|
---|
403 | info->id ? info->id : NullStr,
|
---|
404 | info->id ? " " : NullStr,
|
---|
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;
|
---|
419 |
|
---|
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 | }
|
---|
454 | free(obuff);
|
---|
455 | }
|
---|
456 | free(ibuff);
|
---|
457 | }
|
---|
458 | DosClose(handle);
|
---|
459 | }
|
---|
460 | }
|
---|
461 | else if (!IsFile(currfile)) {
|
---|
462 |
|
---|
463 | static FILEFINDBUF4L ffb[130];
|
---|
464 | CHAR fullname[CCHMAXPATH + 4], szCmmaFmtFileSize[81], szDate[DATE_BUF_BYTES];
|
---|
465 | HDIR hdir = HDIR_CREATE;
|
---|
466 | ULONG x, nm, ml, mc, bufflen;
|
---|
467 | PBYTE fb;
|
---|
468 | PFILEFINDBUF4L pffbFile;
|
---|
469 | PSZ pszBuf;
|
---|
470 | PSZ p;
|
---|
471 | APIRET rc;
|
---|
472 |
|
---|
473 | BldFullPathName(fullname, currfile, "*");
|
---|
474 | DosError(FERR_DISABLEHARDERR);
|
---|
475 | nm = sizeof(ffb) / sizeof(FILEFINDBUF4L);
|
---|
476 | if (AutoviewHeight < 96)
|
---|
477 | nm /= 2;
|
---|
478 | rc = xDosFindFirst(fullname,
|
---|
479 | &hdir,
|
---|
480 | FILE_NORMAL | FILE_DIRECTORY |
|
---|
481 | FILE_READONLY | FILE_ARCHIVED |
|
---|
482 | FILE_SYSTEM | FILE_HIDDEN,
|
---|
483 | &ffb, sizeof(ffb), &nm, FIL_QUERYEASIZEL);
|
---|
484 | if (!rc && nm) {
|
---|
485 | fb = (PBYTE) & ffb;
|
---|
486 | x = ml = 0;
|
---|
487 | while (x < nm) {
|
---|
488 | pffbFile = (PFILEFINDBUF4L) fb;
|
---|
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;
|
---|
498 | pszBuf = xmalloc(bufflen, pszSrcFile, __LINE__);
|
---|
499 | if (pszBuf) {
|
---|
500 | p = pszBuf;
|
---|
501 | *p = 0;
|
---|
502 | fb = (PBYTE) & ffb;
|
---|
503 | x = 0;
|
---|
504 | while (x < nm) {
|
---|
505 | pffbFile = (PFILEFINDBUF4L) fb;
|
---|
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]))))) {
|
---|
512 | CommaFmtULL(szCmmaFmtFileSize,
|
---|
513 | sizeof(szCmmaFmtFileSize),
|
---|
514 | pffbFile->cbFile + CBLIST_TO_EASIZE(pffbFile->cbList),
|
---|
515 | ' ');
|
---|
516 | FDateFormat(szDate, pffbFile->fdateLastWrite);
|
---|
517 | sprintf(p,
|
---|
518 | "%s%-*.*s %-8s [%s%s%s%s] %s "
|
---|
519 | "%02lu%s%02lu%s%02lu\r",
|
---|
520 | pffbFile->attrFile & FILE_DIRECTORY ? PCSZ_BACKSLASH : " ",
|
---|
521 | ml,
|
---|
522 | ml,
|
---|
523 | pffbFile->achName,
|
---|
524 | szCmmaFmtFileSize,
|
---|
525 | pffbFile->attrFile & FILE_READONLY ? "R" : "-",
|
---|
526 | pffbFile->attrFile & FILE_ARCHIVED ? "A" : "-",
|
---|
527 | pffbFile->attrFile & FILE_HIDDEN ? "H" : "-",
|
---|
528 | pffbFile->attrFile & FILE_SYSTEM ? "S" : "-",
|
---|
529 | szDate,
|
---|
530 | pffbFile->ftimeLastWrite.hours, TimeSeparator,
|
---|
531 | pffbFile->ftimeLastWrite.minutes, TimeSeparator,
|
---|
532 | pffbFile->ftimeLastWrite.twosecs * 2);
|
---|
533 | p += strlen(p);
|
---|
534 | }
|
---|
535 | if (!pffbFile->oNextEntryOffset)
|
---|
536 | break;
|
---|
537 | fb += pffbFile->oNextEntryOffset;
|
---|
538 | x++;
|
---|
539 | } // while
|
---|
540 | if (p - pszBuf >= bufflen)
|
---|
541 | Runtime_Error(pszSrcFile, __LINE__, pszBufOvfMsg);
|
---|
542 | if (*pszBuf)
|
---|
543 | WinSetWindowText(hwndAutoview, pszBuf);
|
---|
544 | free(pszBuf);
|
---|
545 | }
|
---|
546 | }
|
---|
547 | if (!rc)
|
---|
548 | DosFindClose(hdir);
|
---|
549 | }
|
---|
550 | }
|
---|
551 | else {
|
---|
552 |
|
---|
553 | APIRET rc;
|
---|
554 | EAOP2 eaop;
|
---|
555 | PGEA2LIST pgealist;
|
---|
556 | PFEA2LIST pfealist;
|
---|
557 | PGEA2 pgea;
|
---|
558 | PFEA2 pfea;
|
---|
559 | CHAR *value, *pszBuf, *p, *data;
|
---|
560 | USHORT len, type, plen, dlen;
|
---|
561 | BOOL readonly = FALSE;
|
---|
562 |
|
---|
563 | pgealist = xmallocz(sizeof(GEA2LIST) + 64, pszSrcFile, __LINE__);
|
---|
564 | if (pgealist) {
|
---|
565 | pgea = &pgealist->list[0];
|
---|
566 | strcpy(pgea->szName, PCSZ_DOTCOMMENTS);
|
---|
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;
|
---|
576 | rc = DosQueryPathInfo((CHAR *)mp1, FIL_QUERYEASFROMLIST,
|
---|
577 | (PVOID) & eaop, (ULONG) sizeof(EAOP2));
|
---|
578 | free(pgealist);
|
---|
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) {
|
---|
585 | pszBuf = xmalloc(65536, pszSrcFile, __LINE__);
|
---|
586 | if (pszBuf) {
|
---|
587 | p = pszBuf;
|
---|
588 | *pszBuf = 0;
|
---|
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)
|
---|
616 | break;
|
---|
617 | type = *(USHORT *) data;
|
---|
618 | data += sizeof(USHORT);
|
---|
619 | len = *(USHORT *) data;
|
---|
620 | data += sizeof(USHORT);
|
---|
621 | } // while
|
---|
622 | if (p - pszBuf >= 65536) {
|
---|
623 | Runtime_Error(pszSrcFile, __LINE__, pszBufOvfMsg);
|
---|
624 | pszBuf[65535] = 0; // Try to stay alive
|
---|
625 | break;
|
---|
626 | }
|
---|
627 | WinSetWindowText(hwndAutoMLE, pszBuf);
|
---|
628 | free(pszBuf);
|
---|
629 | }
|
---|
630 | }
|
---|
631 | else
|
---|
632 | readonly = TRUE;
|
---|
633 | }
|
---|
634 | /* else EA not present */
|
---|
635 | MLEsetchanged(hwndAutoMLE, FALSE);
|
---|
636 | MLEsetreadonly(hwndAutoMLE, readonly);
|
---|
637 | }
|
---|
638 | else {
|
---|
639 | MLEsetchanged(hwndAutoMLE, FALSE);
|
---|
640 | MLEsetreadonly(hwndAutoMLE, FALSE);
|
---|
641 | }
|
---|
642 | free(pfealist);
|
---|
643 | }
|
---|
644 | }
|
---|
645 | }
|
---|
646 | }
|
---|
647 | free((CHAR *)mp1);
|
---|
648 | # ifdef FORTIFY
|
---|
649 | Fortify_LeaveScope();
|
---|
650 | # endif
|
---|
651 | }
|
---|
652 | return 0;
|
---|
653 |
|
---|
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;
|
---|
659 | }
|
---|
660 | return WinDefWindowProc(hwnd, msg, mp1, mp2);
|
---|
661 | }
|
---|
662 |
|
---|
663 | static VOID MakeAutoWinThread(VOID * args)
|
---|
664 | {
|
---|
665 | HAB hab2;
|
---|
666 | HMQ hmq2;
|
---|
667 | HWND hwndParent = (HWND) args;
|
---|
668 | QMSG qmsg2;
|
---|
669 |
|
---|
670 | hab2 = WinInitialize(0);
|
---|
671 | if (hab2) {
|
---|
672 | # ifdef FORTIFY
|
---|
673 | Fortify_EnterScope();
|
---|
674 | # endif
|
---|
675 | hmq2 = WinCreateMsgQueue(hab2, 128);
|
---|
676 | if (hmq2) {
|
---|
677 | DosError(FERR_DISABLEHARDERR);
|
---|
678 | WinRegisterClass(hab2,
|
---|
679 | (CHAR *) WC_OBJECTWINDOW,
|
---|
680 | AutoObjProc, 0, sizeof(PVOID));
|
---|
681 | hwndAutoObj = WinCreateWindow(HWND_OBJECT,
|
---|
682 | (CHAR *) WC_OBJECTWINDOW,
|
---|
683 | (PSZ) NULL,
|
---|
684 | 0,
|
---|
685 | 0L,
|
---|
686 | 0L,
|
---|
687 | 0L,
|
---|
688 | 0L, 0L, HWND_TOP, OBJ_FRAME, NULL, NULL);
|
---|
689 | if (!hwndAutoObj) {
|
---|
690 | Win_Error(HWND_OBJECT, HWND_DESKTOP, pszSrcFile, __LINE__,
|
---|
691 | PCSZ_WINCREATEWINDOW);
|
---|
692 | if (!PostMsg(hwndParent, UM_CLOSE, MPVOID, MPVOID))
|
---|
693 | WinSendMsg(hwndParent, UM_CLOSE, MPVOID, MPVOID);
|
---|
694 | }
|
---|
695 | else {
|
---|
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;
|
---|
702 | }
|
---|
703 | WinDestroyMsgQueue(hmq2);
|
---|
704 | }
|
---|
705 | // else
|
---|
706 | WinTerminate(hab2);
|
---|
707 | # ifdef FORTIFY
|
---|
708 | Fortify_LeaveScope();
|
---|
709 | # endif
|
---|
710 | }
|
---|
711 | }
|
---|
712 |
|
---|
713 | MRESULT EXPENTRY AutoViewProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
714 | {
|
---|
715 | USHORT id = WinQueryWindowUShort(hwnd, QWS_ID);
|
---|
716 |
|
---|
717 | switch (msg) {
|
---|
718 | case WM_CREATE:
|
---|
719 | {
|
---|
720 | MRESULT mr;
|
---|
721 |
|
---|
722 | if (!hwndAutoObj) {
|
---|
723 | if (xbeginthread(MakeAutoWinThread,
|
---|
724 | 65536,
|
---|
725 | (PVOID)hwnd,
|
---|
726 | pszSrcFile,
|
---|
727 | __LINE__) == -1) {
|
---|
728 | PostMsg(hwnd, UM_CLOSE, MPVOID, MPVOID);
|
---|
729 | }
|
---|
730 | }
|
---|
731 | mr = PFNWPStatic(hwnd, msg, mp1, mp2);
|
---|
732 | //fixme to allow user to change presparams 1-10-09 GKY
|
---|
733 | SetPresParams(hwnd,
|
---|
734 | &RGBGREY,
|
---|
735 | &RGBBLACK, &RGBGREY, FNT_4SYSTEMVIO);
|
---|
736 | stopflag = 0;
|
---|
737 | return mr;
|
---|
738 | }
|
---|
739 |
|
---|
740 | case UM_SETUP:
|
---|
741 | MLEsetlimit(hwnd, 32768);
|
---|
742 | MLEsetformat(hwnd, MLFIE_NOTRANS);
|
---|
743 | MLEsetchanged(hwnd, FALSE);
|
---|
744 | return 0;
|
---|
745 |
|
---|
746 | case WM_BUTTON1DOWN:
|
---|
747 | {
|
---|
748 | SWP swp;
|
---|
749 |
|
---|
750 | WinQueryWindowPos(hwnd, &swp);
|
---|
751 | if (SHORT2FROMMP(mp1) > swp.cy - 4) {
|
---|
752 |
|
---|
753 | HPS hps = WinGetPS(WinQueryWindow(hwnd, QW_PARENT));
|
---|
754 | SWP swpC;
|
---|
755 | TRACKINFO track;
|
---|
756 |
|
---|
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;
|
---|
778 | PrfWriteProfileData(fmprof, appname, "AutoviewHeight",
|
---|
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;
|
---|
786 | }
|
---|
787 | else if (id != MAIN_AUTOVIEWMLE)
|
---|
788 | return CommonTextButton(hwnd, msg, mp1, mp2);
|
---|
789 | }
|
---|
790 | break;
|
---|
791 |
|
---|
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;
|
---|
798 |
|
---|
799 | case WM_MOUSEMOVE:
|
---|
800 | shiftstate = (SHORT2FROMMP(mp2) & (KC_ALT | KC_SHIFT | KC_CTRL));
|
---|
801 | {
|
---|
802 | SWP swp;
|
---|
803 |
|
---|
804 | WinQueryWindowPos(hwnd, &swp);
|
---|
805 | if (SHORT2FROMMP(mp1) > swp.cy - 4) {
|
---|
806 | WinSetPointer(HWND_DESKTOP, hptrNS);
|
---|
807 | return (MRESULT) TRUE;
|
---|
808 | }
|
---|
809 | }
|
---|
810 | break;
|
---|
811 |
|
---|
812 | case WM_PAINT:
|
---|
813 | PostMsg(hwnd, UM_PAINT, MPVOID, MPVOID);
|
---|
814 | break;
|
---|
815 |
|
---|
816 | case UM_PAINT:
|
---|
817 | PaintRecessedWindow(hwnd, (HPS) 0, TRUE, TRUE);
|
---|
818 | return 0;
|
---|
819 |
|
---|
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);
|
---|
833 | free(ea);
|
---|
834 | # ifdef FORTIFY
|
---|
835 | Fortify_LeaveScope();
|
---|
836 | # endif
|
---|
837 | }
|
---|
838 | }
|
---|
839 | }
|
---|
840 | }
|
---|
841 | break;
|
---|
842 | default:
|
---|
843 | if (mp2)
|
---|
844 | PostMsg(hwnd, UM_FOCUSME, mp1, mp2);
|
---|
845 | break;
|
---|
846 | }
|
---|
847 | break;
|
---|
848 |
|
---|
849 | case UM_FOCUSME:
|
---|
850 | if (mp2) {
|
---|
851 |
|
---|
852 | PID pid;
|
---|
853 | TID tid;
|
---|
854 |
|
---|
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;
|
---|
861 |
|
---|
862 | case UM_CLICKED:
|
---|
863 | case UM_CLICKED3:
|
---|
864 | if (id != MAIN_AUTOVIEWMLE) {
|
---|
865 | PostMsg(hwnd,
|
---|
866 | WM_COMMAND,
|
---|
867 | MPFROM2SHORT(((msg == UM_CLICKED3) ?
|
---|
868 | IDM_EAS : IDM_VIEWORARC), 0), MPVOID);
|
---|
869 | }
|
---|
870 | return 0;
|
---|
871 |
|
---|
872 | case WM_COMMAND:
|
---|
873 | PostMsg(hwnd, UM_COMMAND, mp1, mp2);
|
---|
874 | return 0;
|
---|
875 |
|
---|
876 | case UM_COMMAND:
|
---|
877 | switch (SHORT1FROMMP(mp1)) {
|
---|
878 | case IDM_RESCAN:
|
---|
879 | if (*currfile) {
|
---|
880 |
|
---|
881 | CHAR *cf = xstrdup(currfile, pszSrcFile, __LINE__);
|
---|
882 |
|
---|
883 | if (cf) {
|
---|
884 | stopflag++;
|
---|
885 | if (!PostMsg(hwndAutoObj, UM_LOADFILE, MPFROMP(cf), MPVOID))
|
---|
886 | free(cf);
|
---|
887 | # ifdef FORTIFY
|
---|
888 | Fortify_LeaveScope();
|
---|
889 | # endif
|
---|
890 | }
|
---|
891 | }
|
---|
892 | break;
|
---|
893 |
|
---|
894 | case IDM_INFO:
|
---|
895 | DefaultView(hwnd, (HWND) 0, hwndMain, NULL, 16, currfile);
|
---|
896 | break;
|
---|
897 |
|
---|
898 | case IDM_VIEW:
|
---|
899 | DefaultView(hwnd, (HWND) 0, hwndMain, NULL, 0, currfile);
|
---|
900 | break;
|
---|
901 |
|
---|
902 | case IDM_EDIT:
|
---|
903 | DefaultView(hwnd, (HWND) 0, hwndMain, NULL, 8, currfile);
|
---|
904 | break;
|
---|
905 |
|
---|
906 | case IDM_EAS:
|
---|
907 | {
|
---|
908 | char *list[2];
|
---|
909 |
|
---|
910 | list[0] = currfile;
|
---|
911 | list[1] = NULL;
|
---|
912 |
|
---|
913 | WinDlgBox(HWND_DESKTOP,
|
---|
914 | hwndMain,
|
---|
915 | DisplayEAsProc, FM3ModHandle, EA_FRAME, (PVOID) list);
|
---|
916 | }
|
---|
917 | break;
|
---|
918 |
|
---|
919 | default:
|
---|
920 | PostMsg(hwndMain, msg, mp1, mp2);
|
---|
921 | }
|
---|
922 | return 0;
|
---|
923 |
|
---|
924 | case WM_MENUEND:
|
---|
925 | if ((HWND) mp2 == AutoMenu) {
|
---|
926 | WinDestroyWindow(AutoMenu);
|
---|
927 | AutoMenu = (HWND) 0;
|
---|
928 | }
|
---|
929 | break;
|
---|
930 |
|
---|
931 | case WM_CONTEXTMENU:
|
---|
932 | CheckMenu(hwnd, &AutoMenu, (id == MAIN_AUTOVIEWMLE) ?
|
---|
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;
|
---|
941 |
|
---|
942 | case UM_LOADFILE:
|
---|
943 | stopflag++;
|
---|
944 | if (!PostMsg(hwndAutoObj, msg, mp1, mp2)) {
|
---|
945 | xfree((CHAR *)mp1, pszSrcFile, __LINE__);
|
---|
946 | # ifdef FORTIFY
|
---|
947 | Fortify_LeaveScope();
|
---|
948 | # endif
|
---|
949 | }
|
---|
950 | return 0;
|
---|
951 |
|
---|
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);
|
---|
969 | break;
|
---|
970 | }
|
---|
971 | break;
|
---|
972 | }
|
---|
973 |
|
---|
974 | if (id == MAIN_AUTOVIEWMLE)
|
---|
975 | return PFNWPMLE(hwnd, msg, mp1, mp2);
|
---|
976 | return PFNWPStatic(hwnd, msg, mp1, mp2);
|
---|
977 | }
|
---|
978 |
|
---|
979 | #pragma alloc_text(AUTOVIEW,AutoViewProc,CreateHexDump,AutoObjProc)
|
---|
980 | #pragma alloc_text(AUTOVIEW2,MakeAutoWinThread,WriteEA,PutComments)
|
---|