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