source: trunk/dll/arccnrs.c@ 1398

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

Move embeded strings to PCSZ variables or string table; Eliminate Error2 functions Runtime_Error with NULL format string returns "No data" error. Change declares from PSZ to PCSZ in functions where the variable isn't changed. Added btm as an executable file type in several additional places. Use fProtectOnly to prevent attempt to execute Dos and Win programs on "Protect only" installs in several additional places.

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