| 1 | 
 | 
|---|
| 2 | /***********************************************************************
 | 
|---|
| 3 | 
 | 
|---|
| 4 |   $Id: select.c 1158 2008-09-05 21:40:35Z jbs $
 | 
|---|
| 5 | 
 | 
|---|
| 6 |   Container item selection support routines
 | 
|---|
| 7 | 
 | 
|---|
| 8 |   Copyright (c) 1993-98 M. Kimes
 | 
|---|
| 9 |   Copyright (c) 2004, 2008 Steven H. Levine
 | 
|---|
| 10 | 
 | 
|---|
| 11 |   01 Aug 04 SHL Rework lstrip/rstrip usage
 | 
|---|
| 12 |   25 May 05 SHL Rework for ULONGLONG
 | 
|---|
| 13 |   06 Jun 05 SHL Drop unused code
 | 
|---|
| 14 |   06 Jul 06 SHL Support compare content (IDM_SELECTSAMECONTENT)
 | 
|---|
| 15 |   13 Jul 06 SHL Use Runtime_Error
 | 
|---|
| 16 |   29 Jul 06 SHL Use xfgets_bstripcr
 | 
|---|
| 17 |   15 Aug 06 SHL Rework SetMask args and logic
 | 
|---|
| 18 |   06 Apr 07 GKY Work around PM DragInfo and DrgFreeDISH limits
 | 
|---|
| 19 |   19 Apr 07 SHL Sync with NumItemsToUnhilite mods
 | 
|---|
| 20 |   12 May 07 SHL Use dcd->ulItemsToUnHilite
 | 
|---|
| 21 |   14 Jun 07 SHL SelectAll: make odd expression go away
 | 
|---|
| 22 |   02 Aug 07 SHL Sync with CNRITEM mods
 | 
|---|
| 23 |   04 Aug 07 SHL Use Runtime_Error
 | 
|---|
| 24 |   05 Aug 07 SHL Rework SpecialSelect to use CNRITEM_EXISTS and
 | 
|---|
| 25 |                not use pszFileName since CNRITEM_EXISTS set implies
 | 
|---|
| 26 |                pszFileName not null
 | 
|---|
| 27 |   14 Aug 07 SHL Revert ExpandAll DosSleep to 0
 | 
|---|
| 28 |   20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat
 | 
|---|
| 29 |   26 Aug 07 GKY DosSleep(1) in loops changed to (0)
 | 
|---|
| 30 |   12 Jan 08 SHL Localize SpecialSelect in comp.c
 | 
|---|
| 31 |   29 Feb 08 GKY Use xfree where appropriate
 | 
|---|
| 32 | 
 | 
|---|
| 33 | ***********************************************************************/
 | 
|---|
| 34 | 
 | 
|---|
| 35 | #include <stdlib.h>
 | 
|---|
| 36 | #include <string.h>
 | 
|---|
| 37 | #include <share.h>
 | 
|---|
| 38 | #include <io.h>
 | 
|---|
| 39 | 
 | 
|---|
| 40 | #define INCL_DOS
 | 
|---|
| 41 | #define INCL_WIN
 | 
|---|
| 42 | #define INCL_LONGLONG
 | 
|---|
| 43 | 
 | 
|---|
| 44 | #include "fm3str.h"
 | 
|---|
| 45 | #include "filldir.h"                    // RemoveCnrItems
 | 
|---|
| 46 | #include "makelist.h"                   // AddToList
 | 
|---|
| 47 | #include "errutil.h"                    // Dos_Error...
 | 
|---|
| 48 | #include "strutil.h"                    // GetPString
 | 
|---|
| 49 | #include "select.h"
 | 
|---|
| 50 | #include "valid.h"                      // TestCDates
 | 
|---|
| 51 | #include "fm3dll.h"
 | 
|---|
| 52 | #include "fortify.h"
 | 
|---|
| 53 | 
 | 
|---|
| 54 | static PSZ pszSrcFile = __FILE__;
 | 
|---|
| 55 | 
 | 
|---|
| 56 | VOID UnHilite(HWND hwndCnr, BOOL all, CHAR *** list, ULONG ulItemsToUnHilite)
 | 
|---|
| 57 | {
 | 
|---|
| 58 |   PCNRITEM pci;
 | 
|---|
| 59 |   UINT numfiles = 0, numalloc = 0;
 | 
|---|
| 60 |   UINT x = 0;
 | 
|---|
| 61 |   INT attribute = CRA_CURSORED;
 | 
|---|
| 62 | 
 | 
|---|
| 63 |   if (all && list && *list) {
 | 
|---|
| 64 |     FreeList(*list);
 | 
|---|
| 65 |     *list = NULL;
 | 
|---|
| 66 |   }
 | 
|---|
| 67 |   pci = (PCNRITEM) CurrentRecord(hwndCnr);
 | 
|---|
| 68 |   if (pci && (INT)pci != -1) {
 | 
|---|
| 69 |     if (pci->rc.flRecordAttr & CRA_SELECTED) {
 | 
|---|
| 70 |       attribute = CRA_SELECTED;
 | 
|---|
| 71 |       pci = WinSendMsg(hwndCnr, CM_QUERYRECORDEMPHASIS, MPFROMLONG(CMA_FIRST),
 | 
|---|
| 72 |                        MPFROMSHORT(attribute));
 | 
|---|
| 73 |     }
 | 
|---|
| 74 |     while (pci && (INT)pci != -1) {
 | 
|---|
| 75 |       WinSendMsg(hwndCnr, CM_SETRECORDEMPHASIS, MPFROMP(pci),
 | 
|---|
| 76 |                  MPFROM2SHORT(FALSE, CRA_SELECTED));
 | 
|---|
| 77 |       if (!all)
 | 
|---|
| 78 |           break;
 | 
|---|
| 79 |       // Count is one extra to ensure non-zero elsewhere
 | 
|---|
| 80 |       // x is 0 based index
 | 
|---|
| 81 |       if (x + 2 == ulItemsToUnHilite)
 | 
|---|
| 82 |         break;
 | 
|---|
| 83 |       if (list)
 | 
|---|
| 84 |         AddToList(pci->pszFileName, list, &numfiles, &numalloc);
 | 
|---|
| 85 |       pci = (PCNRITEM) WinSendMsg(hwndCnr, CM_QUERYRECORDEMPHASIS,
 | 
|---|
| 86 |                                   MPFROMP(pci), MPFROMSHORT(CRA_SELECTED));
 | 
|---|
| 87 |       x++;
 | 
|---|
| 88 |     }
 | 
|---|
| 89 |   }
 | 
|---|
| 90 | }
 | 
|---|
| 91 | 
 | 
|---|
| 92 | VOID SelectList(HWND hwndCnr, BOOL partial, BOOL deselect, BOOL clearfirst,
 | 
|---|
| 93 |                 PCNRITEM pciParent, PSZ filename, CHAR ** list)
 | 
