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