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