source: trunk/dll/arccnrs.c@ 1082

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

Changes so FM2 will use TMP/TEMP directory for all temp files; Replaced save_dir2 with global variable so BldFullPathName could easily replace code that performed the same function; Added #ifdef FORTIFY to free_ function that are only used when fortified.

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