1 |
|
---|
2 | /***********************************************************************
|
---|
3 |
|
---|
4 | $Id: select.c 769 2007-08-06 02:24:09Z stevenhl $
|
---|
5 |
|
---|
6 | Container item selection support routines
|
---|
7 |
|
---|
8 | Copyright (c) 1993-98 M. Kimes
|
---|
9 | Copyright (c) 2004, 2007 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 |
|
---|
28 | ***********************************************************************/
|
---|
29 |
|
---|
30 | #define INCL_DOS
|
---|
31 | #define INCL_WIN
|
---|
32 | #define INCL_LONGLONG
|
---|
33 | #include <os2.h>
|
---|
34 |
|
---|
35 | #include <stdio.h>
|
---|
36 | #include <stdlib.h>
|
---|
37 | #include <string.h>
|
---|
38 | #include <share.h>
|
---|
39 | #include <io.h>
|
---|
40 |
|
---|
41 | #include "fm3dll.h"
|
---|
42 | #include "fm3str.h"
|
---|
43 |
|
---|
44 | #pragma alloc_text(SELECT,UnHilite,SelectAll,DeselectAll,MarkAll,SetMask)
|
---|
45 | #pragma alloc_text(SELECT,SelectList)
|
---|
46 | #pragma alloc_text(SELECT1,Deselect,HideAll,RemoveAll,ExpandAll,InvertAll)
|
---|
47 |
|
---|
48 | static PSZ pszSrcFile = __FILE__;
|
---|
49 |
|
---|
50 | VOID UnHilite(HWND hwndCnr, BOOL all, CHAR *** list, ULONG ulItemsToUnHilite)
|
---|
51 | {
|
---|
52 | PCNRITEM pci;
|
---|
53 | INT numfiles = 0, numalloc = 0, x = 0;
|
---|
54 | INT attribute = CRA_CURSORED;
|
---|
55 |
|
---|
56 | if (all && list && *list) {
|
---|
57 | FreeList(*list);
|
---|
58 | *list = NULL;
|
---|
59 | }
|
---|
60 | pci = (PCNRITEM) CurrentRecord(hwndCnr);
|
---|
61 | if (pci && (INT)pci != -1) {
|
---|
62 | if (pci->rc.flRecordAttr & CRA_SELECTED) {
|
---|
63 | attribute = CRA_SELECTED;
|
---|
64 | pci = WinSendMsg(hwndCnr, CM_QUERYRECORDEMPHASIS, MPFROMLONG(CMA_FIRST),
|
---|
65 | MPFROMSHORT(attribute));
|
---|
66 | }
|
---|
67 | while (pci && (INT)pci != -1) {
|
---|
68 | WinSendMsg(hwndCnr, CM_SETRECORDEMPHASIS, MPFROMP(pci),
|
---|
69 | MPFROM2SHORT(FALSE, CRA_SELECTED));
|
---|
70 | if (!all)
|
---|
71 | break;
|
---|
72 | // Count is one extra to ensure non-zero elsewhere
|
---|
73 | // x is 0 based index
|
---|
74 | if (x + 2 == ulItemsToUnHilite)
|
---|
75 | break;
|
---|
76 | if (list)
|
---|
77 | AddToList(pci->pszFileName, list, &numfiles, &numalloc);
|
---|
78 | pci = (PCNRITEM) WinSendMsg(hwndCnr, CM_QUERYRECORDEMPHASIS,
|
---|
79 | MPFROMP(pci), MPFROMSHORT(CRA_SELECTED));
|
---|
80 | x++;
|
---|
81 | }
|
---|
82 | }
|
---|
83 | }
|
---|
84 |
|
---|
85 | VOID SelectList(HWND hwndCnr, BOOL partial, BOOL deselect, BOOL clearfirst,
|
---|
86 | PCNRITEM pciParent, PSZ filename, CHAR ** list)
|
---|
87 | {
|
---|
88 |
|
---|
89 | PCNRITEM pci;
|
---|
90 | register INT x;
|
---|
91 | BOOL foundone = FALSE;
|
---|
92 | ULONG errs = 0;
|
---|
93 |
|
---|
94 | if (clearfirst && !deselect)
|
---|
95 | UnHilite(hwndCnr, TRUE, NULL, 0);
|
---|
96 | if (list && list[0]) {
|
---|
97 | for (x = 0; list[x]; x++) {
|
---|
98 | pci = FindCnrRecord(hwndCnr,
|
---|
99 | list[x], pciParent, partial, partial, TRUE);
|
---|
100 | if (pci) {
|
---|
101 | WinSendMsg(hwndCnr,
|
---|
102 | CM_SETRECORDEMPHASIS,
|
---|
103 | MPFROMP(pci),
|
---|
104 | MPFROM2SHORT((SHORT) ((deselect) ? FALSE : TRUE),
|
---|
105 | CRA_SELECTED));
|
---|
106 | foundone = TRUE;
|
---|
107 | }
|
---|
108 | }
|
---|
109 | if (!foundone)
|
---|
110 | Runtime_Error(pszSrcFile, __LINE__, "select failed");
|
---|
111 | }
|
---|
112 | else if (filename && *filename) {
|
---|
113 |
|
---|
114 | FILE *fp;
|
---|
115 | CHAR input[1024], *p;
|
---|
116 |
|
---|
117 | fp = _fsopen(filename, "r", SH_DENYNO);
|
---|
118 | if (fp) {
|
---|
119 | while (!feof(fp)) {
|
---|
120 | if (!xfgets_bstripcr(input, sizeof(input), fp, pszSrcFile, __LINE__))
|
---|
121 | break;
|
---|
122 | if (*input == '\"') {
|
---|
123 | memmove(input, input + 1, strlen(input) + 1);
|
---|
124 | lstrip(input);
|
---|
125 | p = strchr(input, '\"');
|
---|
126 | if (p)
|
---|
127 | *p = 0;
|
---|
128 | rstrip(input);
|
---|
129 | }
|
---|
130 | else {
|
---|
131 | p = strchr(input, ' ');
|
---|
132 | if (p)
|
---|
133 | *p = 0;
|
---|
134 | }
|
---|
135 | /* input now contains name of file to select */
|
---|
136 | pci = FindCnrRecord(hwndCnr,
|
---|
137 | input, pciParent, partial, partial, TRUE);
|
---|
138 | if (pci) /* found it? */
|
---|
139 | WinSendMsg(hwndCnr,
|
---|
140 | CM_SETRECORDEMPHASIS,
|
---|
141 | MPFROMP(pci),
|
---|
142 | MPFROM2SHORT((SHORT) ((deselect) ? FALSE : TRUE),
|
---|
143 | CRA_SELECTED));
|
---|
144 | else
|
---|
145 | errs++;
|
---|
146 | if (errs > 50) { /* prevent runaway on bad file */
|
---|
147 |
|
---|
148 | APIRET ret;
|
---|
149 |
|
---|
150 | ret = saymsg(MB_YESNO,
|
---|
151 | hwndCnr,
|
---|
152 | GetPString(IDS_POSSIBLEERRORTEXT),
|
---|
153 | GetPString(IDS_MAYNOTBELISTTEXT), filename);
|
---|
154 | if (ret == MBID_NO)
|
---|
155 | break;
|
---|
156 | errs = 0;
|
---|
157 | }
|
---|
158 | }
|
---|
159 | fclose(fp);
|
---|
160 | }
|
---|
161 | }
|
---|
162 | }
|
---|
163 |
|
---|
164 | VOID SelectAll(HWND hwndCnr, BOOL files, BOOL dirs, PSZ maskstr,
|
---|
165 | PSZ text, BOOL is_arc)
|
---|
166 | {
|
---|
167 |
|
---|
168 | PCNRITEM pci;
|
---|
169 | BOOL markit;
|
---|
170 | PSZ file;
|
---|
171 | PSZ pszToMatch;
|
---|
172 | MASK Mask;
|
---|
173 | INT x;
|
---|
174 | ULONG textlen = 0;
|
---|
175 |
|
---|
176 | if (text)
|
---|
177 | textlen = strlen(text);
|
---|
178 | memset(&Mask, 0, sizeof(Mask));
|
---|
179 | if (maskstr)
|
---|
180 | SetMask(maskstr, &Mask);
|
---|
181 | pci = (PCNRITEM) WinSendMsg(hwndCnr, CM_QUERYRECORD, MPVOID,
|
---|
182 | MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
|
---|
183 | while (pci && (INT)pci != -1) {
|
---|
184 |
|
---|
185 | markit = FALSE;
|
---|
186 |
|
---|
187 | if (~pci->rc.flRecordAttr & CRA_FILTERED) {
|
---|
188 | if (!is_arc) {
|
---|
189 | if (files && ~pci->attrFile & FILE_DIRECTORY)
|
---|
190 | markit = TRUE;
|
---|
191 | if (dirs && pci->attrFile & FILE_DIRECTORY)
|
---|
192 | markit = TRUE;
|
---|
193 | }
|
---|
194 | else
|
---|
195 | markit = TRUE;
|
---|
196 | if (maskstr && *maskstr && markit) {
|
---|
197 | markit = FALSE;
|
---|
198 | // Point a filename part
|
---|
199 | file = strrchr(pci->pszFileName, '\\');
|
---|
200 | if (!file)
|
---|
201 | file = strrchr(pci->pszFileName, ':');
|
---|
202 | if (file)
|
---|
203 | file++;
|
---|
204 | else
|
---|
205 | file = pci->pszFileName;
|
---|
206 | for (x = 0; Mask.pszMasks[x]; x++) {
|
---|
207 | if (*Mask.pszMasks[x]) {
|
---|
208 | if ((strchr(Mask.pszMasks[x], '\\') ||
|
---|
209 | strchr(Mask.pszMasks[x], ':')))
|
---|
210 | pszToMatch = pci->pszFileName;
|
---|
211 | else
|
---|
212 | pszToMatch = file;
|
---|
213 | if (*Mask.pszMasks[x] != '/') {
|
---|
214 | if (wildcard(pszToMatch, Mask.pszMasks[x], FALSE)) {
|
---|
215 | markit = TRUE;
|
---|
216 | }
|
---|
217 | }
|
---|
218 | else {
|
---|
219 | if (wildcard(pszToMatch, Mask.pszMasks[x] + 1, FALSE)) {
|
---|
220 | markit = FALSE;
|
---|
221 | break;
|
---|
222 | }
|
---|
223 | }
|
---|
224 | }
|
---|
225 | } // for
|
---|
226 | }
|
---|
227 | }
|
---|
228 |
|
---|
229 | if (markit && text && *text) {
|
---|
230 | if (~pci->attrFile & FILE_DIRECTORY) {
|
---|
231 | PSZ input;
|
---|
232 | markit = FALSE;
|
---|
233 | input = xmalloc(65537, pszSrcFile, __LINE__);
|
---|
234 | if (input) {
|
---|
235 | ULONG pos;
|
---|
236 | LONG len;
|
---|
237 | FILE *inputFile;
|
---|
238 |
|
---|
239 | if ((inputFile = _fsopen(pci->pszFileName, "rb", SH_DENYNO)) != NULL) {
|
---|
240 | pos = ftell(inputFile);
|
---|
241 | while (!feof(inputFile)) {
|
---|
242 | if (pos)
|
---|
243 | fseek(inputFile, pos - 256, SEEK_SET);
|
---|
244 | len = fread(input, 1, 65536, inputFile);
|
---|
245 | if (len >= 0) {
|
---|
246 | if (findstring(text, textlen, input, len, FALSE)) {
|
---|
247 | markit = TRUE;
|
---|
248 | break;
|
---|
249 | }
|
---|
250 | }
|
---|
251 | else
|
---|
252 | break;
|
---|
253 | }
|
---|
254 | fclose(inputFile);
|
---|
255 | }
|
---|
256 | free(input);
|
---|
257 | DosSleep(1);
|
---|
258 | }
|
---|
259 | }
|
---|
260 | else
|
---|
261 | markit = FALSE;
|
---|
262 | }
|
---|
263 |
|
---|
264 | if (markit)
|
---|
265 | WinSendMsg(hwndCnr, CM_SETRECORDEMPHASIS, MPFROMP(pci),
|
---|
266 | MPFROM2SHORT(TRUE, CRA_SELECTED));
|
---|
267 | pci = (PCNRITEM) WinSendMsg(hwndCnr, CM_QUERYRECORD, MPFROMP(pci),
|
---|
268 | MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
|
---|
269 | } // while
|
---|
270 | }
|
---|
271 |
|
---|
272 | VOID DeselectAll(HWND hwndCnr, BOOL files, BOOL dirs, PSZ maskstr,
|
---|
273 | PSZ text, BOOL is_arc)
|
---|
274 | {
|
---|
275 | PCNRITEM pci;
|
---|
276 | BOOL unmarkit;
|
---|
277 | PSZ file;
|
---|
278 | PSZ pszToMatch;
|
---|
279 | MASK Mask;
|
---|
280 | register INT x;
|
---|
281 | ULONG textlen = 0;
|
---|
282 |
|
---|
283 | if (text)
|
---|
284 | textlen = strlen(text);
|
---|
285 | memset(&Mask, 0, sizeof(Mask));
|
---|
286 | if (maskstr && *maskstr)
|
---|
287 | SetMask(maskstr, &Mask);
|
---|
288 | pci = (PCNRITEM) WinSendMsg(hwndCnr, CM_QUERYRECORD, MPVOID,
|
---|
289 | MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
|
---|
290 | while (pci && (INT)pci != -1) {
|
---|
291 | unmarkit = FALSE;
|
---|
292 | if (~pci->rc.flRecordAttr & CRA_FILTERED) {
|
---|
293 | if (!is_arc) {
|
---|
294 | if (files && ~pci->attrFile & FILE_DIRECTORY)
|
---|
295 | unmarkit = TRUE;
|
---|
296 | if (dirs && (pci->attrFile & FILE_DIRECTORY))
|
---|
297 | unmarkit = TRUE;
|
---|
298 | }
|
---|
299 | else
|
---|
300 | unmarkit = TRUE;
|
---|
301 | if (maskstr && *maskstr && unmarkit) {
|
---|
302 | unmarkit = FALSE;
|
---|
303 | file = strrchr(pci->pszFileName, '\\');
|
---|
304 | if (!file)
|
---|
305 | file = strrchr(pci->pszFileName, ':');
|
---|
306 | if (file)
|
---|
307 | file++;
|
---|
308 | else
|
---|
309 | file = pci->pszFileName;
|
---|
310 | for (x = 0; Mask.pszMasks[x]; x++) {
|
---|
311 | if (*Mask.pszMasks[x]) {
|
---|
312 | if (strchr(Mask.pszMasks[x], '\\') ||
|
---|
313 | strchr(Mask.pszMasks[x], ':'))
|
---|
314 | pszToMatch = pci->pszFileName;
|
---|
315 | else
|
---|
316 | pszToMatch = file;
|
---|
317 | if (*Mask.pszMasks[x] != '/') {
|
---|
318 | if (wildcard(pszToMatch, Mask.pszMasks[x], FALSE))
|
---|
319 | unmarkit = TRUE;
|
---|
320 | }
|
---|
321 | else {
|
---|
322 | if (wildcard(pszToMatch, Mask.pszMasks[x] + 1, FALSE)) {
|
---|
323 | unmarkit = FALSE;
|
---|
324 | break;
|
---|
325 | }
|
---|
326 | }
|
---|
327 | }
|
---|
328 | }
|
---|
329 | }
|
---|
330 | }
|
---|
331 |
|
---|
332 | if (unmarkit && text && *text) {
|
---|
333 | if (~pci->attrFile & FILE_DIRECTORY) {
|
---|
334 | PSZ input;
|
---|
335 | unmarkit = FALSE;
|
---|
336 | input = xmalloc(65537, pszSrcFile, __LINE__);
|
---|
337 | if (input) {
|
---|
338 | ULONG pos;
|
---|
339 | LONG len;
|
---|
340 | FILE *inputFile;
|
---|
341 |
|
---|
342 | if ((inputFile = _fsopen(pci->pszFileName, "rb", SH_DENYNO)) != NULL) {
|
---|
343 | pos = ftell(inputFile);
|
---|
344 | while (!feof(inputFile)) {
|
---|
345 | if (pos)
|
---|
346 | fseek(inputFile, pos - 256, SEEK_SET);
|
---|
347 | len = fread(input, 1, 65536, inputFile);
|
---|
348 | if (len >= 0) {
|
---|
349 | if (findstring(text, textlen, input, len, FALSE)) {
|
---|
350 | unmarkit = TRUE;
|
---|
351 | break;
|
---|
352 | }
|
---|
353 | }
|
---|
354 | else
|
---|
355 | break;
|
---|
356 | }
|
---|
357 | fclose(inputFile);
|
---|
358 | }
|
---|
359 | free(input);
|
---|
360 | DosSleep(1);
|
---|
361 | }
|
---|
362 | }
|
---|
363 | else
|
---|
364 | unmarkit = FALSE;
|
---|
365 | }
|
---|
366 |
|
---|
367 | if (unmarkit)
|
---|
368 | WinSendMsg(hwndCnr, CM_SETRECORDEMPHASIS, pci,
|
---|
369 | MPFROM2SHORT(FALSE, CRA_SELECTED | CRA_CURSORED |
|
---|
370 | CRA_INUSE | CRA_SOURCE));
|
---|
371 | pci = (PCNRITEM) WinSendMsg(hwndCnr, CM_QUERYRECORD, MPFROMP(pci),
|
---|
372 | MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
|
---|
373 | }
|
---|
374 | }
|
---|
375 |
|
---|
376 | VOID Deselect(HWND hwndCnr)
|
---|
377 | {
|
---|
378 | PCNRITEM pcil;
|
---|
379 |
|
---|
380 | pcil = (PCNRITEM) WinSendMsg(hwndCnr, CM_QUERYRECORDEMPHASIS,
|
---|
381 | MPFROMLONG(CMA_FIRST),
|
---|
382 | MPFROMSHORT(CRA_SELECTED));
|
---|
383 | while (pcil && (INT)pcil != -1) {
|
---|
384 | WinSendMsg(hwndCnr, CM_SETRECORDEMPHASIS, MPFROMP(pcil),
|
---|
385 | MPFROM2SHORT(FALSE, CRA_SELECTED));
|
---|
386 | pcil = WinSendMsg(hwndCnr, CM_QUERYRECORDEMPHASIS, MPFROMP(pcil),
|
---|
387 | MPFROMSHORT(CRA_SELECTED));
|
---|
388 | }
|
---|
389 | }
|
---|
390 |
|
---|
391 | //=== HideAll() Hide all selected records ===
|
---|
392 |
|
---|
393 | VOID HideAll(HWND hwndCnr)
|
---|
394 | {
|
---|
395 | PCNRITEM pci, pciH;
|
---|
396 | INT attribute = CRA_CURSORED;
|
---|
397 | CNRINFO cnri;
|
---|
398 | BOOL didone = FALSE;
|
---|
399 |
|
---|
400 | memset(&cnri, 0, sizeof(CNRINFO));
|
---|
401 | cnri.cb = sizeof(CNRINFO);
|
---|
402 | WinSendMsg(hwndCnr, CM_QUERYCNRINFO, MPFROMP(&cnri),
|
---|
403 | MPFROMLONG(sizeof(CNRINFO)));
|
---|
404 | pci = (PCNRITEM) CurrentRecord(hwndCnr);
|
---|
405 | if (pci && (INT)pci != -1) {
|
---|
406 | if (pci->rc.flRecordAttr & CRA_SELECTED) {
|
---|
407 | attribute = CRA_SELECTED;
|
---|
408 | pci = WinSendMsg(hwndCnr, CM_QUERYRECORDEMPHASIS, MPFROMLONG(CMA_FIRST),
|
---|
409 | MPFROMSHORT(attribute));
|
---|
410 | }
|
---|
411 | }
|
---|
412 | while (pci && (INT)pci != -1) {
|
---|
413 | pciH = WinSendMsg(hwndCnr, CM_QUERYRECORDEMPHASIS, MPFROMP(pci),
|
---|
414 | MPFROMSHORT(attribute));
|
---|
415 | WinSendMsg(hwndCnr, CM_SETRECORDEMPHASIS, MPFROMP(pci),
|
---|
416 | MPFROM2SHORT(FALSE, CRA_CURSORED | CRA_SELECTED |
|
---|
417 | CRA_INUSE | CRA_SOURCE));
|
---|
418 | pci->rc.flRecordAttr |= CRA_FILTERED;
|
---|
419 | didone = TRUE;
|
---|
420 | if (fSyncUpdates) {
|
---|
421 | if (cnri.flWindowAttr & CV_DETAIL)
|
---|
422 | WinSendMsg(hwndCnr, CM_INVALIDATERECORD, MPVOID,
|
---|
423 | MPFROM2SHORT(0, CMA_REPOSITION | CMA_ERASE));
|
---|
424 | else
|
---|
425 | WinSendMsg(hwndCnr, CM_INVALIDATERECORD, MPFROMP(&pci),
|
---|
426 | MPFROM2SHORT(1, CMA_REPOSITION | CMA_ERASE));
|
---|
427 | }
|
---|
428 | pci = pciH;
|
---|
429 | }
|
---|
430 | if (didone && !fSyncUpdates)
|
---|
431 | WinSendMsg(hwndCnr, CM_INVALIDATERECORD, MPVOID,
|
---|
432 | MPFROM2SHORT(0, CMA_ERASE | CMA_REPOSITION));
|
---|
433 | }
|
---|
434 |
|
---|
435 | VOID MarkAll(HWND hwndCnr, BOOL quitit, BOOL target, BOOL source)
|
---|
436 | {
|
---|
437 | PCNRITEM pci;
|
---|
438 | INT attribute = CRA_CURSORED;
|
---|
439 |
|
---|
440 | if (quitit)
|
---|
441 | attribute = target ? CRA_TARGET : source ? CRA_SOURCE : CRA_INUSE;
|
---|
442 | pci = (PCNRITEM) WinSendMsg(hwndCnr, CM_QUERYRECORDEMPHASIS,
|
---|
443 | MPFROMLONG(CMA_FIRST), MPFROMSHORT(attribute));
|
---|
444 | if (pci && (INT)pci != -1) {
|
---|
445 | if (attribute == CRA_CURSORED) {
|
---|
446 | if (pci->rc.flRecordAttr & CRA_SELECTED) {
|
---|
447 | attribute = CRA_SELECTED;
|
---|
448 | pci =
|
---|
449 | WinSendMsg(hwndCnr, CM_QUERYRECORDEMPHASIS, MPFROMLONG(CMA_FIRST),
|
---|
450 | MPFROMSHORT(attribute));
|
---|
451 | }
|
---|
452 | }
|
---|
453 | }
|
---|
454 | while (pci && (INT)pci != -1) {
|
---|
455 | WinSendMsg(hwndCnr, CM_SETRECORDEMPHASIS, MPFROMP(pci),
|
---|
456 | MPFROM2SHORT(!quitit,
|
---|
457 | target ? CRA_TARGET : source ? CRA_SOURCE :
|
---|
458 | CRA_INUSE));
|
---|
459 | pci =
|
---|
460 | WinSendMsg(hwndCnr, CM_QUERYRECORDEMPHASIS, MPFROMP(pci),
|
---|
461 | MPFROMSHORT(attribute));
|
---|
462 | }
|
---|
463 | }
|
---|
464 |
|
---|
465 | VOID RemoveAll(HWND hwndCnr, ULONGLONG * pullTotalBytes,
|
---|
466 | ULONG * pulTotalFiles)
|
---|
467 | {
|
---|
468 | PCNRITEM pci;
|
---|
469 | INT attribute = CRA_CURSORED;
|
---|
470 | BOOL didone = FALSE;
|
---|
471 |
|
---|
472 | pci = (PCNRITEM) CurrentRecord(hwndCnr);
|
---|
473 | if (pci && (INT)pci != -1) {
|
---|
474 | if (pci->rc.flRecordAttr & CRA_SELECTED) {
|
---|
475 | attribute = CRA_SELECTED;
|
---|
476 | pci = WinSendMsg(hwndCnr, CM_QUERYRECORDEMPHASIS, MPFROMLONG(CMA_FIRST),
|
---|
477 | MPFROMSHORT(attribute));
|
---|
478 | }
|
---|
479 | }
|
---|
480 | while (pci && (INT)pci != -1) {
|
---|
481 | if (~pci->rc.flRecordAttr & CRA_FILTERED) {
|
---|
482 | didone = TRUE;
|
---|
483 | if (pulTotalFiles)
|
---|
484 | *pulTotalFiles -= 1;
|
---|
485 | if (pullTotalBytes)
|
---|
486 | *pullTotalBytes -= (pci->cbFile + pci->easize);
|
---|
487 | WinSendMsg(hwndCnr, CM_SETRECORDEMPHASIS, MPFROMP(pci),
|
---|
488 | MPFROM2SHORT(0, CRA_SELECTED));
|
---|
489 | if (fSyncUpdates)
|
---|
490 | RemoveCnrItems(hwndCnr, pci, 1, CMA_FREE | CMA_INVALIDATE);
|
---|
491 | else
|
---|
492 | RemoveCnrItems(hwndCnr, pci, 1, CMA_FREE);
|
---|
493 | if (attribute == CRA_CURSORED)
|
---|
494 | break;
|
---|
495 | pci = WinSendMsg(hwndCnr, CM_QUERYRECORDEMPHASIS, MPFROMLONG(CMA_FIRST),
|
---|
496 | MPFROMSHORT(attribute));
|
---|
497 | }
|
---|
498 | else
|
---|
499 | pci = WinSendMsg(hwndCnr, CM_QUERYRECORDEMPHASIS, MPFROMP(pci),
|
---|
500 | MPFROMSHORT(attribute));
|
---|
501 | }
|
---|
502 | if (didone && !fSyncUpdates)
|
---|
503 | WinSendMsg(hwndCnr, CM_INVALIDATERECORD, MPVOID,
|
---|
504 | MPFROM2SHORT(0, CMA_REPOSITION));
|
---|
505 | }
|
---|
506 |
|
---|
507 | //== SetMask() Convert mask string to array of pointers to masks ==
|
---|
508 |
|
---|
509 | VOID SetMask(PSZ maskstr, MASK * mask)
|
---|
510 | {
|
---|
511 | UINT x;
|
---|
512 | PSZ p;
|
---|
513 |
|
---|
514 | if (maskstr)
|
---|
515 | strcpy(mask->szMask, maskstr); // Got new mask string
|
---|
516 | // Build array of pointers
|
---|
517 | p = mask->szMaskCopy;
|
---|
518 | strcpy(p, mask->szMask);
|
---|
519 | // Allow up to 25 masks - ignore extras
|
---|
520 | for (x = 0; *p && x < 25; x++) {
|
---|
521 | mask->pszMasks[x] = p;
|
---|
522 | while (*p && *p != ';')
|
---|
523 | p++; // Find separator
|
---|
524 | if (*p) {
|
---|
525 | *p = 0; // Replace ;
|
---|
526 | p++;
|
---|
527 | }
|
---|
528 | } // for
|
---|
529 | mask->pszMasks[x] = NULL; // Mark end
|
---|
530 | }
|
---|
531 |
|
---|
532 | VOID ExpandAll(HWND hwndCnr, BOOL expand, PCNRITEM pciParent)
|
---|
533 | {
|
---|
534 | PCNRITEM pci;
|
---|
535 |
|
---|
536 | if (!pciParent)
|
---|
537 | pciParent = WinSendMsg(hwndCnr, CM_QUERYRECORD, MPFROMP(NULL),
|
---|
538 | MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
|
---|
539 | if (pciParent) {
|
---|
540 | if (expand && ~pciParent->rc.flRecordAttr & CRA_EXPANDED)
|
---|
541 | WinSendMsg(hwndCnr, CM_EXPANDTREE, MPFROMP(pciParent), MPVOID);
|
---|
542 | else if (!expand && (pciParent->rc.flRecordAttr & CRA_EXPANDED))
|
---|
543 | WinSendMsg(hwndCnr, CM_COLLAPSETREE, MPFROMP(pciParent), MPVOID);
|
---|
544 | pci = (PCNRITEM) WinSendMsg(hwndCnr, CM_QUERYRECORD, MPFROMP(pciParent),
|
---|
545 | MPFROM2SHORT(CMA_FIRSTCHILD, CMA_ITEMORDER));
|
---|
546 | if (pci)
|
---|
547 | DosSleep(1);
|
---|
548 | while (pci && (INT)pci != -1) {
|
---|
549 | ExpandAll(hwndCnr, expand, pci);
|
---|
550 | pci = (PCNRITEM) WinSendMsg(hwndCnr, CM_QUERYRECORD, MPFROMP(pci),
|
---|
551 | MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
|
---|
552 | }
|
---|
553 | }
|
---|
554 | DosSleep(1);
|
---|
555 | }
|
---|
556 |
|
---|
557 | VOID InvertAll(HWND hwndCnr)
|
---|
558 | {
|
---|
559 | PCNRITEM pci;
|
---|
560 |
|
---|
561 | pci = (PCNRITEM) WinSendMsg(hwndCnr, CM_QUERYRECORD, MPVOID,
|
---|
562 | MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
|
---|
563 | while (pci && (INT)pci != -1) {
|
---|
564 | if (~pci->rc.flRecordAttr & CRA_FILTERED) {
|
---|
565 | if (~pci->rc.flRecordAttr & CRA_SELECTED)
|
---|
566 | WinSendMsg(hwndCnr, CM_SETRECORDEMPHASIS, MPFROMP(pci),
|
---|
567 | MPFROM2SHORT(TRUE, CRA_SELECTED));
|
---|
568 | else
|
---|
569 | WinSendMsg(hwndCnr, CM_SETRECORDEMPHASIS, MPFROMP(pci),
|
---|
570 | MPFROM2SHORT(FALSE, CRA_SELECTED));
|
---|
571 | }
|
---|
572 | pci = (PCNRITEM) WinSendMsg(hwndCnr, CM_QUERYRECORD, MPFROMP(pci),
|
---|
573 | MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
|
---|
574 | }
|
---|
575 | }
|
---|
576 |
|
---|
577 | #pragma alloc_text (SELECT3,SpecialSelect)
|
---|
578 | #pragma alloc_text(SELECT4,FreeCnrs,SpecialSelect2,CompSSNames,CompSSNamesB)
|
---|
579 |
|
---|
580 | /**
|
---|
581 | * Do select actions for compare directories containers
|
---|
582 | *
|
---|
583 | */
|
---|
584 |
|
---|
585 | VOID SpecialSelect(HWND hwndCnrS, HWND hwndCnrD, INT action, BOOL reset)
|
---|
586 | {
|
---|
587 | PCNRITEM pciS, pciD, *pciSa = NULL, *pciDa = NULL;
|
---|
588 | CNRINFO cnri;
|
---|
589 | BOOL slow = FALSE;
|
---|
590 | UINT x, numD, numS;
|
---|
591 |
|
---|
592 | if (!hwndCnrS || !hwndCnrD) {
|
---|
593 | Runtime_Error(pszSrcFile, __LINE__, "hwndCnrS %p hwndCnrD %p", hwndCnrS, hwndCnrD);
|
---|
594 | return;
|
---|
595 | }
|
---|
596 |
|
---|
597 | memset(&cnri, 0, sizeof(CNRINFO));
|
---|
598 | cnri.cb = sizeof(CNRINFO);
|
---|
599 | WinSendMsg(hwndCnrD, CM_QUERYCNRINFO, MPFROMP(&cnri),
|
---|
600 | MPFROMLONG(sizeof(CNRINFO)));
|
---|
601 | numD = cnri.cRecords;
|
---|
602 | memset(&cnri, 0, sizeof(CNRINFO));
|
---|
603 | cnri.cb = sizeof(CNRINFO);
|
---|
604 | WinSendMsg(hwndCnrS, CM_QUERYCNRINFO, MPFROMP(&cnri),
|
---|
605 | MPFROMLONG(sizeof(CNRINFO)));
|
---|
606 | numS = cnri.cRecords;
|
---|
607 | if (!numD || numS != numD) {
|
---|
608 | Runtime_Error(pszSrcFile, __LINE__, "numD %u != numS %u", numD, numS);
|
---|
609 | return;
|
---|
610 | }
|
---|
611 | pciDa = xmalloc(sizeof(PCNRITEM) * numD, pszSrcFile, __LINE__);
|
---|
612 | if (!pciDa)
|
---|
613 | return;
|
---|
614 |
|
---|
615 | pciSa = xmalloc(sizeof(PCNRITEM) * numS, pszSrcFile, __LINE__);
|
---|
616 | if (!pciSa) {
|
---|
617 | free(pciDa);
|
---|
618 | return;
|
---|
619 | }
|
---|
620 |
|
---|
621 | Restart:
|
---|
622 |
|
---|
623 | memset(pciDa, 0, sizeof(PCNRITEM) * numD);
|
---|
624 | memset(pciSa, 0, sizeof(PCNRITEM) * numS);
|
---|
625 |
|
---|
626 | pciD = (PCNRITEM)WinSendMsg(hwndCnrD, CM_QUERYRECORD, MPVOID,
|
---|
627 | MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
|
---|
628 | x = 0;
|
---|
629 | while (pciD && (INT)pciD != -1 && x < numD) {
|
---|
630 | if (reset)
|
---|
631 | pciD->flags = 0;
|
---|
632 | pciDa[x] = pciD;
|
---|
633 | x++;
|
---|
634 | if (!slow)
|
---|
635 | pciD = (PCNRITEM) pciD->rc.preccNextRecord;
|
---|
636 | else
|
---|
637 | pciD = (PCNRITEM) WinSendMsg(hwndCnrD, CM_QUERYRECORD, MPFROMP(pciD),
|
---|
638 | MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
|
---|
639 | if (!(x % 500))
|
---|
640 | DosSleep(1L);
|
---|
641 | // else if (!(x % 50))
|
---|
642 | // DosSleep(0L);
|
---|
643 | } // while
|
---|
644 |
|
---|
645 | if (numD != x) {
|
---|
646 | if (!slow) {
|
---|
647 | slow = TRUE;
|
---|
648 | goto Restart;
|
---|
649 | }
|
---|
650 | free(pciDa);
|
---|
651 | free(pciSa);
|
---|
652 | Runtime_Error(pszSrcFile, __LINE__, "numD %u != x %lu", numD, x);
|
---|
653 | return;
|
---|
654 | }
|
---|
655 |
|
---|
656 | pciS = (PCNRITEM) WinSendMsg(hwndCnrS, CM_QUERYRECORD, MPVOID,
|
---|
657 | MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
|
---|
658 | x = 0;
|
---|
659 | while (pciS && (INT)pciS != -1 && x < numS) {
|
---|
660 | if (reset)
|
---|
661 | pciS->flags = 0;
|
---|
662 | pciSa[x] = pciS;
|
---|
663 | x++;
|
---|
664 | if (!slow)
|
---|
665 | pciS = (PCNRITEM) pciS->rc.preccNextRecord;
|
---|
666 | else
|
---|
667 | pciS = (PCNRITEM) WinSendMsg(hwndCnrS, CM_QUERYRECORD, MPFROMP(pciS),
|
---|
668 | MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
|
---|
669 | if (!(x % 500))
|
---|
670 | DosSleep(1L);
|
---|
671 | // else if (!(x % 50))
|
---|
672 | // DosSleep(0L);
|
---|
673 | } // while
|
---|
674 |
|
---|
675 | if (numS != x) {
|
---|
676 | if (!slow) {
|
---|
677 | slow = TRUE;
|
---|
678 | goto Restart;
|
---|
679 | }
|
---|
680 | free(pciSa);
|
---|
681 | free(pciDa);
|
---|
682 | Runtime_Error(pszSrcFile, __LINE__, "numS (%lu) != x (%lu)", numS, x);
|
---|
683 | return;
|
---|
684 | }
|
---|
685 |
|
---|
686 | // 05 Aug 07 SHL fixme to know what sets reset
|
---|
687 | if (reset) {
|
---|
688 | // Update flags for files that exist on both sides
|
---|
689 | for (x = 0; x < numS; x++) {
|
---|
690 |
|
---|
691 | // 05 Aug 07 SHL fixme to know if should clear first
|
---|
692 | if (!*pciSa[x]->pszFileName || !*pciDa[x]->pszFileName)
|
---|
693 | continue;
|
---|
694 |
|
---|
695 | pciSa[x]->flags |= CNRITEM_EXISTS; // File exists on both sides
|
---|
696 | pciDa[x]->flags |= CNRITEM_EXISTS;
|
---|
697 | if (pciSa[x]->cbFile + pciSa[x]->easize >
|
---|
698 | pciDa[x]->cbFile + pciDa[x]->easize) {
|
---|
699 | pciSa[x]->flags |= CNRITEM_LARGER;
|
---|
700 | pciDa[x]->flags |= CNRITEM_SMALLER;
|
---|
701 | }
|
---|
702 | else if (pciSa[x]->cbFile + pciSa[x]->easize <
|
---|
703 | pciDa[x]->cbFile + pciDa[x]->easize) {
|
---|
704 | pciSa[x]->flags |= CNRITEM_SMALLER;
|
---|
705 | pciDa[x]->flags |= CNRITEM_LARGER;
|
---|
706 | }
|
---|
707 | if ((pciSa[x]->date.year > pciDa[x]->date.year) ? TRUE :
|
---|
708 | (pciSa[x]->date.year < pciDa[x]->date.year) ? FALSE :
|
---|
709 | (pciSa[x]->date.month > pciDa[x]->date.month) ? TRUE :
|
---|
710 | (pciSa[x]->date.month < pciDa[x]->date.month) ? FALSE :
|
---|
711 | (pciSa[x]->date.day > pciDa[x]->date.day) ? TRUE :
|
---|
712 | (pciSa[x]->date.day < pciDa[x]->date.day) ? FALSE :
|
---|
713 | (pciSa[x]->time.hours > pciDa[x]->time.hours) ? TRUE :
|
---|
714 | (pciSa[x]->time.hours < pciDa[x]->time.hours) ? FALSE :
|
---|
715 | (pciSa[x]->time.minutes > pciDa[x]->time.minutes) ? TRUE :
|
---|
716 | (pciSa[x]->time.minutes < pciDa[x]->time.minutes) ? FALSE :
|
---|
717 | (pciSa[x]->time.seconds > pciDa[x]->time.seconds) ? TRUE :
|
---|
718 | (pciSa[x]->time.seconds < pciDa[x]->time.seconds) ? FALSE : FALSE) {
|
---|
719 | pciSa[x]->flags |= CNRITEM_NEWER;
|
---|
720 | pciDa[x]->flags |= CNRITEM_OLDER;
|
---|
721 | }
|
---|
722 | else if ((pciSa[x]->date.year < pciDa[x]->date.year) ? TRUE :
|
---|
723 | (pciSa[x]->date.year > pciDa[x]->date.year) ? FALSE :
|
---|
724 | (pciSa[x]->date.month < pciDa[x]->date.month) ? TRUE :
|
---|
725 | (pciSa[x]->date.month > pciDa[x]->date.month) ? FALSE :
|
---|
726 | (pciSa[x]->date.day < pciDa[x]->date.day) ? TRUE :
|
---|
727 | (pciSa[x]->date.day > pciDa[x]->date.day) ? FALSE :
|
---|
728 | (pciSa[x]->time.hours < pciDa[x]->time.hours) ? TRUE :
|
---|
729 | (pciSa[x]->time.hours > pciDa[x]->time.hours) ? FALSE :
|
---|
730 | (pciSa[x]->time.minutes < pciDa[x]->time.minutes) ? TRUE :
|
---|
731 | (pciSa[x]->time.minutes > pciDa[x]->time.minutes) ? FALSE :
|
---|
732 | (pciSa[x]->time.seconds < pciDa[x]->time.seconds) ? TRUE :
|
---|
733 | (pciSa[x]->time.seconds > pciDa[x]->time.seconds) ? FALSE :
|
---|
734 | FALSE) {
|
---|
735 | pciSa[x]->flags |= CNRITEM_OLDER;
|
---|
736 | pciDa[x]->flags |= CNRITEM_NEWER;
|
---|
737 | }
|
---|
738 | if (!(x % 500))
|
---|
739 | DosSleep(1L);
|
---|
740 | // else if (!(x % 50))
|
---|
741 | // DosSleep(0L);
|
---|
742 | } // for
|
---|
743 | } // if reset
|
---|
744 |
|
---|
745 | switch (action) {
|
---|
746 | case IDM_SELECTIDENTICAL:
|
---|
747 | for (x = 0; x < numS; x++) {
|
---|
748 | if (~pciSa[x]->rc.flRecordAttr & CRA_FILTERED &&
|
---|
749 | pciSa[x]->flags & CNRITEM_EXISTS &&
|
---|
750 | ~pciSa[x]->flags & CNRITEM_SMALLER &&
|
---|
751 | ~pciSa[x]->flags & CNRITEM_LARGER &&
|
---|
752 | ~pciSa[x]->flags & CNRITEM_NEWER &&
|
---|
753 | ~pciSa[x]->flags & CNRITEM_OLDER) {
|
---|
754 | if (~pciSa[x]->rc.flRecordAttr & CRA_SELECTED)
|
---|
755 | WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pciSa[x]),
|
---|
756 | MPFROM2SHORT(TRUE, CRA_SELECTED));
|
---|
757 | if (~pciDa[x]->rc.flRecordAttr & CRA_SELECTED)
|
---|
758 | WinSendMsg(hwndCnrD, CM_SETRECORDEMPHASIS, MPFROMP(pciDa[x]),
|
---|
759 | MPFROM2SHORT(TRUE, CRA_SELECTED));
|
---|
760 | }
|
---|
761 | if (!(x % 500))
|
---|
762 | DosSleep(1L);
|
---|
763 | // else if (!(x % 50))
|
---|
764 | // DosSleep(0L);
|
---|
765 | } // for
|
---|
766 | break;
|
---|
767 |
|
---|
768 | case IDM_SELECTSAME:
|
---|
769 | for (x = 0; x < numS; x++) {
|
---|
770 | if (~pciSa[x]->rc.flRecordAttr & CRA_FILTERED &&
|
---|
771 | pciSa[x]->flags & CNRITEM_EXISTS &&
|
---|
772 | ~pciSa[x]->flags & CNRITEM_SMALLER &&
|
---|
773 | ~pciSa[x]->flags & CNRITEM_LARGER) {
|
---|
774 | if (~pciSa[x]->rc.flRecordAttr & CRA_SELECTED)
|
---|
775 | WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pciSa[x]),
|
---|
776 | MPFROM2SHORT(TRUE, CRA_SELECTED));
|
---|
777 | if (~pciDa[x]->rc.flRecordAttr & CRA_SELECTED)
|
---|
778 | WinSendMsg(hwndCnrD, CM_SETRECORDEMPHASIS, MPFROMP(pciDa[x]),
|
---|
779 | MPFROM2SHORT(TRUE, CRA_SELECTED));
|
---|
780 | }
|
---|
781 | if (!(x % 500))
|
---|
782 | DosSleep(1L);
|
---|
783 | // else if (!(x % 50))
|
---|
784 | // DosSleep(0L);
|
---|
785 | }
|
---|
786 | break;
|
---|
787 |
|
---|
788 | case IDM_SELECTSAMECONTENT:
|
---|
789 | for (x = 0; x < numS; x++) {
|
---|
790 | if (~pciSa[x]->rc.flRecordAttr & CRA_FILTERED &&
|
---|
791 | pciSa[x]->flags & CNRITEM_EXISTS)
|
---|
792 | {
|
---|
793 | FILE *fp1 = NULL;
|
---|
794 | FILE *fp2 = NULL;
|
---|
795 | BOOL gotMatch = FALSE;
|
---|
796 | UINT errLineNo = 0;
|
---|
797 | UINT compErrno = 0;
|
---|
798 | CHAR buf1[1024];
|
---|
799 | CHAR buf2[1024];
|
---|
800 | HAB hab = WinQueryAnchorBlock(hwndCnrS);
|
---|
801 |
|
---|
802 | if (!*pciSa[x]->pszFileName ||
|
---|
803 | !*pciDa[x]->pszFileName) {
|
---|
804 | Runtime_Error(pszSrcFile, __LINE__,
|
---|
805 | "CNRITEM_EXISTS set with null file name for index %u", x);
|
---|
806 | break;
|
---|
807 | }
|
---|
808 |
|
---|
809 | fp1 = _fsopen(pciSa[x]->pszFileName, "rb", SH_DENYNO);
|
---|
810 | if (!fp1) {
|
---|
811 | errLineNo = __LINE__;
|
---|
812 | compErrno = errno;
|
---|
813 | }
|
---|
814 | else {
|
---|
815 | fp2 = _fsopen(pciDa[x]->pszFileName, "rb", SH_DENYNO);
|
---|
816 | if (!fp2) {
|
---|
817 | errLineNo = __LINE__;
|
---|
818 | compErrno = errno;
|
---|
819 | }
|
---|
820 | else {
|
---|
821 | size_t len1 = filelength(fileno(fp1));
|
---|
822 | size_t len2 = filelength(fileno(fp2));
|
---|
823 |
|
---|
824 | if (len1 == len2) {
|
---|
825 | setbuf(fp1, NULL);
|
---|
826 | setbuf(fp2, NULL);
|
---|
827 | while (WinIsWindow(hab, hwndCnrS)) {
|
---|
828 | size_t numread1 = fread(buf1, 1, 1024, fp1);
|
---|
829 | size_t numread2 = fread(buf2, 1, 1024, fp2);
|
---|
830 |
|
---|
831 | if (!numread1 || !numread2 || numread1 != numread2) {
|
---|
832 | if (ferror(fp1) || ferror(fp2)) {
|
---|
833 | errLineNo = __LINE__;
|
---|
834 | compErrno = errno;
|
---|
835 | }
|
---|
836 | else if (feof(fp1) && feof(fp2))
|
---|
837 | gotMatch = TRUE;
|
---|
838 | break;
|
---|
839 | }
|
---|
840 | else if (memcmp(buf1, buf2, numread1))
|
---|
841 | break;
|
---|
842 | } // while
|
---|
843 | } // same len
|
---|
844 | }
|
---|
845 | }
|
---|
846 |
|
---|
847 | if (fp1)
|
---|
848 | fclose(fp1);
|
---|
849 |
|
---|
850 | if (fp2)
|
---|
851 | fclose(fp2);
|
---|
852 |
|
---|
853 | if (errLineNo) {
|
---|
854 | Runtime_Error(pszSrcFile, errLineNo,
|
---|
855 | "error %d while comparing", compErrno);
|
---|
856 | }
|
---|
857 |
|
---|
858 | if (gotMatch) {
|
---|
859 | if (~pciSa[x]->rc.flRecordAttr & CRA_SELECTED)
|
---|
860 | WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pciSa[x]),
|
---|
861 | MPFROM2SHORT(TRUE, CRA_SELECTED));
|
---|
862 | if (~pciDa[x]->rc.flRecordAttr & CRA_SELECTED)
|
---|
863 | WinSendMsg(hwndCnrD, CM_SETRECORDEMPHASIS, MPFROMP(pciDa[x]),
|
---|
864 | MPFROM2SHORT(TRUE, CRA_SELECTED));
|
---|
865 | }
|
---|
866 | }
|
---|
867 | if (!(x % 500))
|
---|
868 | DosSleep(1L);
|
---|
869 | // else if (!(x % 50))
|
---|
870 | // DosSleep(0L);
|
---|
871 | } // for
|
---|
872 | break;
|
---|
873 |
|
---|
874 | case IDM_SELECTBOTH:
|
---|
875 | for (x = 0; x < numS; x++) {
|
---|
876 | if (~pciSa[x]->rc.flRecordAttr & CRA_FILTERED &&
|
---|
877 | pciSa[x]->flags & CNRITEM_EXISTS) {
|
---|
878 | if (~pciSa[x]->rc.flRecordAttr & CRA_SELECTED)
|
---|
879 | WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pciSa[x]),
|
---|
880 | MPFROM2SHORT(TRUE, CRA_SELECTED));
|
---|
881 | if (~pciDa[x]->rc.flRecordAttr & CRA_SELECTED)
|
---|
882 | WinSendMsg(hwndCnrD, CM_SETRECORDEMPHASIS, MPFROMP(pciDa[x]),
|
---|
883 | MPFROM2SHORT(TRUE, CRA_SELECTED));
|
---|
884 | }
|
---|
885 | if (!(x % 500))
|
---|
886 | DosSleep(1L);
|
---|
887 | // else if (!(x % 50))
|
---|
888 | // DosSleep(0L);
|
---|
889 | }
|
---|
890 | break;
|
---|
891 |
|
---|
892 | case IDM_SELECTONE:
|
---|
893 | for (x = 0; x < numS; x++) {
|
---|
894 | if (~pciSa[x]->rc.flRecordAttr & CRA_FILTERED &&
|
---|
895 | ~pciSa[x]->flags & CNRITEM_EXISTS) {
|
---|
896 | if (*pciSa[x]->pszFileName) {
|
---|
897 | if (~pciSa[x]->rc.flRecordAttr & CRA_SELECTED) {
|
---|
898 | WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pciSa[x]),
|
---|
899 | MPFROM2SHORT(TRUE, CRA_SELECTED));
|
---|
900 | }
|
---|
901 | }
|
---|
902 | else if (~pciDa[x]->rc.flRecordAttr & CRA_SELECTED) {
|
---|
903 | WinSendMsg(hwndCnrD, CM_SETRECORDEMPHASIS, MPFROMP(pciDa[x]),
|
---|
904 | MPFROM2SHORT(TRUE, CRA_SELECTED));
|
---|
905 | }
|
---|
906 | }
|
---|
907 | if (!(x % 500))
|
---|
908 | DosSleep(1L);
|
---|
909 | // else if (!(x % 50))
|
---|
910 | // DosSleep(0L);
|
---|
911 | }
|
---|
912 | break;
|
---|
913 |
|
---|
914 | case IDM_SELECTBIGGER:
|
---|
915 | for (x = 0; x < numS; x++) {
|
---|
916 | if (~pciSa[x]->rc.flRecordAttr & CRA_FILTERED) {
|
---|
917 | if (pciSa[x]->flags & CNRITEM_LARGER) {
|
---|
918 | if (~pciSa[x]->rc.flRecordAttr & CRA_SELECTED)
|
---|
919 | WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pciSa[x]),
|
---|
920 | MPFROM2SHORT(TRUE, CRA_SELECTED));
|
---|
921 | }
|
---|
922 | else if (pciDa[x]->flags & CNRITEM_LARGER) {
|
---|
923 | if (~pciDa[x]->rc.flRecordAttr & CRA_SELECTED)
|
---|
924 | WinSendMsg(hwndCnrD, CM_SETRECORDEMPHASIS, MPFROMP(pciDa[x]),
|
---|
925 | MPFROM2SHORT(TRUE, CRA_SELECTED));
|
---|
926 | }
|
---|
927 | }
|
---|
928 | if (!(x % 500))
|
---|
929 | DosSleep(1L);
|
---|
930 | // else if (!(x % 50))
|
---|
931 | // DosSleep(0L);
|
---|
932 | }
|
---|
933 | break;
|
---|
934 |
|
---|
935 | case IDM_SELECTSMALLER:
|
---|
936 | for (x = 0; x < numS; x++) {
|
---|
937 | if (~pciSa[x]->rc.flRecordAttr & CRA_FILTERED) {
|
---|
938 | if (pciSa[x]->flags & CNRITEM_SMALLER) {
|
---|
939 | if (~pciSa[x]->rc.flRecordAttr & CRA_SELECTED)
|
---|
940 | WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pciSa[x]),
|
---|
941 | MPFROM2SHORT(TRUE, CRA_SELECTED));
|
---|
942 | }
|
---|
943 | else if (pciDa[x]->flags & CNRITEM_SMALLER) {
|
---|
944 | if (~pciDa[x]->rc.flRecordAttr & CRA_SELECTED)
|
---|
945 | WinSendMsg(hwndCnrD, CM_SETRECORDEMPHASIS, MPFROMP(pciDa[x]),
|
---|
946 | MPFROM2SHORT(TRUE, CRA_SELECTED));
|
---|
947 | }
|
---|
948 | }
|
---|
949 | if (!(x % 500))
|
---|
950 | DosSleep(1L);
|
---|
951 | // else if (!(x % 50))
|
---|
952 | // DosSleep(0L);
|
---|
953 | }
|
---|
954 | break;
|
---|
955 |
|
---|
956 | case IDM_SELECTNEWER:
|
---|
957 | for (x = 0; x < numS; x++) {
|
---|
958 | if (~pciSa[x]->rc.flRecordAttr & CRA_FILTERED) {
|
---|
959 | if (pciSa[x]->flags & CNRITEM_NEWER) {
|
---|
960 | if (~pciSa[x]->rc.flRecordAttr & CRA_SELECTED)
|
---|
961 | WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pciSa[x]),
|
---|
962 | MPFROM2SHORT(TRUE, CRA_SELECTED));
|
---|
963 | }
|
---|
964 | else if (pciDa[x]->flags & CNRITEM_NEWER) {
|
---|
965 | if (~pciDa[x]->rc.flRecordAttr & CRA_SELECTED)
|
---|
966 | WinSendMsg(hwndCnrD, CM_SETRECORDEMPHASIS, MPFROMP(pciDa[x]),
|
---|
967 | MPFROM2SHORT(TRUE, CRA_SELECTED));
|
---|
968 | }
|
---|
969 | }
|
---|
970 | if (!(x % 500))
|
---|
971 | DosSleep(1L);
|
---|
972 | // else if (!(x % 50))
|
---|
973 | // DosSleep(0L);
|
---|
974 | }
|
---|
975 | break;
|
---|
976 |
|
---|
977 | case IDM_SELECTOLDER:
|
---|
978 | for (x = 0; x < numS; x++) {
|
---|
979 | if (~pciSa[x]->rc.flRecordAttr & CRA_FILTERED) {
|
---|
980 | if (pciSa[x]->flags & CNRITEM_OLDER) {
|
---|
981 | if (~pciSa[x]->rc.flRecordAttr & CRA_SELECTED)
|
---|
982 | WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pciSa[x]),
|
---|
983 | MPFROM2SHORT(TRUE, CRA_SELECTED));
|
---|
984 | }
|
---|
985 | else if (pciDa[x]->flags & CNRITEM_OLDER) {
|
---|
986 | if (~pciDa[x]->rc.flRecordAttr & CRA_SELECTED)
|
---|
987 | WinSendMsg(hwndCnrD, CM_SETRECORDEMPHASIS, MPFROMP(pciDa[x]),
|
---|
988 | MPFROM2SHORT(TRUE, CRA_SELECTED));
|
---|
989 | }
|
---|
990 | }
|
---|
991 | if (!(x % 500))
|
---|
992 | DosSleep(1L);
|
---|
993 | // else if (!(x % 50))
|
---|
994 | // DosSleep(0L);
|
---|
995 | }
|
---|
996 | break;
|
---|
997 |
|
---|
998 | case IDM_DESELECTBOTH:
|
---|
999 | for (x = 0; x < numS; x++) {
|
---|
1000 | if (~pciSa[x]->rc.flRecordAttr & CRA_FILTERED &&
|
---|
1001 | pciSa[x]->flags & CNRITEM_EXISTS) {
|
---|
1002 | if (pciSa[x]->rc.flRecordAttr & CRA_SELECTED)
|
---|
1003 | WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pciSa[x]),
|
---|
1004 | MPFROM2SHORT(FALSE, CRA_SELECTED));
|
---|
1005 | if (pciDa[x]->rc.flRecordAttr & CRA_SELECTED)
|
---|
1006 | WinSendMsg(hwndCnrD, CM_SETRECORDEMPHASIS, MPFROMP(pciDa[x]),
|
---|
1007 | MPFROM2SHORT(FALSE, CRA_SELECTED));
|
---|
1008 | }
|
---|
1009 | if (!(x % 500))
|
---|
1010 | DosSleep(1L);
|
---|
1011 | // else if (!(x % 50))
|
---|
1012 | // DosSleep(0L);
|
---|
1013 | }
|
---|
1014 | break;
|
---|
1015 |
|
---|
1016 | case IDM_DESELECTONE:
|
---|
1017 | for (x = 0; x < numS; x++) {
|
---|
1018 | if (~pciSa[x]->rc.flRecordAttr & CRA_FILTERED) {
|
---|
1019 | if (~pciSa[x]->flags & CNRITEM_EXISTS) {
|
---|
1020 | if (*pciSa[x]->pszFileName) {
|
---|
1021 | if (pciSa[x]->rc.flRecordAttr & CRA_SELECTED)
|
---|
1022 | WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pciSa[x]),
|
---|
1023 | MPFROM2SHORT(FALSE, CRA_SELECTED));
|
---|
1024 | }
|
---|
1025 | else if (pciDa[x]->rc.flRecordAttr & CRA_SELECTED)
|
---|
1026 | WinSendMsg(hwndCnrD, CM_SETRECORDEMPHASIS, MPFROMP(pciDa[x]),
|
---|
1027 | MPFROM2SHORT(FALSE, CRA_SELECTED));
|
---|
1028 | }
|
---|
1029 | }
|
---|
1030 | if (!(x % 500))
|
---|
1031 | DosSleep(1L);
|
---|
1032 | // else if (!(x % 50))
|
---|
1033 | // DosSleep(0L);
|
---|
1034 | }
|
---|
1035 | break;
|
---|
1036 |
|
---|
1037 | case IDM_DESELECTBIGGER:
|
---|
1038 | for (x = 0; x < numS; x++) {
|
---|
1039 | if (~pciSa[x]->rc.flRecordAttr & CRA_FILTERED) {
|
---|
1040 | if (pciSa[x]->flags & CNRITEM_LARGER) {
|
---|
1041 | if (pciSa[x]->rc.flRecordAttr & CRA_SELECTED)
|
---|
1042 | WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pciSa[x]),
|
---|
1043 | MPFROM2SHORT(FALSE, CRA_SELECTED));
|
---|
1044 | }
|
---|
1045 | else if (pciDa[x]->flags & CNRITEM_LARGER) {
|
---|
1046 | if (pciDa[x]->rc.flRecordAttr & CRA_SELECTED)
|
---|
1047 | WinSendMsg(hwndCnrD, CM_SETRECORDEMPHASIS, MPFROMP(pciDa[x]),
|
---|
1048 | MPFROM2SHORT(FALSE, CRA_SELECTED));
|
---|
1049 | }
|
---|
1050 | }
|
---|
1051 | if (!(x % 500))
|
---|
1052 | DosSleep(1L);
|
---|
1053 | // else if (!(x % 50))
|
---|
1054 | // DosSleep(0L);
|
---|
1055 | }
|
---|
1056 | break;
|
---|
1057 |
|
---|
1058 | case IDM_DESELECTSMALLER:
|
---|
1059 | for (x = 0; x < numS; x++) {
|
---|
1060 | if (~pciSa[x]->rc.flRecordAttr & CRA_FILTERED) {
|
---|
1061 | if (pciSa[x]->flags & CNRITEM_SMALLER) {
|
---|
1062 | if (pciSa[x]->rc.flRecordAttr & CRA_SELECTED)
|
---|
1063 | WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pciSa[x]),
|
---|
1064 | MPFROM2SHORT(FALSE, CRA_SELECTED));
|
---|
1065 | }
|
---|
1066 | else if (pciDa[x]->flags & CNRITEM_SMALLER) {
|
---|
1067 | if (pciDa[x]->rc.flRecordAttr & CRA_SELECTED)
|
---|
1068 | WinSendMsg(hwndCnrD, CM_SETRECORDEMPHASIS, MPFROMP(pciDa[x]),
|
---|
1069 | MPFROM2SHORT(FALSE, CRA_SELECTED));
|
---|
1070 | }
|
---|
1071 | }
|
---|
1072 | if (!(x % 500))
|
---|
1073 | DosSleep(1L);
|
---|
1074 | // else if (!(x % 50))
|
---|
1075 | // DosSleep(0L);
|
---|
1076 | }
|
---|
1077 | break;
|
---|
1078 |
|
---|
1079 | case IDM_DESELECTNEWER:
|
---|
1080 | for (x = 0; x < numS; x++) {
|
---|
1081 | if (~pciSa[x]->rc.flRecordAttr & CRA_FILTERED) {
|
---|
1082 | if (pciSa[x]->flags & CNRITEM_NEWER) {
|
---|
1083 | if (pciSa[x]->rc.flRecordAttr & CRA_SELECTED)
|
---|
1084 | WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pciSa[x]),
|
---|
1085 | MPFROM2SHORT(FALSE, CRA_SELECTED));
|
---|
1086 | }
|
---|
1087 | else if (pciDa[x]->flags & CNRITEM_NEWER) {
|
---|
1088 | if (pciDa[x]->rc.flRecordAttr & CRA_SELECTED)
|
---|
1089 | WinSendMsg(hwndCnrD, CM_SETRECORDEMPHASIS, MPFROMP(pciDa[x]),
|
---|
1090 | MPFROM2SHORT(FALSE, CRA_SELECTED));
|
---|
1091 | }
|
---|
1092 | }
|
---|
1093 | if (!(x % 500))
|
---|
1094 | DosSleep(1L);
|
---|
1095 | // else if (!(x % 50))
|
---|
1096 | // DosSleep(0L);
|
---|
1097 | }
|
---|
1098 | break;
|
---|
1099 |
|
---|
1100 | case IDM_DESELECTOLDER:
|
---|
1101 | for (x = 0; x < numS; x++) {
|
---|
1102 | if (~pciSa[x]->rc.flRecordAttr & CRA_FILTERED) {
|
---|
1103 | if (pciSa[x]->flags & CNRITEM_OLDER) {
|
---|
1104 | if (pciSa[x]->rc.flRecordAttr & CRA_SELECTED)
|
---|
1105 | WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pciSa[x]),
|
---|
1106 | MPFROM2SHORT(FALSE, CRA_SELECTED));
|
---|
1107 | }
|
---|
1108 | else if (pciDa[x]->flags & CNRITEM_OLDER) {
|
---|
1109 | if (pciDa[x]->rc.flRecordAttr & CRA_SELECTED)
|
---|
1110 | WinSendMsg(hwndCnrD, CM_SETRECORDEMPHASIS, MPFROMP(pciDa[x]),
|
---|
1111 | MPFROM2SHORT(FALSE, CRA_SELECTED));
|
---|
1112 | }
|
---|
1113 | }
|
---|
1114 | if (!(x % 500))
|
---|
1115 | DosSleep(1L);
|
---|
1116 | // else if (!(x % 50))
|
---|
1117 | // DosSleep(0L);
|
---|
1118 | }
|
---|
1119 | break;
|
---|
1120 |
|
---|
1121 | default:
|
---|
1122 | break;
|
---|
1123 | }
|
---|
1124 |
|
---|
1125 | if (reset) {
|
---|
1126 | while (numS) {
|
---|
1127 | WinSendMsg(hwndCnrS, CM_INVALIDATERECORD,
|
---|
1128 | MPFROMP(pciSa), MPFROM2SHORT((min(numS, 65535)), 0));
|
---|
1129 | DosSleep(1);
|
---|
1130 | WinSendMsg(hwndCnrD, CM_INVALIDATERECORD,
|
---|
1131 | MPFROMP(pciDa), MPFROM2SHORT((min(numD, 65535)), 0));
|
---|
1132 | numS -= min(numS, 65535);
|
---|
1133 | if (numS)
|
---|
1134 | DosSleep(1);
|
---|
1135 | }
|
---|
1136 | }
|
---|
1137 |
|
---|
1138 | free(pciSa);
|
---|
1139 | free(pciDa);
|
---|
1140 | DosPostEventSem(CompactSem);
|
---|
1141 | }
|
---|
1142 |
|
---|
1143 | struct SS
|
---|
1144 | {
|
---|
1145 | PCNRITEM pci;
|
---|
1146 | BOOL unique, all, smallest, largest, newest, oldest;
|
---|
1147 | };
|
---|
1148 |
|
---|
1149 | struct Cnr
|
---|
1150 | {
|
---|
1151 | HWND hwndCnr;
|
---|
1152 | ULONG numfiles;
|
---|
1153 | struct SS *ss;
|
---|
1154 | };
|
---|
1155 |
|
---|
1156 | static int CompSSNamesB(const void *s1, const void *s2)
|
---|
1157 | {
|
---|
1158 | struct SS *ss2 = (struct SS *)s2;
|
---|
1159 |
|
---|
1160 | return stricmp((PSZ)s1, ss2->pci->pszFileName);
|
---|
1161 | }
|
---|
1162 |
|
---|
1163 | static int CompSSNames(const void *s1, const void *s2)
|
---|
1164 | {
|
---|
1165 | struct SS *ss1 = (struct SS *)s1;
|
---|
1166 | struct SS *ss2 = (struct SS *)s2;
|
---|
1167 |
|
---|
1168 | return stricmp(ss1->pci->pszFileName, ss2->pci->pszFileName);
|
---|
1169 | }
|
---|
1170 |
|
---|
1171 | VOID FreeCnrs(struct Cnr * Cnrs, INT numw)
|
---|
1172 | {
|
---|
1173 | register INT z;
|
---|
1174 |
|
---|
1175 | for (z = 0; z < numw; z++) {
|
---|
1176 | if (Cnrs[z].ss)
|
---|
1177 | free(Cnrs[z].ss);
|
---|
1178 | }
|
---|
1179 | free(Cnrs);
|
---|
1180 | DosPostEventSem(CompactSem);
|
---|
1181 | }
|
---|
1182 |
|
---|
1183 | /**
|
---|
1184 | * Do select actions for single container
|
---|
1185 | *
|
---|
1186 | */
|
---|
1187 |
|
---|
1188 | VOID SpecialSelect2(HWND hwndParent, INT action)
|
---|
1189 | {
|
---|
1190 | PCNRITEM pci;
|
---|
1191 | HENUM henum;
|
---|
1192 | HWND hwnd;
|
---|
1193 | register INT numwindows = 0, w, x, z, cmp;
|
---|
1194 | struct Cnr *Cnrs = NULL;
|
---|
1195 | struct SS *bsres;
|
---|
1196 |
|
---|
1197 | if (!hwndParent)
|
---|
1198 | return;
|
---|
1199 |
|
---|
1200 | /* count directory containers, build array of hwnds */
|
---|
1201 | henum = WinBeginEnumWindows(hwndParent);
|
---|
1202 | while ((hwnd = WinGetNextWindow(henum)) != NULLHANDLE) {
|
---|
1203 | if (WinWindowFromID(WinWindowFromID(hwnd, FID_CLIENT), DIR_CNR)) {
|
---|
1204 | Cnrs =
|
---|
1205 | xrealloc(Cnrs, (numwindows + 1) * sizeof(struct Cnr), pszSrcFile,
|
---|
1206 | __LINE__);
|
---|
1207 | if (!Cnrs) {
|
---|
1208 | Notify(GetPString(IDS_OUTOFMEMORY));
|
---|
1209 | return;
|
---|
1210 | }
|
---|
1211 | memset(&Cnrs[numwindows], 0, sizeof(struct Cnr));
|
---|
1212 | Cnrs[numwindows].hwndCnr = WinWindowFromID(WinWindowFromID(hwnd,
|
---|
1213 | FID_CLIENT),
|
---|
1214 | DIR_CNR);
|
---|
1215 | numwindows++;
|
---|
1216 | }
|
---|
1217 | }
|
---|
1218 | WinEndEnumWindows(henum);
|
---|
1219 | if (numwindows < 2) {
|
---|
1220 | FreeCnrs(Cnrs, numwindows);
|
---|
1221 | Runtime_Error(pszSrcFile, __LINE__, "expected two windows");
|
---|
1222 | Notify(GetPString(IDS_COMPSEL2ORMORETEXT));
|
---|
1223 | return;
|
---|
1224 | }
|
---|
1225 | if (numwindows > 4) {
|
---|
1226 | WinSendMsg(Cnrs[0].
|
---|
1227 | hwndCnr,
|
---|
1228 | UM_NOTIFY, MPFROMP(GetPString(IDS_BUILDINGLISTSTEXT)), MPVOID);
|
---|
1229 | DosSleep(1);
|
---|
1230 | }
|
---|
1231 |
|
---|
1232 | /* count records, build array of pointers to records */
|
---|
1233 | for (z = 0; z < numwindows; z++) {
|
---|
1234 | pci = (PCNRITEM) WinSendMsg(Cnrs[z].hwndCnr,
|
---|
1235 | CM_QUERYRECORD,
|
---|
1236 | MPVOID,
|
---|
1237 | MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
|
---|
1238 | x = 0;
|
---|
1239 | while (pci && (INT)pci != -1) {
|
---|
1240 | if (~pci->rc.flRecordAttr & CRA_FILTERED &&
|
---|
1241 | ~pci->attrFile & FILE_DIRECTORY) {
|
---|
1242 | Cnrs[z].ss =
|
---|
1243 | xrealloc(Cnrs[z].ss, (x + 1) * sizeof(struct SS), pszSrcFile,
|
---|
1244 | __LINE__);
|
---|
1245 | if (!Cnrs[z].ss) {
|
---|
1246 | FreeCnrs(Cnrs, numwindows);
|
---|
1247 | Notify(GetPString(IDS_OUTOFMEMORY));
|
---|
1248 | return;
|
---|
1249 | }
|
---|
1250 | memset(&Cnrs[z].ss[x], 0, sizeof(struct SS));
|
---|
1251 | Cnrs[z].ss[x].pci = pci;
|
---|
1252 | x++;
|
---|
1253 | }
|
---|
1254 | pci = (PCNRITEM) WinSendMsg(Cnrs[z].hwndCnr,
|
---|
1255 | CM_QUERYRECORD,
|
---|
1256 | MPFROMP(pci),
|
---|
1257 | MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
|
---|
1258 | }
|
---|
1259 | DosSleep(1);
|
---|
1260 | Cnrs[z].numfiles = x;
|
---|
1261 | if (Cnrs[z].numfiles)
|
---|
1262 | qsort(Cnrs[z].ss, Cnrs[z].numfiles, sizeof(struct SS), CompSSNames);
|
---|
1263 | }
|
---|
1264 |
|
---|
1265 | for (z = 0; z < numwindows; z++) {
|
---|
1266 | for (x = 0; x < Cnrs[z].numfiles; x++) {
|
---|
1267 | Cnrs[z].ss[x].all = Cnrs[z].ss[x].unique = Cnrs[z].ss[x].newest =
|
---|
1268 | Cnrs[z].ss[x].oldest = Cnrs[z].ss[x].smallest =
|
---|
1269 | Cnrs[z].ss[x].largest = TRUE;
|
---|
1270 | for (w = 0; w < numwindows; w++) {
|
---|
1271 | if (w != z && Cnrs[w].numfiles) {
|
---|
1272 | bsres = (struct SS *)bsearch(Cnrs[z].ss[x].pci->pszFileName,
|
---|
1273 | Cnrs[w].ss, Cnrs[w].numfiles,
|
---|
1274 | sizeof(struct SS), CompSSNamesB);
|
---|
1275 | if (bsres) {
|
---|
1276 | Cnrs[z].ss[x].unique = FALSE;
|
---|
1277 | if (Cnrs[z].ss[x].pci->cbFile + Cnrs[z].ss[x].pci->easize >
|
---|
1278 | bsres->pci->cbFile + bsres->pci->easize)
|
---|
1279 | Cnrs[z].ss[x].smallest = FALSE;
|
---|
1280 | if (Cnrs[z].ss[x].pci->cbFile + Cnrs[z].ss[x].pci->easize <
|
---|
1281 | bsres->pci->cbFile + bsres->pci->easize)
|
---|
1282 | Cnrs[z].ss[x].largest = FALSE;
|
---|
1283 | cmp =
|
---|
1284 | (Cnrs[z].ss[x].pci->date.year >
|
---|
1285 | bsres->pci->date.year) ? TRUE : (Cnrs[z].ss[x].pci->date.year <
|
---|
1286 | bsres->pci->date.
|
---|
1287 | year) ? FALSE : (Cnrs[z].
|
---|
1288 | ss[x].pci->
|
---|
1289 | date.month >
|
---|
1290 | bsres->pci->
|
---|
1291 | date.
|
---|
1292 | month) ? TRUE
|
---|
1293 | : (Cnrs[z].ss[x].pci->date.month <
|
---|
1294 | bsres->pci->date.month) ? FALSE : (Cnrs[z].ss[x].pci->date.
|
---|
1295 | day >
|
---|
1296 | bsres->pci->date.
|
---|
1297 | day) ? TRUE : (Cnrs[z].
|
---|
1298 | ss[x].pci->
|
---|
1299 | date.day <
|
---|
1300 | bsres->
|
---|
1301 | pci->date.
|
---|
1302 | day) ?
|
---|
1303 | FALSE : (Cnrs[z].ss[x].pci->time.hours >
|
---|
1304 | bsres->pci->time.hours) ? TRUE : (Cnrs[z].ss[x].pci->
|
---|
1305 | time.hours <
|
---|
1306 | bsres->pci->time.
|
---|
1307 | hours) ? FALSE
|
---|
1308 | : (Cnrs[z].ss[x].pci->time.minutes >
|
---|
1309 | bsres->pci->time.minutes) ? TRUE : (Cnrs[z].ss[x].pci->time.
|
---|
1310 | minutes <
|
---|
1311 | bsres->pci->time.
|
---|
1312 | minutes) ? FALSE
|
---|
1313 | : (Cnrs[z].ss[x].pci->time.seconds >
|
---|
1314 | bsres->pci->time.seconds) ? TRUE : (Cnrs[z].ss[x].pci->time.
|
---|
1315 | seconds <
|
---|
1316 | bsres->pci->time.
|
---|
1317 | seconds) ? FALSE : FALSE;
|
---|
1318 | if (!cmp)
|
---|
1319 | Cnrs[z].ss[x].newest = FALSE;
|
---|
1320 | cmp =
|
---|
1321 | (Cnrs[z].ss[x].pci->date.year <
|
---|
1322 | bsres->pci->date.year) ? TRUE : (Cnrs[z].ss[x].pci->date.year >
|
---|
1323 | bsres->pci->date.
|
---|
1324 | year) ? FALSE : (Cnrs[z].
|
---|
1325 | ss[x].pci->
|
---|
1326 | date.month <
|
---|
1327 | bsres->pci->
|
---|
1328 | date.
|
---|
1329 | month) ? TRUE
|
---|
1330 | : (Cnrs[z].ss[x].pci->date.month >
|
---|
1331 | bsres->pci->date.month) ? FALSE : (Cnrs[z].ss[x].pci->date.
|
---|
1332 | day <
|
---|
1333 | bsres->pci->date.
|
---|
1334 | day) ? TRUE : (Cnrs[z].
|
---|
1335 | ss[x].pci->
|
---|
1336 | date.day >
|
---|
1337 | bsres->
|
---|
1338 | pci->date.
|
---|
1339 | day) ?
|
---|
1340 | FALSE : (Cnrs[z].ss[x].pci->time.hours <
|
---|
1341 | bsres->pci->time.hours) ? TRUE : (Cnrs[z].ss[x].pci->
|
---|
1342 | time.hours >
|
---|
1343 | bsres->pci->time.
|
---|
1344 | hours) ? FALSE
|
---|
1345 | : (Cnrs[z].ss[x].pci->time.minutes <
|
---|
1346 | bsres->pci->time.minutes) ? TRUE : (Cnrs[z].ss[x].pci->time.
|
---|
1347 | minutes >
|
---|
1348 | bsres->pci->time.
|
---|
1349 | minutes) ? FALSE
|
---|
1350 | : (Cnrs[z].ss[x].pci->time.seconds <
|
---|
1351 | bsres->pci->time.seconds) ? TRUE : (Cnrs[z].ss[x].pci->time.
|
---|
1352 | seconds >
|
---|
1353 | bsres->pci->time.
|
---|
1354 | seconds) ? FALSE : FALSE;
|
---|
1355 | if (!cmp)
|
---|
1356 | Cnrs[z].ss[x].oldest = FALSE;
|
---|
1357 | cmp = 0;
|
---|
1358 | break;
|
---|
1359 | }
|
---|
1360 | else
|
---|
1361 | Cnrs[z].ss[x].all = FALSE;
|
---|
1362 | }
|
---|
1363 | }
|
---|
1364 | if (Cnrs[z].ss[x].unique)
|
---|
1365 | Cnrs[z].ss[x].oldest = Cnrs[z].ss[x].newest = Cnrs[z].ss[x].all =
|
---|
1366 | Cnrs[z].ss[x].largest = Cnrs[z].ss[x].smallest = FALSE;
|
---|
1367 | DosSleep(1);
|
---|
1368 | }
|
---|
1369 | DosSleep(1);
|
---|
1370 | }
|
---|
1371 |
|
---|
1372 | switch (action) {
|
---|
1373 | case IDM_SELECTBOTH:
|
---|
1374 | for (z = 0; z < numwindows; z++) {
|
---|
1375 | for (x = 0; x < Cnrs[z].numfiles; x++) {
|
---|
1376 | if (Cnrs[z].ss[x].all)
|
---|
1377 | WinSendMsg(Cnrs[z].hwndCnr, CM_SETRECORDEMPHASIS,
|
---|
1378 | MPFROMP(Cnrs[z].ss[x].pci),
|
---|
1379 | MPFROM2SHORT(TRUE, CRA_SELECTED));
|
---|
1380 | }
|
---|
1381 | DosSleep(1);
|
---|
1382 | }
|
---|
1383 | break;
|
---|
1384 | case IDM_SELECTMORE:
|
---|
1385 | for (z = 0; z < numwindows; z++) {
|
---|
1386 | for (x = 0; x < Cnrs[z].numfiles; x++) {
|
---|
1387 | if (!Cnrs[z].ss[x].unique)
|
---|
1388 | WinSendMsg(Cnrs[z].hwndCnr, CM_SETRECORDEMPHASIS,
|
---|
1389 | MPFROMP(Cnrs[z].ss[x].pci),
|
---|
1390 | MPFROM2SHORT(TRUE, CRA_SELECTED));
|
---|
1391 | }
|
---|
1392 | DosSleep(1);
|
---|
1393 | }
|
---|
1394 | break;
|
---|
1395 | case IDM_SELECTONE:
|
---|
1396 | for (z = 0; z < numwindows; z++) {
|
---|
1397 | for (x = 0; x < Cnrs[z].numfiles; x++) {
|
---|
1398 | if (Cnrs[z].ss[x].unique)
|
---|
1399 | WinSendMsg(Cnrs[z].hwndCnr, CM_SETRECORDEMPHASIS,
|
---|
1400 | MPFROMP(Cnrs[z].ss[x].pci),
|
---|
1401 | MPFROM2SHORT(TRUE, CRA_SELECTED));
|
---|
1402 | }
|
---|
1403 | DosSleep(1);
|
---|
1404 | }
|
---|
1405 | break;
|
---|
1406 | case IDM_SELECTNEWER:
|
---|
1407 | for (z = 0; z < numwindows; z++) {
|
---|
1408 | for (x = 0; x < Cnrs[z].numfiles; x++) {
|
---|
1409 | if (Cnrs[z].ss[x].newest)
|
---|
1410 | WinSendMsg(Cnrs[z].hwndCnr, CM_SETRECORDEMPHASIS,
|
---|
1411 | MPFROMP(Cnrs[z].ss[x].pci),
|
---|
1412 | MPFROM2SHORT(TRUE, CRA_SELECTED));
|
---|
1413 | }
|
---|
1414 | DosSleep(1);
|
---|
1415 | }
|
---|
1416 | break;
|
---|
1417 | case IDM_SELECTOLDER:
|
---|
1418 | for (z = 0; z < numwindows; z++) {
|
---|
1419 | for (x = 0; x < Cnrs[z].numfiles; x++) {
|
---|
1420 | if (Cnrs[z].ss[x].oldest)
|
---|
1421 | WinSendMsg(Cnrs[z].hwndCnr, CM_SETRECORDEMPHASIS,
|
---|
1422 | MPFROMP(Cnrs[z].ss[x].pci),
|
---|
1423 | MPFROM2SHORT(TRUE, CRA_SELECTED));
|
---|
1424 | }
|
---|
1425 | DosSleep(1);
|
---|
1426 | }
|
---|
1427 | break;
|
---|
1428 | case IDM_SELECTBIGGER:
|
---|
1429 | for (z = 0; z < numwindows; z++) {
|
---|
1430 | for (x = 0; x < Cnrs[z].numfiles; x++) {
|
---|
1431 | if (Cnrs[z].ss[x].largest)
|
---|
1432 | WinSendMsg(Cnrs[z].hwndCnr, CM_SETRECORDEMPHASIS,
|
---|
1433 | MPFROMP(Cnrs[z].ss[x].pci),
|
---|
1434 | MPFROM2SHORT(TRUE, CRA_SELECTED));
|
---|
1435 | }
|
---|
1436 | DosSleep(1);
|
---|
1437 | }
|
---|
1438 | break;
|
---|
1439 | case IDM_SELECTSMALLER:
|
---|
1440 | for (z = 0; z < numwindows; z++) {
|
---|
1441 | for (x = 0; x < Cnrs[z].numfiles; x++) {
|
---|
1442 | if (Cnrs[z].ss[x].smallest)
|
---|
1443 | WinSendMsg(Cnrs[z].hwndCnr, CM_SETRECORDEMPHASIS,
|
---|
1444 | MPFROMP(Cnrs[z].ss[x].pci),
|
---|
1445 | MPFROM2SHORT(TRUE, CRA_SELECTED));
|
---|
1446 | }
|
---|
1447 | DosSleep(1);
|
---|
1448 | }
|
---|
1449 | break;
|
---|
1450 |
|
---|
1451 | case IDM_DESELECTBOTH:
|
---|
1452 | for (z = 0; z < numwindows; z++) {
|
---|
1453 | for (x = 0; x < Cnrs[z].numfiles; x++) {
|
---|
1454 | if (Cnrs[z].ss[x].all)
|
---|
1455 | WinSendMsg(Cnrs[z].hwndCnr, CM_SETRECORDEMPHASIS,
|
---|
1456 | MPFROMP(Cnrs[z].ss[x].pci),
|
---|
1457 | MPFROM2SHORT(FALSE, CRA_SELECTED));
|
---|
1458 | }
|
---|
1459 | DosSleep(1);
|
---|
1460 | }
|
---|
1461 | break;
|
---|
1462 | case IDM_DESELECTMORE:
|
---|
1463 | for (z = 0; z < numwindows; z++) {
|
---|
1464 | for (x = 0; x < Cnrs[z].numfiles; x++) {
|
---|
1465 | if (!Cnrs[z].ss[x].unique)
|
---|
1466 | WinSendMsg(Cnrs[z].hwndCnr, CM_SETRECORDEMPHASIS,
|
---|
1467 | MPFROMP(Cnrs[z].ss[x].pci),
|
---|
1468 | MPFROM2SHORT(FALSE, CRA_SELECTED));
|
---|
1469 | }
|
---|
1470 | DosSleep(1);
|
---|
1471 | }
|
---|
1472 | break;
|
---|
1473 | case IDM_DESELECTONE:
|
---|
1474 | for (z = 0; z < numwindows; z++) {
|
---|
1475 | for (x = 0; x < Cnrs[z].numfiles; x++) {
|
---|
1476 | if (Cnrs[z].ss[x].unique)
|
---|
1477 | WinSendMsg(Cnrs[z].hwndCnr, CM_SETRECORDEMPHASIS,
|
---|
1478 | MPFROMP(Cnrs[z].ss[x].pci),
|
---|
1479 | MPFROM2SHORT(FALSE, CRA_SELECTED));
|
---|
1480 | }
|
---|
1481 | DosSleep(1);
|
---|
1482 | }
|
---|
1483 | break;
|
---|
1484 | case IDM_DESELECTNEWER:
|
---|
1485 | for (z = 0; z < numwindows; z++) {
|
---|
1486 | for (x = 0; x < Cnrs[z].numfiles; x++) {
|
---|
1487 | if (Cnrs[z].ss[x].newest)
|
---|
1488 | WinSendMsg(Cnrs[z].hwndCnr, CM_SETRECORDEMPHASIS,
|
---|
1489 | MPFROMP(Cnrs[z].ss[x].pci),
|
---|
1490 | MPFROM2SHORT(FALSE, CRA_SELECTED));
|
---|
1491 | }
|
---|
1492 | DosSleep(1);
|
---|
1493 | }
|
---|
1494 | break;
|
---|
1495 | case IDM_DESELECTOLDER:
|
---|
1496 | for (z = 0; z < numwindows; z++) {
|
---|
1497 | for (x = 0; x < Cnrs[z].numfiles; x++) {
|
---|
1498 | if (Cnrs[z].ss[x].oldest)
|
---|
1499 | WinSendMsg(Cnrs[z].hwndCnr, CM_SETRECORDEMPHASIS,
|
---|
1500 | MPFROMP(Cnrs[z].ss[x].pci),
|
---|
1501 | MPFROM2SHORT(FALSE, CRA_SELECTED));
|
---|
1502 | }
|
---|
1503 | DosSleep(1);
|
---|
1504 | }
|
---|
1505 | break;
|
---|
1506 | case IDM_DESELECTBIGGER:
|
---|
1507 | for (z = 0; z < numwindows; z++) {
|
---|
1508 | for (x = 0; x < Cnrs[z].numfiles; x++) {
|
---|
1509 | if (Cnrs[z].ss[x].largest)
|
---|
1510 | WinSendMsg(Cnrs[z].hwndCnr, CM_SETRECORDEMPHASIS,
|
---|
1511 | MPFROMP(Cnrs[z].ss[x].pci),
|
---|
1512 | MPFROM2SHORT(FALSE, CRA_SELECTED));
|
---|
1513 | }
|
---|
1514 | DosSleep(1);
|
---|
1515 | }
|
---|
1516 | break;
|
---|
1517 | case IDM_DESELECTSMALLER:
|
---|
1518 | for (z = 0; z < numwindows; z++) {
|
---|
1519 | for (x = 0; x < Cnrs[z].numfiles; x++) {
|
---|
1520 | if (Cnrs[z].ss[x].smallest)
|
---|
1521 | WinSendMsg(Cnrs[z].hwndCnr, CM_SETRECORDEMPHASIS,
|
---|
1522 | MPFROMP(Cnrs[z].ss[x].pci),
|
---|
1523 | MPFROM2SHORT(FALSE, CRA_SELECTED));
|
---|
1524 | }
|
---|
1525 | DosSleep(1);
|
---|
1526 | }
|
---|
1527 | break;
|
---|
1528 | }
|
---|
1529 |
|
---|
1530 | FreeCnrs(Cnrs, numwindows);
|
---|
1531 | }
|
---|