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