|---|
| 94 | {
 | 
|---|
| 95 | 
 | 
|---|
| 96 |   PCNRITEM pci;
 | 
|---|
| 97 |   register INT x;
 | 
|---|
| 98 |   BOOL foundone = FALSE;
 | 
|---|
| 99 |   ULONG errs = 0;
 | 
|---|
| 100 | 
 | 
|---|
| 101 |   if (clearfirst && !deselect)
 | 
|---|
| 102 |     UnHilite(hwndCnr, TRUE, NULL, 0);
 | 
|---|
| 103 |   if (list && list[0]) {
 | 
|---|
| 104 |     for (x = 0; list[x]; x++) {
 | 
|---|
| 105 |       pci = FindCnrRecord(hwndCnr,
 | 
|---|
| 106 |                           list[x], pciParent, partial, partial, TRUE);
 | 
|---|
| 107 |       if (pci) {
 | 
|---|
| 108 |         WinSendMsg(hwndCnr,
 | 
|---|
| 109 |                    CM_SETRECORDEMPHASIS,
 | 
|---|
| 110 |                    MPFROMP(pci),
 | 
|---|
| 111 |                    MPFROM2SHORT((SHORT) ((deselect) ? FALSE : TRUE),
 | 
|---|
| 112 |                                 CRA_SELECTED));
 | 
|---|
| 113 |         foundone = TRUE;
 | 
|---|
| 114 |       }
 | 
|---|
| 115 |     }
 | 
|---|
| 116 |     if (!foundone)
 | 
|---|
| 117 |       Runtime_Error(pszSrcFile, __LINE__, "select failed");
 | 
|---|
| 118 |   }
 | 
|---|
| 119 |   else if (filename && *filename) {
 | 
|---|
| 120 | 
 | 
|---|
| 121 |     FILE *fp;
 | 
|---|
| 122 |     CHAR input[1024], *p;
 | 
|---|
| 123 | 
 | 
|---|
| 124 |     fp = _fsopen(filename, "r", SH_DENYNO);
 | 
|---|
| 125 |     if (fp) {
 | 
|---|
| 126 |       while (!feof(fp)) {
 | 
|---|
| 127 |         if (!xfgets_bstripcr(input, sizeof(input), fp, pszSrcFile, __LINE__))
 | 
|---|
| 128 |           break;
 | 
|---|
| 129 |         if (*input == '\"') {
 | 
|---|
| 130 |           memmove(input, input + 1, strlen(input) + 1);
 | 
|---|
| 131 |           lstrip(input);
 | 
|---|
| 132 |           p = strchr(input, '\"');
 | 
|---|
| 133 |           if (p)
 | 
|---|
| 134 |             *p = 0;
 | 
|---|
| 135 |           rstrip(input);
 | 
|---|
| 136 |         }
 | 
|---|
| 137 |         else {
 | 
|---|
| 138 |           p = strchr(input, ' ');
 | 
|---|
| 139 |           if (p)
 | 
|---|
| 140 |             *p = 0;
 | 
|---|
| 141 |         }
 | 
|---|
| 142 |         /* input now contains name of file to select */
 | 
|---|
| 143 |         pci = FindCnrRecord(hwndCnr,
 | 
|---|
| 144 |                             input, pciParent, partial, partial, TRUE);
 | 
|---|
| 145 |         if (pci)                        /* found it? */
 | 
|---|
| 146 |           WinSendMsg(hwndCnr,
 | 
|---|
| 147 |                      CM_SETRECORDEMPHASIS,
 | 
|---|
| 148 |                      MPFROMP(pci),
 | 
|---|
| 149 |                      MPFROM2SHORT((SHORT) ((deselect) ? FALSE : TRUE),
 | 
|---|
| 150 |                                   CRA_SELECTED));
 | 
|---|
| 151 |         else
 | 
|---|
| 152 |           errs++;
 | 
|---|
| 153 |         if (errs > 50) {                /* prevent runaway on bad file */
 | 
|---|
| 154 | 
 | 
|---|
| 155 |           APIRET ret;
 | 
|---|
| 156 | 
 | 
|---|
| 157 |           ret = saymsg(MB_YESNO,
 | 
|---|
| 158 |                        hwndCnr,
 | 
|---|
| 159 |                        GetPString(IDS_POSSIBLEERRORTEXT),
 | 
|---|
| 160 |                        GetPString(IDS_MAYNOTBELISTTEXT), filename);
 | 
|---|
| 161 |           if (ret == MBID_NO)
 | 
|---|
| 162 |             break;
 | 
|---|
| 163 |           errs = 0;
 | 
|---|
| 164 |         }
 | 
|---|
| 165 |       }
 | 
|---|
| 166 |       fclose(fp);
 | 
|---|
| 167 |     }
 | 
|---|
| 168 |   }
 | 
|---|
| 169 | }
 | 
|---|
| 170 | 
 | 
|---|
| 171 | VOID SelectAll(HWND hwndCnr, BOOL files, BOOL dirs, PSZ maskstr,
 | 
|---|
| 172 |                PSZ text, BOOL is_arc)
 | 
