source: trunk/dll/arccnrs.c@ 1272

Last change on this file since 1272 was 1272, checked in by Gregg Young, 17 years ago

Remove priority_bumped from WaitChildThread and added some comments (Ticket 58)

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