source: trunk/dll/arccnrs.c@ 1753

Last change on this file since 1753 was 1753, checked in by Gregg Young, 11 years ago

Fixed typo that reversed the function of the saymsg dialog g/bzip check. Added option to suppress message regarding missing bzip2.exe or gzip.exe on TAR.B/GZ archives. Ticket 526

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