|---|
| 173 | {
 | 
|---|
| 174 | 
 | 
|---|
| 175 |   PCNRITEM pci;
 | 
|---|
| 176 |   BOOL markit;
 | 
|---|
| 177 |   PSZ file;
 | 
|---|
| 178 |   PSZ pszToMatch;
 | 
|---|
| 179 |   MASK Mask;
 | 
|---|
| 180 |   INT x;
 | 
|---|
| 181 |   ULONG textlen = 0;
 | 
|---|
| 182 | 
 | 
|---|
| 183 |   if (text)
 | 
|---|
| 184 |     textlen = strlen(text);
 | 
|---|
| 185 |   memset(&Mask, 0, sizeof(Mask));
 | 
|---|
| 186 |   if (maskstr)
 | 
|---|
| 187 |     SetMask(maskstr, &Mask);
 | 
|---|
| 188 |   pci = (PCNRITEM) WinSendMsg(hwndCnr, CM_QUERYRECORD, MPVOID,
 | 
|---|
| 189 |                               MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
 | 
|---|
| 190 |   while (pci && (INT)pci != -1) {
 | 
|---|
| 191 | 
 | 
|---|
| 192 |     markit = FALSE;
 | 
|---|
| 193 | 
 | 
|---|
| 194 |     if (~pci->rc.flRecordAttr & CRA_FILTERED) {
 | 
|---|
| 195 |       if (!is_arc) {
 | 
|---|
| 196 |         if (files && ~pci->attrFile & FILE_DIRECTORY)
 | 
|---|
| 197 |           markit = TRUE;
 | 
|---|
| 198 |         if (dirs && pci->attrFile & FILE_DIRECTORY)
 | 
|---|
| 199 |           markit = TRUE;
 | 
|---|
| 200 |       }
 | 
|---|
| 201 |       else
 | 
|---|
| 202 |         markit = TRUE;
 | 
|---|
| 203 |       if (maskstr && *maskstr && markit) {
 | 
|---|
| 204 |         markit = FALSE;
 | 
|---|
| 205 |         // Point a filename part
 | 
|---|
| 206 |         file = strrchr(pci->pszFileName, '\\');
 | 
|---|
| 207 |         if (!file)
 | 
|---|
| 208 |           file = strrchr(pci->pszFileName, ':');
 | 
|---|
| 209 |         if (file)
 | 
|---|
| 210 |           file++;
 | 
|---|
| 211 |         else
 | 
|---|
| 212 |           file = pci->pszFileName;
 | 
|---|
| 213 |         for (x = 0; Mask.pszMasks[x]; x++) {
 | 
|---|
| 214 |           if (*Mask.pszMasks[x]) {
 | 
|---|
| 215 |             if ((strchr(Mask.pszMasks[x], '\\') ||
 | 
|---|
| 216 |                 strchr(Mask.pszMasks[x], ':')))
 | 
|---|
| 217 |               pszToMatch = pci->pszFileName;
 | 
|---|
| 218 |             else
 | 
|---|
| 219 |               pszToMatch = file;
 | 
|---|
| 220 |             if (*Mask.pszMasks[x] != '/') {
 | 
|---|
| 221 |               if (wildcard(pszToMatch, Mask.pszMasks[x], FALSE)) {
 | 
|---|
| 222 |                 markit = TRUE;
 | 
|---|
| 223 |               }
 | 
|---|
| 224 |             }
 | 
|---|
| 225 |             else {
 | 
|---|
| 226 |               if (wildcard(pszToMatch, Mask.pszMasks[x] + 1, FALSE)) {
 | 
|---|
| 227 |                 markit = FALSE;
 | 
|---|
| 228 |                 break;
 | 
|---|
| 229 |               }
 | 
|---|
| 230 |             }
 | 
|---|
| 231 |           }
 | 
|---|
| 232 |         } // for
 | 
|---|
| 233 |       }
 | 
|---|
| 234 |     }
 | 
|---|
| 235 | 
 | 
|---|
| 236 |     if (markit && text && *text) {
 | 
|---|
| 237 |       if (~pci->attrFile & FILE_DIRECTORY) {
 | 
|---|
| 238 |         PSZ input;
 | 
|---|
| 239 |         markit = FALSE;
 | 
|---|
| 240 |         input = xmalloc(65537, pszSrcFile, __LINE__);
 | 
|---|
| 241 |         if (input) {
 | 
|---|
| 242 |           ULONG pos;
 | 
|---|
| 243 |           LONG len;
 | 
|---|
| 244 |           FILE *inputFile;
 | 
|---|
| 245 | 
 | 
|---|
| 246 |           if ((inputFile = _fsopen(pci->pszFileName, "rb", SH_DENYNO)) != NULL) {
 | 
|---|
| 247 |             pos = ftell(inputFile);
 | 
|---|
| 248 |             while (!feof(inputFile)) {
 | 
|---|
| 249 |               if (pos)
 | 
|---|
| 250 |                 fseek(inputFile, pos - 256, SEEK_SET);
 | 
|---|
| 251 |               len = fread(input, 1, 65536, inputFile);
 | 
|---|
| 252 |               if (len >= 0) {
 | 
|---|
| 253 |                 if (findstring(text, textlen, input, len, FALSE)) {
 | 
|---|
| 254 |                   markit = TRUE;
 | 
|---|
| 255 |                   break;
 | 
|---|
| 256 |                 }
 | 
|---|
| 257 |               }
 | 
|---|
| 258 |               else
 | 
|---|
| 259 |                 break;
 | 
|---|
| 260 |             } // while
 | 
|---|
| 261 |             fclose(inputFile);
 | 
|---|
| 262 |           }
 | 
|---|
| 263 |           free(input);
 | 
|---|
| 264 |           DosSleep(1);
 | 
|---|
| 265 |         }
 | 
|---|
| 266 |       }
 | 
|---|
| 267 |       else
 | 
|---|
| 268 |         markit = FALSE;
 | 
|---|
| 269 |     }
 | 
|---|
| 270 | 
 | 
|---|
| 271 |     if (markit)
 | 
|---|
| 272 |       WinSendMsg(hwndCnr, CM_SETRECORDEMPHASIS, MPFROMP(pci),
 | 
|---|
| 273 |                  MPFROM2SHORT(TRUE, CRA_SELECTED));
 | 
|---|
| 274 |     pci = (PCNRITEM) WinSendMsg(hwndCnr, CM_QUERYRECORD, MPFROMP(pci),
 | 
|---|
| 275 |                                 MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
 | 
|---|
| 276 |   }                                     // while
 | 
|---|
| 277 | }
 | 
|---|
| 278 | 
 | 
|---|
| 279 | VOID DeselectAll(HWND hwndCnr, BOOL files, BOOL dirs, PSZ maskstr,
 | 
|---|
| 280 |                  PSZ text, BOOL is_arc)
 | 
|---|
| 281 | {
 | 
|---|
| 282 |   PCNRITEM pci;
 | 
|---|
| 283 |   BOOL unmarkit;
 | 
|---|
| 284 |   PSZ file;
 | 
|---|
| 285 |   PSZ pszToMatch;
 | 
|---|
| 286 |   MASK Mask;
 | 
|---|
| 287 |   register INT x;
 | 
|---|
| 288 |   ULONG textlen = 0;
 | 
|---|
| 289 | 
 | 
|---|
| 290 |   if (text)
 | 
|---|
| 291 |     textlen = strlen(text);
 | 
|---|
| 292 |   memset(&Mask, 0, sizeof(Mask));
 | 
|---|
| 293 |   if (maskstr && *maskstr)
 | 
|---|
| 294 |     SetMask(maskstr, &Mask);
 | 
|---|
| 295 |   pci = (PCNRITEM) WinSendMsg(hwndCnr, CM_QUERYRECORD, MPVOID,
 | 
|---|
| 296 |                               MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
 | 
|---|
| 297 |   while (pci && (INT)pci != -1) {
 | 
|---|
| 298 |     unmarkit = FALSE;
 | 
|---|
| 299 |     if (~pci->rc.flRecordAttr & CRA_FILTERED) {
 | 
|---|
| 300 |       if (!is_arc) {
 | 
|---|
| 301 |         if (files && ~pci->attrFile & FILE_DIRECTORY)
 | 
|---|
| 302 |           unmarkit = TRUE;
 | 
|---|
| 303 |         if (dirs && (pci->attrFile & FILE_DIRECTORY))
 | 
|---|
| 304 |           unmarkit = TRUE;
 | 
|---|
| 305 |       }
 | 
|---|
| 306 |       else
 | 
|---|
| 307 |         unmarkit = TRUE;
 | 
|---|
| 308 |       if (maskstr && *maskstr && unmarkit) {
 | 
|---|
| 309 |         unmarkit = FALSE;
 | 
|---|
| 310 |         file = strrchr(pci->pszFileName, '\\');
 | 
|---|
| 311 |         if (!file)
 | 
|---|
| 312 |           file = strrchr(pci->pszFileName, ':');
 | 
|---|
| 313 |         if (file)
 | 
|---|
| 314 |           file++;
 | 
|---|
| 315 |         else
 | 
|---|
| 316 |           file = pci->pszFileName;
 | 
|---|
| 317 |         for (x = 0; Mask.pszMasks[x]; x++) {
 | 
|---|
| 318 |           if (*Mask.pszMasks[x]) {
 | 
|---|
| 319 |             if (strchr(Mask.pszMasks[x], '\\') ||
 | 
|---|
| 320 |                 strchr(Mask.pszMasks[x], ':'))
 | 
|---|
| 321 |               pszToMatch = pci->pszFileName;
 | 
|---|
| 322 |             else
 | 
|---|
| 323 |               pszToMatch = file;
 | 
|---|
| 324 |             if (*Mask.pszMasks[x] != '/') {
 | 
|---|
| 325 |               if (wildcard(pszToMatch, Mask.pszMasks[x], FALSE))
 | 
|---|
| 326 |                 unmarkit = TRUE;
 | 
|---|
| 327 |             }
 | 
|---|
| 328 |             else {
 | 
|---|
| 329 |               if (wildcard(pszToMatch, Mask.pszMasks[x] + 1, FALSE)) {
 | 
|---|
| 330 |                 unmarkit = FALSE;
 | 
|---|
| 331 |                 break;
 | 
|---|
| 332 |               }
 | 
|---|
| 333 |             }
 | 
|---|
| 334 |           }
 | 
|---|
| 335 |         }
 | 
|---|
| 336 |       }
 | 
|---|
| 337 |     }
 | 
|---|
| 338 | 
 | 
|---|
| 339 |     if (unmarkit && text && *text) {
 | 
|---|
| 340 |       if (~pci->attrFile & FILE_DIRECTORY) {
 | 
|---|
| 341 |         PSZ input;
 | 
|---|
| 342 |         unmarkit = FALSE;
 | 
|---|
| 343 |         input = xmalloc(65537, pszSrcFile, __LINE__);
 | 
|---|
| 344 |         if (input) {
 | 
|---|
| 345 |           ULONG pos;
 | 
|---|
| 346 |           LONG len;
 | 
|---|
| 347 |           FILE *inputFile;
 | 
|---|
| 348 | 
 | 
|---|
| 349 |           if ((inputFile = _fsopen(pci->pszFileName, "rb", SH_DENYNO)) != NULL) {
 | 
|---|
| 350 |             pos = ftell(inputFile);
 | 
|---|
| 351 |             while (!feof(inputFile)) {
 | 
|---|
| 352 |               if (pos)
 | 
|---|
| 353 |                 fseek(inputFile, pos - 256, SEEK_SET);
 | 
|---|
| 354 |               len = fread(input, 1, 65536, inputFile);
 | 
|---|
| 355 |               if (len >= 0) {
 | 
|---|
| 356 |                 if (findstring(text, textlen, input, len, FALSE)) {
 | 
|---|
| 357 |                   unmarkit = TRUE;
 | 
|---|
| 358 |                   break;
 | 
|---|
| 359 |                 }
 | 
|---|
| 360 |               }
 | 
|---|
| 361 |               else
 | 
|---|
| 362 |                 break;
 | 
|---|
| 363 |             } // while
 | 
|---|
| 364 |             fclose(inputFile);
 | 
|---|
| 365 |           }
 | 
|---|
| 366 |           free(input);
 | 
|---|
| 367 |           DosSleep(1);
 | 
|---|
| 368 |         }
 | 
|---|
| 369 |       }
 | 
|---|
| 370 |       else
 | 
|---|
| 371 |         unmarkit = FALSE;
 | 
|---|
| 372 |     }
 | 
|---|
| 373 | 
 | 
|---|
| 374 |     if (unmarkit)
 | 
|---|
| 375 |       WinSendMsg(hwndCnr, CM_SETRECORDEMPHASIS, pci,
 | 
|---|
| 376 |                  MPFROM2SHORT(FALSE, CRA_SELECTED | CRA_CURSORED |
 | 
|---|
| 377 |                               CRA_INUSE | CRA_SOURCE));
 | 
|---|
| 378 |     pci = (PCNRITEM) WinSendMsg(hwndCnr, CM_QUERYRECORD, MPFROMP(pci),
 | 
|---|
| 379 |                                 MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
 | 
|---|
| 380 |   }
 | 
|---|
| 381 | }
 | 
|---|
| 382 | 
 | 
|---|
| 383 | VOID Deselect(HWND hwndCnr)
 | 
|---|
| 384 | {
 | 
|---|
| 385 |   PCNRITEM pcil;
 | 
|---|
| 386 | 
 | 
|---|
| 387 |   pcil = (PCNRITEM) WinSendMsg(hwndCnr, CM_QUERYRECORDEMPHASIS,
 | 
|---|
| 388 |                                MPFROMLONG(CMA_FIRST),
 | 
|---|
| 389 |                                MPFROMSHORT(CRA_SELECTED));
 | 
|---|
| 390 |   while (pcil && (INT)pcil != -1) {
 | 
|---|
| 391 |     WinSendMsg(hwndCnr, CM_SETRECORDEMPHASIS, MPFROMP(pcil),
 | 
|---|
| 392 |                MPFROM2SHORT(FALSE, CRA_SELECTED));
 | 
|---|
| 393 |     pcil = WinSendMsg(hwndCnr, CM_QUERYRECORDEMPHASIS, MPFROMP(pcil),
 | 
|---|
| 394 |                       MPFROMSHORT(CRA_SELECTED));
 | 
|---|
| 395 |   }
 | 
|---|
| 396 | }
 | 
|---|
| 397 | 
 | 
|---|
| 398 | //=== HideAll() Hide all selected records ===
 | 
|---|
| 399 | 
 | 
|---|
| 400 | VOID HideAll(HWND hwndCnr)
 | 
|---|
| 401 | {
 | 
|---|
| 402 |   PCNRITEM pci, pciH;
 | 
|---|
| 403 |   INT attribute = CRA_CURSORED;
 | 
|---|
| 404 |   CNRINFO cnri;
 | 
|---|
| 405 |   BOOL didone = FALSE;
 | 
|---|
| 406 | 
 | 
|---|
| 407 |   memset(&cnri, 0, sizeof(CNRINFO));
 | 
|---|
| 408 |   cnri.cb = sizeof(CNRINFO);
 | 
|---|
| 409 |   WinSendMsg(hwndCnr, CM_QUERYCNRINFO, MPFROMP(&cnri),
 | 
|---|
| 410 |              MPFROMLONG(sizeof(CNRINFO)));
 | 
|---|
| 411 |   pci = (PCNRITEM) CurrentRecord(hwndCnr);
 | 
|---|
| 412 |   if (pci && (INT)pci != -1) {
 | 
|---|
| 413 |     if (pci->rc.flRecordAttr & CRA_SELECTED) {
 | 
|---|
| 414 |       attribute = CRA_SELECTED;
 | 
|---|
| 415 |       pci = WinSendMsg(hwndCnr, CM_QUERYRECORDEMPHASIS, MPFROMLONG(CMA_FIRST),
 | 
|---|
| 416 |                        MPFROMSHORT(attribute));
 | 
|---|
| 417 |     }
 | 
|---|
| 418 |   }
 | 
|---|
| 419 |   while (pci && (INT)pci != -1) {
 | 
|---|
| 420 |     pciH = WinSendMsg(hwndCnr, CM_QUERYRECORDEMPHASIS, MPFROMP(pci),
 | 
|---|
| 421 |                       MPFROMSHORT(attribute));
 | 
|---|
| 422 |     WinSendMsg(hwndCnr, CM_SETRECORDEMPHASIS, MPFROMP(pci),
 | 
|---|
| 423 |                MPFROM2SHORT(FALSE, CRA_CURSORED | CRA_SELECTED |
 | 
|---|
| 424 |                             CRA_INUSE | CRA_SOURCE));
 | 
|---|
| 425 |     pci->rc.flRecordAttr |= CRA_FILTERED;
 | 
|---|
| 426 |     didone = TRUE;
 | 
|---|
| 427 |     if (fSyncUpdates) {
 | 
|---|
| 428 |       if (cnri.flWindowAttr & CV_DETAIL)
 | 
|---|
| 429 |         WinSendMsg(hwndCnr, CM_INVALIDATERECORD, MPVOID,
 | 
|---|
| 430 |                    MPFROM2SHORT(0, CMA_REPOSITION | CMA_ERASE));
 | 
|---|
| 431 |       else
 | 
|---|
| 432 |         WinSendMsg(hwndCnr, CM_INVALIDATERECORD, MPFROMP(&pci),
 | 
|---|
| 433 |                    MPFROM2SHORT(1, CMA_REPOSITION | CMA_ERASE));
 | 
|---|
| 434 |     }
 | 
|---|
| 435 |     pci = pciH;
 | 
|---|
| 436 |   }
 | 
|---|
| 437 |   if (didone && !fSyncUpdates)
 | 
|---|
| 438 |     WinSendMsg(hwndCnr, CM_INVALIDATERECORD, MPVOID,
 | 
|---|
| 439 |                MPFROM2SHORT(0, CMA_ERASE | CMA_REPOSITION));
 | 
|---|
| 440 | }
 | 
|---|
| 441 | 
 | 
|---|
| 442 | VOID MarkAll(HWND hwndCnr, BOOL quitit, BOOL target, BOOL source)
 | 
|---|
| 443 | {
 | 
|---|
| 444 |   PCNRITEM pci;
 | 
|---|
| 445 |   INT attribute = CRA_CURSORED;
 | 
|---|
| 446 | 
 | 
|---|
| 447 |   if (quitit)
 | 
|---|
| 448 |     attribute = target ? CRA_TARGET : source ? CRA_SOURCE : CRA_INUSE;
 | 
|---|
| 449 |   pci = (PCNRITEM) WinSendMsg(hwndCnr, CM_QUERYRECORDEMPHASIS,
 | 
|---|
| 450 |                               MPFROMLONG(CMA_FIRST), MPFROMSHORT(attribute));
 | 
|---|
| 451 |   if (pci && (INT)pci != -1) {
 | 
|---|
| 452 |     if (attribute == CRA_CURSORED) {
 | 
|---|
| 453 |       if (pci->rc.flRecordAttr & CRA_SELECTED) {
 | 
|---|
| 454 |         attribute = CRA_SELECTED;
 | 
|---|
| 455 |         pci =
 | 
|---|
| 456 |           WinSendMsg(hwndCnr, CM_QUERYRECORDEMPHASIS, MPFROMLONG(CMA_FIRST),
 | 
|---|
| 457 |                      MPFROMSHORT(attribute));
 | 
|---|
| 458 |       }
 | 
|---|
| 459 |     }
 | 
|---|
| 460 |   }
 | 
|---|
| 461 |   while (pci && (INT)pci != -1) {
 | 
|---|
| 462 |     WinSendMsg(hwndCnr, CM_SETRECORDEMPHASIS, MPFROMP(pci),
 | 
|---|
| 463 |                MPFROM2SHORT(!quitit,
 | 
|---|
| 464 |                             target ? CRA_TARGET : source ? CRA_SOURCE :
 | 
|---|
| 465 |                              CRA_INUSE));
 | 
|---|
| 466 |     pci =
 | 
|---|
| 467 |       WinSendMsg(hwndCnr, CM_QUERYRECORDEMPHASIS, MPFROMP(pci),
 | 
|---|
| 468 |                  MPFROMSHORT(attribute));
 | 
|---|
| 469 |   }
 | 
|---|
| 470 | }
 | 
|---|
| 471 | 
 | 
|---|
| 472 | VOID RemoveAll(HWND hwndCnr, ULONGLONG * pullTotalBytes,
 | 
|---|
| 473 |                ULONG * pulTotalFiles)
 | 
|---|
| 474 | {
 | 
|---|
| 475 |   PCNRITEM pci;
 | 
|---|
| 476 |   INT attribute = CRA_CURSORED;
 | 
|---|
| 477 |   BOOL didone = FALSE;
 | 
|---|
| 478 | 
 | 
|---|
| 479 |   pci = (PCNRITEM) CurrentRecord(hwndCnr);
 | 
|---|
| 480 |   if (pci && (INT)pci != -1) {
 | 
|---|
| 481 |     if (pci->rc.flRecordAttr & CRA_SELECTED) {
 | 
|---|
| 482 |       attribute = CRA_SELECTED;
 | 
|---|
| 483 |       pci = WinSendMsg(hwndCnr, CM_QUERYRECORDEMPHASIS, MPFROMLONG(CMA_FIRST),
 | 
|---|
| 484 |                        MPFROMSHORT(attribute));
 | 
|---|
| 485 |     }
 | 
|---|
| 486 |   }
 | 
|---|
| 487 |   while (pci && (INT)pci != -1) {
 | 
|---|
| 488 |     if (~pci->rc.flRecordAttr & CRA_FILTERED) {
 | 
|---|
| 489 |       didone = TRUE;
 | 
|---|
| 490 |       if (pulTotalFiles)
 | 
|---|
| 491 |         *pulTotalFiles -= 1;
 | 
|---|
| 492 |       if (pullTotalBytes)
 | 
|---|
| 493 |         *pullTotalBytes -= (pci->cbFile + pci->easize);
 | 
|---|
| 494 |       WinSendMsg(hwndCnr, CM_SETRECORDEMPHASIS, MPFROMP(pci),
 | 
|---|
| 495 |                  MPFROM2SHORT(0, CRA_SELECTED));
 | 
|---|
| 496 |       if (fSyncUpdates)
 | 
|---|
| 497 |         RemoveCnrItems(hwndCnr, pci, 1, CMA_FREE | CMA_INVALIDATE);
 | 
|---|
| 498 |       else
 | 
|---|
| 499 |         RemoveCnrItems(hwndCnr, pci, 1, CMA_FREE);
 | 
|---|
| 500 |       if (attribute == CRA_CURSORED)
 | 
|---|
| 501 |         break;
 | 
|---|
| 502 |       pci = WinSendMsg(hwndCnr, CM_QUERYRECORDEMPHASIS, MPFROMLONG(CMA_FIRST),
 | 
|---|
| 503 |                        MPFROMSHORT(attribute));
 | 
|---|
| 504 |     }
 | 
|---|
| 505 |     else
 | 
|---|
| 506 |       pci = WinSendMsg(hwndCnr, CM_QUERYRECORDEMPHASIS, MPFROMP(pci),
 | 
|---|
| 507 |                        MPFROMSHORT(attribute));
 | 
|---|
| 508 |   }
 | 
|---|
| 509 |   if (didone && !fSyncUpdates)
 | 
|---|
| 510 |     WinSendMsg(hwndCnr, CM_INVALIDATERECORD, MPVOID,
 | 
|---|
| 511 |                MPFROM2SHORT(0, CMA_REPOSITION));
 | 
|---|
| 512 | }
 | 
|---|
| 513 | 
 | 
|---|
| 514 | //== SetMask() Convert mask string to array of pointers to masks ==
 | 
|---|
| 515 | 
 | 
|---|
| 516 | VOID SetMask(PSZ maskstr, MASK * mask)
 | 
|---|
| 517 | {
 | 
|---|
| 518 |   UINT x;
 | 
|---|
| 519 |   PSZ p;
 | 
|---|
| 520 | 
 | 
|---|
| 521 |   if (maskstr)
 | 
|---|
| 522 |     strcpy(mask->szMask, maskstr);      // Got new mask string
 | 
|---|
| 523 |   // Build array of pointers
 | 
|---|
| 524 |   p = mask->szMaskCopy;
 | 
|---|
| 525 |   strcpy(p, mask->szMask);
 | 
|---|
| 526 |   // Allow up to 25 masks - ignore extras
 | 
|---|
| 527 |   for (x = 0; *p && x < 25; x++) {
 | 
|---|
| 528 |     mask->pszMasks[x] = p;
 | 
|---|
| 529 |     while (*p && *p != ';')
 | 
|---|
| 530 |       p++;                              // Find separator
 | 
|---|
| 531 |     if (*p) {
 | 
|---|
| 532 |       *p = 0;                           // Replace ;
 | 
|---|
| 533 |       p++;
 | 
|---|
| 534 |     }
 | 
|---|
| 535 |   }                                     // for
 | 
|---|
| 536 |   mask->pszMasks[x] = NULL;             // Mark end
 | 
|---|
| 537 | }
 | 
|---|
| 538 | 
 | 
|---|
| 539 | VOID ExpandAll(HWND hwndCnr, BOOL expand, PCNRITEM pciParent)
 | 
|---|
| 540 | {
 | 
|---|
| 541 |   PCNRITEM pci;
 | 
|---|
| 542 | 
 | 
|---|
| 543 |   if (!pciParent)
 | 
|---|
| 544 |     pciParent = WinSendMsg(hwndCnr, CM_QUERYRECORD, MPFROMP(NULL),
 | 
|---|
| 545 |                            MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
 | 
|---|
| 546 |   if (pciParent) {
 | 
|---|
| 547 |     if (expand && ~pciParent->rc.flRecordAttr & CRA_EXPANDED)
 | 
|---|
| 548 |       WinSendMsg(hwndCnr, CM_EXPANDTREE, MPFROMP(pciParent), MPVOID);
 | 
|---|
| 549 |     else if (!expand && (pciParent->rc.flRecordAttr & CRA_EXPANDED))
 | 
|---|
| 550 |       WinSendMsg(hwndCnr, CM_COLLAPSETREE, MPFROMP(pciParent), MPVOID);
 | 
|---|
| 551 |     pci = (PCNRITEM) WinSendMsg(hwndCnr, CM_QUERYRECORD, MPFROMP(pciParent),
 | 
|---|
| 552 |                                 MPFROM2SHORT(CMA_FIRSTCHILD, CMA_ITEMORDER));
 | 
|---|
| 553 |     if (pci)
 | 
|---|
| 554 |       DosSleep(0);
 | 
|---|
| 555 |     while (pci && (INT)pci != -1) {
 | 
|---|
| 556 |       ExpandAll(hwndCnr, expand, pci);
 | 
|---|
| 557 |       pci = (PCNRITEM) WinSendMsg(hwndCnr, CM_QUERYRECORD, MPFROMP(pci),
 | 
|---|
| 558 |                                   MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
 | 
|---|
| 559 |     }
 | 
|---|
| 560 |   }
 | 
|---|
| 561 |   DosSleep(0);
 | 
|---|
| 562 | }
 | 
|---|
| 563 | 
 | 
|---|
| 564 | VOID InvertAll(HWND hwndCnr)
 | 
|---|
| 565 | {
 | 
|---|
| 566 |   PCNRITEM pci;
 | 
|---|
| 567 | 
 | 
|---|
| 568 |   pci = (PCNRITEM) WinSendMsg(hwndCnr, CM_QUERYRECORD, MPVOID,
 | 
|---|
| 569 |                               MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
 | 
|---|
| 570 |   while (pci && (INT)pci != -1) {
 | 
|---|
| 571 |     if (~pci->rc.flRecordAttr & CRA_FILTERED) {
 | 
|---|
| 572 |       if (~pci->rc.flRecordAttr & CRA_SELECTED)
 | 
|---|
| 573 |         WinSendMsg(hwndCnr, CM_SETRECORDEMPHASIS, MPFROMP(pci),
 | 
|---|
| 574 |                    MPFROM2SHORT(TRUE, CRA_SELECTED));
 | 
|---|
| 575 |       else
 | 
|---|
| 576 |         WinSendMsg(hwndCnr, CM_SETRECORDEMPHASIS, MPFROMP(pci),
 | 
|---|
| 577 |                    MPFROM2SHORT(FALSE, CRA_SELECTED));
 | 
|---|
| 578 |     }
 | 
|---|
| 579 |     pci = (PCNRITEM) WinSendMsg(hwndCnr, CM_QUERYRECORD, MPFROMP(pci),
 | 
|---|
| 580 |                                 MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
 | 
|---|
| 581 |   }
 | 
|---|
| 582 | }
 | 
|---|
| 583 | 
 | 
|---|
| 584 | struct SS
 | 
|---|
| 585 | {
 | 
|---|
| 586 |   PCNRITEM pci;
 | 
|---|
| 587 |   BOOL unique, all, smallest, largest, newest, oldest;
 | 
|---|
| 588 | };
 | 
|---|
| 589 | 
 | 
|---|
| 590 | struct Cnr
 | 
|---|
| 591 | {
 | 
|---|
| 592 |   HWND hwndCnr;
 | 
|---|
| 593 |   ULONG numfiles;
 | 
|---|
| 594 |   struct SS *ss;
 | 
|---|
| 595 | };
 | 
|---|
| 596 | 
 | 
|---|
| 597 | static int CompSSNamesB(const void *s1, const void *s2)
 | 
|---|
| 598 | {
 | 
|---|
| 599 |   struct SS *ss2 = (struct SS *)s2;
 | 
|---|
| 600 | 
 | 
|---|
| 601 |   return stricmp((PSZ)s1, ss2->pci->pszFileName);
 | 
|---|
| 602 | }
 | 
|---|
| 603 | 
 | 
|---|
| 604 | static int CompSSNames(const void *s1, const void *s2)
 | 
|---|
| 605 | {
 | 
|---|
| 606 |   struct SS *ss1 = (struct SS *)s1;
 | 
|---|
| 607 |   struct SS *ss2 = (struct SS *)s2;
 | 
|---|
| 608 | 
 | 
|---|
| 609 |   return stricmp(ss1->pci->pszFileName, ss2->pci->pszFileName);
 | 
|---|
| 610 | }
 | 
|---|
| 611 | 
 | 
|---|
| 612 | VOID FreeCnrs(struct Cnr * Cnrs, INT numw)
 | 
|---|
| 613 | {
 | 
|---|
| 614 |   register INT z;
 | 
|---|
| 615 | 
 | 
|---|
| 616 |   for (z = 0; z < numw; z++) {
 | 
|---|
| 617 |     xfree(Cnrs[z].ss, pszSrcFile, __LINE__);
 | 
|---|
| 618 |   }
 | 
|---|
| 619 |   xfree(Cnrs, pszSrcFile, __LINE__);
 | 
|---|
| 620 |   DosPostEventSem(CompactSem);
 | 
|---|
| 621 | }
 | 
|---|
| 622 | 
 | 
|---|
| 623 | /**
 | 
|---|
| 624 |  * Do select actions for single container
 | 
|---|
| 625 |  *
 | 
|---|
| 626 |  */
 | 
|---|
| 627 | 
 | 
|---|
| 628 | VOID SpecialSelect2(HWND hwndParent, INT action)
 | 
|---|
| 629 | {
 | 
|---|
| 630 |   PCNRITEM pci;
 | 
|---|
| 631 |   HENUM henum;
 | 
|---|
| 632 |   HWND hwnd;
 | 
|---|
| 633 |   INT numwindows = 0, w, x, z, cmp = 0;
 | 
|---|
| 634 |   struct Cnr *Cnrs = NULL;
 | 
|---|
| 635 |   struct SS *bsres;
 | 
|---|
| 636 | 
 | 
|---|
| 637 |   if (!hwndParent)
 | 
|---|
| 638 |     return;
 | 
|---|
| 639 | 
 | 
|---|
| 640 |   /* count directory containers, build array of hwnds */
 | 
|---|
| 641 |   henum = WinBeginEnumWindows(hwndParent);
 | 
|---|
| 642 |   while ((hwnd = WinGetNextWindow(henum)) != NULLHANDLE) {
 | 
|---|
| 643 |     if (WinWindowFromID(WinWindowFromID(hwnd, FID_CLIENT), DIR_CNR)) {
 | 
|---|
| 644 |       Cnrs =
 | 
|---|
| 645 |         xrealloc(Cnrs, (numwindows + 1) * sizeof(struct Cnr), pszSrcFile,
 | 
|---|
| 646 |                  __LINE__);
 | 
|---|
| 647 |       if (!Cnrs) {
 | 
|---|
| 648 |         Notify(GetPString(IDS_OUTOFMEMORY));
 | 
|---|
| 649 |         return;
 | 
|---|
| 650 |       }
 | 
|---|
| 651 |       memset(&Cnrs[numwindows], 0, sizeof(struct Cnr));
 | 
|---|
| 652 |       Cnrs[numwindows].hwndCnr = WinWindowFromID(WinWindowFromID(hwnd,
 | 
|---|
| 653 |                                                                  FID_CLIENT),
 | 
|---|
| 654 |                                                  DIR_CNR);
 | 
|---|
| 655 |       numwindows++;
 | 
|---|
| 656 |     }
 | 
|---|
| 657 |   }
 | 
|---|
| 658 |   WinEndEnumWindows(henum);
 | 
|---|
| 659 |   if (numwindows < 2) {
 | 
|---|
| 660 |     FreeCnrs(Cnrs, numwindows);
 | 
|---|
| 661 |     Runtime_Error(pszSrcFile, __LINE__, "expected two windows");
 | 
|---|
| 662 |     Notify(GetPString(IDS_COMPSEL2ORMORETEXT));
 | 
|---|
| 663 |     return;
 | 
|---|
| 664 |   }
 | 
|---|
| 665 |   if (numwindows > 4) {
 | 
|---|
| 666 |     WinSendMsg(Cnrs[0].
 | 
|---|
| 667 |                hwndCnr,
 | 
|---|
| 668 |                UM_NOTIFY, MPFROMP(GetPString(IDS_BUILDINGLISTSTEXT)), MPVOID);
 | 
|---|
| 669 |     DosSleep(0); //26 Aug 07 GKY 1
 | 
|---|
| 670 |   }
 | 
|---|
| 671 | 
 | 
|---|
| 672 |   /* count records, build array of pointers to records */
 | 
|---|
| 673 |   for (z = 0; z < numwindows; z++) {
 | 
|---|
| 674 |     pci = (PCNRITEM) WinSendMsg(Cnrs[z].hwndCnr,
 | 
|---|
| 675 |                                 CM_QUERYRECORD,
 | 
|---|
| 676 |                                 MPVOID,
 | 
|---|
| 677 |                                 MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
 | 
|---|
| 678 |     x = 0;
 | 
|---|
| 679 |     while (pci && (INT)pci != -1) {
 | 
|---|
| 680 |       if (~pci->rc.flRecordAttr & CRA_FILTERED &&
 | 
|---|
| 681 |           ~pci->attrFile & FILE_DIRECTORY) {
 | 
|---|
| 682 |         Cnrs[z].ss =
 | 
|---|
| 683 |           xrealloc(Cnrs[z].ss, (x + 1) * sizeof(struct SS), pszSrcFile,
 | 
|---|
| 684 |                    __LINE__);
 | 
|---|
| 685 |         if (!Cnrs[z].ss) {
 | 
|---|
| 686 |           FreeCnrs(Cnrs, numwindows);
 | 
|---|
| 687 |           Notify(GetPString(IDS_OUTOFMEMORY));
 | 
|---|
| 688 |           return;
 | 
|---|
| 689 |         }
 | 
|---|
| 690 |         memset(&Cnrs[z].ss[x], 0, sizeof(struct SS));
 | 
|---|
| 691 |         Cnrs[z].ss[x].pci = pci;
 | 
|---|
| 692 |         x++;
 | 
|---|
| 693 |       }
 | 
|---|
| 694 |       pci = (PCNRITEM) WinSendMsg(Cnrs[z].hwndCnr,
 | 
|---|
| 695 |                                   CM_QUERYRECORD,
 | 
|---|
| 696 |                                   MPFROMP(pci),
 | 
|---|
| 697 |                                   MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
 | 
|---|
| 698 |     }
 | 
|---|
| 699 |     DosSleep(0);  //26 Aug 07 GKY 1
 | 
|---|
| 700 |     Cnrs[z].numfiles = x;
 | 
|---|
| 701 |     if (Cnrs[z].numfiles)
 | 
|---|
| 702 |       qsort(Cnrs[z].ss, Cnrs[z].numfiles, sizeof(struct SS), CompSSNames);
 | 
|---|
| 703 |   }
 | 
|---|
| 704 | 
 | 
|---|
| 705 |   for (z = 0; z < numwindows; z++) {
 | 
|---|
| 706 |     for (x = 0; x < Cnrs[z].numfiles; x++) {
 | 
|---|
| 707 |       Cnrs[z].ss[x].all = Cnrs[z].ss[x].unique = Cnrs[z].ss[x].newest =
 | 
|---|
| 708 |         Cnrs[z].ss[x].oldest = Cnrs[z].ss[x].smallest =
 | 
|---|
| 709 |         Cnrs[z].ss[x].largest = TRUE;
 | 
|---|
| 710 |       for (w = 0; w < numwindows; w++) {
 | 
|---|
| 711 |         if (w != z && Cnrs[w].numfiles) {
 | 
|---|
| 712 |           bsres = (struct SS *)bsearch(Cnrs[z].ss[x].pci->pszFileName,
 | 
|---|
| 713 |                                        Cnrs[w].ss, Cnrs[w].numfiles,
 | 
|---|
| 714 |                                        sizeof(struct SS), CompSSNamesB);
 | 
|---|
| 715 |           if (bsres) {
 | 
|---|
| 716 |             Cnrs[z].ss[x].unique = FALSE;
 | 
|---|
| 717 |             if (Cnrs[z].ss[x].pci->cbFile + Cnrs[z].ss[x].pci->easize >
 | 
|---|
| 718 |                 bsres->pci->cbFile + bsres->pci->easize)
 | 
|---|
| 719 |               Cnrs[z].ss[x].smallest = FALSE;
 | 
|---|
| 720 |             if (Cnrs[z].ss[x].pci->cbFile + Cnrs[z].ss[x].pci->easize <
 | 
|---|
| 721 |                 bsres->pci->cbFile + bsres->pci->easize)
 | 
|---|
| 722 |               Cnrs[z].ss[x].largest = FALSE;
 | 
|---|
| 723 |             cmp = TestCDates(&bsres->pci->date, &bsres->pci->time,
 | 
|---|
| 724 |                              &Cnrs[z].ss[x].pci->date, &Cnrs[z].ss[x].pci->time);
 | 
|---|
| 725 |               /*(Cnrs[z].ss[x].pci->date.year >
 | 
|---|
| 726 |                bsres->pci->date.year) ? TRUE : (Cnrs[z].ss[x].pci->date.year <
 | 
|---|
| 727 |                                                 bsres->pci->date.
 | 
|---|
| 728 |                                                 year) ? FALSE : (Cnrs[z].
 | 
|---|
| 729 |                                                                  ss[x].pci->
 | 
|---|
| 730 |                                                                  date.month >
 | 
|---|
| 731 |                                                                  bsres->pci->
 | 
|---|
| 732 |                                                                  date.
 | 
|---|
| 733 |                                                                  month) ? TRUE
 | 
|---|
| 734 |               : (Cnrs[z].ss[x].pci->date.month <
 | 
|---|
| 735 |                  bsres->pci->date.month) ? FALSE : (Cnrs[z].ss[x].pci->date.
 | 
|---|
| 736 |                                                     day >
 | 
|---|
| 737 |                                                     bsres->pci->date.
 | 
|---|
| 738 |                                                     day) ? TRUE : (Cnrs[z].
 | 
|---|
| 739 |                                                                    ss[x].pci->
 | 
|---|
| 740 |                                                                    date.day <
 | 
|---|
| 741 |                                                                    bsres->
 | 
|---|
| 742 |                                                                    pci->date.
 | 
|---|
| 743 |                                                                    day) ?
 | 
|---|
| 744 |               FALSE : (Cnrs[z].ss[x].pci->time.hours >
 | 
|---|
| 745 |                        bsres->pci->time.hours) ? TRUE : (Cnrs[z].ss[x].pci->
 | 
|---|
| 746 |                                                          time.hours <
 | 
|---|
| 747 |                                                          bsres->pci->time.
 | 
|---|
| 748 |                                                          hours) ? FALSE
 | 
|---|
| 749 |               : (Cnrs[z].ss[x].pci->time.minutes >
 | 
|---|
| 750 |                  bsres->pci->time.minutes) ? TRUE : (Cnrs[z].ss[x].pci->time.
 | 
|---|
| 751 |                                                      minutes <
 | 
|---|
| 752 |                                                      bsres->pci->time.
 | 
|---|
| 753 |                                                      minutes) ? FALSE
 | 
|---|
| 754 |               : (Cnrs[z].ss[x].pci->time.seconds >
 | 
|---|
| 755 |                  bsres->pci->time.seconds) ? TRUE : (Cnrs[z].ss[x].pci->time.
 | 
|---|
| 756 |                                                      seconds <
 | 
|---|
| 757 |                                                      bsres->pci->time.
 | 
|---|
| 758 |                                                      seconds) ? FALSE : FALSE;*/
 | 
|---|
| 759 |             if (cmp != 1)
 | 
|---|
| 760 |               Cnrs[z].ss[x].newest = FALSE;
 | 
|---|
| 761 |             /*cmp =
 | 
|---|
| 762 |               (Cnrs[z].ss[x].pci->date.year <
 | 
|---|
| 763 |                bsres->pci->date.year) ? TRUE : (Cnrs[z].ss[x].pci->date.year >
 | 
|---|
| 764 |                                                 bsres->pci->date.
 | 
|---|
| 765 |                                                 year) ? FALSE : (Cnrs[z].
 | 
|---|
| 766 |                                                                  ss[x].pci->
 | 
|---|
| 767 |                                                                  date.month <
 | 
|---|
| 768 |                                                                  bsres->pci->
 | 
|---|
| 769 |                                                                  date.
 | 
|---|
| 770 |                                                                  month) ? TRUE
 | 
|---|
| 771 |               : (Cnrs[z].ss[x].pci->date.month >
 | 
|---|
| 772 |                  bsres->pci->date.month) ? FALSE : (Cnrs[z].ss[x].pci->date.
 | 
|---|
| 773 |                                                     day <
 | 
|---|
| 774 |                                                     bsres->pci->date.
 | 
|---|
| 775 |                                                     day) ? TRUE : (Cnrs[z].
 | 
|---|
| 776 |                                                                    ss[x].pci->
 | 
|---|
| 777 |                                                                    date.day >
 | 
|---|
| 778 |                                                                    bsres->
 | 
|---|
| 779 |                                                                    pci->date.
 | 
|---|
| 780 |                                                                    day) ?
 | 
|---|
| 781 |               FALSE : (Cnrs[z].ss[x].pci->time.hours <
 | 
|---|
| 782 |                        bsres->pci->time.hours) ? TRUE : (Cnrs[z].ss[x].pci->
 | 
|---|
| 783 |                                                          time.hours >
 | 
|---|
| 784 |                                                          bsres->pci->time.
 | 
|---|
| 785 |                                                          hours) ? FALSE
 | 
|---|
| 786 |               : (Cnrs[z].ss[x].pci->time.minutes <
 | 
|---|
| 787 |                  bsres->pci->time.minutes) ? TRUE : (Cnrs[z].ss[x].pci->time.
 | 
|---|
| 788 |                                                      minutes >
 | 
|---|
| 789 |                                                      bsres->pci->time.
 | 
|---|
| 790 |                                                      minutes) ? FALSE
 | 
|---|
| 791 |               : (Cnrs[z].ss[x].pci->time.seconds <
 | 
|---|
| 792 |                  bsres->pci->time.seconds) ? TRUE : (Cnrs[z].ss[x].pci->time.
 | 
|---|
| 793 |                                                      seconds >
 | 
|---|
| 794 |                                                      bsres->pci->time.
 | 
|---|
| 795 |                                                      seconds) ? FALSE : FALSE;*/
 | 
|---|
| 796 |             if (cmp != -1)
 | 
|---|
| 797 |               Cnrs[z].ss[x].oldest = FALSE;
 | 
|---|
| 798 |             cmp = 0;
 | 
|---|
| 799 |             break;
 | 
|---|
| 800 |           }
 | 
|---|
| 801 |           else
 | 
|---|
| 802 |             Cnrs[z].ss[x].all = FALSE;
 | 
|---|
| 803 |         }
 | 
|---|
| 804 |       }
 | 
|---|
| 805 |       if (Cnrs[z].ss[x].unique)
 | 
|---|
| 806 |         Cnrs[z].ss[x].oldest = Cnrs[z].ss[x].newest = Cnrs[z].ss[x].all =
 | 
|---|
| 807 |           Cnrs[z].ss[x].largest = Cnrs[z].ss[x].smallest = FALSE;
 | 
|---|
| 808 |       DosSleep(1);
 | 
|---|
| 809 |     }
 | 
|---|
| 810 |     DosSleep(1);
 | 
|---|
| 811 |   }
 | 
|---|
| 812 | 
 | 
|---|
| 813 |   switch (action) {
 | 
|---|
| 814 |   case IDM_SELECTBOTH:
 | 
|---|
| 815 |     for (z = 0; z < numwindows; z++) {
 | 
|---|
| 816 |       for (x = 0; x < Cnrs[z].numfiles; x++) {
 | 
|---|
| 817 |         if (Cnrs[z].ss[x].all)
 | 
|---|
| 818 |           WinSendMsg(Cnrs[z].hwndCnr, CM_SETRECORDEMPHASIS,
 | 
|---|
| 819 |                      MPFROMP(Cnrs[z].ss[x].pci),
 | 
|---|
| 820 |                      MPFROM2SHORT(TRUE, CRA_SELECTED));
 | 
|---|
| 821 |       }
 | 
|---|
| 822 |       DosSleep(0); //26 Aug 07 GKY 1
 | 
|---|
| 823 |     }
 | 
|---|
| 824 |     break;
 | 
|---|
| 825 |   case IDM_SELECTMORE:
 | 
|---|
| 826 |     for (z = 0; z < numwindows; z++) {
 | 
|---|
| 827 |       for (x = 0; x < Cnrs[z].numfiles; x++) {
 | 
|---|
| 828 |         if (!Cnrs[z].ss[x].unique)
 | 
|---|
| 829 |           WinSendMsg(Cnrs[z].hwndCnr, CM_SETRECORDEMPHASIS,
 | 
|---|
| 830 |                      MPFROMP(Cnrs[z].ss[x].pci),
 | 
|---|
| 831 |                      MPFROM2SHORT(TRUE, CRA_SELECTED));
 | 
|---|
| 832 |       }
 | 
|---|
| 833 |       DosSleep(0);  //26 Aug 07 GKY 1
 | 
|---|
| 834 |     }
 | 
|---|
| 835 |     break;
 | 
|---|
| 836 |   case IDM_SELECTONE:
 | 
|---|
| 837 |     for (z = 0; z < numwindows; z++) {
 | 
|---|
| 838 |       for (x = 0; x < Cnrs[z].numfiles; x++) {
 | 
|---|
| 839 |         if (Cnrs[z].ss[x].unique)
 | 
|---|
| 840 |           WinSendMsg(Cnrs[z].hwndCnr, CM_SETRECORDEMPHASIS,
 | 
|---|
| 841 |                      MPFROMP(Cnrs[z].ss[x].pci),
 | 
|---|
| 842 |                      MPFROM2SHORT(TRUE, CRA_SELECTED));
 | 
|---|
| 843 |       }
 | 
|---|
| 844 |       DosSleep(0);  //26 Aug 07 GKY 1
 | 
|---|
| 845 |     }
 | 
|---|
| 846 |     break;
 | 
|---|
| 847 |   case IDM_SELECTNEWER:
 | 
|---|
| 848 |     for (z = 0; z < numwindows; z++) {
 | 
|---|
| 849 |       for (x = 0; x < Cnrs[z].numfiles; x++) {
 | 
|---|
| 850 |         if (Cnrs[z].ss[x].newest)
 | 
|---|
| 851 |           WinSendMsg(Cnrs[z].hwndCnr, CM_SETRECORDEMPHASIS,
 | 
|---|
| 852 |                      MPFROMP(Cnrs[z].ss[x].pci),
 | 
|---|
| 853 |                      MPFROM2SHORT(TRUE, CRA_SELECTED));
 | 
|---|
| 854 |       }
 | 
|---|
| 855 |       DosSleep(0); //26 Aug 07 GKY 1
 | 
|---|
| 856 |     }
 | 
|---|
| 857 |     break;
 | 
|---|
| 858 |   case IDM_SELECTOLDER:
 | 
|---|
| 859 |     for (z = 0; z < numwindows; z++) {
 | 
|---|
| 860 |       for (x = 0; x < Cnrs[z].numfiles; x++) {
 | 
|---|
| 861 |         if (Cnrs[z].ss[x].oldest)
 | 
|---|
| 862 |           WinSendMsg(Cnrs[z].hwndCnr, CM_SETRECORDEMPHASIS,
 | 
|---|
| 863 |                      MPFROMP(Cnrs[z].ss[x].pci),
 | 
|---|
| 864 |                      MPFROM2SHORT(TRUE, CRA_SELECTED));
 | 
|---|
| 865 |       }
 | 
|---|
| 866 |       DosSleep(0); //26 Aug 07 GKY 1
 | 
|---|
| 867 |     }
 | 
|---|
| 868 |     break;
 | 
|---|
| 869 |   case IDM_SELECTBIGGER:
 | 
|---|
| 870 |     for (z = 0; z < numwindows; z++) {
 | 
|---|
| 871 |       for (x = 0; x < Cnrs[z].numfiles; x++) {
 | 
|---|
| 872 |         if (Cnrs[z].ss[x].largest)
 | 
|---|
| 873 |           WinSendMsg(Cnrs[z].hwndCnr, CM_SETRECORDEMPHASIS,
 | 
|---|
| 874 |                      MPFROMP(Cnrs[z].ss[x].pci),
 | 
|---|
| 875 |                      MPFROM2SHORT(TRUE, CRA_SELECTED));
 | 
|---|
| 876 |       }
 | 
|---|
| 877 |       DosSleep(0); //26 Aug 07 GKY 1
 | 
|---|
| 878 |     }
 | 
|---|
| 879 |     break;
 | 
|---|
| 880 |   case IDM_SELECTSMALLER:
 | 
|---|
| 881 |     for (z = 0; z < numwindows; z++) {
 | 
|---|
| 882 |       for (x = 0; x < Cnrs[z].numfiles; x++) {
 | 
|---|
| 883 |         if (Cnrs[z].ss[x].smallest)
 | 
|---|
| 884 |           WinSendMsg(Cnrs[z].hwndCnr, CM_SETRECORDEMPHASIS,
 | 
|---|
| 885 |                      MPFROMP(Cnrs[z].ss[x].pci),
 | 
|---|
| 886 |                      MPFROM2SHORT(TRUE, CRA_SELECTED));
 | 
|---|
| 887 |       }
 | 
|---|
| 888 |       DosSleep(0); //26 Aug 07 GKY 1
 | 
|---|
| 889 |     }
 | 
|---|
| 890 |     break;
 | 
|---|
| 891 | 
 | 
|---|
| 892 |   case IDM_DESELECTBOTH:
 | 
|---|
| 893 |     for (z = 0; z < numwindows; z++) {
 | 
|---|
| 894 |       for (x = 0; x < Cnrs[z].numfiles; x++) {
 | 
|---|
| 895 |         if (Cnrs[z].ss[x].all)
 | 
|---|
| 896 |           WinSendMsg(Cnrs[z].hwndCnr, CM_SETRECORDEMPHASIS,
 | 
|---|
| 897 |                      MPFROMP(Cnrs[z].ss[x].pci),
 | 
|---|
| 898 |                      MPFROM2SHORT(FALSE, CRA_SELECTED));
 | 
|---|
| 899 |       }
 | 
|---|
| 900 |       DosSleep(0); //26 Aug 07 GKY 1
 | 
|---|
| 901 |     }
 | 
|---|
| 902 |     break;
 | 
|---|
| 903 |   case IDM_DESELECTMORE:
 | 
|---|
| 904 |     for (z = 0; z < numwindows; z++) {
 | 
|---|
| 905 |       for (x = 0; x < Cnrs[z].numfiles; x++) {
 | 
|---|
| 906 |         if (!Cnrs[z].ss[x].unique)
 | 
|---|
| 907 |           WinSendMsg(Cnrs[z].hwndCnr, CM_SETRECORDEMPHASIS,
 | 
|---|
| 908 |                      MPFROMP(Cnrs[z].ss[x].pci),
 | 
|---|
| 909 |                      MPFROM2SHORT(FALSE, CRA_SELECTED));
 | 
|---|
| 910 |       }
 | 
|---|
| 911 |       DosSleep(0); //26 Aug 07 GKY 1
 | 
|---|
| 912 |     }
 | 
|---|
| 913 |     break;
 | 
|---|
| 914 |   case IDM_DESELECTONE:
 | 
|---|
| 915 |     for (z = 0; z < numwindows; z++) {
 | 
|---|
| 916 |       for (x = 0; x < Cnrs[z].numfiles; x++) {
 | 
|---|
| 917 |         if (Cnrs[z].ss[x].unique)
 | 
|---|
| 918 |           WinSendMsg(Cnrs[z].hwndCnr, CM_SETRECORDEMPHASIS,
 | 
|---|
| 919 |                      MPFROMP(Cnrs[z].ss[x].pci),
 | 
|---|
| 920 |                      MPFROM2SHORT(FALSE, CRA_SELECTED));
 | 
|---|
| 921 |       }
 | 
|---|
| 922 |       DosSleep(0); //26 Aug 07 GKY 1
 | 
|---|
| 923 |     }
 | 
|---|
| 924 |     break;
 | 
|---|
| 925 |   case IDM_DESELECTNEWER:
 | 
|---|
| 926 |     for (z = 0; z < numwindows; z++) {
 | 
|---|
| 927 |       for (x = 0; x < Cnrs[z].numfiles; x++) {
 | 
|---|
| 928 |         if (Cnrs[z].ss[x].newest)
 | 
|---|
| 929 |           WinSendMsg(Cnrs[z].hwndCnr, CM_SETRECORDEMPHASIS,
 | 
|---|
| 930 |                      MPFROMP(Cnrs[z].ss[x].pci),
 | 
|---|
| 931 |                      MPFROM2SHORT(FALSE, CRA_SELECTED));
 | 
|---|
| 932 |       }
 | 
|---|
| 933 |       DosSleep(0); //26 Aug 07 GKY 1
 | 
|---|
| 934 |     }
 | 
|---|
| 935 |     break;
 | 
|---|
| 936 |   case IDM_DESELECTOLDER:
 | 
|---|
| 937 |     for (z = 0; z < numwindows; z++) {
 | 
|---|
| 938 |       for (x = 0; x < Cnrs[z].numfiles; x++) {
 | 
|---|
| 939 |         if (Cnrs[z].ss[x].oldest)
 | 
|---|
| 940 |           WinSendMsg(Cnrs[z].hwndCnr, CM_SETRECORDEMPHASIS,
 | 
|---|
| 941 |                      MPFROMP(Cnrs[z].ss[x].pci),
 | 
|---|
| 942 |                      MPFROM2SHORT(FALSE, CRA_SELECTED));
 | 
|---|
| 943 |       }
 | 
|---|
| 944 |       DosSleep(0); //26 Aug 07 GKY 1
 | 
|---|
| 945 |     }
 | 
|---|
| 946 |     break;
 | 
|---|
| 947 |   case IDM_DESELECTBIGGER:
 | 
|---|
| 948 |     for (z = 0; z < numwindows; z++) {
 | 
|---|
| 949 |       for (x = 0; x < Cnrs[z].numfiles; x++) {
 | 
|---|
| 950 |         if (Cnrs[z].ss[x].largest)
 | 
|---|
| 951 |           WinSendMsg(Cnrs[z].hwndCnr, CM_SETRECORDEMPHASIS,
 | 
|---|
| 952 |                      MPFROMP(Cnrs[z].ss[x].pci),
 | 
|---|
| 953 |                      MPFROM2SHORT(FALSE, CRA_SELECTED));
 | 
|---|
| 954 |       }
 | 
|---|
| 955 |       DosSleep(0); //26 Aug 07 GKY 1
 | 
|---|
| 956 |     }
 | 
|---|
| 957 |     break;
 | 
|---|
| 958 |   case IDM_DESELECTSMALLER:
 | 
|---|
| 959 |     for (z = 0; z < numwindows; z++) {
 | 
|---|
| 960 |       for (x = 0; x < Cnrs[z].numfiles; x++) {
 | 
|---|
| 961 |         if (Cnrs[z].ss[x].smallest)
 | 
|---|
| 962 |           WinSendMsg(Cnrs[z].hwndCnr, CM_SETRECORDEMPHASIS,
 | 
|---|
| 963 |                      MPFROMP(Cnrs[z].ss[x].pci),
 | 
|---|
| 964 |                      MPFROM2SHORT(FALSE, CRA_SELECTED));
 | 
|---|
| 965 |       }
 | 
|---|
| 966 |       DosSleep(0); //26 Aug 07 GKY 1
 | 
|---|
| 967 |     }
 | 
|---|
| 968 |     break;
 | 
|---|
| 969 |   }
 | 
|---|
| 970 | 
 | 
|---|
| 971 |   FreeCnrs(Cnrs, numwindows);
 | 
|---|
| 972 | }
 | 
|---|
| 973 | 
 | 
|---|
| 974 | #pragma alloc_text(SELECT,UnHilite,SelectAll,DeselectAll,MarkAll,SetMask)
 | 
|---|
| 975 | #pragma alloc_text(SELECT,SelectList)
 | 
|---|
| 976 | #pragma alloc_text(SELECT1,Deselect,HideAll,RemoveAll,ExpandAll,InvertAll)
 | 
|---|
| 977 | #pragma alloc_text(SELECT4,FreeCnrs,SpecialSelect2,CompSSNames,CompSSNamesB)
 | 
|---|