source: trunk/dll/arccnrs.c@ 1168

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

Ticket 187: Draft 1: Functions only

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