source: trunk/dll/arccnrs.c@ 1203

Last change on this file since 1203 was 1203, checked in by John Small, 17 years ago

Ticket 187: Move datadevlarations/definitions out of fm3dll.h

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 101.8 KB
Line 
1
2/***********************************************************************
3
4 $Id: arccnrs.c 1203 2008-09-13 06:46:02Z jbs $
5
6 Archive containers
7
8 Copyright (c) 1993-98 M. Kimes
9 Copyright (c) 2001, 2008 Steven H. Levine
10
11 11 Jun 02 SHL Ensure archive name not garbage
12 22 May 03 SHL ArcObjWndProc: fix UM_RESCAN now that we understand it
13 01 Aug 04 SHL Rework lstrip/rstrip usage
14 23 May 05 SHL Use QWL_USER
15 25 May 05 SHL Rename comnam to szCommonName and fix typo
16 25 May 05 SHL Use ULONGLONG and CommaFmtULL
17 05 Jun 05 SHL Drop obsolete, localize
18 05 Jun 05 SHL Correct last sort logic
19 05 Jun 05 SHL Use QWL_USER
20 22 Jun 05 SHL ArcSort: correct typo in last sort fix
21 13 Aug 05 SHL FillArcCnr: optimize
22 08 Dec 05 SHL FillArcCnr: allow list start and end markers to be empty (i.e. tar)
23 08 Dec 05 SHL ArcCnrWndProc: suppress IDM_EXTRACT if no simple extract (i.e. tar)
24 30 Dec 05 SHL ArcCnrWndProc: correct date/time column display setup
25 29 May 06 SHL Comments
26 14 Jul 06 SHL Use Runtime_Error
27 26 Jul 06 SHL Correct SelectAll usage
28 29 Jul 06 SHL Use xfgets_bstripcr
29 31 Jul 06 SHL Lower priority for archives with more than 1000 entries
30 02 Aug 06 SHL Add logic to stop processing large archives
31 23 Aug 06 SHL Integrate John Small's switch list title logic
32 03 Nov 06 SHL Renames
33 14 Mar 07 SHL ArcObjWndProc/UM_ENTER: delay before starting viewer
34 30 Mar 07 GKY Remove GetPString for window class names
35 06 Apr 07 GKY Work around PM DragInfo and DrgFreeISH limit
36 06 Apr 07 GKY Add some error checking in drag/drop
37 20 Apr 07 SHL Sync with NumItemsToUnhilite mods
38 21 Apr 07 GKY Find FM2Utils by path or utils directory
39 12 May 07 SHL Use dcd->ulItemsToUnHilite; sync with UnHilite arg mods
40 10 Jun 07 GKY Add CheckPmDrgLimit including IsFm2Window as part of work around PM drag limit
41 16 Jun 07 SHL Use DosQueryAppType not DosQAppType
42 02 Aug 07 SHL Sync with ARCITEM mods
43 06 Aug 07 SHL Use BldFullPathName and BldQuotedFileName
44 06 Aug 07 SHL Move BldQuotedFileName and BldQuotedFullPathNamehere
45 to be near primary caller
46 06 Aug 07 GKY Reduce DosSleep times (ticket 148)
47 20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat
48 26 Aug 07 GKY DosSleep(1) in loops changed to (0)
49 22 Nov 07 GKY Use CopyPresParams to fix presparam inconsistencies in menus
50 30 Dec 07 GKY Use TestCDates for sort by date
51 10 Jan 08 SHL Sync with CfgDlgProc mods
52 10 Feb 08 GKY Implement bubble help for bitmap menu items
53 15 Feb 08 SHL Sync with settings menu rework
54 29 Feb 08 GKY Use xfree where appropriate
55 14 Jul 08 JBS Ticket 126: Add support for WPS open default & open settings in arccnrs
56 16 Jul 08 GKY Fix trap on viewing multiple files from an archive (misplaced free)
57 16 Jul 08 GKY Use TMP directory for temp files if present. Use MakeTempName
58 19 Jul 08 GKY Replace save_dir2(dir) with pFM2SaveDirectory
59 25 Aug 08 GKY Check TMP directory space warn if lee than 5 MiB prevent archiver from opening if
60 less than 10 KiB (It hangs and can't be closed)
61
62***********************************************************************/
63
64#include <stdlib.h> // free..
65#include <string.h>
66#include <ctype.h>
67#include <direct.h> // rmdir
68#include <share.h> // SH_DENYWR
69#include <limits.h> // ULONG_MAX
70#include <process.h> // _beginthread
71
72#if 0
73#include <malloc.h> // _heapchk
74#endif
75
76#define INCL_DOS
77#define INCL_DOSERRORS
78#define INCL_WIN
79#define INCL_LONGLONG
80
81#include "fm3dll.h"
82#include "mainwnd2.h" // Data declaration(s)
83#include "grep.h" // Data declaration(s)
84#include "dircnrs.h" // Data declaration(s)
85#include "info.h" // Data declaration(s)
86#include "init.h" // Data declaration(s)
87#include "arccnrs.h" // StartArcCnr
88#include "fm3dlg.h"
89#include "fm3str.h"
90#include "mle.h"
91#include "pathutil.h" // BldFullPathName
92#include "filldir.h" // EmptyCnr...
93#include "errutil.h" // Dos_Error...
94#include "strutil.h" // GetPString
95#include "notebook.h" // CfgDlgProc
96#include "worker.h" // Action, MassAction
97#include "avv.h" // ArcReviewDlgProc, rewrite_archiverbb2
98#include "chklist.h" // CenterOverWindow, CheckListProc
99#include "common.h" // CommonCreateTextChildren, CommonFrameWndProc, CommonTextPaint
100 // CommonTextButton
101#include "draglist.h" // DoFileDrag, DragOne
102#include "valid.h" // GetDesktopName, TestCDates
103#include "mainwnd.h" // GetNextWindowPos, MakeBubble, TopWindowName
104#include "objwin.h" // MakeObjWin
105#include "shadow.h" // MakeShadows
106#include "objcnr.h" // ObjCnrDlgProc
107#include "printer.h" // PrintListThread
108#include "srchpath.h" // RunFM2Util
109#include "misc.h" // Broadcast, CheckMenu, CurrentRecord, SayFilter, SaySort
110 // DrawTargetEmphasis, IsFm2Window
111#include "select.h" // SelectAll, SelectList
112#include "findrec.h" // ShowCnrRecord
113#include "walkem.h" // WalkExtractDlgProc
114#include "droplist.h" // AcceptOneDrop, CheckPmDrgLimit, DropHelp, GetOneDrop
115#include "archive.h" // ArchiveDlgProc
116#include "common.h" // CommonTextProc
117#include "presparm.h" // CopyPresParams
118#include "defview.h" // DefaultViewKeys
119#include "systemf.h" // ExecOnList
120#include "filter.h" // PickMaskDlgProc
121#include "avl.h" // SBoxDlgProc
122#include "mkdir.h" // SetDir
123#include "collect.h" // StartCollector
124#include "viewer.h" // StartMLEEditor
125#include "newview.h" // StartViewer
126#include "commafmt.h" // commafmt
127#include "copyf.h" // unlinkf
128#include "literal.h" // wildcard
129#include "wrappers.h" // xrealloc
130#include "misc.h" // AdjustCnrColVis, QuickPopup, SetSortChecks, SwitchCommand
131#include "select.h" // DeselectAll, InvertAll
132#include "strips.h" // bstrip
133#include "dirs.h" // save_dir2
134#include "fortify.h"
135
136#pragma data_seg(DATA1)
137static INT DefArcSortFlags;
138
139// Data definitions
140static PSZ pszSrcFile = __FILE__;
141#pragma data_seg(GLOBAL1)
142HWND ArcCnrMenu;
143HWND ArcMenu;
144CHAR ArcTempRoot[CCHMAXPATH];
145BOOL fArcStuffVisible;
146
147#pragma data_seg(GLOBAL2)
148CHAR lastextractpath[CCHMAXPATH];
149ULONGLONG ullDATFileSpaceNeeded;
150
151static MRESULT EXPENTRY ArcErrProc(HWND hwnd, ULONG msg, MPARAM mp1,
152 MPARAM mp2)
153{
154 ARCDUMP *ad;
155 CHAR szQuotedArcName[CCHMAXPATH];
156
157 switch (msg) {
158 case WM_INITDLG:
159 if (!mp2)
160 WinDismissDlg(hwnd, 0);
161 else {
162 ad = (ARCDUMP *) mp2;
163 WinSetWindowPtr(hwnd, QWL_USER, ad);
164 if (ad->errmsg)
165 WinSetDlgItemText(hwnd, ARCERR_TEXT, ad->errmsg);
166 if (!ad->info->test)
167 WinEnableWindow(WinWindowFromID(hwnd, ARCERR_TEST), FALSE);
168 if (ad->listname) {
169 MLEsetlimit(WinWindowFromID(hwnd, ARCERR_MLE), -1L);
170 MLEsetformat(WinWindowFromID(hwnd, ARCERR_MLE), MLFIE_NOTRANS);
171 MLEsetcurpos(WinWindowFromID(hwnd, ARCERR_MLE),
172 MLEgetlen(WinWindowFromID(hwnd, ARCERR_MLE)));
173 MLEinsert(WinWindowFromID(hwnd, ARCERR_MLE),
174 GetPString(IDS_ARCHIVERREPORTTEXT));
175 MLEinsertfile(WinWindowFromID(hwnd, ARCERR_MLE), ad->listname);
176 }
177 }
178 break;
179
180 case WM_COMMAND:
181 switch (SHORT1FROMMP(mp1)) {
182 case DID_CANCEL:
183 WinDismissDlg(hwnd, 0);
184 break;
185
186 case IDM_HELP:
187 if (hwndHelp) {
188 WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
189 MPFROM2SHORT(HELP_ARCERR, 0), MPFROMSHORT(HM_RESOURCEID));
190 }
191 break;
192
193 case DID_OK:
194 ad = WinQueryWindowPtr(hwnd, QWL_USER);
195 WinDlgBox(HWND_DESKTOP, hwnd, ArcReviewDlgProc, FM3ModHandle,
196 AD_FRAME, MPFROMP(ad));
197 WinDismissDlg(hwnd, 0);
198 break;
199
200 case ARCERR_VIEW:
201 ad = WinQueryWindowPtr(hwnd, QWL_USER);
202 {
203 CHAR *list[2];
204
205 list[0] = ad->arcname;
206 list[1] = NULL;
207 if (TestBinary(ad->arcname)) {
208 if (*binview)
209 ExecOnList((HWND) 0, binview, WINDOWED | SEPARATE, NULL, list,
210 NULL, pszSrcFile, __LINE__);
211 else
212 StartMLEEditor(HWND_DESKTOP, 16 + 4 + 1, ad->arcname, hwnd);
213 }
214 else {
215 if (*viewer) {
216 ExecOnList((HWND) 0, viewer, WINDOWED | SEPARATE |
217 (fViewChild ? CHILD : 0),
218 NULL, list, NULL, pszSrcFile, __LINE__);
219 }
220 else
221 StartMLEEditor(HWND_DESKTOP, 8 + 4 + 1, ad->arcname, hwnd);
222 }
223 }
224 break;
225
226 case ARCERR_TEST:
227 ad = WinQueryWindowPtr(hwnd, QWL_USER);
228 runemf2(SEPARATEKEEP | WINDOWED | MAXIMIZED,
229 hwnd, pszSrcFile, __LINE__, NULL, NULL,
230 "%s %s",
231 ad->info->test,
232 BldQuotedFileName(szQuotedArcName, ad->arcname));
233 break;
234 }
235 return 0;
236 }
237 return WinDefDlgProc(hwnd, msg, mp1, mp2);
238}
239
240static SHORT APIENTRY ArcSort(PMINIRECORDCORE pmrc1, PMINIRECORDCORE pmrc2,
241 PVOID pStorage)
242{
243 PARCITEM pai1 = (PARCITEM) pmrc1;
244 PARCITEM pai2 = (PARCITEM) pmrc2;
245 DIRCNRDATA *pdcd = (DIRCNRDATA *) pStorage;
246 SHORT ret = 0;
247 CHAR *pext, *ppext;
248 INT sortFlags;
249
250 if (!pdcd) {
251 HWND hwndCnr = pai1->hwndCnr;
252
253 pdcd = WinQueryWindowPtr(hwndCnr, QWL_USER);
254 if (!pdcd) {
255 Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
256 return ret;
257 }
258 }
259
260 sortFlags = pdcd->sortFlags; // Optimize
261
262 if (sortFlags) {
263 switch (sortFlags & (~SORT_REVERSE)) {
264 case SORT_FIRSTEXTENSION:
265 pext = strchr(pai1->pszFileName, '.');
266 ppext = strchr(pai2->pszFileName, '.');
267 if (!pext)
268 pext = NullStr;
269 if (!ppext)
270 ppext = NullStr;
271 ret = stricmp(pext, ppext);
272 break;
273
274 case SORT_LASTEXTENSION:
275 pext = strrchr(pai1->pszFileName, '.');
276 ppext = strrchr(pai2->pszFileName, '.');
277 if (!pext)
278 pext = NullStr;
279 if (!ppext)
280 ppext = NullStr;
281 ret = stricmp(pext, ppext);
282 break;
283
284 case SORT_LWDATE:
285 ret = TestCDates(&pai1->date, &pai1->time,
286 &pai2->date, &pai2->time);
287 /*(pai1->date.year < pai2->date.year) ? 1 :
288 (pai1->date.year > pai2->date.year) ? -1 :
289 (pai1->date.month < pai2->date.month) ? 1 :
290 (pai1->date.month > pai2->date.month) ? -1 :
291 (pai1->date.day < pai2->date.day) ? 1 :
292 (pai1->date.day > pai2->date.day) ? -1 :
293 (pai1->time.hours < pai2->time.hours) ? 1 :
294 (pai1->time.hours > pai2->time.hours) ? -1 :
295 (pai1->time.minutes < pai2->time.minutes) ? 1 :
296 (pai1->time.minutes > pai2->time.minutes) ? -1 :
297 (pai1->time.seconds < pai2->time.seconds) ? 1 :
298 (pai1->time.seconds > pai2->time.seconds) ? -1 : 0;*/
299 break;
300
301 case SORT_SIZE:
302 ret =
303 (pai1->cbFile < pai2->cbFile) ? 1 : (pai1->cbFile ==
304 pai2->cbFile) ? 0 : -1;
305 if (!ret)
306 ret =
307 (pai1->cbComp < pai2->cbComp) ? 1 : (pai1->cbComp ==
308 pai2->cbComp) ? 0 : -1;
309 break;
310
311 case SORT_EASIZE:
312 ret =
313 (pai1->cbComp < pai2->cbComp) ? 1 : (pai1->cbComp ==
314 pai2->cbComp) ? 0 : -1;
315 if (!ret)
316 ret =
317 (pai1->cbFile < pai2->cbFile) ? 1 : (pai1->cbFile ==
318 pai2->cbFile) ? 0 : -1;
319 break;
320 }
321 if (!ret)
322 ret = (SHORT) stricmp(pai1->pszFileName, pai2->pszFileName);
323 if (ret && (sortFlags & SORT_REVERSE))
324 ret = ret > 0 ? -1 : 1;
325 return ret;
326 }
327 return (SHORT) stricmp(pai1->pszFileName, pai2->pszFileName);
328}
329
330static INT APIENTRY ArcFilter(PMINIRECORDCORE rmini, PVOID arg)
331{
332 DIRCNRDATA *dcd = (DIRCNRDATA *) arg;
333 PARCITEM r;
334 register INT x;
335 INT ret = FALSE;
336
337 if (dcd && *dcd->mask.szMask) {
338 r = (PARCITEM) rmini;
339 if (dcd->mask.pszMasks[1]) {
340 for (x = 0; dcd->mask.pszMasks[x]; x++) {
341 if (*dcd->mask.pszMasks[x]) {
342 if (*dcd->mask.pszMasks[x] != '/') {
343 if (wildcard(r->pszFileName, dcd->mask.pszMasks[x], FALSE))
344 ret = TRUE;
345 }
346 else {
347 if (wildcard(r->pszFileName, dcd->mask.pszMasks[x] + 1, FALSE)) {
348 ret = FALSE;
349 break;
350 }
351 }
352 }
353 }
354 }
355 else {
356 if (wildcard(r->pszFileName, dcd->mask.szMask, FALSE))
357 ret = TRUE;
358 }
359 }
360 else
361 ret = TRUE;
362 return ret;
363}
364
365static MRESULT EXPENTRY ArcFrameWndProc(HWND hwnd, ULONG msg, MPARAM mp1,
366 MPARAM mp2)
367{
368 return CommonFrameWndProc(ARC_CNR, hwnd, msg, mp1, mp2);
369}
370
371static BOOL IsArcThere(HWND hwnd, CHAR * arcname)
372{
373 if (arcname) {
374 if (IsFile(arcname) != 1) {
375 saymsg(MB_CANCEL, hwnd,
376 GetPString(IDS_SAYWHATTEXT),
377 GetPString(IDS_ARCNOTTHERETEXT), arcname);
378 return FALSE;
379 }
380 return TRUE;
381 }
382 return FALSE;
383}
384
385/**
386 * Free storage associated with archive container item
387 * Caller is responsible for correcting pointers
388 */
389
390static VOID FreeArcItemData(PARCITEM pai)
391{
392 // DbgMsg(pszSrcFile, __LINE__, "FreeArcItemData %p", pai);
393 PSZ psz;
394
395 if (pai->pszFileName && pai->pszFileName != NullStr) {
396 psz = pai->pszFileName;
397 pai->pszFileName = NULL; // 08 Jul 08 SHL was NulStr
398 free(psz);
399 }
400}
401
402/**
403 * Remove item(s) from archive container and free associated storage if requested
404 * @param paiFirst points to first item to remove or NULL to remove all
405 * @param usCnt is remove count or 0 to remove all
406 */
407
408static VOID RemoveArcItems(HWND hwnd, PARCITEM paiFirst, USHORT usCnt, USHORT usFlags)
409{
410 INT remaining = usCnt;
411 PARCITEM pai;
412
413 if ((usCnt && !paiFirst) || (!usCnt && paiFirst))
414 Runtime_Error(pszSrcFile, __LINE__, "paiFirst %p usCnt %u mismatch", paiFirst, usCnt);
415 else {
416 // Free our buffers if free requested
417 if (usFlags & CMA_FREE) {
418 if (paiFirst)
419 pai = paiFirst;
420 else {
421 pai = (PARCITEM)WinSendMsg(hwnd, CM_QUERYRECORD, MPVOID,
422 MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
423 if ((INT)pai == -1) {
424 Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__,"CM_QUERYRECORD");
425 remaining = -1;
426 pai = NULL;
427 }
428 }
429 while (pai) {
430 FreeArcItemData(pai);
431 pai = (PARCITEM)pai->rc.preccNextRecord;
432 if (remaining && --remaining == 0)
433 break;
434 }
435 }
436 }
437
438 // DbgMsg(pszSrcFile, __LINE__, "RemoveArcItems %p %u %s", pai, usCnt, pai->pszFileName);
439
440 if (remaining != - 1) {
441 remaining = (INT)WinSendMsg(hwnd, CM_REMOVERECORD, MPFROMP(&paiFirst), MPFROM2SHORT(usCnt, usFlags));
442 if (remaining == -1) {
443 // Win_Error2(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__,IDS_CMREMOVEERRTEXT);
444 Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__,"CM_REMOVERECORD hwnd %x pai %p cnt %u", hwnd, paiFirst, usCnt);
445 }
446 }
447}
448
449/**
450 * Empty all records from an archive container and
451 * free associated storage and free up field infos
452 */
453
454static VOID EmptyArcCnr(HWND hwnd)
455{
456#if 0 // fixme to be gone or to be configurable
457 {
458 int state = _heapchk();
459 if (state != _HEAPOK)
460 Runtime_Error(pszSrcFile, __LINE__, "heap corrupted %d", state);
461 else
462 DbgMsg(pszSrcFile, __LINE__, "_memavl %u", _memavl());
463 }
464#endif
465
466 // Remove all ARCITEM records
467 RemoveArcItems(hwnd, NULL, 0, CMA_FREE);
468
469 // Use common code to remove rest
470 EmptyCnr(hwnd);
471}
472
473//== FillArcCnr() generate archive content list and fill container window ==
474
475static INT FillArcCnr(HWND hwndCnr, CHAR * arcname, ARC_TYPE ** arcinfo,
476 ULONGLONG * pullTotalBytes, volatile PCHAR pStopFlag)
477{
478 FILE *fp;
479 HFILE oldstdout;
480 HFILE newstdout;
481 CHAR s[CCHMAXPATH * 2], lonename[CCHMAXPATH + 2],
482 *nsize, *osize, *fdate, *fname, *p, *pp, *arctemp;
483 BOOL gotstart;
484 BOOL gotend;
485 BOOL wasquote;
486 BOOL nomove = FALSE; // fixme to be gone?
487 INT highest = 0, x, counter = 0, numarcfiles = 0;
488 PARCITEM lastpai;
489 ARC_TYPE *info;
490 ARC_TYPE *tinfo;
491 ULONG apptype;
492 APIRET rc;
493
494 if (!arcname || !arcinfo)
495 return 0;
496
497 info = *arcinfo;
498 if (!info)
499 info = find_type(arcname, NULL);
500 arctemp = xmallocz(CCHMAXPATH, pszSrcFile, __LINE__);
501 if (CheckDriveSpaceAvail(ArcTempRoot, ullDATFileSpaceNeeded, ullTmpSpaceNeeded) == 1)
502 saymsg(MB_OK,
503 HWND_DESKTOP,
504 NullStr,
505 GetPString(IDS_ARCTMPDRIVESPACELIMITED),
506 ArcTempRoot);
507 MakeTempName(arctemp, ArcTempRoot, 2);
508
509
510ReTry:
511
512#ifdef DEBUG
513 if (info && info->id)
514 WinSetWindowText(WinQueryWindow
515 (WinQueryWindow(hwndCnr, QW_PARENT), QW_PARENT),
516 info->id);
517#endif
518
519 tinfo = NULL;
520 numarcfiles = counter = highest = 0;
521 gotstart = gotend = FALSE;
522 lastpai = NULL;
523 *pullTotalBytes = 0;
524 if (!info || !info->list)
525 Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
526 else {
527 RemoveArcItems(hwndCnr, NULL, 0, CMA_FREE | CMA_INVALIDATE | CMA_ERASE);
528 *arcinfo = info;
529 highest = info->osizepos;
530 if (info->nsizepos > highest)
531 highest = info->nsizepos;
532 if (info->fdpos > highest)
533 highest = info->fdpos;
534 if (info->fnpos > highest)
535 highest = info->fnpos;
536 if (highest > 50) {
537 saymsg(MB_ENTER | MB_ICONEXCLAMATION, HWND_DESKTOP,
538 GetPString(IDS_SHAMETEXT), "%s", GetPString(IDS_BUNGEDUPTEXT));
539 }
540 if (info->fnpos == -1)
541 highest = 32767;
542
543 DosError(FERR_DISABLEHARDERR);
544 DosForceDelete(arctemp);
545 DosError(FERR_DISABLEHARDERR);
546
547 strcpy(s, info->list);
548 p = strchr(s, ' ');
549 if (p)
550 *p = 0;
551 DosError(FERR_DISABLEHARDERR);
552 if (!DosQueryAppType(s, &apptype) &&
553 (apptype & FAPPTYP_DOS ||
554 apptype & FAPPTYP_WINDOWSREAL ||
555 apptype & FAPPTYP_WINDOWSPROT ||
556 apptype & FAPPTYP_WINDOWSPROT31)) {
557 p = GetCmdSpec(TRUE);
558 runemf2(SEPARATE | INVISIBLE | MINIMIZED | BACKGROUND | WAIT,
559 hwndCnr, pszSrcFile, __LINE__, NULL, "DOS_BACKGROUND_EXECUTION=1",
560 "%s /C %s %s >%s",
561 p, // shell
562 info->list, // list command
563 BldQuotedFileName(s, arcname),
564 arctemp);
565 }
566 else {
567 fp = xfopen(arctemp, "w", pszSrcFile, __LINE__);
568 if (!fp) {
569 xfree(arctemp, pszSrcFile, __LINE__);
570 return 0;
571 }
572 else {
573 newstdout = -1;
574 DosError(FERR_DISABLEHARDERR);
575 rc = DosDupHandle(fileno(stdout), &newstdout);
576 if (rc) {
577 Dos_Error(MB_CANCEL, rc, hwndCnr, pszSrcFile, __LINE__,
578 "DosDupHandle");
579 xfree(arctemp, pszSrcFile, __LINE__);
580 return 0;
581 }
582 else {
583 oldstdout = fileno(stdout);
584 DosError(FERR_DISABLEHARDERR);
585 rc = DosDupHandle(fileno(fp), &oldstdout);
586 if (rc) {
587 Dos_Error(MB_CANCEL, rc, hwndCnr, pszSrcFile, __LINE__,
588 "DosDupHandle");
589 xfree(arctemp, pszSrcFile, __LINE__);
590 return 0;
591 }
592 else {
593 runemf2(SEPARATE | INVISIBLE | FULLSCREEN | BACKGROUND | WAIT,
594 hwndCnr, pszSrcFile, __LINE__, NULL, NULL,
595 "%s %s",
596 info->list,
597 BldQuotedFileName(s, arcname));
598 oldstdout = fileno(stdout);
599 DosError(FERR_DISABLEHARDERR);
600 DosDupHandle(newstdout, &oldstdout);
601 DosClose(newstdout);
602 fclose(fp);
603 }
604 }
605 }
606 }
607
608 DosError(FERR_DISABLEHARDERR);
609 fp = _fsopen(arctemp, "r", SH_DENYWR);
610
611 if (fp) {
612 gotstart = !info->startlist || !*info->startlist; // If list has no start marker
613
614 while (!feof(fp) && !gotend && !*pStopFlag) {
615 if (!xfgets_bstripcr(s, sizeof(s), fp, pszSrcFile, __LINE__))
616 break;
617 if (!gotstart) {
618 if (!strcmp(s, info->startlist))
619 gotstart = TRUE;
620 }
621 else if (info->endlist && !strcmp(s, info->endlist))
622 gotend = TRUE;
623 else {
624 /* add to container */
625 fname = NULL;
626 bstrip(s);
627 if (info->nameisfirst) {
628 strncpy(lonename, s, CCHMAXPATH + 2);
629 lonename[CCHMAXPATH + 1] = 0;
630 fname = lonename;
631 if (!xfgets_bstripcr(s, sizeof(s), fp, pszSrcFile, __LINE__))
632 break;
633 if (*fname == '\"') {
634 memmove(fname, fname + 1, strlen(fname) + 1);
635 p = strchr(fname, '\"');
636 if (p)
637 *p = 0;
638 }
639 }
640 nsize = NULL;
641 osize = fdate = NullStr;
642 p = s;
643 for (x = 0; x <= highest; x++) {
644 pp = p;
645 while (*pp && (*pp == ' ' || *pp == '\t')) /* skip leading */
646 pp++;
647 if (!*pp)
648 break;
649 wasquote = FALSE;
650 p = pp;
651 while (*p && (wasquote ||
652 ((x != info->fnpos || !info->nameislast) ?
653 (*p != ' ' && *p != '\t') : TRUE))) {
654 if (*p == '\"') {
655 if (!wasquote) {
656 wasquote = TRUE;
657 memmove(p, p + 1, strlen(p));
658 while (*p == ' ' || *p == '\t')
659 p++;
660 }
661 else {
662 memmove(p, p + 1, strlen(p));
663 break;
664 }
665 }
666 else if (*p)
667 p++;
668 }
669 if (*p) {
670 *p = 0;
671 p++;
672 }
673 if (x == info->nsizepos)
674 nsize = pp;
675 else if (x == info->osizepos)
676 osize = pp;
677 else if (x == info->fdpos) {
678 fdate = pp;
679 if (info->fdflds > 1 && info->fdflds < 24) {
680 INT y;
681
682 if (*p) {
683 p--;
684 *p = ' ';
685 for (y = 0; y < info->fdflds - 1; y++) {
686 while (*p && (*p == ' ' || *p == '\t'))
687 p++;
688 while (*p && (*p != ' ' && *p != '\t'))
689 p++;
690 x++;
691 }
692 if (*p) {
693 *p = 0;
694 p++;
695 }
696 }
697 }
698 }
699 else if (x == info->fnpos) {
700 fname = pp;
701 if (pp && *pp == '*' && !*(pp + 1)) /* workaround for LH.EXE */
702 fname = NULL;
703 if (info->nameislast)
704 break;
705 }
706 else if ((!p || !*p) && info->fnpos == -1) {
707 fname = pp;
708 break;
709 }
710 }
711 if (info->nameisnext) {
712 if (!xfgets_bstripcr
713 (lonename, sizeof(lonename), fp, pszSrcFile, __LINE__))
714 break;
715 fname = lonename;
716 }
717 // fixme to complain?
718 if (fname && *fname) {
719
720 RECORDINSERT ri;
721 PARCITEM pai;
722
723#ifdef DEBUG
724 saymsg(MB_ENTER, hwndCnr, DEBUG_STRING,
725 "fname: %s\r\rpp: %s\r\rp: %s\r\rlonename: %s\r\rhighest: %ld\r\rx: %ld\r\rfdate: %s",
726 fname ? fname : "NULL",
727 pp ? pp : "NULL",
728 p ? p : "NULL",
729 lonename, highest, x, (fdate) ? fdate : "NULL");
730#endif
731
732 pai = WinSendMsg(hwndCnr,
733 CM_ALLOCRECORD,
734 MPFROMLONG(EXTRA_ARCRECORD_BYTES),
735 MPFROMLONG(1L));
736 if (!pai) {
737 Runtime_Error(pszSrcFile, __LINE__, "CM_ALLOCRECORD");
738 break;
739 }
740 else {
741 memset(pai, 0, sizeof(ARCITEM));
742 pai->hwndCnr = hwndCnr;
743 if (*fname == '*') {
744 fname++;
745 pai->flags = ARCFLAGS_REALDIR;
746 }
747 if (fname[strlen(fname) - 1] == '\\' ||
748 fname[strlen(fname) - 1] == '/')
749 pai->flags = ARCFLAGS_REALDIR;
750 pai->pszFileName = xstrdup(fname,pszSrcFile, __LINE__);
751 pai->pszDisplayName = pai->pszFileName;
752 pai->rc.pszIcon = pai->pszDisplayName;
753 if (fdate)
754 strcpy(pai->szDate, fdate);
755 // pai->pszFileName = pai->pszFileName;
756 pai->rc.pszIcon = pai->pszFileName;
757 pai->rc.hptrIcon = (pai->flags & ARCFLAGS_REALDIR) != 0 ?
758 hptrDir : hptrFile;
759 pai->pszDate = pai->szDate;
760 if (osize)
761 pai->cbFile = atol(osize);
762 if (nsize)
763 pai->cbComp = atol(nsize);
764 if (info->datetype && fdate && *fdate)
765 ArcDateTime(fdate, info->datetype, &pai->date, &pai->time);
766 memset(&ri, 0, sizeof(RECORDINSERT));
767 ri.cb = sizeof(RECORDINSERT);
768 ri.pRecordOrder = (PRECORDCORE) CMA_END;
769 ri.pRecordParent = (PRECORDCORE) NULL;
770 ri.zOrder = (USHORT) CMA_TOP;
771 ri.cRecordsInsert = 1L;
772 ri.fInvalidateRecord = FALSE;
773 if (WinSendMsg(hwndCnr,
774 CM_INSERTRECORD, MPFROMP(pai), MPFROMP(&ri))) {
775 *pullTotalBytes += pai->cbFile;
776 }
777 numarcfiles++;
778 if (!(++counter % 50)) {
779 if (!lastpai)
780 lastpai = pai;
781 WinSendMsg(hwndCnr,
782 CM_INVALIDATERECORD,
783 lastpai,
784 MPFROM2SHORT(10, CMA_ERASE | CMA_REPOSITION));
785 lastpai = pai;
786 }
787 // Avoid hogging system for large archive
788 if (numarcfiles == 100)
789 priority_idle();
790 }
791 }
792 }
793 } // while !eof
794
795 fclose(fp);
796
797 if (*pStopFlag)
798 numarcfiles = 0; // Request close
799 else if (!numarcfiles || !gotstart
800 || (!gotend && info->endlist && *info->endlist)) {
801 // Oops
802 ARCDUMP ad;
803 CHAR errstr[CCHMAXPATH + 256];
804
805 // Try for alternate archiver
806 tinfo = info;
807 do {
808 tinfo = tinfo->next;
809 if (tinfo)
810 tinfo = find_type(arcname, tinfo);
811 if (tinfo) {
812 DosError(FERR_DISABLEHARDERR);
813 DosForceDelete(arctemp);
814 info = tinfo;
815 goto ReTry;
816 }
817 } while (tinfo);
818 DosBeep(750, 50); // wake up user
819 sprintf(errstr, GetPString(IDS_ARCERRORINFOTEXT),
820 arcname,
821 !gotstart ? GetPString(IDS_NOGOTSTARTTEXT) : NullStr,
822 !numarcfiles ? GetPString(IDS_NOARCFILESFOUNDTEXT) :
823 NullStr,
824 !gotend ? GetPString(IDS_NOENDOFLISTTEXT) : NullStr);
825 memset(&ad, 0, sizeof(ARCDUMP));
826 ad.info = info;
827 strcpy(ad.listname, arctemp);
828 strcpy(ad.arcname, arcname);
829 ad.errmsg = errstr;
830 WinDlgBox(HWND_DESKTOP,
831 hwndCnr,
832 ArcErrProc, FM3ModHandle, ARCERR_FRAME, MPFROMP(&ad));
833 }
834 else if (!nomove && tinfo) {
835 /* if we got a false hit, move working hit to top */
836 tinfo = info->next;
837 info->next = arcsighead;
838 arcsighead->prev = info;
839 if (tinfo)
840 tinfo->next->prev = info->prev;
841 info->prev->next = tinfo;
842 info->prev = NULL;
843 arcsighead = info;
844 rewrite_archiverbb2(NULL); // Rewrite with warning
845 }
846 } // if opened
847
848 DosError(FERR_DISABLEHARDERR);
849 DosForceDelete(arctemp);
850 xfree(arctemp, pszSrcFile, __LINE__);
851 }
852
853 if (numarcfiles)
854 priority_normal();
855
856 return numarcfiles;
857}
858
859MRESULT EXPENTRY ArcTextProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
860{
861 static BOOL emphasized = FALSE;
862 static HWND hwndButtonPopup = (HWND) 0;
863 static ULONG timestamp = ULONG_MAX;
864 static USHORT lastid = 0;
865
866 switch (msg) {
867 case WM_CREATE:
868 return CommonTextProc(hwnd, msg, mp1, mp2);
869
870 case WM_COMMAND:
871 return WinSendMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
872 ARC_CNR), msg, mp1, mp2);
873
874 case UM_CONTEXTMENU:
875 case WM_CONTEXTMENU:
876 {
877 USHORT id;
878
879 id = WinQueryWindowUShort(hwnd, QWS_ID);
880 switch (id) {
881 case DIR_SELECTED:
882 case DIR_VIEW:
883 case DIR_SORT:
884 {
885 POINTL ptl = { 0, 0 };
886 SWP swp;
887 DIRCNRDATA *dcd;
888
889 if (hwndButtonPopup)
890 WinDestroyWindow(hwndButtonPopup);
891 if (id == DIR_SELECTED)
892 id = DIR_RESTORE;
893 if (id == lastid) {
894
895 ULONG check;
896
897 DosQuerySysInfo(QSV_MS_COUNT, QSV_MS_COUNT, &check,
898 sizeof(check));
899 if (check < timestamp + 500) {
900 lastid = 0;
901 goto MenuAbort;
902 }
903 }
904 hwndButtonPopup = WinLoadMenu(HWND_DESKTOP, FM3ModHandle, id);
905 if (hwndButtonPopup) {
906 WinSetWindowUShort(hwndButtonPopup, QWS_ID, id);
907 dcd = WinQueryWindowPtr(WinWindowFromID(WinQueryWindow(hwnd,
908 QW_PARENT),
909 ARC_CNR), QWL_USER);
910 if (id == DIR_SORT) {
911 if (dcd)
912 SetSortChecks(hwndButtonPopup, dcd->sortFlags);
913 WinSendMsg(hwndButtonPopup,
914 MM_DELETEITEM,
915 MPFROM2SHORT(IDM_SORTNONE, FALSE), MPVOID);
916 WinSendMsg(hwndButtonPopup,
917 MM_DELETEITEM,
918 MPFROM2SHORT(IDM_SORTNAME, FALSE), MPVOID);
919 WinSendMsg(hwndButtonPopup,
920 MM_DELETEITEM,
921 MPFROM2SHORT(IDM_SORTLADATE, FALSE), MPVOID);
922 WinSendMsg(hwndButtonPopup,
923 MM_DELETEITEM,
924 MPFROM2SHORT(IDM_SORTCRDATE, FALSE), MPVOID);
925 WinSendMsg(hwndButtonPopup,
926 MM_DELETEITEM,
927 MPFROM2SHORT(IDM_SORTDIRSFIRST, FALSE), MPVOID);
928 WinSendMsg(hwndButtonPopup,
929 MM_DELETEITEM,
930 MPFROM2SHORT(IDM_SORTDIRSLAST, FALSE), MPVOID);
931 WinSendMsg(hwndButtonPopup,
932 MM_DELETEITEM,
933 MPFROM2SHORT(IDM_SORTSUBJECT, FALSE), MPVOID);
934 WinSendMsg(hwndButtonPopup,
935 MM_SETITEMTEXT,
936 MPFROM2SHORT(IDM_SORTEASIZE, 0),
937 MPFROMP(GetPString(IDS_COMPRESSEDSIZEMENUTEXT)));
938 WinSendMsg(hwndButtonPopup,
939 MM_SETITEMTEXT,
940 MPFROM2SHORT(IDM_SORTLWDATE, 0),
941 MPFROMP(GetPString(IDS_DATEMENUTEXT)));
942 }
943 ptl.x = 0;
944 if (WinPopupMenu(HWND_OBJECT,
945 HWND_OBJECT,
946 hwndButtonPopup, -32767, -32767, 0, 0)) {
947 WinQueryWindowPos(hwndButtonPopup, &swp);
948 ptl.y = -(swp.cy + 2);
949 }
950 else {
951 WinQueryWindowPos(hwnd, &swp);
952 ptl.y = swp.cy + 2;
953 }
954 if (WinPopupMenu(hwnd,
955 hwnd,
956 hwndButtonPopup,
957 ptl.x,
958 ptl.y,
959 0,
960 PU_HCONSTRAIN | PU_VCONSTRAIN |
961 PU_KEYBOARD | PU_MOUSEBUTTON1)) {
962 CenterOverWindow(hwndButtonPopup);
963 PaintRecessedWindow(hwnd, (HPS) 0, FALSE, FALSE);
964 }
965 }
966 }
967 break;
968 default:
969 PostMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
970 ARC_CNR),
971 WM_CONTROL, MPFROM2SHORT(ARC_CNR, CN_CONTEXTMENU), MPVOID);
972 break;
973 }
974 }
975 MenuAbort:
976 if (msg == UM_CONTEXTMENU)
977 return 0;
978 break;
979
980 case WM_MENUEND:
981 if (hwndButtonPopup == (HWND) mp2) {
982 lastid = WinQueryWindowUShort((HWND) mp2, QWS_ID);
983 WinDestroyWindow(hwndButtonPopup);
984 hwndButtonPopup = (HWND) 0;
985 DosQuerySysInfo(QSV_MS_COUNT, QSV_MS_COUNT, &timestamp,
986 sizeof(timestamp));
987 switch (lastid) {
988 case DIR_VIEW:
989 case DIR_SORT:
990 case DIR_RESTORE:
991 case DIR_SELECTED:
992 PaintRecessedWindow(hwnd, (HPS) 0, TRUE, FALSE);
993 break;
994 }
995 }
996 break;
997
998 case WM_MOUSEMOVE:
999 {
1000 USHORT id = WinQueryWindowUShort(hwnd, QWS_ID);
1001 char *s = NULL;
1002
1003 if (fOtherHelp) {
1004 if ((!hwndBubble ||
1005 WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd) &&
1006 !WinQueryCapture(HWND_DESKTOP)) {
1007 switch (id) {
1008 case DIR_TOTALS:
1009 s = GetPString(IDS_ARCCNRTOTALSHELPTEXT);
1010 break;
1011 case DIR_SELECTED:
1012 s = GetPString(IDS_ARCCNRSELECTEDHELPTEXT);
1013 break;
1014 case DIR_VIEW:
1015 s = GetPString(IDS_ARCCNRVIEWHELPTEXT);
1016 break;
1017 case DIR_SORT:
1018 s = GetPString(IDS_DIRCNRSORTHELP);
1019 break;
1020 case DIR_FILTER:
1021 s = GetPString(IDS_DIRCNRFILTERHELP);
1022 break;
1023 case DIR_FOLDERICON:
1024 s = GetPString(IDS_ARCCNRFOLDERHELPTEXT);
1025 break;
1026 default:
1027 break;
1028 }
1029 if (s)
1030 MakeBubble(hwnd, TRUE, s);
1031 else if (hwndBubble)
1032 WinDestroyWindow(hwndBubble);
1033 }
1034 }
1035 switch (id) {
1036 case DIR_FILTER:
1037 case DIR_SORT:
1038 case DIR_VIEW:
1039 case DIR_SELECTED:
1040 case DIR_FOLDERICON:
1041 return CommonTextButton(hwnd, msg, mp1, mp2);
1042 }
1043 }
1044 break;
1045
1046 case WM_BUTTON3UP:
1047 case WM_BUTTON1UP:
1048 case WM_BUTTON1DOWN:
1049 case WM_BUTTON3DOWN:
1050 {
1051 USHORT id;
1052
1053 id = WinQueryWindowUShort(hwnd, QWS_ID);
1054 switch (id) {
1055 case DIR_FILTER:
1056 case DIR_SORT:
1057 case DIR_VIEW:
1058 case DIR_SELECTED:
1059 case DIR_FOLDERICON:
1060 return CommonTextButton(hwnd, msg, mp1, mp2);
1061 }
1062 }
1063 break;
1064
1065 case UM_CLICKED:
1066 case UM_CLICKED3:
1067 {
1068 USHORT id, cmd = 0;
1069
1070 id = WinQueryWindowUShort(hwnd, QWS_ID);
1071 switch (id) {
1072 case DIR_FOLDERICON:
1073 switch (msg) {
1074 case WM_BUTTON3CLICK:
1075 case WM_CHORD:
1076 cmd = IDM_RESCAN;
1077 break;
1078 default:
1079 if ((SHORT2FROMMP(mp2) & KC_ALT) != 0)
1080 cmd = IDM_WINDOWDLG;
1081 else
1082 cmd = IDM_WALKDIR;
1083 break;
1084 }
1085 break;
1086 case DIR_VIEW:
1087 case DIR_SORT:
1088 case DIR_SELECTED:
1089 PostMsg(hwnd, UM_CONTEXTMENU, MPVOID, MPVOID);
1090 break;
1091 case DIR_FILTER:
1092 cmd = IDM_FILTER;
1093 break;
1094 default:
1095 break;
1096 }
1097 if (cmd)
1098 PostMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
1099 ARC_CNR),
1100 WM_COMMAND, MPFROM2SHORT(cmd, 0), MPVOID);
1101 }
1102 return 0;
1103
1104 case WM_BEGINDRAG:
1105 case DM_DROP:
1106 case DM_DRAGOVER:
1107 case DM_DRAGLEAVE:
1108 case DM_DROPHELP:
1109 if (msg == DM_DRAGOVER) {
1110 if (!emphasized) {
1111 emphasized = TRUE;
1112 DrawTargetEmphasis(hwnd, emphasized);
1113 }
1114 }
1115 else if (msg != WM_BEGINDRAG) {
1116 if (emphasized) {
1117 emphasized = FALSE;
1118 DrawTargetEmphasis(hwnd, emphasized);
1119 }
1120 }
1121 switch (WinQueryWindowUShort(hwnd, QWS_ID)) {
1122 case DIR_FOLDERICON:
1123 switch (msg) {
1124 case DM_DRAGOVER:
1125 if (AcceptOneDrop(hwnd, mp1, mp2))
1126 return MRFROM2SHORT(DOR_DROP, DO_MOVE);
1127 return MRFROM2SHORT(DOR_NODROP, 0); /* Drop not valid */
1128 case DM_DROPHELP:
1129 DropHelp(mp1, mp2, hwnd, GetPString(IDS_ARCCNRFOLDERDROPHELPTEXT));
1130 return 0;
1131 case DM_DROP:
1132 {
1133 char szFrom[CCHMAXPATH + 2];
1134
1135 if (emphasized) {
1136 emphasized = FALSE;
1137 DrawTargetEmphasis(hwnd, emphasized);
1138 }
1139 if (GetOneDrop(hwnd, mp1, mp2, szFrom, sizeof(szFrom)))
1140 WinSendMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
1141 ARC_CNR),
1142 WM_COMMAND,
1143 MPFROM2SHORT(IDM_SWITCH, 0), MPFROMP(szFrom));
1144 }
1145 return 0;
1146 default:
1147 return PFNWPStatic(hwnd, msg, mp1, mp2);
1148 }
1149 default:
1150 {
1151 CNRDRAGINFO cnd;
1152 USHORT dcmd;
1153
1154 switch (msg) {
1155 case DM_DROP:
1156 dcmd = CN_DROP;
1157 break;
1158 case DM_DRAGOVER:
1159 dcmd = CN_DRAGOVER;
1160 break;
1161 case DM_DRAGLEAVE:
1162 dcmd = CN_DRAGLEAVE;
1163 break;
1164 case DM_DROPHELP:
1165 dcmd = CN_DROPHELP;
1166 break;
1167 case WM_BEGINDRAG:
1168 dcmd = CN_INITDRAG;
1169 break;
1170 }
1171 cnd.pDragInfo = (PDRAGINFO) mp1;
1172 cnd.pRecord = NULL;
1173 return WinSendMsg(WinQueryWindow(hwnd, QW_PARENT),
1174 WM_CONTROL,
1175 MPFROM2SHORT(ARC_CNR, dcmd), MPFROMP(&cnd));
1176 }
1177 }
1178 }
1179 return PFNWPStatic(hwnd, msg, mp1, mp2);
1180}
1181
1182MRESULT EXPENTRY ArcClientWndProc(HWND hwnd, ULONG msg, MPARAM mp1,
1183 MPARAM mp2)
1184{
1185
1186 switch (msg) {
1187 case UM_CONTAINERHWND:
1188 return MRFROMLONG(WinWindowFromID(hwnd, ARC_CNR));
1189
1190 case UM_VIEWSMENU:
1191 // fixme to disble menu items as needed
1192 return MRFROMLONG(CheckMenu(hwnd, &ArcCnrMenu, ARCCNR_POPUP));
1193
1194 case UM_FILESMENU:
1195 // fixme to disble menu items as needed
1196 return MRFROMLONG(CheckMenu(hwnd, &ArcMenu, ARC_POPUP));
1197
1198 case MM_PORTHOLEINIT:
1199 case WM_INITMENU:
1200 case UM_INITMENU:
1201 case UM_COMMAND:
1202 case UM_LOADFILE:
1203 case UM_UPDATERECORD:
1204 case UM_UPDATERECORDLIST:
1205 case WM_COMMAND:
1206 case WM_CONTROL:
1207 case WM_CLOSE:
1208 return WinSendMsg(WinWindowFromID(hwnd, ARC_CNR), msg, mp1, mp2);
1209
1210 case WM_PSETFOCUS:
1211 case WM_SETFOCUS:
1212 if (mp2)
1213 PostMsg(hwnd, UM_FOCUSME, MPVOID, MPVOID);
1214 break;
1215
1216 case UM_FOCUSME:
1217 WinSetFocus(HWND_DESKTOP, WinWindowFromID(hwnd, ARC_CNR));
1218 break;
1219
1220 case WM_PAINT:
1221 {
1222 HPS hps;
1223 RECTL rcl;
1224
1225 hps = WinBeginPaint(hwnd, (HPS) 0, NULL);
1226 if (hps) {
1227 WinQueryWindowRect(hwnd, &rcl);
1228 WinFillRect(hps, &rcl, CLR_PALEGRAY);
1229 CommonTextPaint(hwnd, hps);
1230 WinEndPaint(hps);
1231 }
1232 }
1233 break;
1234
1235 case UM_SIZE:
1236 case WM_SIZE:
1237 if (msg == UM_SIZE) {
1238
1239 SWP swp;
1240
1241 WinQueryWindowPos(hwnd, &swp);
1242 mp1 = MPFROM2SHORT(swp.cx, swp.cy);
1243 mp2 = MPFROM2SHORT(swp.cx, swp.cy);
1244 }
1245 {
1246 USHORT cx, cy, bx;
1247
1248 cx = SHORT1FROMMP(mp2);
1249 cy = SHORT2FROMMP(mp2);
1250 WinSetWindowPos(WinWindowFromID(hwnd, ARC_CNR), HWND_TOP,
1251 0,
1252 22, cx, cy - (24 + 22), SWP_SHOW | SWP_MOVE | SWP_SIZE);
1253 WinSetWindowPos(WinWindowFromID(hwnd, ARC_EXTRACTDIR), HWND_TOP,
1254 0, 0, cx, 22, SWP_SHOW | SWP_MOVE | SWP_SIZE);
1255 WinSetWindowPos(WinWindowFromID(hwnd, DIR_FOLDERICON), HWND_TOP,
1256 2, cy - 22, 24, 20, SWP_SHOW | SWP_MOVE | SWP_SIZE);
1257 WinSetWindowPos(WinWindowFromID(hwnd, DIR_TOTALS), HWND_TOP,
1258 29,
1259 cy - 22,
1260 (cx / 3) - 2, 20, SWP_SHOW | SWP_MOVE | SWP_SIZE);
1261 WinSetWindowPos(WinWindowFromID(hwnd, DIR_SELECTED), HWND_TOP,
1262 29 + (cx / 3) + 2,
1263 cy - 22,
1264 (cx / 3) - 2, 20, SWP_SHOW | SWP_MOVE | SWP_SIZE);
1265 bx = (cx - (29 + (((cx / 3) + 2) * 2))) / 3;
1266 WinSetWindowPos(WinWindowFromID(hwnd, DIR_VIEW), HWND_TOP,
1267 29 + (((cx / 3) + 2) * 2),
1268 cy - 22, bx - 4, 20, SWP_SHOW | SWP_MOVE | SWP_SIZE);
1269 WinSetWindowPos(WinWindowFromID(hwnd, DIR_SORT), HWND_TOP,
1270 29 + (((cx / 3) + 2) * 2) + bx,
1271 cy - 22, bx - 4, 20, SWP_SHOW | SWP_MOVE | SWP_SIZE);
1272 WinSetWindowPos(WinWindowFromID(hwnd, DIR_FILTER), HWND_TOP,
1273 29 + (((cx / 3) + 2) * 2) + (bx * 2),
1274 cy - 22, bx - 4, 20, SWP_SHOW | SWP_MOVE | SWP_SIZE);
1275 }
1276 CommonTextPaint(hwnd, (HPS) 0);
1277 if (msg == UM_SIZE) {
1278 WinSetWindowPos(WinQueryWindow(hwnd, QW_PARENT), HWND_TOP, 0, 0, 0, 0,
1279 SWP_SHOW | SWP_ZORDER | SWP_ACTIVATE);
1280 return 0;
1281 }
1282 break;
1283 }
1284 return WinDefWindowProc(hwnd, msg, mp1, mp2);
1285}
1286
1287MRESULT EXPENTRY ArcObjWndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
1288{
1289 DIRCNRDATA *dcd;
1290 PSZ psz;
1291 CHAR szQuotedArcName[CCHMAXPATH];
1292 CHAR szQuotedMemberName[CCHMAXPATH];
1293
1294 switch (msg) {
1295 case WM_CREATE:
1296 DbgMsg(pszSrcFile, __LINE__, "WM_CREATE mp1 %p mp2 %p", mp1, mp2); // 18 Jul 08 SHL fixme
1297 break;
1298
1299 case DM_PRINTOBJECT:
1300 case DM_DISCARDOBJECT:
1301 dcd = INSTDATA(hwnd);
1302 if (dcd) {
1303
1304 LISTINFO *li;
1305 CNRDRAGINFO cni;
1306
1307 cni.pRecord = NULL;
1308 cni.pDragInfo = (PDRAGINFO) mp1;
1309 li = DoFileDrop(dcd->hwndCnr,
1310 dcd->directory, FALSE, MPVOID, MPFROMP(&cni));
1311 CheckPmDrgLimit(cni.pDragInfo);
1312 if (li) {
1313 li->type = (msg == DM_DISCARDOBJECT) ? IDM_DELETE : IDM_PRINT;
1314 if (!li->list ||
1315 !li->list[0] || !PostMsg(hwnd, UM_ACTION, MPFROMP(li), MPVOID))
1316 FreeListInfo(li);
1317 else
1318 return MRFROMLONG(DRR_SOURCE);
1319 }
1320 }
1321 return MRFROMLONG(DRR_TARGET);
1322
1323 case DM_RENDERPREPARE:
1324 return (MRESULT) TRUE;
1325
1326 case DM_RENDER:
1327 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
1328 if (dcd && dcd->info && dcd->info->extract && dcd->arcname) {
1329
1330 PDRAGTRANSFER pdt = (PDRAGTRANSFER) mp1;
1331 CHAR filename[CCHMAXPATH];
1332 ULONG len;
1333
1334 if (pdt->hwndClient && pdt->pditem && pdt->hstrSelectedRMF &&
1335 pdt->hstrRenderToName) {
1336 if (pdt->usOperation == DO_COPY || pdt->usOperation == DO_MOVE) {
1337 *filename = 0;
1338 len = DrgQueryStrName(pdt->hstrSelectedRMF, CCHMAXPATH, filename);
1339 filename[len] = 0;
1340 if (!strnicmp(filename, "OS2FILE,", 8)) {
1341 // saymsg(MB_ENTER,HWND_DESKTOP,DEBUG_STRING,"RMF = \"%s\"",filename);
1342 }
1343 else {
1344 *filename = 0;
1345 len =
1346 DrgQueryStrName(pdt->hstrRenderToName, CCHMAXPATH, filename);
1347 filename[len] = 0;
1348 if (len && *filename) {
1349 psz = xstrdup(filename, pszSrcFile, __LINE__);
1350 if (psz) {
1351 PostMsg(hwnd, UM_RENDER, MPFROMP(pdt), MPFROMP(psz));
1352 return (MRESULT) TRUE;
1353 }
1354 }
1355 else {
1356 // saymsg(MB_ENTER,HWND_DESKTOP,DEBUG_STRING,"No render-to name given.");
1357 }
1358 }
1359 }
1360 pdt->fsReply = DMFL_RENDERRETRY;
1361 }
1362 }
1363 return (MRESULT) FALSE;
1364
1365 case UM_RENDER:
1366 {
1367 PDRAGTRANSFER pdt = (PDRAGTRANSFER) mp1;
1368 USHORT usRes = DMFL_RENDERFAIL;
1369
1370 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
1371 if (dcd && dcd->info && dcd->info->extract && dcd->arcname) {
1372
1373 CHAR *filename = (CHAR *) mp2, *p;
1374 ULONG len;
1375 CHAR membername[CCHMAXPATH], construct[CCHMAXPATH * 2];
1376
1377 *membername = 0;
1378 len = DrgQueryStrName(pdt->pditem->hstrSourceName,
1379 CCHMAXPATH, membername);
1380 membername[len] = 0;
1381 if (*membername && len && filename) {
1382 unlinkf("%s", filename);
1383 strcpy(construct, filename);
1384 p = strrchr(filename, '\\');
1385 if (!p)
1386 *construct = 0;
1387 else {
1388 if (p == filename || *(p - 1) == ':')
1389 p++;
1390 *p = 0;
1391 }
1392 // saymsg(MB_ENTER,HWND_DESKTOP,DEBUG_STRING,"%s %s %s\r[%s]",dcd->info->extract,dcd->arcname,membername,construct);
1393 runemf2(SEPARATE | WINDOWED | WAIT |
1394 (fArcStuffVisible ? 0 : BACKGROUND | MINIMIZED),
1395 dcd->hwndClient, pszSrcFile, __LINE__, construct, NULL,
1396 "%s %s %s",
1397 dcd->info->extract,
1398 BldQuotedFileName(szQuotedArcName, dcd->arcname),
1399 BldQuotedFileName(szQuotedMemberName, membername));
1400 BldFullPathName(construct, construct, membername);
1401 if (IsFile(construct) != -1) {
1402 rename(construct, filename);
1403 unlinkf("%s", construct);
1404 if (IsFile(filename) != -1)
1405 usRes = DMFL_RENDEROK;
1406 }
1407 }
1408 }
1409 xfree((CHAR *)mp2, pszSrcFile, __LINE__);
1410 PostMsg(pdt->hwndClient, DM_RENDERCOMPLETE, MPFROMP(pdt),
1411 MPFROM2SHORT(usRes, 0));
1412 }
1413 return 0;
1414
1415 case UM_SETUP:
1416# ifdef FORTIFY
1417 Fortify_EnterScope();
1418# endif
1419 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
1420 if (!dcd) {
1421 Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
1422 PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
1423 }
1424 else {
1425# ifdef FORTIFY
1426 Fortify_BecomeOwner(dcd);
1427# endif
1428 /* set unique id */
1429 WinSetWindowUShort(hwnd, QWS_ID, ARCOBJ_FRAME + (ARC_FRAME - dcd->id));
1430 dcd->hwndObject = hwnd; // pass back hwnd
1431 if (ParentIsDesktop(hwnd, dcd->hwndParent))
1432 DosSleep(100); //05 Aug 07 GKY 250 // Avoid race?
1433 }
1434 return 0;
1435
1436 case UM_RESCAN:
1437 /*
1438 * populate container
1439 */
1440 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
1441 if (dcd) {
1442 if (mp1)
1443 strcpy(dcd->arcname, (CHAR *) mp1); // Update name on request
1444 dcd->ullTotalBytes = dcd->totalfiles =
1445 dcd->selectedfiles = dcd->selectedbytes = 0;
1446 WinSetDlgItemText(dcd->hwndClient, DIR_TOTALS, "0");
1447 WinSetDlgItemText(dcd->hwndClient, DIR_SELECTED, "0 / 0k");
1448 dcd->totalfiles = FillArcCnr(dcd->hwndCnr,
1449 dcd->arcname,
1450 &dcd->info,
1451 &dcd->ullTotalBytes, &dcd->stopflag);
1452 if (!dcd->totalfiles)
1453 PostMsg(dcd->hwndCnr, WM_CLOSE, MPVOID, MPVOID);
1454 else {
1455 dcd->arcfilled = TRUE;
1456 if (!PostMsg(dcd->hwndCnr, UM_RESCAN, MPVOID, MPVOID))
1457 WinSendMsg(dcd->hwndCnr, UM_RESCAN, MPVOID, MPVOID);
1458 PostMsg(dcd->hwndCnr, UM_SETUP2, MPVOID, MPVOID);
1459 WinSendMsg(dcd->hwndCnr,
1460 CM_INVALIDATERECORD,
1461 MPVOID, MPFROM2SHORT(0, CMA_ERASE | CMA_REPOSITION));
1462 }
1463 }
1464 return 0;
1465
1466 case UM_SELECT:
1467 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
1468 if (dcd) {
1469 switch (SHORT1FROMMP(mp1)) {
1470 case IDM_SELECTALL:
1471 case IDM_SELECTALLFILES:
1472 SelectAll(dcd->hwndCnr, TRUE, TRUE, NULL, NULL, TRUE);
1473 break;
1474 case IDM_DESELECTALL:
1475 case IDM_DESELECTALLFILES:
1476 DeselectAll(dcd->hwndCnr, TRUE, TRUE, NULL, NULL, TRUE);
1477 break;
1478 case IDM_DESELECTMASK:
1479 case IDM_SELECTMASK:
1480 {
1481 MASK mask;
1482 PARCITEM pci = (PARCITEM) mp2;
1483
1484 memset(&mask, 0, sizeof(MASK));
1485 mask.fNoAttribs = TRUE;
1486 mask.fNoDirs = TRUE;
1487 strcpy(mask.prompt,
1488 GetPString((SHORT1FROMMP(mp1) == IDM_SELECTMASK) ?
1489 IDS_SELECTFILTERTEXT : IDS_DESELECTFILTERTEXT));
1490 if (pci && (INT) pci != -1)
1491 strcpy(mask.szMask, pci->pszFileName);
1492 if (WinDlgBox(HWND_DESKTOP, dcd->hwndCnr, PickMaskDlgProc,
1493 FM3ModHandle, MSK_FRAME, MPFROMP(&mask))) {
1494 if (SHORT1FROMMP(mp1) == IDM_SELECTMASK)
1495 SelectAll(dcd->hwndCnr, TRUE, TRUE, mask.szMask, NULL, FALSE);
1496 else
1497 DeselectAll(dcd->hwndCnr, TRUE, TRUE, mask.szMask, NULL, FALSE);
1498 }
1499 }
1500
1501 case IDM_INVERT:
1502 InvertAll(dcd->hwndCnr);
1503 break;
1504 }
1505 }
1506 return 0;
1507
1508 case UM_ENTER:
1509 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
1510 if (dcd) {
1511
1512 CHAR *s = (CHAR *) mp1, *p, *pp, filename[CCHMAXPATH];
1513
1514 if (s) {
1515 if (!dcd->info->extract) {
1516 Runtime_Error(pszSrcFile, __LINE__, "no extract");
1517 free(s);
1518 return 0;
1519 }
1520 runemf2(SEPARATE | WINDOWED | WAIT |
1521 (fArcStuffVisible ? 0 : BACKGROUND | MINIMIZED),
1522 dcd->hwndClient, pszSrcFile, __LINE__, dcd->workdir, NULL,
1523 "%s %s %s",
1524 dcd->info->exwdirs ? dcd->info->exwdirs :
1525 dcd->info->extract,
1526 BldQuotedFileName(szQuotedArcName, dcd->arcname),
1527 BldQuotedFileName(szQuotedMemberName, s));
1528 if (!dcd->info->exwdirs) {
1529 p = s;
1530 p = strrchr(s, '\\');
1531 pp = strrchr(s, '/');
1532 if (p && pp)
1533 p = max(p, pp);
1534 else if (!p)
1535 p = pp;
1536 if (p)
1537 memmove(s, p + 1, strlen(p + 1));
1538 }
1539 sprintf(filename, "%s\\%s", dcd->workdir, s);
1540 p = filename;
1541 while (*p) {
1542 if (*p == '/')
1543 *p = '\\';
1544 p++;
1545 }
1546 // printf("%s %d UM_ENTER %s %s\n",__FILE__, __LINE__,filename, s); fflush(stdout); // 10 Mar 07 SHL hang
1547 free(s);
1548 if (IsFile(filename) == 1) {
1549#if 1 // 06 Oct 07 SHL fixme to be gone - set to 0 for ticket #58 testing
1550 if (fViewChild && fArcStuffVisible)
1551 DosSleep(100); // Allow unzip session to finish closing 14 Mar 07 SHL
1552#endif
1553 WinSendMsg(dcd->hwndCnr, UM_ENTER, MPFROMP(filename), MPVOID);
1554 }
1555 }
1556 }
1557 return 0;
1558
1559 case UM_COMMAND:
1560 if (mp1) {
1561 if (PostMsg(hwnd, UM_ACTION, mp1, mp2))
1562 return (MRESULT) TRUE;
1563 }
1564 return 0;
1565
1566 case UM_ACTION:
1567 DosError(FERR_DISABLEHARDERR);
1568 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
1569 if (dcd) {
1570
1571 LISTINFO *li = (LISTINFO *) mp1;
1572 register INT x;
1573
1574 if (li && li->list && li->list[0]) {
1575 printf("%x/r", li->type); fflush(stdout);
1576 switch (li->type) {
1577 case IDM_ARCHIVE:
1578 case IDM_ARCHIVEM:
1579 {
1580 DIRCNRDATA ad;
1581 CHAR szBuffer[1025], *p;
1582
1583 if (!li->list[1] && !stricmp(li->list[0], dcd->arcname)) {
1584 Runtime_Error(pszSrcFile, __LINE__, "arc to self");
1585 break;
1586 }
1587 ad = *dcd;
1588 ad.namecanchange = 0;
1589 ad.fmoving = (li->type == IDM_ARCHIVEM);
1590 if (!WinDlgBox(HWND_DESKTOP, dcd->hwndClient, ArchiveDlgProc, FM3ModHandle, ARCH_FRAME, (PVOID) & ad) || !*ad.arcname || !*ad.command) /* we blew it */
1591 break;
1592 /* build the sucker */
1593 strcpy(szBuffer, ad.command);
1594 strcat(szBuffer, " ");
1595
1596 BldQuotedFileName(szBuffer + strlen(szBuffer), ad.arcname);
1597
1598 p = &szBuffer[strlen(szBuffer)]; // Remeber where archiver name ends
1599
1600 if (ad.mask.szMask) {
1601 strcat(szBuffer, " ");
1602
1603 BldQuotedFileName(szBuffer + strlen(szBuffer), ad.mask.szMask);
1604 }
1605 strcat(szBuffer, " ");
1606 x = 0;
1607
1608 // Run commands avoiding command line overflow
1609 while (li->list[x]) {
1610
1611 if (IsFile(li->list[x]))
1612 BldQuotedFileName(szBuffer + strlen(szBuffer), li->list[x]);
1613 else
1614 BldQuotedFullPathName(szBuffer + strlen(szBuffer), li->list[x], "*");
1615
1616 x++;
1617 if (!li->list[x] || strlen(szBuffer) +
1618 strlen(li->list[x]) + 5 > MaxComLineStrg) {
1619 runemf2(SEPARATE | WINDOWED |
1620 (fArcStuffVisible ? 0 : BACKGROUND | MINIMIZED) |
1621 WAIT, hwnd, pszSrcFile, __LINE__,
1622 NULL, NULL, "%s", szBuffer);
1623 *p = 0;
1624 }
1625 strcat(szBuffer, " ");
1626 } // while
1627
1628 PostMsg(dcd->hwndCnr, UM_RESCAN, MPFROMSHORT(1), MPVOID);
1629 Broadcast(WinQueryAnchorBlock(hwnd),
1630 hwndMain, UM_UPDATERECORD, MPFROMP(ad.arcname), MPVOID);
1631 Broadcast(WinQueryAnchorBlock(hwnd),
1632 hwndMain,
1633 UM_UPDATERECORDLIST, MPFROMP(li->list), MPVOID);
1634 }
1635 break;
1636
1637 case IDM_REFRESH:
1638 case IDM_DELETE:
1639 {
1640 CHAR *endofit;
1641 PSZ pszCmdLine;
1642 INT z;
1643 CHECKLIST ck;
1644 CHAR prompt[CCHMAXPATH + 257];
1645
1646 if (!dcd->info->delete)
1647 break;
1648 memset(&ck, 0, sizeof(ck));
1649 ck.size = sizeof(ck);
1650 ck.list = li->list;
1651 ck.cmd = li->type;
1652 ck.prompt = prompt;
1653 sprintf(prompt, GetPString(IDS_ARCCNRDELREFTEXT),
1654 (li->type == IDM_DELETE) ?
1655 GetPString(IDS_DELETELOWERTEXT) :
1656 GetPString(IDS_REFRESHLOWERTEXT),
1657 &"s"[li->list[1] == NULL],
1658 dcd->arcname,
1659 (li->type == IDM_DELETE) ?
1660 GetPString(IDS_DELETELOWERTEXT) :
1661 GetPString(IDS_REFRESHLOWERTEXT));
1662 if (!WinDlgBox(HWND_DESKTOP, hwnd, CheckListProc,
1663 FM3ModHandle, CHECK_FRAME, MPFROMP(&ck)))
1664 break;
1665 li->list = ck.list;
1666 if (!li->list || !li->list[0])
1667 break;
1668 pszCmdLine = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
1669 if (!pszCmdLine)
1670 break;
1671 strcpy(pszCmdLine, li->type == IDM_DELETE ?
1672 dcd->info->delete :
1673 dcd->info->create);
1674 strcat(pszCmdLine, " ");
1675 BldQuotedFileName(pszCmdLine + strlen(pszCmdLine), dcd->arcname);
1676 endofit = &pszCmdLine[strlen(pszCmdLine)];
1677 z = 0;
1678 do {
1679 for (x = z; li->list[x] &&
1680 strlen(pszCmdLine) + strlen(li->list[x]) < 999; x++) {
1681 strcat(pszCmdLine, " ");
1682 BldQuotedFileName(pszCmdLine + strlen(pszCmdLine), li->list[x]);
1683 }
1684 z = x;
1685 runemf2(SEPARATE | WINDOWED | WAIT |
1686 (fArcStuffVisible ? 0 : BACKGROUND | MINIMIZED),
1687 hwnd, pszSrcFile, __LINE__, NullStr, NULL, "%s", pszCmdLine);
1688 *endofit = 0;
1689 free(pszCmdLine);
1690 } while (li->list[x]);
1691 PostMsg(dcd->hwndCnr, UM_RESCAN, MPFROMSHORT(1), MPVOID);
1692 Broadcast(WinQueryAnchorBlock(hwnd),
1693 hwndMain,
1694 UM_UPDATERECORD, MPFROMP(dcd->arcname), MPVOID);
1695 }
1696 break;
1697
1698 case IDM_PRINT:
1699 case IDM_VIRUSSCAN:
1700 case IDM_VIEW:
1701 case IDM_MCIPLAY:
1702 case IDM_VIEWARCHIVE:
1703 case IDM_VIEWTEXT:
1704 case IDM_VIEWBINARY:
1705 case IDM_EDIT:
1706 case IDM_EDITTEXT:
1707 case IDM_EDITBINARY:
1708 case IDM_EXEC:
1709 case IDM_EXTRACTWDIRS:
1710 case IDM_EXTRACT:
1711 case IDM_OPENDEFAULT:
1712 case IDM_OPENSETTINGS:
1713 {
1714 CHAR *endofit, *ptr;
1715 PSZ pszCmdLine;
1716 INT z;
1717 if ((li->type == IDM_EXTRACT && !li->info->extract) ||
1718 ((li->type == IDM_VIEW || li->type == IDM_VIEWTEXT ||
1719 li->type == IDM_VIEWBINARY || li->type == IDM_EDIT ||
1720 li->type == IDM_VIEWARCHIVE || li->type == IDM_EDITTEXT ||
1721 li->type == IDM_EDITBINARY || li->type == IDM_MCIPLAY) &&
1722 (!li->info->extract && !li->info->exwdirs)) ||
1723 (li->type != IDM_EXTRACT && li->type != IDM_EDIT &&
1724 li->type != IDM_VIEW && li->type != IDM_VIEWTEXT &&
1725 li->type != IDM_VIEWBINARY &&
1726 li->type != IDM_VIEWARCHIVE &&
1727 li->type != IDM_EDITTEXT &&
1728 li->type != IDM_EDITBINARY &&
1729 li->type != IDM_MCIPLAY && !li->info->exwdirs)) {
1730 Runtime_Error(pszSrcFile, __LINE__, "no cmd for request");
1731 break;
1732 }
1733 if (li->type == IDM_EXTRACT || li->type == IDM_EXTRACTWDIRS) {
1734
1735 CHAR fullname[CCHMAXPATH * 2];
1736 CHAR **exfiles = NULL;
1737 UINT numfiles = 0, numalloc = 0;
1738
1739 for (x = 0; li->list[x]; x++) {
1740 BldFullPathName(fullname, li->targetpath, li->list[x]);
1741 if (IsFile(fullname) != -1) {
1742 AddToList(li->list[x], &exfiles, &numfiles, &numalloc);
1743 li->list = RemoveFromList(li->list, li->list[x]);
1744 if (!li->list)
1745 break;
1746 x--;
1747 }
1748 }
1749 if (exfiles && numfiles) {
1750
1751 CHECKLIST ckl;
1752 CHAR prompt[(CCHMAXPATH * 2) + 256];
1753
1754 memset(&ckl, 0, sizeof(ckl));
1755 ckl.size = sizeof(ckl);
1756 ckl.list = exfiles;
1757 ckl.prompt = prompt;
1758 ckl.cmd = li->type;
1759 sprintf(prompt,
1760 GetPString(IDS_REPLACEWARNTEXT),
1761 &"s"[numfiles == 1],
1762 li->arcname, &"s"[numfiles != 1], li->targetpath);
1763 if (!WinDlgBox(HWND_DESKTOP, hwnd, CheckListProc,
1764 FM3ModHandle, CHECK_FRAME, MPFROMP(&ckl))) {
1765 if (ckl.list)
1766 FreeList(ckl.list);
1767 break;
1768 }
1769 else if (ckl.list)
1770 li->list = CombineLists(li->list, ckl.list);
1771 }
1772 }
1773 if (!li->list || !li->list[0])
1774 break;
1775 pszCmdLine = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
1776 if (!pszCmdLine)
1777 break;
1778 strcpy(pszCmdLine,
1779 (li->type == IDM_EXTRACT ||
1780 ((li->type == IDM_VIEW ||
1781 li->type == IDM_VIEWTEXT ||
1782 li->type == IDM_VIEWBINARY ||
1783 li->type == IDM_VIEWARCHIVE ||
1784 li->type == IDM_PRINT ||
1785 li->type == IDM_EDIT ||
1786 li->type == IDM_EDITTEXT ||
1787 li->type == IDM_OPENDEFAULT ||
1788 li->type == IDM_OPENSETTINGS ||
1789 (li->type == IDM_EDITBINARY && // JBS No way for this () to be true??
1790 li->type == IDM_MCIPLAY)) &&
1791 !li->info->exwdirs)) ?
1792 li->info->extract :
1793 li->info->exwdirs);
1794 strcat(pszCmdLine, " ");
1795 BldQuotedFileName(pszCmdLine + strlen(pszCmdLine), li->arcname);
1796 endofit = &pszCmdLine[strlen(pszCmdLine)];
1797 z = 0;
1798 do {
1799 for (x = z; li->list[x] &&
1800 strlen(pszCmdLine) + strlen(li->list[x]) < MaxComLineStrg - 1 ; x++) {
1801 strcat(pszCmdLine, " ");
1802 BldQuotedFileName(pszCmdLine + strlen(pszCmdLine), li->list[x]);
1803 ptr = li->list[x];
1804 while (*ptr) {
1805 if (*ptr == '/')
1806 *ptr = '\\';
1807 ptr++;
1808 }
1809 }
1810 z = x;
1811 runemf2(SEPARATE | WINDOWED |
1812 (fArcStuffVisible ? 0 : BACKGROUND | MINIMIZED) |
1813 WAIT, hwnd, pszSrcFile, __LINE__,
1814 li->targetpath, NULL, "%s", pszCmdLine);
1815 *endofit = 0;
1816 } while (li->list[x]);
1817 if (li->type == IDM_EXTRACT || li->type == IDM_EXTRACTWDIRS) {
1818 /* update windows */
1819 for (x = 0; li->list[x]; x++) {
1820
1821 CHAR *temp, *p;
1822
1823 temp = li->list[x];
1824 p = temp;
1825 while (*p) {
1826 if (*p == '/')
1827 *p = '\\';
1828 p++;
1829 }
1830 p = xmalloc(strlen(temp) + strlen(li->targetpath) + 2,
1831 pszSrcFile, __LINE__);
1832 if (p) {
1833 BldFullPathName(p, li->targetpath, temp);
1834 li->list[x] = p;
1835 free(temp);
1836 }
1837 }
1838 if (fFolderAfterExtract) {
1839
1840 CHAR objectpath[CCHMAXPATH], *p;
1841 APIRET rc;
1842
1843 GetDesktopName(objectpath, sizeof(objectpath));
1844 rc = WinDlgBox(HWND_DESKTOP, dcd->hwndParent, ObjCnrDlgProc,
1845 FM3ModHandle, OBJCNR_FRAME,
1846 MPFROMP(objectpath));
1847 if (rc) {
1848 if (rc > 1)
1849 strcpy(objectpath, "<WP_DESKTOP>");
1850 p = NULL;
1851 if (li->arcname) {
1852 p = strrchr(li->arcname, '\\');
1853 if (p)
1854 p++;
1855 }
1856 MakeShadows(dcd->hwndParent, li->list, 2, objectpath, p);
1857 }
1858 }
1859 Broadcast(WinQueryAnchorBlock(hwnd),
1860 hwndMain,
1861 UM_UPDATERECORDLIST, MPFROMP(li->list), MPVOID);
1862 }
1863 else if (li->type == IDM_EXEC)
1864 ExecOnList(hwnd,
1865 li->runfile,
1866 WINDOWED | SEPARATEKEEP | PROMPT,
1867 li->targetpath,
1868 NULL, GetPString(IDS_EXECARCFILETITLETEXT),
1869 pszSrcFile, __LINE__);
1870 else if (li->type == IDM_VIRUSSCAN)
1871 ExecOnList(hwnd, virus, PROMPT | WINDOWED | SEPARATEKEEP,
1872 li->targetpath, NULL,
1873 GetPString(IDS_VIRUSSCANARCHIVETITLETEXT),
1874 pszSrcFile, __LINE__);
1875 else if (li->type == IDM_VIEW || li->type == IDM_VIEWTEXT ||
1876 li->type == IDM_VIEWBINARY || li->type == IDM_EDIT ||
1877 li->type == IDM_EDITTEXT ||
1878 li->type == IDM_VIEWARCHIVE ||
1879 li->type == IDM_EDITBINARY ||
1880 li->type == IDM_OPENDEFAULT ||
1881 li->type == IDM_OPENSETTINGS ||
1882 li->type == IDM_MCIPLAY || li->type == IDM_PRINT) {
1883
1884 CHAR *temp, *p;
1885 for (x = 0; li->list[x]; x++) {
1886 if (!li->info->exwdirs) {
1887 temp = li->list[x];
1888 p = strrchr(li->list[x], '\\');
1889 if (p) {
1890 p++;
1891 li->list[x] = xstrdup(p, pszSrcFile, __LINE__);
1892 if (!li->list[x])
1893 li->list[x] = temp;
1894 else {
1895 xfree(temp, pszSrcFile, __LINE__);
1896 }
1897 }
1898 }
1899 BldFullPathName(pszCmdLine, li->targetpath, li->list[x]);
1900 temp = li->list[x];
1901 li->list[x] = xstrdup(pszCmdLine, pszSrcFile, __LINE__);
1902 if (!li->list[x])
1903 li->list[x] = temp;
1904 else
1905 xfree(temp, pszSrcFile, __LINE__);
1906 }
1907 free(pszCmdLine);
1908 if (li->type == IDM_VIEW || li->type == IDM_EDIT) {
1909
1910 BOOL isit = TestBinary(li->list[0]);
1911
1912 if (isit) {
1913 if (li->type == IDM_VIEW)
1914 li->type = IDM_VIEWBINARY;
1915 else
1916 li->type = IDM_EDITBINARY;
1917 }
1918 else {
1919 if (li->type == IDM_VIEW)
1920 li->type = IDM_VIEWTEXT;
1921 else
1922 li->type = IDM_EDITTEXT;
1923 }
1924 }
1925 if (li->type == IDM_MCIPLAY) {
1926
1927 FILE *fp;
1928 CHAR szTempFile[CCHMAXPATH];
1929
1930 BldFullPathName(szTempFile, pTmpDir, "$FM2PLAY.$$$");
1931 fp = xfopen(szTempFile, "w", pszSrcFile, __LINE__);
1932 if (fp) {
1933 fprintf(fp, "%s", ";AV/2-built FM2Play listfile\n");
1934 for (x = 0; li->list[x]; x++)
1935 fprintf(fp, "%s\n", li->list[x]);
1936 fprintf(fp, ";end\n");
1937 fclose(fp);
1938 strrev(szTempFile);
1939 strcat(szTempFile, "@/");
1940 strrev(szTempFile);
1941 RunFM2Util("FM2PLAY.EXE", szTempFile);
1942 }
1943 }
1944 else if (li->type == IDM_PRINT) {
1945 strcpy(li->targetpath, printer);
1946 if (_beginthread(PrintListThread, NULL, 65536, (PVOID) li) !=
1947 -1) {
1948 Runtime_Error(pszSrcFile, __LINE__,
1949 GetPString(IDS_COULDNTSTARTTHREADTEXT));
1950 li = NULL;
1951 }
1952 }
1953 else if (li->type == IDM_VIEWARCHIVE) {
1954
1955 ARC_TYPE *info;
1956
1957 for (x = 0; li->list[x]; x++) {
1958 if (IsFile(li->list[x]) == 1) {
1959 info = NULL; // Do not hide dups - fixme to know why?
1960 if (WinDlgBox(HWND_DESKTOP, HWND_DESKTOP,
1961 SBoxDlgProc, FM3ModHandle, ASEL_FRAME,
1962 (PVOID) & info) && info) {
1963 StartArcCnr(HWND_DESKTOP,
1964 HWND_DESKTOP, li->list[x], 4, info);
1965 }
1966 }
1967 }
1968 }
1969 else if ((li->type == IDM_VIEWTEXT && *viewer) ||
1970 (li->type == IDM_VIEWBINARY && *binview) ||
1971 (li->type == IDM_EDITTEXT && *editor) ||
1972 (li->type == IDM_EDITBINARY && *bined)) {
1973 DosSleep(32); //05 Aug 07 GKY 100
1974 ExecOnList(hwnd, ((li->type == IDM_VIEWTEXT) ? viewer :
1975 (li->type == IDM_VIEWBINARY) ? binview :
1976 (li->type == IDM_EDITTEXT) ? editor :
1977 bined),
1978 WINDOWED | SEPARATE, li->targetpath, li->list,
1979 NULL, pszSrcFile, __LINE__);
1980 }
1981 else if (li->type == IDM_OPENDEFAULT ||
1982 li->type == IDM_OPENSETTINGS) {
1983 WORKER *wk;
1984# ifdef FORTIFY
1985 Fortify_EnterScope();
1986# endif
1987 wk = xmallocz(sizeof(WORKER), pszSrcFile, __LINE__);
1988 if (!wk)
1989 FreeListInfo(li);
1990 else {
1991 wk->size = sizeof(WORKER);
1992 wk->hwndCnr = dcd->hwndCnr;
1993 wk->hwndParent = dcd->hwndParent;
1994 wk->hwndFrame = dcd->hwndFrame;
1995 wk->hwndClient = dcd->hwndClient;
1996 wk->li = li;
1997 strcpy(wk->directory, dcd->directory);
1998 if (_beginthread(Action, NULL, 122880, (PVOID) wk) == -1) {
1999 Runtime_Error(pszSrcFile, __LINE__,
2000 GetPString(IDS_COULDNTSTARTTHREADTEXT));
2001 free(wk);
2002 FreeListInfo((LISTINFO *) mp1);
2003 }
2004 }
2005# ifdef FORTIFY
2006 Fortify_LeaveScope();
2007# endif
2008 }
2009 else {
2010 if (li->hwnd) {
2011
2012 ULONG viewtype;
2013
2014 for (x = 0; li->list[x]; x++) {
2015 if (x == 0) {
2016 if (li->type == IDM_VIEWBINARY ||
2017 li->type == IDM_EDITBINARY)
2018 viewtype = 16;
2019 else
2020 viewtype = 8;
2021 }
2022 else
2023 viewtype = 0;
2024# ifdef FORTIFY
2025 Fortify_EnterScope();
2026# endif
2027 temp = xstrdup(li->list[x], pszSrcFile, __LINE__);
2028 if (temp) {
2029 if (!PostMsg(WinQueryWindow(li->hwnd, QW_PARENT),
2030 UM_LOADFILE,
2031 MPFROMLONG(4L +
2032 (li->type == IDM_VIEWTEXT ||
2033 li->type == IDM_VIEWBINARY) +
2034 viewtype), MPFROMP(temp)))
2035 free(temp);
2036 }
2037# ifdef FORTIFY
2038 DosSleep(1); // Allow MassAction to take ownership
2039 Fortify_LeaveScope();
2040# endif
2041 }
2042 }
2043 }
2044 }
2045 }
2046 break;
2047
2048 case IDM_FIND:
2049 {
2050 UINT numfiles = 0, numalloced = 0;
2051 CHAR **list2 = NULL, fullname[CCHMAXPATH * 2], *p;
2052
2053 for (x = 0; li->list[x]; x++) {
2054 p = li->list[x];
2055 while (*p) {
2056 if (*p == '/')
2057 *p = '\\';
2058 p++;
2059 }
2060 BldFullPathName(fullname, dcd->directory, li->list[x]);
2061 if (IsFile(fullname) != -1)
2062 if (AddToList(fullname, &list2, &numfiles, &numalloced))
2063 break;
2064 if (strchr(li->list[x], '\\')) {
2065 p = strrchr(li->list[x], '\\');
2066 if (p) {
2067 p++;
2068 if (*p) {
2069 BldFullPathName(fullname, dcd->directory, p);
2070 if (IsFile(fullname) != -1)
2071 if (AddToList(fullname, &list2, &numfiles, &numalloced))
2072 break;
2073 }
2074 }
2075 }
2076 }
2077 if (!numfiles || !list2)
2078 Runtime_Error(pszSrcFile, __LINE__, "no files or list");
2079 else {
2080 WinSendMsg(dcd->hwndCnr, WM_COMMAND,
2081 MPFROM2SHORT(IDM_COLLECTOR, 0), MPVOID);
2082 DosSleep(10); //05 Aug 07 GKY 128
2083 if (Collector) {
2084 if (!PostMsg(Collector, WM_COMMAND,
2085 MPFROM2SHORT(IDM_COLLECTOR, 0), MPFROMP(list2)))
2086 FreeList(list2);
2087 }
2088 else
2089 FreeList(list2);
2090 }
2091 }
2092 break;
2093 }
2094 }
2095 if (li->type != IDM_OPENDEFAULT && li->type != IDM_OPENSETTINGS)
2096 {
2097 FreeListInfo(li);
2098 }
2099 }
2100 return 0;
2101
2102 case WM_CLOSE:
2103 WinDestroyWindow(hwnd);
2104 break;
2105
2106 case WM_DESTROY:
2107 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
2108 if (dcd) {
2109 if (*dcd->workdir) {
2110 DosSleep(16); //05 Aug 07 GKY 33
2111 wipeallf("%s\\*", dcd->workdir);
2112 if (rmdir(dcd->workdir)) {
2113 DosSleep(100); //05 Aug 07 GKY 256
2114 wipeallf("%s\\*", dcd->workdir);
2115 rmdir(dcd->workdir);
2116 }
2117 }
2118 FreeList(dcd->lastselection);
2119 WinSendMsg(dcd->hwndCnr, UM_CLOSE, MPVOID, MPVOID);
2120 free(dcd);
2121# ifdef FORTIFY
2122 Fortify_LeaveScope();
2123# endif
2124 WinSetWindowPtr(dcd->hwndCnr, QWL_USER, NULL);
2125 }
2126 if (!PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID))
2127 WinSendMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID);
2128 break;
2129 } // switch
2130 return WinDefWindowProc(hwnd, msg, mp1, mp2);
2131}
2132
2133static MRESULT EXPENTRY ArcCnrWndProc(HWND hwnd, ULONG msg, MPARAM mp1,
2134 MPARAM mp2)
2135{
2136 DIRCNRDATA *dcd = INSTDATA(hwnd);
2137 CHAR szQuotedArcName[CCHMAXPATH];
2138
2139 switch (msg) {
2140 case DM_PRINTOBJECT:
2141 case DM_DISCARDOBJECT:
2142 if (dcd)
2143 return WinSendMsg(dcd->hwndObject, msg, mp1, mp2);
2144 else
2145 return MRFROMLONG(DRR_TARGET);
2146
2147 case WM_CHAR:
2148 shiftstate = (SHORT1FROMMP(mp1) & (KC_SHIFT | KC_ALT | KC_CTRL));
2149 if (SHORT1FROMMP(mp1) & KC_KEYUP)
2150 return (MRESULT) TRUE;
2151 if (SHORT1FROMMP(mp1) & KC_VIRTUALKEY) {
2152 switch (SHORT2FROMMP(mp2)) {
2153 case VK_DELETE:
2154 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_DELETE, 0), MPVOID);
2155 break;
2156 }
2157 }
2158 if (shiftstate || fNoSearch)
2159 break;
2160 if (SHORT1FROMMP(mp1) & KC_CHAR) {
2161
2162 ULONG thistime, len;
2163 SEARCHSTRING srch;
2164 PCNRITEM pci;
2165
2166 if (!dcd)
2167 break;
2168 switch (SHORT1FROMMP(mp2)) {
2169 case '\x1b':
2170 case '\r':
2171 case '\n':
2172 dcd->lasttime = 0;
2173 *dcd->szCommonName = 0;
2174 break;
2175 default:
2176 thistime = WinQueryMsgTime(WinQueryAnchorBlock(hwnd));
2177 if (thistime > dcd->lasttime + 1250)
2178 *dcd->szCommonName = 0;
2179 dcd->lasttime = thistime;
2180 if (SHORT1FROMMP(mp2) == ' ' && !*dcd->szCommonName)
2181 break;
2182 KbdRetry:
2183 len = strlen(dcd->szCommonName);
2184 if (len >= CCHMAXPATH - 1) {
2185 *dcd->szCommonName = 0;
2186 len = 0;
2187 }
2188 dcd->szCommonName[len] = toupper(SHORT1FROMMP(mp2));
2189 dcd->szCommonName[len + 1] = 0;
2190 memset(&srch, 0, sizeof(SEARCHSTRING));
2191 srch.cb = (ULONG) sizeof(SEARCHSTRING);
2192 srch.pszSearch = dcd->szCommonName;
2193 srch.fsPrefix = TRUE;
2194 srch.fsCaseSensitive = FALSE;
2195 srch.usView = CV_ICON;
2196 pci = WinSendMsg(hwnd,
2197 CM_SEARCHSTRING,
2198 MPFROMP(&srch), MPFROMLONG(CMA_FIRST));
2199 if (pci && (INT) pci != -1) {
2200
2201 USHORT attrib = CRA_CURSORED;
2202
2203
2204 /* make found item current item */
2205 if (!stricmp(pci->pszFileName, dcd->szCommonName))
2206 attrib |= CRA_SELECTED;
2207 WinSendMsg(hwnd,
2208 CM_SETRECORDEMPHASIS,
2209 MPFROMP(pci), MPFROM2SHORT(TRUE, attrib));
2210 /* make sure that record shows in viewport */
2211 ShowCnrRecord(hwnd, (PMINIRECORDCORE) pci);
2212 return (MRESULT) TRUE;
2213 }
2214 else {
2215 if (SHORT1FROMMP(mp2) == ' ') {
2216 dcd->szCommonName[len] = 0;
2217 break;
2218 }
2219 *dcd->szCommonName = 0;
2220 dcd->lasttime = 0;
2221 if (len) // retry as first letter if no match
2222 goto KbdRetry;
2223 }
2224 break;
2225 }
2226 }
2227 break;
2228
2229 case WM_MOUSEMOVE:
2230 case WM_BUTTON1UP:
2231 case WM_BUTTON2UP:
2232 case WM_BUTTON3UP:
2233 case WM_CHORD:
2234 shiftstate = (SHORT2FROMMP(mp2) & (KC_SHIFT | KC_ALT | KC_CTRL));
2235 break;
2236
2237 case WM_BUTTON1MOTIONEND:
2238 {
2239 CNRINFO cnri;
2240
2241 memset(&cnri, 0, sizeof(CNRINFO));
2242 cnri.cb = sizeof(CNRINFO);
2243 if (WinSendMsg(hwnd,
2244 CM_QUERYCNRINFO,
2245 MPFROMP(&cnri), MPFROMLONG(sizeof(CNRINFO)))) {
2246 if (cnri.flWindowAttr & CV_DETAIL)
2247 PrfWriteProfileData(fmprof,
2248 appname,
2249 "ArcCnrSplitBar",
2250 (PVOID) & cnri.xVertSplitbar, sizeof(LONG));
2251 }
2252 }
2253 break;
2254
2255 case WM_PRESPARAMCHANGED:
2256 PresParamChanged(hwnd, "ArcCnr", mp1, mp2);
2257 break;
2258
2259 case UM_UPDATERECORD:
2260 case UM_UPDATERECORDLIST:
2261 if (dcd && !IsArcThere(hwnd, dcd->arcname))
2262 PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
2263 return 0;
2264
2265 case WM_SETFOCUS:
2266 /*
2267 * put name of our window (archive name) on status line
2268 */
2269 if (dcd && hwndStatus && mp2)
2270 WinSendMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
2271 break;
2272
2273 case UM_SETUP2:
2274 if (dcd && dcd->info) {
2275 if (dcd->info->fdpos == -1 || !dcd->info->datetype)
2276 dcd->sortFlags &= (~SORT_LWDATE);
2277 if (dcd->info->nsizepos == -1)
2278 dcd->sortFlags &= (~SORT_EASIZE);
2279 if (dcd->info->osizepos == -1)
2280 dcd->sortFlags &= (~SORT_SIZE);
2281 AdjustCnrColVis(hwnd,
2282 GetPString(IDS_OLDSIZECOLTEXT),
2283 dcd->info->osizepos != -1, FALSE);
2284 AdjustCnrColVis(hwnd,
2285 GetPString(IDS_NEWSIZECOLTEXT),
2286 dcd->info->nsizepos != -1, FALSE);
2287 // Display unsullied date/time string if type 0
2288 AdjustCnrColVis(hwnd,
2289 GetPString(IDS_DATETIMECOLTEXT),
2290 dcd->info->fdpos != -1 && !dcd->info->datetype, FALSE);
2291 // Display parsed date/time columns if type specified
2292 AdjustCnrColVis(hwnd,
2293 GetPString(IDS_TIMECOLTEXT),
2294 dcd->info->fdpos != -1 && dcd->info->datetype, FALSE);
2295 AdjustCnrColVis(hwnd,
2296 GetPString(IDS_DATECOLTEXT),
2297 dcd->info->fdpos != -1 && dcd->info->datetype, FALSE);
2298 WinSendMsg(hwnd, CM_INVALIDATEDETAILFIELDINFO, MPVOID, MPVOID);
2299 }
2300 return 0;
2301
2302 case UM_RESCAN:
2303 if (dcd) {
2304 CNRINFO cnri;
2305 CHAR s[CCHMAXPATH * 2], tb[81], tf[81];
2306 PARCITEM pci;
2307
2308 if (mp1) {
2309 PostMsg(dcd->hwndObject, UM_RESCAN, MPVOID, MPVOID);
2310 return 0;
2311 }
2312 memset(&cnri, 0, sizeof(CNRINFO));
2313 cnri.cb = sizeof(CNRINFO);
2314 WinSendMsg(hwnd,
2315 CM_QUERYCNRINFO,
2316 MPFROMP(&cnri), MPFROMLONG(sizeof(CNRINFO)));
2317 dcd->totalfiles = cnri.cRecords;
2318 commafmt(tf, sizeof(tf), dcd->selectedfiles);
2319 if (dcd->ullTotalBytes)
2320 CommaFmtULL(tb, sizeof(tb), dcd->selectedbytes, 'K');
2321 else
2322 *tb = 0;
2323 sprintf(s, "%s%s%s", tf, *tb ? " / " : NullStr, tb);
2324 WinSetDlgItemText(dcd->hwndClient, DIR_SELECTED, s);
2325 commafmt(tf, sizeof(tf), dcd->totalfiles);
2326 if (dcd->ullTotalBytes)
2327 CommaFmtULL(tb, sizeof(tb), dcd->ullTotalBytes, 'K');
2328 else
2329 *tb = 0;
2330 sprintf(s, "%s%s%s", tf, *tb ? " / " : NullStr, tb);
2331 WinSetDlgItemText(dcd->hwndClient, DIR_TOTALS, s);
2332 if (hwndStatus &&
2333 dcd->hwndFrame == WinQueryActiveWindow(dcd->hwndParent)) {
2334 sprintf(s, " [%s%s%s]%s%s%s %s",
2335 tf,
2336 *tb ? " / " : NullStr,
2337 tb,
2338 *dcd->mask.szMask ? " (" : NullStr,
2339 *dcd->mask.szMask ? dcd->mask.szMask : NullStr,
2340 *dcd->mask.szMask ? ")" : NullStr, dcd->arcname);
2341 WinSetWindowText(hwndStatus, s);
2342 if (!ParentIsDesktop(hwnd, dcd->hwndParent)) {
2343 pci = WinSendMsg(hwnd,
2344 CM_QUERYRECORDEMPHASIS,
2345 MPFROMLONG(CMA_FIRST), MPFROMSHORT(CRA_CURSORED));
2346 if (pci && (INT) pci != -1) {
2347 if (fSplitStatus && hwndStatus2) {
2348 if (dcd->ullTotalBytes)
2349 CommaFmtULL(tb, sizeof(tb), pci->cbFile, ' ');
2350 else
2351 *tb = 0;
2352 sprintf(s, "%s%s%s%s",
2353 *tb ? " " : NullStr,
2354 tb, *tb ? " " : NullStr, pci->pszFileName);
2355 WinSetWindowText(hwndStatus2, s);
2356 }
2357 if (fMoreButtons)
2358 WinSetWindowText(hwndName, pci->pszFileName);
2359 }
2360 else {
2361 WinSetWindowText(hwndStatus2, NullStr);
2362 WinSetWindowText(hwndName, NullStr);
2363 }
2364 WinSetWindowText(hwndDate, NullStr);
2365 WinSetWindowText(hwndAttr, NullStr);
2366 }
2367 }
2368 if ((dcd->arcfilled && !dcd->totalfiles) ||
2369 !IsArcThere(hwnd, dcd->arcname))
2370 PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
2371 }
2372 return 0;
2373
2374 case UM_SETUP:
2375 if (!dcd) {
2376 Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
2377 PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
2378 return 0;
2379 }
2380 else {
2381 if (!dcd->hwndObject) {
2382 /*
2383 * first time through -- set things up
2384 */
2385 {
2386 CHAR *p, *pp;
2387 ULONG z, was;
2388 APIRET rc;
2389
2390 rc = DosCreateDir(dcd->workdir, 0);
2391 if (rc) {
2392 if (rc == ERROR_ACCESS_DENIED) {
2393 p = strrchr(dcd->workdir, '.');
2394 if (p) {
2395 p++;
2396 pp = p;
2397 was = strtoul(p, &pp, 16);
2398 for (z = 0; z < 99; z++) {
2399 was++;
2400 sprintf(p, "%03x");
2401 rc = DosCreateDir(dcd->workdir, 0);
2402 if (!rc || rc != ERROR_ACCESS_DENIED)
2403 break;
2404 }
2405 }
2406 }
2407 if (rc)
2408 PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
2409 return 0;
2410 }
2411 }
2412 RestorePresParams(hwnd, "ArcCnr");
2413 dcd->mask.fNoAttribs = TRUE;
2414 dcd->mask.fNoDirs = TRUE;
2415 *dcd->mask.prompt = 0;
2416 {
2417 PFIELDINFO pfi, pfiLastLeftCol;
2418 ULONG numcols = CON_COLS;
2419 CNRINFO cnri;
2420 ULONG size;
2421
2422 pfi = WinSendMsg(hwnd,
2423 CM_ALLOCDETAILFIELDINFO,
2424 MPFROMLONG(numcols), NULL);
2425 if (pfi) {
2426
2427 PFIELDINFO pfiFirst;
2428 FIELDINFOINSERT fii;
2429
2430 pfiFirst = pfi;
2431 pfi->flData = CFA_STRING | CFA_LEFT | CFA_FIREADONLY;
2432 pfi->flTitle = CFA_CENTER;
2433 pfi->pTitleData = GetPString(IDS_FILENAMECOLTEXT);
2434 pfi->offStruct = FIELDOFFSET(ARCITEM, pszDisplayName);
2435 pfiLastLeftCol = pfi;
2436 pfi = pfi->pNextFieldInfo;
2437 pfi->flData =
2438 CFA_ULONG | CFA_RIGHT | CFA_SEPARATOR | CFA_FIREADONLY;
2439 pfi->flTitle = CFA_CENTER;
2440 pfi->pTitleData = GetPString(IDS_OLDSIZECOLTEXT);
2441 pfi->offStruct = FIELDOFFSET(ARCITEM, cbFile);
2442 pfi = pfi->pNextFieldInfo;
2443 pfi->flData =
2444 CFA_ULONG | CFA_RIGHT | CFA_SEPARATOR | CFA_FIREADONLY;
2445 pfi->flTitle = CFA_CENTER;
2446 pfi->pTitleData = GetPString(IDS_NEWSIZECOLTEXT);
2447 pfi->offStruct = FIELDOFFSET(ARCITEM, cbComp);
2448 pfi = pfi->pNextFieldInfo;
2449 pfi->flData =
2450 CFA_STRING | CFA_CENTER | CFA_SEPARATOR | CFA_FIREADONLY;
2451 pfi->flTitle = CFA_CENTER | CFA_FITITLEREADONLY;
2452 pfi->pTitleData = GetPString(IDS_DATETIMECOLTEXT);
2453 pfi->offStruct = FIELDOFFSET(ARCITEM, pszDate);
2454 pfi = pfi->pNextFieldInfo;
2455 pfi->flData = CFA_DATE | CFA_RIGHT | CFA_FIREADONLY;
2456 pfi->flTitle = CFA_CENTER;
2457 pfi->pTitleData = GetPString(IDS_DATECOLTEXT);
2458 pfi->offStruct = FIELDOFFSET(ARCITEM, date);
2459 pfi = pfi->pNextFieldInfo;
2460 pfi->flData = CFA_TIME | CFA_RIGHT | CFA_FIREADONLY;
2461 pfi->flTitle = CFA_CENTER | CFA_FITITLEREADONLY;
2462 pfi->pTitleData = GetPString(IDS_TIMECOLTEXT);
2463 pfi->offStruct = FIELDOFFSET(ARCITEM, time);
2464 memset(&fii, 0, sizeof(FIELDINFOINSERT));
2465 fii.cb = sizeof(FIELDINFOINSERT);
2466 fii.pFieldInfoOrder = (PFIELDINFO) CMA_FIRST;
2467 fii.cFieldInfoInsert = (SHORT) numcols;
2468 fii.fInvalidateFieldInfo = TRUE;
2469 WinSendMsg(hwnd,
2470 CM_INSERTDETAILFIELDINFO,
2471 MPFROMP(pfiFirst), MPFROMP(&fii));
2472 PostMsg(hwnd, UM_SETUP2, MPVOID, MPVOID);
2473
2474 memset(&cnri, 0, sizeof(cnri));
2475 cnri.cb = sizeof(CNRINFO);
2476 cnri.pFieldInfoLast = pfiLastLeftCol;
2477 cnri.xVertSplitbar = DIR_SPLITBAR_OFFSET + 32;
2478
2479 size = sizeof(LONG);
2480 PrfQueryProfileData(fmprof, appname, "ArcCnrSplitBar",
2481 &cnri.xVertSplitbar, &size);
2482 if (cnri.xVertSplitbar <= 0)
2483 cnri.xVertSplitbar = DIR_SPLITBAR_OFFSET + 32;
2484
2485 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT | CV_NAME));
2486 cnri.flWindowAttr |= (CV_DETAIL | CA_DETAILSVIEWTITLES | CV_FLOW);
2487 cnri.flWindowAttr &= (~(CA_ORDEREDTARGETEMPH |
2488 CA_MIXEDTARGETEMPH));
2489 cnri.pSortRecord = (PVOID) ArcSort;
2490 WinSendMsg(hwnd,
2491 CM_SETCNRINFO,
2492 MPFROMP(&cnri),
2493 MPFROMLONG(CMA_PFIELDINFOLAST |
2494 CMA_XVERTSPLITBAR |
2495 CMA_PSORTRECORD | CMA_FLWINDOWATTR));
2496 }
2497 }
2498 WinSendMsg(hwnd, CM_SORTRECORD, MPFROMP(ArcSort), MPFROMP(dcd));
2499 if (_beginthread(MakeObjWin, NULL, 245760, (PVOID) dcd) == -1) {
2500 Runtime_Error(pszSrcFile, __LINE__,
2501 GetPString(IDS_COULDNTSTARTTHREADTEXT));
2502 PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
2503 return 0;
2504 }
2505 else
2506 DosSleep(1);
2507 SayFilter(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
2508 DIR_FILTER), &dcd->mask, TRUE);
2509 SaySort(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
2510 DIR_SORT), dcd->sortFlags, TRUE);
2511 DefArcSortFlags = dcd->sortFlags; // Remember for new windows
2512 }
2513 }
2514 return 0;
2515
2516 case UM_SETDIR:
2517 if (dcd) {
2518
2519 CHAR s[CCHMAXPATH], *p;
2520 ULONG ret = 0;
2521
2522 WinQueryDlgItemText(dcd->hwndClient, ARC_EXTRACTDIR, CCHMAXPATH, s);
2523 bstrip(s);
2524 MakeFullName(s);
2525 if (*s) {
2526 while ((p = strchr(s, '/')) != NULL)
2527 *p = '\\';
2528 while (strlen(s) > 3 && s[strlen(s) - 1] == '\\')
2529 s[strlen(s) - 1] = 0;
2530 if (stricmp(s, dcd->directory)) {
2531 if (IsFullName(s)) {
2532 if (driveflags[toupper(*s) - 'A'] &
2533 (DRIVE_NOTWRITEABLE | DRIVE_IGNORE | DRIVE_INVALID)) {
2534 Runtime_Error(pszSrcFile, __LINE__, "drive %s bad", s);
2535 WinSetDlgItemText(dcd->hwndClient,
2536 ARC_EXTRACTDIR, dcd->directory);
2537 return 0;
2538 }
2539 }
2540 if (!SetDir(dcd->hwndParent, hwnd, s, 0)) {
2541 if (stricmp(dcd->directory, s)) {
2542 DosEnterCritSec();
2543 strcpy(lastextractpath, s);
2544 DosExitCritSec();
2545 }
2546 strcpy(dcd->directory, s);
2547 if ((!isalpha(*s) || s[1] != ':') && *s != '.')
2548 saymsg(MB_ENTER | MB_ICONASTERISK,
2549 hwnd,
2550 GetPString(IDS_WARNINGTEXT),
2551 GetPString(IDS_SPECIFYDRIVETEXT));
2552 }
2553 else
2554 ret = 1;
2555 }
2556 }
2557 WinSetDlgItemText(dcd->hwndClient, ARC_EXTRACTDIR, dcd->directory);
2558 return (MRESULT) ret;
2559 }
2560 return 0;
2561
2562 case UM_ENTER:
2563 if (WinSendMsg(hwnd, UM_SETDIR, MPVOID, MPVOID))
2564 return 0;
2565 SetShiftState();
2566 if (dcd && (CHAR *) mp1) {
2567
2568 SWP swp;
2569 CHAR *filename = mp1;
2570
2571 if (IsFile(filename) != 1)
2572 return 0;
2573 WinQueryWindowPos(dcd->hwndFrame, &swp);
2574 DefaultViewKeys(hwnd, dcd->hwndFrame, dcd->hwndParent, &swp, filename);
2575 if (fUnHilite)
2576 UnHilite(hwnd, FALSE, &dcd->lastselection, 0);
2577 }
2578 return 0;
2579
2580 case WM_MENUEND:
2581 if (dcd) {
2582
2583 HWND hwndMenu = (HWND) mp2;
2584
2585 if (hwndMenu == ArcCnrMenu || hwndMenu == ArcMenu) {
2586 MarkAll(hwnd, TRUE, FALSE, TRUE);
2587 if (dcd->cnremphasized) {
2588 WinSendMsg(hwnd,
2589 CM_SETRECORDEMPHASIS,
2590 MPVOID, MPFROM2SHORT(FALSE, CRA_SOURCE));
2591 dcd->cnremphasized = FALSE;
2592 }
2593 }
2594 }
2595 break;
2596
2597 case MM_PORTHOLEINIT:
2598 if (dcd) {
2599 switch (SHORT1FROMMP(mp1)) {
2600 case 0:
2601 case 1:
2602 {
2603 ULONG wmsg;
2604
2605 wmsg = SHORT1FROMMP(mp1) == 0 ? UM_FILESMENU : UM_VIEWSMENU;
2606 PortholeInit((HWND) WinSendMsg(dcd->hwndClient,
2607 wmsg, MPVOID, MPVOID), mp1, mp2);
2608 }
2609 break;
2610 }
2611 }
2612 break;
2613
2614 case UM_INITMENU:
2615 case WM_INITMENU:
2616 if (dcd) {
2617 switch (SHORT1FROMMP(mp1)) {
2618 case IDM_FILESMENU:
2619 if (dcd->info) {
2620 WinEnableMenuItem((HWND) mp2,
2621 IDM_DELETE, dcd->info->delete != NULL);
2622 WinEnableMenuItem((HWND) mp2, IDM_TEST, dcd->info->test != NULL);
2623 WinEnableMenuItem((HWND) mp2,
2624 IDM_EXTRACT, dcd->info->extract != NULL);
2625 WinEnableMenuItem((HWND) mp2,
2626 IDM_EXTRACTWDIRS, dcd->info->exwdirs != NULL);
2627 WinEnableMenuItem((HWND) mp2,
2628 IDM_ARCEXTRACTWDIRS, dcd->info->exwdirs != NULL);
2629 WinEnableMenuItem((HWND) mp2,
2630 IDM_ARCEXTRACTWDIRSEXIT,
2631 dcd->info->exwdirs != NULL);
2632 }
2633 break;
2634
2635 case IDM_VIEWSMENU:
2636 WinCheckMenuItem((HWND) mp2,
2637 IDM_MINIICONS, (dcd->flWindowAttr & CV_MINI) != 0);
2638 WinEnableMenuItem((HWND) mp2,
2639 IDM_RESELECT, (dcd->lastselection != NULL));
2640 break;
2641
2642 case IDM_COMMANDSMENU:
2643 SetupCommandMenu((HWND) mp2, hwnd);
2644 break;
2645
2646 case IDM_SORTSUBMENU:
2647 SetSortChecks((HWND) mp2, dcd->sortFlags);
2648 break;
2649
2650 case IDM_WINDOWSMENU:
2651 /*
2652 * add switchlist entries to end of pulldown menu
2653 */
2654 SetupWinList((HWND)mp2,
2655 hwndMain ? hwndMain : (HWND)0, dcd->hwndFrame);
2656 break;
2657 }
2658 dcd->hwndLastMenu = (HWND) mp2;
2659 }
2660 if (msg == WM_INITMENU)
2661 break;
2662 return 0;
2663
2664 case UM_LOADFILE:
2665 if (dcd && mp2) {
2666
2667 HWND hwnd;
2668
2669 if ((INT)mp1 == 5 || (INT)mp1 == 13 || (INT)mp1 == 21)
2670 hwnd = StartViewer(HWND_DESKTOP, (INT)mp1,
2671 (CHAR *)mp2, dcd->hwndFrame);
2672 else
2673 hwnd = StartMLEEditor(dcd->hwndParent,
2674 (INT)mp1, (CHAR *)mp2, dcd->hwndFrame);
2675 free((CHAR *)mp2);
2676 return MRFROMLONG(hwnd);
2677 }
2678 return 0;
2679
2680 case UM_COMMAND:
2681 if (mp1) {
2682 if (dcd) {
2683 if (!PostMsg(dcd->hwndObject, UM_COMMAND, mp1, mp2)) {
2684 Runtime_Error(pszSrcFile, __LINE__, "post");
2685 FreeListInfo((LISTINFO *) mp1);
2686 }
2687 else
2688 return (MRESULT) TRUE;
2689 }
2690 else
2691 FreeListInfo((LISTINFO *) mp1);
2692 }
2693 return 0;
2694
2695 case UM_OPENWINDOWFORME:
2696 if (dcd) {
2697 if (mp1 && !IsFile((CHAR *) mp1)) {
2698 OpenDirCnr((HWND) 0, hwndMain, dcd->hwndFrame, FALSE, (char *)mp1);
2699 }
2700 else if (mp1 && IsFile(mp1) == 1 &&
2701 CheckDriveSpaceAvail(ArcTempRoot, ullDATFileSpaceNeeded, ullTmpSpaceNeeded) != 2) {
2702 StartArcCnr(HWND_DESKTOP,
2703 dcd->hwndFrame, (CHAR *) mp1, 4, (ARC_TYPE *) mp2);
2704 }
2705 }
2706 return 0;
2707
2708 case WM_COMMAND:
2709 DosError(FERR_DISABLEHARDERR);
2710 if (dcd) {
2711 if (SwitchCommand(dcd->hwndLastMenu, SHORT1FROMMP(mp1)))
2712 return 0;
2713 if (WinSendMsg(hwnd, UM_SETDIR, MPVOID, MPVOID))
2714 return 0;
2715 if (!IsArcThere(hwnd, dcd->arcname)) {
2716 PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
2717 return 0;
2718 }
2719 switch (SHORT1FROMMP(mp1)) {
2720 case IDM_TREEVIEW:
2721
2722 break;
2723
2724 case IDM_CONTEXTMENU:
2725 {
2726 PCNRITEM pci;
2727
2728 pci = (PCNRITEM) CurrentRecord(hwnd);
2729 PostMsg(hwnd,
2730 WM_CONTROL,
2731 MPFROM2SHORT(ARC_CNR, CN_CONTEXTMENU), MPFROMP(pci));
2732 }
2733 break;
2734
2735 case IDM_NEXTWINDOW:
2736 case IDM_PREVWINDOW:
2737 {
2738 HWND hwndActive;
2739
2740 hwndActive = WinQueryFocus(HWND_DESKTOP);
2741 WinSetFocus(HWND_DESKTOP,
2742 hwndActive == hwnd ?
2743 WinWindowFromID(dcd->hwndClient, ARC_EXTRACTDIR) :
2744 hwnd);
2745 }
2746 break;
2747
2748 case IDM_FOLDERAFTEREXTRACT:
2749 fFolderAfterExtract = fFolderAfterExtract ? FALSE : TRUE;
2750 PrfWriteProfileData(fmprof, appname, "FolderAfterExtract",
2751 &fFolderAfterExtract, sizeof(BOOL));
2752 break;
2753
2754 case IDM_SHOWSELECT:
2755 QuickPopup(hwnd, dcd, CheckMenu(hwnd, &ArcCnrMenu, ARCCNR_POPUP),
2756 IDM_SELECTSUBMENU);
2757 break;
2758
2759 case IDM_SHOWSORT:
2760 QuickPopup(hwnd, dcd, CheckMenu(hwnd, &ArcCnrMenu, ARCCNR_POPUP),
2761 IDM_SORTSUBMENU);
2762 break;
2763
2764 case IDM_ARCHIVERSETTINGS:
2765 if (!ParentIsDesktop(dcd->hwndParent, dcd->hwndParent))
2766 PostMsg(dcd->hwndParent, msg, MPFROMLONG(IDM_ARCHIVERSETTINGS), mp2);
2767 else {
2768 WinDlgBox(HWND_DESKTOP,
2769 hwnd,
2770 CfgDlgProc,
2771 FM3ModHandle,
2772 CFG_FRAME,
2773 MPFROMLONG(IDM_ARCHIVERSETTINGS));
2774 }
2775 break;
2776
2777 case IDM_RESCAN:
2778 dcd->ullTotalBytes = dcd->totalfiles =
2779 dcd->selectedfiles = dcd->selectedbytes = 0;
2780 WinSetDlgItemText(dcd->hwndClient, DIR_TOTALS, "0");
2781 WinSetDlgItemText(dcd->hwndClient, DIR_SELECTED, "0 / 0k");
2782 dcd->totalfiles = FillArcCnr(dcd->hwndCnr,
2783 dcd->arcname,
2784 &dcd->info,
2785 &dcd->ullTotalBytes, &dcd->stopflag);
2786 PostMsg(dcd->hwndCnr, UM_RESCAN, MPVOID, MPVOID);
2787 PostMsg(dcd->hwndCnr, UM_SETUP2, MPVOID, MPVOID);
2788 WinSendMsg(dcd->hwndCnr,
2789 CM_INVALIDATERECORD,
2790 MPVOID, MPFROM2SHORT(0, CMA_ERASE | CMA_REPOSITION));
2791 break;
2792
2793 case IDM_RESELECT:
2794 SelectList(hwnd, TRUE, FALSE, FALSE, NULL, NULL, dcd->lastselection);
2795 break;
2796
2797 case IDM_HELP:
2798 if (hwndHelp)
2799 WinSendMsg(hwndHelp,
2800 HM_DISPLAY_HELP,
2801 MPFROM2SHORT(HELP_ARCLIST, 0),
2802 MPFROMSHORT(HM_RESOURCEID));
2803 break;
2804
2805 case IDM_WINDOWDLG:
2806 if (!ParentIsDesktop(dcd->hwndParent, dcd->hwndFrame))
2807 PostMsg(dcd->hwndParent,
2808 UM_COMMAND, MPFROM2SHORT(IDM_WINDOWDLG, 0), MPVOID);
2809 break;
2810
2811 case IDM_SELECTALL:
2812 case IDM_SELECTALLFILES:
2813 case IDM_DESELECTALL:
2814 case IDM_DESELECTALLFILES:
2815 case IDM_SELECTMASK:
2816 case IDM_DESELECTMASK:
2817 case IDM_INVERT:
2818 {
2819 PARCITEM pci;
2820
2821 pci = (PARCITEM) WinSendMsg(hwnd,
2822 CM_QUERYRECORDEMPHASIS,
2823 MPFROMLONG(CMA_FIRST),
2824 MPFROMSHORT(CRA_CURSORED));
2825 if ((INT) pci == -1)
2826 pci = NULL;
2827 if (SHORT1FROMMP(mp1) == IDM_HIDEALL) {
2828 if (pci) {
2829 if (!(pci->rc.flRecordAttr & CRA_SELECTED))
2830 pci->rc.flRecordAttr |= CRA_FILTERED;
2831 WinSendMsg(hwnd,
2832 CM_INVALIDATERECORD,
2833 MPFROMP(&pci),
2834 MPFROM2SHORT(1, CMA_ERASE | CMA_REPOSITION));
2835 break;
2836 }
2837 }
2838 PostMsg(dcd->hwndObject, UM_SELECT, mp1, MPFROMP(pci));
2839 }
2840 break;
2841
2842 case IDM_SORTSMARTNAME:
2843 case IDM_SORTNAME:
2844 case IDM_SORTFILENAME:
2845 case IDM_SORTSIZE:
2846 case IDM_SORTEASIZE:
2847 case IDM_SORTFIRST:
2848 case IDM_SORTLAST:
2849 case IDM_SORTLWDATE:
2850 dcd->sortFlags &= SORT_REVERSE;
2851 /* intentional fallthru */
2852 case IDM_SORTREVERSE:
2853 switch (SHORT1FROMMP(mp1)) {
2854 case IDM_SORTSMARTNAME:
2855 case IDM_SORTFILENAME:
2856 dcd->sortFlags |= SORT_FILENAME;
2857 break;
2858 case IDM_SORTSIZE:
2859 dcd->sortFlags |= SORT_SIZE;
2860 break;
2861 case IDM_SORTEASIZE:
2862 dcd->sortFlags |= SORT_EASIZE;
2863 break;
2864 case IDM_SORTFIRST:
2865 dcd->sortFlags |= SORT_FIRSTEXTENSION;
2866 break;
2867 case IDM_SORTLAST:
2868 dcd->sortFlags |= SORT_LASTEXTENSION;
2869 break;
2870 case IDM_SORTLWDATE:
2871 dcd->sortFlags |= SORT_LWDATE;
2872 break;
2873 case IDM_SORTREVERSE:
2874 if (dcd->sortFlags & SORT_REVERSE)
2875 dcd->sortFlags &= (~SORT_REVERSE);
2876 else
2877 dcd->sortFlags |= SORT_REVERSE;
2878 break;
2879 }
2880 WinSendMsg(hwnd, CM_SORTRECORD, MPFROMP(ArcSort), MPFROMP(dcd));
2881 SaySort(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
2882 DIR_SORT), dcd->sortFlags, TRUE);
2883 DefArcSortFlags = dcd->sortFlags; // Remember for new windows
2884 break;
2885
2886 case IDM_COLLECTOR:
2887 if (!Collector) {
2888 HWND hwndC;
2889 SWP swp;
2890
2891 if (ParentIsDesktop(hwnd, dcd->hwndParent) && !fAutoTile &&
2892 (!fExternalCollector && !strcmp(realappname, FM3Str)))
2893 GetNextWindowPos(dcd->hwndParent, &swp, NULL, NULL);
2894 hwndC = StartCollector(fExternalCollector ||
2895 strcmp(realappname, FM3Str) ?
2896 HWND_DESKTOP : dcd->hwndParent, 4);
2897 if (hwndC) {
2898 if (!ParentIsDesktop(hwnd, dcd->hwndParent) && !fAutoTile &&
2899 (!fExternalCollector && !strcmp(realappname, FM3Str)))
2900 WinSetWindowPos(hwndC,
2901 HWND_TOP,
2902 swp.x,
2903 swp.y,
2904 swp.cx,
2905 swp.cy,
2906 SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_ZORDER);
2907 else if (!ParentIsDesktop(hwnd, dcd->hwndParent) &&
2908 fAutoTile && !strcmp(realappname, FM3Str)) {
2909 TileChildren(dcd->hwndParent, TRUE);
2910 }
2911 WinSetWindowPos(hwndC, HWND_TOP, 0, 0, 0, 0, SWP_ACTIVATE);
2912 DosSleep(100); //05 Aug 07 GKY 128
2913 }
2914 }
2915 else
2916 StartCollector(dcd->hwndParent, 4);
2917 break;
2918
2919 case IDM_ARCEXTRACTEXIT:
2920 case IDM_ARCEXTRACT:
2921 if (dcd->info->extract)
2922 runemf2(SEPARATE | WINDOWED |
2923 (fArcStuffVisible ? 0 : BACKGROUND | MINIMIZED),
2924 hwnd, pszSrcFile, __LINE__,
2925 dcd->directory, NULL, "%s %s", dcd->info->extract,
2926 BldQuotedFileName(szQuotedArcName, dcd->arcname));
2927 if (SHORT1FROMMP(mp1) == IDM_ARCEXTRACTEXIT)
2928 PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
2929 break;
2930
2931 case IDM_ARCEXTRACTWDIRSEXIT:
2932 case IDM_ARCEXTRACTWDIRS:
2933 if (dcd->info->exwdirs)
2934 runemf2(SEPARATE | WINDOWED |
2935 (fArcStuffVisible ? 0 : BACKGROUND | MINIMIZED),
2936 hwnd, pszSrcFile, __LINE__,
2937 dcd->directory, NULL, "%s %s",
2938 dcd->info->exwdirs,
2939 BldQuotedFileName(szQuotedArcName, dcd->arcname));
2940 if (SHORT1FROMMP(mp1) == IDM_ARCEXTRACTWDIRSEXIT)
2941 PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
2942 break;
2943
2944 case IDM_RESORT:
2945 WinSendMsg(hwnd, CM_SORTRECORD, MPFROMP(ArcSort), MPFROMP(dcd));
2946 break;
2947
2948 case IDM_FILTER:
2949 {
2950 BOOL empty = FALSE;
2951 PARCITEM pci;
2952
2953 if (!*dcd->mask.szMask) {
2954 empty = TRUE;
2955 pci = (PARCITEM) CurrentRecord(hwnd);
2956 if (pci && strchr(pci->pszFileName, '.'))
2957 strcpy(dcd->mask.szMask, pci->pszFileName);
2958 }
2959
2960 if (WinDlgBox(HWND_DESKTOP, hwnd, PickMaskDlgProc,
2961 FM3ModHandle, MSK_FRAME, MPFROMP(&dcd->mask))) {
2962 WinSendMsg(hwnd, CM_FILTER, MPFROMP(ArcFilter), MPFROMP(dcd));
2963 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
2964 }
2965 else if (empty)
2966 *dcd->mask.szMask = 0;
2967 SayFilter(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
2968 DIR_FILTER), &dcd->mask, TRUE);
2969 }
2970 break;
2971
2972 case IDM_SWITCH:
2973 if (mp2) {
2974 if (stricmp(dcd->directory, (CHAR *) mp2)) {
2975 DosEnterCritSec();
2976 strcpy(lastextractpath, (CHAR *) mp2);
2977 MakeValidDir(lastextractpath);
2978 DosExitCritSec();
2979 }
2980 strcpy(dcd->directory, (CHAR *) mp2);
2981 MakeValidDir(dcd->directory);
2982 WinSetWindowText(dcd->hwndExtract, dcd->directory);
2983 }
2984 break;
2985
2986 case IDM_WALKDIR:
2987 {
2988 CHAR newdir[CCHMAXPATH];
2989
2990 strcpy(newdir, dcd->directory);
2991 if (!WinDlgBox(HWND_DESKTOP, dcd->hwndParent, WalkExtractDlgProc,
2992 FM3ModHandle, WALK_FRAME,
2993 MPFROMP(newdir)) || !*newdir)
2994 break;
2995 if (stricmp(newdir, dcd->directory)) {
2996 strcpy(dcd->directory, newdir);
2997 if (stricmp(lastextractpath, newdir))
2998 strcpy(lastextractpath, newdir);
2999 WinSetWindowText(dcd->hwndExtract, dcd->directory);
3000 }
3001 }
3002 break;
3003
3004 case IDM_TEST:
3005 if (dcd->info->test)
3006 runemf2(SEPARATEKEEP | WINDOWED | MAXIMIZED,
3007 hwnd, pszSrcFile, __LINE__, NULL, NULL,
3008 "%s %s",dcd->info->test,
3009 BldQuotedFileName(szQuotedArcName, dcd->arcname));
3010 break;
3011
3012 case IDM_REFRESH:
3013 case IDM_DELETE:
3014 case IDM_PRINT:
3015 case IDM_VIEW:
3016 case IDM_VIEWTEXT:
3017 case IDM_VIEWBINARY:
3018 case IDM_VIEWARCHIVE:
3019 case IDM_EDIT:
3020 case IDM_EDITTEXT:
3021 case IDM_EDITBINARY:
3022 case IDM_EXTRACT:
3023 case IDM_EXTRACTWDIRS:
3024 case IDM_FIND:
3025 case IDM_EXEC:
3026 case IDM_VIRUSSCAN:
3027 case IDM_OPENDEFAULT:
3028 case IDM_OPENSETTINGS:
3029 case IDM_MCIPLAY:
3030 {
3031 LISTINFO *li;
3032# ifdef FORTIFY
3033 Fortify_EnterScope();
3034# endif
3035 li = xmallocz(sizeof(LISTINFO), pszSrcFile, __LINE__);
3036 if (li) {
3037 li->type = SHORT1FROMMP(mp1);
3038 li->hwnd = hwnd;
3039 li->list = BuildArcList(hwnd);
3040 if (li->type == IDM_REFRESH) {
3041
3042 CHAR s[CCHMAXPATH], *p;
3043 INT x, y;
3044
3045 for (x = 0; li->list && li->list[x]; x++) {
3046 BldFullPathName(s, dcd->workdir, li->list[x]);
3047 if (IsFile(s) != 1) {
3048 free(li->list[x]);
3049 li->list[x] = NULL;
3050 for (y = x; li->list[y]; y++)
3051 li->list[y] = li->list[y + 1];
3052 li->list =
3053 xrealloc(li->list, y * sizeof(CHAR *), pszSrcFile,
3054 __LINE__);
3055 x--;
3056 }
3057 else {
3058 p = xstrdup(s, pszSrcFile, __LINE__);
3059 if (p) {
3060 free(li->list[x]);
3061 li->list[x] = p;
3062 }
3063 }
3064 } // for
3065 }
3066 strcpy(li->arcname, dcd->arcname);
3067 li->info = dcd->info;
3068 {
3069 PARCITEM pai;
3070
3071 if (SHORT1FROMMP(mp1) != IDM_EXEC)
3072 pai = (PARCITEM) CurrentRecord(hwnd);
3073 else
3074 pai = (PARCITEM) WinSendMsg(hwnd, CM_QUERYRECORDEMPHASIS,
3075 MPFROMLONG(CMA_FIRST),
3076 MPFROMSHORT(CRA_CURSORED));
3077 if (pai && (INT) pai != -1)
3078 strcpy(li->runfile, pai->pszFileName);
3079 else
3080 strcpy(li->runfile, li->list[0]);
3081 }
3082 switch (SHORT1FROMMP(mp1)) {
3083 case IDM_VIEW:
3084 case IDM_VIEWTEXT:
3085 case IDM_VIEWBINARY:
3086 case IDM_VIEWARCHIVE:
3087 case IDM_EDIT:
3088 case IDM_EDITTEXT:
3089 case IDM_EDITBINARY:
3090 case IDM_EXEC:
3091 case IDM_PRINT:
3092 case IDM_VIRUSSCAN:
3093 case IDM_OPENDEFAULT:
3094 case IDM_OPENSETTINGS:
3095 case IDM_MCIPLAY:
3096 strcpy(li->targetpath, dcd->workdir);
3097 break;
3098 default:
3099 strcpy(li->targetpath, dcd->directory);
3100 break;
3101 }
3102 if (li->list) {
3103 if (!PostMsg(dcd->hwndObject, UM_ACTION, MPFROMP(li), MPVOID)) {
3104 Runtime_Error(pszSrcFile, __LINE__, "post");
3105 FreeListInfo(li);
3106 }
3107 else if (fUnHilite && SHORT1FROMMP(mp1) != IDM_EDIT)
3108 UnHilite(hwnd, TRUE, &dcd->lastselection, 0);
3109 }
3110 else {
3111 free(li);
3112 }
3113 }
3114# ifdef FORTIFY
3115 Fortify_LeaveScope();
3116# endif
3117 }
3118 break;
3119 }
3120 }
3121 return 0;
3122
3123 case WM_CONTROL:
3124 DosError(FERR_DISABLEHARDERR);
3125 if (dcd) {
3126 switch (SHORT2FROMMP(mp1)) {
3127 case CN_BEGINEDIT:
3128 PostMsg(hwnd, CM_CLOSEEDIT, MPVOID, MPVOID);
3129 break;
3130
3131 case CN_ENDEDIT:
3132 if (!((PCNREDITDATA) mp2)->pRecord) {
3133
3134 PFIELDINFO pfi = ((PCNREDITDATA) mp2)->pFieldInfo;
3135 USHORT cmd = 0;
3136
3137 if (!pfi || pfi->offStruct == FIELDOFFSET(ARCITEM, pszDisplayName))
3138 cmd = IDM_SORTSMARTNAME;
3139 else if (pfi->offStruct == FIELDOFFSET(ARCITEM, cbFile))
3140 cmd = IDM_SORTSIZE;
3141 else if (pfi->offStruct == FIELDOFFSET(ARCITEM, cbComp))
3142 cmd = IDM_SORTEASIZE;
3143 else if (pfi->offStruct == FIELDOFFSET(ARCITEM, date))
3144 cmd = IDM_SORTLWDATE;
3145 else if (pfi->offStruct == FIELDOFFSET(ARCITEM, time))
3146 cmd = IDM_SORTLWDATE;
3147 if (cmd)
3148 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(cmd, 0), MPVOID);
3149 }
3150 break;
3151
3152 case CN_DROPHELP:
3153 saymsg(MB_ENTER, hwnd,
3154 GetPString(IDS_DROPHELPHDRTEXT),
3155 GetPString(IDS_ARCCNRDROPHELPTEXT), dcd->arcname);
3156 return 0;
3157
3158 case CN_DRAGLEAVE:
3159 if (mp2) {
3160
3161 PDRAGINFO pDInfo;
3162
3163 pDInfo = ((PCNRDRAGINFO) mp2)->pDragInfo;
3164 DrgAccessDraginfo(pDInfo); /* Access DRAGINFO */
3165 DrgFreeDraginfo(pDInfo); /* Free DRAGINFO */
3166 }
3167 return 0;
3168
3169 case CN_DRAGAFTER:
3170 case CN_DRAGOVER:
3171 if (mp2) {
3172
3173 PDRAGITEM pDItem; /* Pointer to DRAGITEM */
3174 PDRAGINFO pDInfo; /* Pointer to DRAGINFO */
3175 PARCITEM pci;
3176
3177 pci = (PARCITEM) ((PCNRDRAGINFO) mp2)->pRecord;
3178 if (SHORT1FROMMP(mp1) == CN_DRAGAFTER)
3179 pci = NULL;
3180 pDInfo = ((PCNRDRAGINFO) mp2)->pDragInfo;
3181 DrgAccessDraginfo(pDInfo); /* Access DRAGINFO */
3182 if (*dcd->arcname) {
3183 if ((driveflags[toupper(*dcd->arcname) - 'A'] &
3184 DRIVE_NOTWRITEABLE) || !dcd->info || !dcd->info->create) {
3185 DrgFreeDraginfo(pDInfo);
3186 return MRFROM2SHORT(DOR_NEVERDROP, 0);
3187 }
3188 }
3189 if (pci) {
3190 DrgFreeDraginfo(pDInfo);
3191 return MRFROM2SHORT(DOR_NODROP, 0);
3192 }
3193 pDItem = DrgQueryDragitemPtr(pDInfo, /* Access DRAGITEM */
3194 0); /* Index to DRAGITEM */
3195 if (DrgVerifyRMF(pDItem, /* Check valid rendering */
3196 DRM_OS2FILE, /* mechanisms and data */
3197 NULL) && !(pDItem->fsControl & DC_PREPARE)) {
3198 DrgFreeDraginfo(pDInfo); /* Free DRAGINFO */
3199 return MRFROM2SHORT(DOR_DROP, /* Return okay to drop */
3200 fCopyDefault ? DO_COPY : DO_MOVE);
3201 }
3202 DrgFreeDraginfo(pDInfo); /* Free DRAGINFO */
3203 }
3204 return (MRFROM2SHORT(DOR_NEVERDROP, 0)); /* Drop not valid */
3205
3206 case CN_INITDRAG:
3207 if (mp2) {
3208
3209 BOOL wasemphasized = FALSE;
3210 PCNRDRAGINIT pcd = (PCNRDRAGINIT) mp2;
3211 PARCITEM pci;
3212
3213 if (pcd) {
3214 pci = (PARCITEM) pcd->pRecord;
3215 if (pci) {
3216 if (pci->rc.flRecordAttr & CRA_SELECTED)
3217 wasemphasized = TRUE;
3218 if (!ParentIsDesktop(hwnd, dcd->hwndParent) &&
3219 fSplitStatus && hwndStatus2)
3220 WinSetWindowText(hwndStatus2, GetPString(IDS_DRAGARCMEMTEXT));
3221 if (DoFileDrag(hwnd,
3222 dcd->hwndObject,
3223 mp2, dcd->arcname, NULL, TRUE)) {
3224 if ((fUnHilite && wasemphasized) || dcd->ulItemsToUnHilite)
3225 UnHilite(hwnd, TRUE, &dcd->lastselection, dcd->ulItemsToUnHilite);
3226 }
3227 if (!ParentIsDesktop(hwnd, dcd->hwndParent) &&
3228 fSplitStatus && hwndStatus2) {
3229 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
3230 }
3231 }
3232 else {
3233 if (!ParentIsDesktop(hwnd, dcd->hwndParent) &&
3234 fSplitStatus && hwndStatus2)
3235 WinSetWindowText(hwndStatus2,
3236 GetPString(IDS_DRAGARCFILETEXT));
3237 DragOne(hwnd, dcd->hwndObject, dcd->arcname, FALSE);
3238 if (!ParentIsDesktop(hwnd, dcd->hwndParent) &&
3239 fSplitStatus && hwndStatus2)
3240 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
3241 }
3242 }
3243 }
3244 return 0;
3245
3246 case CN_DROP:
3247 if (mp2) {
3248
3249 LISTINFO *li;
3250
3251 DosBeep(500, 100); // fixme to know why beep?
3252 li = DoFileDrop(hwnd, dcd->arcname, FALSE, mp1, mp2);
3253 DosBeep(50, 100); // fixme to know why beep?
3254 CheckPmDrgLimit(((PCNRDRAGINFO)mp2)->pDragInfo);
3255 if (li) {
3256 li->type = li->type == DO_MOVE ? IDM_ARCHIVEM : IDM_ARCHIVE;
3257 strcpy(li->targetpath, dcd->arcname);
3258 if (!li->list ||
3259 !li->list[0] ||
3260 !PostMsg(dcd->hwndObject, UM_ACTION, MPFROMP(li), MPVOID))
3261 FreeListInfo(li);
3262 }
3263 }
3264 return 0;
3265
3266 case CN_CONTEXTMENU:
3267 {
3268 PARCITEM pci = (PARCITEM) mp2;
3269
3270 if (pci) {
3271 WinSendMsg(hwnd, CM_SETRECORDEMPHASIS, MPFROMP(pci),
3272 MPFROM2SHORT(TRUE, CRA_CURSORED));
3273 MarkAll(hwnd, FALSE, FALSE, TRUE);
3274 dcd->hwndLastMenu = CheckMenu(hwnd, &ArcMenu, ARC_POPUP);
3275 }
3276 else {
3277 dcd->hwndLastMenu = CheckMenu(hwnd, &ArcCnrMenu, ARCCNR_POPUP);
3278 if (dcd->hwndLastMenu && !dcd->cnremphasized) {
3279 WinSendMsg(hwnd, CM_SETRECORDEMPHASIS, MPVOID,
3280 MPFROM2SHORT(TRUE, CRA_SOURCE));
3281 dcd->cnremphasized = TRUE;
3282 }
3283 }
3284 if (dcd->hwndLastMenu) {
3285 if (dcd->hwndLastMenu == ArcCnrMenu) {
3286 if (dcd->flWindowAttr & CV_MINI)
3287 WinCheckMenuItem(dcd->hwndLastMenu, IDM_MINIICONS, TRUE);
3288 }
3289 WinCheckMenuItem(dcd->hwndLastMenu, IDM_FOLDERAFTEREXTRACT,
3290 fFolderAfterExtract);
3291 if (!PopupMenu(hwnd, hwnd, dcd->hwndLastMenu)) {
3292 if (dcd->cnremphasized) {
3293 WinSendMsg(hwnd, CM_SETRECORDEMPHASIS, MPVOID,
3294 MPFROM2SHORT(FALSE, CRA_SOURCE));
3295 dcd->cnremphasized = TRUE;
3296 }
3297 MarkAll(hwnd, TRUE, FALSE, TRUE);
3298 }
3299 }
3300 }
3301 break;
3302
3303 case CN_EMPHASIS:
3304 if (mp2) {
3305
3306 PNOTIFYRECORDEMPHASIS pre = mp2;
3307 PARCITEM pci;
3308 CHAR s[CCHMAXPATHCOMP + 91], tf[81], tb[81];
3309
3310 pci = (PARCITEM)(pre ? pre->pRecord : NULL);
3311 if (!pci) {
3312 if (!ParentIsDesktop(hwnd, dcd->hwndParent)) {
3313 if (hwndStatus2)
3314 WinSetWindowText(hwndStatus2, NullStr);
3315 if (fMoreButtons)
3316 WinSetWindowText(hwndName, NullStr);
3317 }
3318 break;
3319 }
3320 if (pre->fEmphasisMask & CRA_SELECTED) {
3321 if (pci->rc.flRecordAttr & CRA_SELECTED) {
3322 dcd->selectedbytes += pci->cbFile;
3323 dcd->selectedfiles++;
3324 }
3325 else if (dcd->selectedfiles) {
3326 dcd->selectedbytes -= pci->cbFile;
3327 dcd->selectedfiles--;
3328 }
3329 commafmt(tf, sizeof(tf), dcd->selectedfiles);
3330 if (dcd->ullTotalBytes)
3331 CommaFmtULL(tb, sizeof(tb), dcd->selectedbytes, ' ');
3332 else
3333 *tb = 0;
3334 sprintf(s, "%s%s%s", tf, *tb ? " / " : NullStr, tb);
3335 WinSetDlgItemText(dcd->hwndClient, DIR_SELECTED, s);
3336 }
3337 else if (WinQueryActiveWindow(dcd->hwndParent) ==
3338 dcd->hwndFrame &&
3339 !ParentIsDesktop(hwnd, dcd->hwndParent)) {
3340 if (pre->fEmphasisMask & CRA_CURSORED) {
3341 if (pci->rc.flRecordAttr & CRA_CURSORED) {
3342 if (fSplitStatus && hwndStatus2) {
3343 if (dcd->ullTotalBytes)
3344 CommaFmtULL(tb, sizeof(tb), pci->cbFile, ' ');
3345 else
3346 *tb = 0;
3347 sprintf(s, "%s%s%s%s",
3348 *tb ? " " : NullStr,
3349 tb, *tb ? " " : NullStr, pci->pszFileName);
3350 WinSetWindowText(hwndStatus2, s);
3351 }
3352 if (fMoreButtons)
3353 WinSetWindowText(hwndName, pci->pszFileName);
3354 }
3355 }
3356 }
3357 }
3358 break;
3359
3360 case CN_ENTER:
3361 if (mp2) {
3362
3363 PARCITEM pci = (PARCITEM) ((PNOTIFYRECORDENTER) mp2)->pRecord;
3364
3365 if (pci) {
3366
3367 CHAR *s;
3368
3369 if ((pci->rc.flRecordAttr & CRA_INUSE) ||
3370 (pci->flags & (ARCFLAGS_REALDIR | ARCFLAGS_PSEUDODIR)))
3371 break;
3372 s = xstrdup(pci->pszFileName, pszSrcFile, __LINE__);
3373 if (s) {
3374 if (!PostMsg(dcd->hwndObject, UM_ENTER, MPFROMP(s), MPVOID)) {
3375 Runtime_Error(pszSrcFile, __LINE__, "post");
3376 free(s);
3377 }
3378 }
3379 }
3380 }
3381 break;
3382 }
3383 }
3384 return 0;
3385
3386 case UM_FOLDUP:
3387 if (!PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID))
3388 DosExit(EXIT_PROCESS, 1);
3389 return 0;
3390
3391 case UM_CLOSE:
3392 WinDestroyWindow(WinQueryWindow(WinQueryWindow(hwnd, QW_PARENT),
3393 QW_PARENT));
3394 return 0;
3395
3396 case WM_SAVEAPPLICATION:
3397 if (dcd && ParentIsDesktop(hwnd, dcd->hwndParent)) {
3398 SWP swp;
3399
3400 WinQueryWindowPos(dcd->hwndFrame, &swp);
3401 if (!(swp.fl & (SWP_HIDE | SWP_MINIMIZE | SWP_MAXIMIZE)))
3402 PrfWriteProfileData(fmprof, appname, "AV2SizePos", &swp, sizeof(swp));
3403 }
3404 break;
3405
3406 case WM_CLOSE:
3407 WinSendMsg(hwnd, WM_SAVEAPPLICATION, MPVOID, MPVOID);
3408 if (dcd)
3409 dcd->stopflag++;
3410 if (dcd && dcd->hwndObject) {
3411 if (!PostMsg(dcd->hwndObject, WM_CLOSE, MPVOID, MPVOID))
3412 WinSendMsg(dcd->hwndObject, WM_CLOSE, MPVOID, MPVOID);
3413 }
3414 // In case object window frees dcd
3415 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
3416 if (!dcd ||
3417 (!dcd->dontclose &&
3418 !dcd->amextracted && ParentIsDesktop(hwnd, dcd->hwndParent))) {
3419 if (!PostMsg(hwnd, UM_FOLDUP, MPVOID, MPVOID))
3420 WinSendMsg(hwnd, UM_FOLDUP, MPVOID, MPVOID);
3421 }
3422 return 0;
3423
3424 case WM_DESTROY:
3425 if (ArcMenu)
3426 WinDestroyWindow(ArcMenu);
3427 if (ArcCnrMenu)
3428 WinDestroyWindow(ArcCnrMenu);
3429 ArcMenu = ArcCnrMenu = (HWND) 0;
3430 EmptyArcCnr(hwnd);
3431# ifdef FORTIFY
3432 Fortify_LeaveScope();
3433# endif
3434 break;
3435 }
3436 if (dcd && dcd->oldproc){
3437 return dcd->oldproc(hwnd, msg, mp1, mp2);
3438 }
3439 else
3440 return PFNWPCnr(hwnd, msg, mp1, mp2);
3441}
3442
3443MRESULT EXPENTRY ArcCnrMenuProc(HWND hwnd, ULONG msg, MPARAM mp1,
3444 MPARAM mp2)
3445{
3446 PFNWP oldMenuProc = WinQueryWindowPtr(hwnd, QWL_USER);
3447 static short sLastMenuitem;
3448
3449 switch (msg) {
3450 case WM_MOUSEMOVE: {
3451 if (fOtherHelp) {
3452 RECTL rectl;
3453 SHORT i, sCurrentMenuitem;
3454 SHORT MenuItems = 10;
3455 SHORT asMenuIDs[10] = {IDM_VIEW,
3456 IDM_DELETE,
3457 IDM_EXEC,
3458 IDM_EXTRACT,
3459 IDM_TEST,
3460 IDM_VIRUSSCAN,
3461 IDM_RESCAN,
3462 IDM_WALKDIR,
3463 IDM_FILTER,
3464 0};
3465 char *szHelpString = NULL;
3466
3467
3468 for (i=0; i<MenuItems; i++) {
3469 sCurrentMenuitem = asMenuIDs[i];
3470 oldMenuProc(hwnd,MM_QUERYITEMRECT,
3471 MPFROM2SHORT(asMenuIDs[i], FALSE),
3472 &rectl);
3473
3474 if (MOUSEMSG(&msg)->x > rectl.xLeft &&
3475 MOUSEMSG(&msg)->x < rectl.xRight &&
3476 MOUSEMSG(&msg)->y > rectl.yBottom &&
3477 MOUSEMSG(&msg)->y < rectl.yTop)
3478 break;
3479 } // for
3480
3481
3482 switch (sCurrentMenuitem) {
3483 case 0:
3484 break;
3485 case IDM_VIEW:
3486 szHelpString = GetPString(IDS_ARCCNRVIEWMENUHELP);
3487 break;
3488 case IDM_DELETE:
3489 szHelpString = GetPString(IDS_ARCCNRDELETEMENUHELP);
3490 break;
3491 case IDM_EXEC:
3492 szHelpString = GetPString(IDS_ARCCNREXECMENUHELP);
3493 break;
3494 case IDM_EXTRACT:
3495 szHelpString = GetPString(IDS_ARCCNREXTRACTMENUHELP);
3496 break;
3497 case IDM_TEST:
3498 szHelpString = GetPString(IDS_ARCCNRTESTMENUHELP);
3499 break;
3500 case IDM_VIRUSSCAN:
3501 szHelpString = GetPString(IDS_ARCCNRVIRUSMENUHELP);
3502 break;
3503 case IDM_RESCAN:
3504 szHelpString = GetPString(IDS_ARCCNRRESCANMENUHELP);
3505 break;
3506 case IDM_WALKDIR:
3507 szHelpString = GetPString(IDS_ARCCNRWALKDIRMENUHELP);
3508 break;
3509 case IDM_FILTER:
3510 szHelpString = GetPString(IDS_ARCCNRFILTERMENUHELP);
3511 break;
3512 default:
3513 break;
3514 }
3515
3516 if (sLastMenuitem != sCurrentMenuitem && szHelpString) {
3517 sLastMenuitem = sCurrentMenuitem;
3518 MakeBubble(hwnd, TRUE, szHelpString);
3519 }
3520 else if (hwndBubble && !sCurrentMenuitem){
3521 sLastMenuitem = sCurrentMenuitem;
3522 WinDestroyWindow(hwndBubble);
3523 }
3524 }
3525 }
3526 }
3527 return oldMenuProc(hwnd, msg, mp1, mp2);
3528}
3529
3530HWND StartArcCnr(HWND hwndParent, HWND hwndCaller, CHAR * arcname, INT flags,
3531 ARC_TYPE * sinfo)
3532{
3533 /*
3534 * bitmapped flags:
3535 * 1 = am extracted from another archive
3536 * 4 = don't kill proc on close
3537 */
3538
3539 HWND hwndFrame = (HWND) 0, hwndClient;
3540 ULONG FrameFlags = FCF_TITLEBAR | FCF_SYSMENU |
3541 FCF_SIZEBORDER | FCF_MINMAX | FCF_ICON | FCF_NOBYTEALIGN | FCF_ACCELTABLE;
3542 USHORT id;
3543 DIRCNRDATA *dcd;
3544 ARC_TYPE *info = sinfo;
3545 CHAR title[MAXNAMEL + 1] = "AV/2 - ";
3546 CHAR fullname[CCHMAXPATH + 8], *p, temp;
3547 static USHORT idinc = 0;
3548
3549 if (!idinc)
3550 idinc = (rand() % 256);
3551 if (ParentIsDesktop(hwndParent, hwndParent))
3552 FrameFlags |= (FCF_TASKLIST | FCF_MENU);
3553 if (arcname) {
3554 DosError(FERR_DISABLEHARDERR);
3555 if (DosQueryPathInfo(arcname,
3556 FIL_QUERYFULLNAME, fullname, sizeof(fullname)))
3557 strcpy(fullname, arcname);
3558 p = fullname;
3559 while (*p) {
3560 if (*p == '/')
3561 *p = '\\';
3562 p++;
3563 }
3564 if (!info)
3565 info = find_type(fullname, arcsighead);
3566 if (!info)
3567 return hwndFrame;
3568 if (strlen(title) + strlen(fullname) > MAXNAMEL) {
3569 p = title + strlen(title);
3570 strncpy(p, fullname, MAXNAMEL / 2 - 5);
3571 strcpy(p + MAXNAMEL / 2 - 5, "...");
3572 strcat(title, fullname + strlen(fullname) - (MAXNAMEL / 2 - 5));
3573 }
3574 else {
3575 strcat(title, fullname);
3576 }
3577 hwndFrame = WinCreateStdWindow(hwndParent,
3578 WS_VISIBLE,
3579 &FrameFlags,
3580 WC_ARCCONTAINER,
3581 title,
3582 WS_VISIBLE | fwsAnimate,
3583 FM3ModHandle, ARC_FRAME, &hwndClient);
3584 if (hwndFrame && hwndClient) {
3585 id = ARC_FRAME + idinc++;
3586 if (idinc > 512)
3587 idinc = 0;
3588 WinSetWindowUShort(hwndFrame, QWS_ID, id);
3589# ifdef FORTIFY
3590 Fortify_EnterScope();
3591# endif
3592 dcd = xmallocz(sizeof(DIRCNRDATA), pszSrcFile, __LINE__);
3593 if (!dcd) {
3594 PostMsg(hwndClient, WM_CLOSE, MPVOID, MPVOID);
3595 hwndFrame = (HWND) 0;
3596 }
3597 else {
3598 dcd->size = sizeof(DIRCNRDATA);
3599 dcd->id = id;
3600 dcd->type = ARC_FRAME;
3601 if (!pTmpDir)
3602 strcpy(dcd->workdir, pFM2SaveDirectory);
3603 MakeTempName(dcd->workdir, ArcTempRoot, 2);
3604 /*if (dcd->workdir[strlen(dcd->workdir) - 1] != '\\')
3605 strcat(dcd->workdir, "\\");
3606 sprintf(dcd->workdir + strlen(dcd->workdir), "%s.%03x",
3607 ArcTempRoot, (clock() & 4095));
3608 else
3609 sprintf(dcd->workdir, "%s.%03x",
3610 ArcTempRoot, (clock() & 4095));*/
3611 strcpy(dcd->arcname, fullname);
3612 if (*extractpath) {
3613 if (!strcmp(extractpath, "*")) {
3614 p = strrchr(fullname, '\\');
3615 if (p) {
3616 if (p < fullname + 3)
3617 p++;
3618 temp = *p;
3619 *p = 0;
3620 strcpy(dcd->directory, fullname);
3621 *p = temp;
3622 }
3623 }
3624 else
3625 strcpy(dcd->directory, extractpath);
3626 }
3627 if (!*dcd->directory && *lastextractpath) {
3628 DosEnterCritSec();
3629 strcpy(dcd->directory, lastextractpath);
3630 DosExitCritSec();
3631 }
3632 if (!*dcd->directory) {
3633 if (!ParentIsDesktop(hwndParent, hwndParent))
3634 TopWindowName(hwndParent, hwndCaller, dcd->directory);
3635 if (!*dcd->directory) {
3636 p = strrchr(fullname, '\\');
3637 if (p) {
3638 if (p < fullname + 3)
3639 p++;
3640 *p = 0;
3641 strcpy(dcd->directory, fullname);
3642 }
3643 }
3644 }
3645 if (!*dcd->directory ||
3646 IsFile(dcd->directory) ||
3647 (isalpha(*dcd->directory) &&
3648 (driveflags[toupper(*dcd->directory) - 'A'] &
3649 DRIVE_NOTWRITEABLE)))
3650 strcpy(dcd->directory, pFM2SaveDirectory);
3651 dcd->hwndParent = hwndParent ? hwndParent : HWND_DESKTOP;
3652 dcd->hwndFrame = hwndFrame;
3653 dcd->hwndClient = hwndClient;
3654 dcd->amextracted = (flags & 1) != 0;
3655 dcd->dontclose = (flags & 4) != 0;
3656 dcd->info = info;
3657 dcd->sortFlags = DefArcSortFlags;
3658 {
3659 PFNWP oldproc;
3660
3661 oldproc = WinSubclassWindow(hwndFrame, (PFNWP) ArcFrameWndProc);
3662 WinSetWindowPtr(hwndFrame, QWL_USER, (PVOID) oldproc);
3663 }
3664 dcd->hwndCnr = WinCreateWindow(hwndClient,
3665 WC_CONTAINER,
3666 NULL,
3667 CCS_AUTOPOSITION | CCS_MINIICONS |
3668 CCS_MINIRECORDCORE | ulCnrType |
3669 WS_VISIBLE,
3670 0,
3671 0,
3672 0,
3673 0,
3674 hwndClient,
3675 HWND_TOP, (ULONG) ARC_CNR, NULL, NULL);
3676 if (!dcd->hwndCnr) {
3677 Win_Error2(hwndClient, hwndClient, pszSrcFile, __LINE__,
3678 IDS_WINCREATEWINDOW);
3679 PostMsg(hwndClient, WM_CLOSE, MPVOID, MPVOID);
3680 free(dcd);
3681 hwndFrame = (HWND) 0;
3682 }
3683 else {
3684 WinSetWindowPtr(dcd->hwndCnr, QWL_USER, (PVOID) dcd);
3685 dcd->oldproc = WinSubclassWindow(dcd->hwndCnr,
3686 (PFNWP) ArcCnrWndProc);
3687 {
3688 USHORT ids[] = { DIR_TOTALS, DIR_SELECTED, DIR_VIEW, DIR_SORT,
3689 DIR_FILTER, DIR_FOLDERICON, 0
3690 };
3691
3692 CommonCreateTextChildren(dcd->hwndClient,
3693 WC_ARCSTATUS, ids);
3694 }
3695 WinEnableWindow(WinWindowFromID(dcd->hwndClient, DIR_VIEW), FALSE);
3696 dcd->hwndExtract = WinCreateWindow(dcd->hwndClient,
3697 WC_ENTRYFIELD,
3698 NULL,
3699 ES_AUTOSCROLL,
3700 0,
3701 0,
3702 0,
3703 0,
3704 dcd->hwndClient,
3705 HWND_TOP,
3706 ARC_EXTRACTDIR, NULL, NULL);
3707 WinSendMsg(dcd->hwndExtract,
3708 EM_SETTEXTLIMIT, MPFROM2SHORT(CCHMAXPATH, 0), MPVOID);
3709 WinSetWindowText(dcd->hwndExtract, dcd->directory);
3710 if (!PostMsg(dcd->hwndCnr, UM_SETUP, MPVOID, MPVOID))
3711 WinSendMsg(dcd->hwndCnr, UM_SETUP, MPVOID, MPVOID);
3712 if (FrameFlags & FCF_MENU) {
3713 PFNWP oldmenuproc;
3714 HWND hwndMenu = WinWindowFromID(hwndFrame, FID_MENU);
3715
3716 oldmenuproc = WinSubclassWindow(hwndMenu, (PFNWP) ArcCnrMenuProc);
3717 WinSetWindowPtr(hwndMenu, QWL_USER, (PVOID) oldmenuproc);
3718 if (!fToolbar) {
3719
3720 if (hwndMenu) {
3721 WinSendMsg(hwndMenu, MM_DELETEITEM,
3722 MPFROM2SHORT(IDM_VIEW, FALSE), MPVOID);
3723 WinSendMsg(hwndMenu, MM_DELETEITEM,
3724 MPFROM2SHORT(IDM_EXEC, FALSE), MPVOID);
3725 WinSendMsg(hwndMenu, MM_DELETEITEM,
3726 MPFROM2SHORT(IDM_RESCAN, FALSE), MPVOID);
3727 WinSendMsg(hwndMenu, MM_DELETEITEM,
3728 MPFROM2SHORT(IDM_DELETE, FALSE), MPVOID);
3729 WinSendMsg(hwndMenu, MM_DELETEITEM,
3730 MPFROM2SHORT(IDM_EXTRACT, FALSE), MPVOID);
3731 WinSendMsg(hwndMenu, MM_DELETEITEM,
3732 MPFROM2SHORT(IDM_TEST, FALSE), MPVOID);
3733 WinSendMsg(hwndMenu, MM_DELETEITEM,
3734 MPFROM2SHORT(IDM_VIRUSSCAN, FALSE), MPVOID);
3735 WinSendMsg(hwndMenu, MM_DELETEITEM,
3736 MPFROM2SHORT(IDM_WALKDIR, FALSE), MPVOID);
3737 WinSendMsg(hwndMenu, MM_DELETEITEM,
3738 MPFROM2SHORT(IDM_FILTER, FALSE), MPVOID);
3739 }
3740 }
3741 }
3742 if (FrameFlags & FCF_TASKLIST) {
3743
3744 SWP swp, swpD;
3745 ULONG size = sizeof(swp);
3746 LONG cxScreen, cyScreen;
3747
3748 WinQueryTaskSizePos(WinQueryAnchorBlock(hwndFrame), 0, &swp);
3749 if (PrfQueryProfileData(fmprof,
3750 appname, "AV2SizePos", &swpD, &size)) {
3751 cxScreen = WinQuerySysValue(HWND_DESKTOP, SV_CXSCREEN);
3752 cyScreen = WinQuerySysValue(HWND_DESKTOP, SV_CYSCREEN);
3753 if (swp.x + swpD.cx > cxScreen)
3754 swp.x = cxScreen - swpD.cx;
3755 if (swp.y + swpD.cy > cyScreen)
3756 swp.y = cyScreen - swpD.cy;
3757 swp.cx = swpD.cx;
3758 swp.cy = swpD.cy;
3759 }
3760 WinSetWindowPos(hwndFrame,
3761 HWND_TOP,
3762 swp.x,
3763 swp.y,
3764 swp.cx,
3765 swp.cy,
3766 SWP_SIZE | SWP_MOVE | SWP_SHOW | SWP_ZORDER |
3767 SWP_ACTIVATE);
3768 }
3769 }
3770 }
3771# ifdef FORTIFY
3772 Fortify_LeaveScope();
3773# endif
3774 }
3775 }
3776 return hwndFrame;
3777}
3778
3779#pragma alloc_text(ARCCNRS,ArcCnrWndProc,ArcObjWndProc,ArcClientWndProc,BldQuotedFullPathName)
3780#pragma alloc_text(ARCCNRS,ArcTextProc,FillArcCnr,ArcFilter,BldQuotedFileName)
3781#pragma alloc_text(ARCCNRS,ArcSort,ArcFrameWndProc,IsArcThere,ArcErrProc)
3782#pragma alloc_text(STARTUP,StartArcCnr)
Note: See TracBrowser for help on using the repository browser.