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