source: trunk/dll/arccnrs.c@ 1120

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

Check TMP directory space warn if lee than 5 MiB prevent archiver from opening if less than 10 KiB (It hangs and can't be closed) (Ticket 214) Also some cleanup of the error messages for CheckDriveSpaceAvail.

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