Changeset 157 for trunk/dll/sortcnr.c
- Timestamp:
- May 26, 2005, 4:18:54 AM (20 years ago)
- File:
-
- 1 edited
-
trunk/dll/sortcnr.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/dll/sortcnr.c
r2 r157 1 2 /*********************************************************************** 3 4 $Id$ 5 6 Sort container items 7 8 Copyright (c) 1993-98 M. Kimes 9 Copyright (c) 2005 Steven H. Levine 10 11 24 May 05 SHL Rework for CNRITEM.szSubject 12 25 May 05 SHL Rework with ULONGLONG 13 14 ***********************************************************************/ 15 1 16 #define INCL_WIN 17 #define INCL_LONGLONG 18 #include <os2.h> 2 19 3 #include <os2.h>4 20 #include <stdio.h> 5 21 #include <stdlib.h> 6 22 #include <string.h> 23 7 24 #include "fm3dll.h" 8 25 … … 11 28 12 29 SHORT APIENTRY SortTreeCnr (PMINIRECORDCORE p1,PMINIRECORDCORE p2, 13 PVOID pStorage) { 14 30 PVOID pStorage) 31 { 15 32 return SortCnr(p1,p2,((pStorage) ? (INT)pStorage : TreesortFlags)); 16 33 } … … 18 35 19 36 SHORT APIENTRY SortDirCnr (PMINIRECORDCORE p1,PMINIRECORDCORE p2, 20 PVOID pStorage) { 21 37 PVOID pStorage) 38 { 22 39 DIRCNRDATA *dcd = WinQueryWindowPtr(((PCNRITEM)p1)->hwndCnr,0); 23 40 24 41 return SortCnr(p1,p2,((pStorage) ? (INT)pStorage : 25 (dcd && dcd->size == sizeof(DIRCNRDATA)) ?26 dcd->sortFlags : sortFlags));42 (dcd && dcd->size == sizeof(DIRCNRDATA)) ? 43 dcd->sortFlags : sortFlags)); 27 44 } 28 45 29 46 30 47 SHORT APIENTRY SortCollectorCnr (PMINIRECORDCORE p1,PMINIRECORDCORE p2, 31 PVOID pStorage) { 32 48 PVOID pStorage) 49 { 33 50 return SortCnr(p1,p2,((pStorage) ? (INT)pStorage : CollectorsortFlags)); 34 51 } 35 52 36 53 37 SHORT SortCnr (PMINIRECORDCORE p1,PMINIRECORDCORE p2,INT SortFlags) { 38 39 PCNRITEM p = (PCNRITEM)p1,pp = (PCNRITEM)p2; 54 SHORT SortCnr (PMINIRECORDCORE pRec1,PMINIRECORDCORE pRec2,INT SortFlags) 55 { 56 PCNRITEM pCI1 = (PCNRITEM)pRec1; 57 PCNRITEM pCI2 = (PCNRITEM)pRec2; 40 58 SHORT ret = 0; 41 CHAR *p ext,*ppext;59 CHAR *pch1,*pch2; 42 60 43 61 if(SortFlags & SORT_NOSORT) 44 62 return 0; 45 if(SortFlags && p ->szFileName[3] && pp->szFileName[3]) {63 if(SortFlags && pCI1->szFileName[3] && pCI2->szFileName[3]) { 46 64 if(SortFlags & SORT_DIRSFIRST) { 47 if((p ->attrFile & FILE_DIRECTORY) != (pp->attrFile & FILE_DIRECTORY))48 return (p->attrFile & FILE_DIRECTORY) ? -1 : 1;65 if((pCI1->attrFile & FILE_DIRECTORY) != (pCI2->attrFile & FILE_DIRECTORY)) 66 return (pCI1->attrFile & FILE_DIRECTORY) ? -1 : 1; 49 67 } 50 68 else if(SortFlags & SORT_DIRSLAST) { 51 if((p ->attrFile & FILE_DIRECTORY) != (pp->attrFile & FILE_DIRECTORY))52 return (p->attrFile & FILE_DIRECTORY) ? 1 : -1;69 if((pCI1->attrFile & FILE_DIRECTORY) != (pCI2->attrFile & FILE_DIRECTORY)) 70 return (pCI1->attrFile & FILE_DIRECTORY) ? 1 : -1; 53 71 } 54 72 switch(SortFlags & (~(SORT_DIRSFIRST | SORT_DIRSLAST | SORT_REVERSE))) { 55 73 case SORT_SUBJECT: 56 if(*p->subject && *pp->subject)57 ret = stricmp(p->subject,pp->subject);58 else {59 ret = (*pp->subject) ? 1 : (*p->subject) ? -1 : 0;60 if(ret && (SortFlags & SORT_REVERSE))61 ret = (ret > 0) ? -1 : 1;62 }63 break;74 if(*pCI1->szSubject && *pCI2->szSubject) 75 ret = stricmp(pCI1->szSubject,pCI2->szSubject); 76 else { 77 ret = (*pCI2->szSubject) ? 1 : (*pCI1->szSubject) ? -1 : 0; 78 if(ret && (SortFlags & SORT_REVERSE)) 79 ret = (ret > 0) ? -1 : 1; 80 } 81 break; 64 82 65 83 case SORT_FILENAME: 66 pext = strrchr(p->szFileName,'\\');67 ppext = strrchr(pp->szFileName,'\\');68 if(!pext)69 pext= NullStr;70 if(!ppext)71 ppext= NullStr;72 ret = stricmp(pext,ppext);73 break;84 pch1 = strrchr(pCI1->szFileName,'\\'); 85 pch2 = strrchr(pCI2->szFileName,'\\'); 86 if(!pch1) 87 pch1 = NullStr; 88 if(!pch2) 89 pch2 = NullStr; 90 ret = stricmp(pch1,pch2); 91 break; 74 92 75 93 case SORT_FIRSTEXTENSION: 76 pext = strrchr(p->szFileName,'\\');77 ppext = strrchr(pp->szFileName,'\\');78 if(!pext)79 pext = p->szFileName;80 if(!ppext)81 ppext = pp->szFileName;82 pext = strchr(pext,'.');83 ppext = strchr(ppext,'.');84 if(!pext)85 pext= NullStr;86 if(!ppext)87 ppext= NullStr;88 ret = stricmp(pext,ppext);89 break;94 pch1 = strrchr(pCI1->szFileName,'\\'); 95 pch2 = strrchr(pCI2->szFileName,'\\'); 96 if(!pch1) 97 pch1 = pCI1->szFileName; 98 if(!pch2) 99 pch2 = pCI2->szFileName; 100 pch1 = strchr(pch1,'.'); 101 pch2 = strchr(pch2,'.'); 102 if(!pch1) 103 pch1 = NullStr; 104 if(!pch2) 105 pch2 = NullStr; 106 ret = stricmp(pch1,pch2); 107 break; 90 108 91 109 case SORT_LASTEXTENSION: 92 pext = strrchr(p->szFileName,'\\');93 ppext = strrchr(pp->szFileName,'\\');94 if(!pext)95 pext = p->szFileName;96 if(!ppext)97 ppext = pp->szFileName;98 pext = strrchr(pext,'.');99 ppext = strrchr(ppext,'.');100 if(!pext)101 pext= NullStr;102 if(!ppext)103 ppext= NullStr;104 ret = stricmp(pext,ppext);105 break;110 pch1 = strrchr(pCI1->szFileName,'\\'); 111 pch2 = strrchr(pCI2->szFileName,'\\'); 112 if(!pch1) 113 pch1 = pCI1->szFileName; 114 if(!pch2) 115 pch2 = pCI2->szFileName; 116 pch1 = strrchr(pch1,'.'); 117 pch2 = strrchr(pch2,'.'); 118 if(!pch1) 119 pch1 = NullStr; 120 if(!pch2) 121 pch2 = NullStr; 122 ret = stricmp(pch1,pch2); 123 break; 106 124 107 125 case SORT_SIZE: 108 ret = (p->cbFile < pp->cbFile) ? 1 : (p->cbFile == pp->cbFile) ?109 0 : -1;110 if(!ret)111 ret = (p->easize < pp->easize) ? 1 : (p->easize == pp->easize) ?112 0 : -1;113 break;126 ret = (pCI1->cbFile < pCI2->cbFile) ? 1 : (pCI1->cbFile == pCI2->cbFile) ? 127 0 : -1; 128 if(!ret) 129 ret = (pCI1->easize < pCI2->easize) ? 1 : (pCI1->easize == pCI2->easize) ? 130 0 : -1; 131 break; 114 132 115 133 case SORT_EASIZE: 116 ret = (p->easize < pp->easize) ? 1 : (p->easize == pp->easize) ?117 0 : -1;118 if(!ret)119 ret = (p->cbFile < pp->cbFile) ? 1 : (p->cbFile == pp->cbFile) ?120 0 : -1;121 break;134 ret = (pCI1->easize < pCI2->easize) ? 1 : (pCI1->easize == pCI2->easize) ? 135 0 : -1; 136 if(!ret) 137 ret = (pCI1->cbFile < pCI2->cbFile) ? 1 : (pCI1->cbFile == pCI2->cbFile) ? 138 0 : -1; 139 break; 122 140 123 141 case SORT_LWDATE: 124 ret = (p->date.year < pp->date.year) ? 1 :125 (p->date.year > pp->date.year) ? -1 :126 (p->date.month < pp->date.month) ? 1 :127 (p->date.month > pp->date.month) ? -1 :128 (p->date.day < pp->date.day) ? 1 :129 (p->date.day > pp->date.day) ? -1 :130 (p->time.hours < pp->time.hours) ? 1 :131 (p->time.hours > pp->time.hours) ? -1 :132 (p->time.minutes < pp->time.minutes) ? 1 :133 (p->time.minutes > pp->time.minutes) ? -1 :134 (p->time.seconds < pp->time.seconds) ? 1 :135 (p->time.seconds > pp->time.seconds) ? -1 : 0;136 break;142 ret = (pCI1->date.year < pCI2->date.year) ? 1 : 143 (pCI1->date.year > pCI2->date.year) ? -1 : 144 (pCI1->date.month < pCI2->date.month) ? 1 : 145 (pCI1->date.month > pCI2->date.month) ? -1 : 146 (pCI1->date.day < pCI2->date.day) ? 1 : 147 (pCI1->date.day > pCI2->date.day) ? -1 : 148 (pCI1->time.hours < pCI2->time.hours) ? 1 : 149 (pCI1->time.hours > pCI2->time.hours) ? -1 : 150 (pCI1->time.minutes < pCI2->time.minutes) ? 1 : 151 (pCI1->time.minutes > pCI2->time.minutes) ? -1 : 152 (pCI1->time.seconds < pCI2->time.seconds) ? 1 : 153 (pCI1->time.seconds > pCI2->time.seconds) ? -1 : 0; 154 break; 137 155 138 156 case SORT_LADATE: 139 ret = (p->ladate.year < pp->ladate.year) ? 1 :140 (p->ladate.year > pp->ladate.year) ? -1 :141 (p->ladate.month < pp->ladate.month) ? 1 :142 (p->ladate.month > pp->ladate.month) ? -1 :143 (p->ladate.day < pp->ladate.day) ? 1 :144 (p->ladate.day > pp->ladate.day) ? -1 :145 (p->latime.hours < pp->latime.hours) ? 1 :146 (p->latime.hours > pp->latime.hours) ? -1 :147 (p->latime.minutes < pp->latime.minutes) ? 1 :148 (p->latime.minutes > pp->latime.minutes) ? -1 :149 (p->latime.seconds < pp->latime.seconds) ? 1 :150 (p->latime.seconds > pp->latime.seconds) ? -1 : 0;151 break;157 ret = (pCI1->ladate.year < pCI2->ladate.year) ? 1 : 158 (pCI1->ladate.year > pCI2->ladate.year) ? -1 : 159 (pCI1->ladate.month < pCI2->ladate.month) ? 1 : 160 (pCI1->ladate.month > pCI2->ladate.month) ? -1 : 161 (pCI1->ladate.day < pCI2->ladate.day) ? 1 : 162 (pCI1->ladate.day > pCI2->ladate.day) ? -1 : 163 (pCI1->latime.hours < pCI2->latime.hours) ? 1 : 164 (pCI1->latime.hours > pCI2->latime.hours) ? -1 : 165 (pCI1->latime.minutes < pCI2->latime.minutes) ? 1 : 166 (pCI1->latime.minutes > pCI2->latime.minutes) ? -1 : 167 (pCI1->latime.seconds < pCI2->latime.seconds) ? 1 : 168 (pCI1->latime.seconds > pCI2->latime.seconds) ? -1 : 0; 169 break; 152 170 153 171 case SORT_CRDATE: 154 ret = (p->crdate.year < pp->crdate.year) ? 1 :155 (p->crdate.year > pp->crdate.year) ? -1 :156 (p->crdate.month < pp->crdate.month) ? 1 :157 (p->crdate.month > pp->crdate.month) ? -1 :158 (p->crdate.day < pp->crdate.day) ? 1 :159 (p->crdate.day > pp->crdate.day) ? -1 :160 (p->crtime.hours < pp->crtime.hours) ? 1 :161 (p->crtime.hours > pp->crtime.hours) ? -1 :162 (p->crtime.minutes < pp->crtime.minutes) ? 1 :163 (p->crtime.minutes > pp->crtime.minutes) ? -1 :164 (p->crtime.seconds < pp->crtime.seconds) ? 1 :165 (p->crtime.seconds > pp->crtime.seconds) ? -1 : 0;166 break;172 ret = (pCI1->crdate.year < pCI2->crdate.year) ? 1 : 173 (pCI1->crdate.year > pCI2->crdate.year) ? -1 : 174 (pCI1->crdate.month < pCI2->crdate.month) ? 1 : 175 (pCI1->crdate.month > pCI2->crdate.month) ? -1 : 176 (pCI1->crdate.day < pCI2->crdate.day) ? 1 : 177 (pCI1->crdate.day > pCI2->crdate.day) ? -1 : 178 (pCI1->crtime.hours < pCI2->crtime.hours) ? 1 : 179 (pCI1->crtime.hours > pCI2->crtime.hours) ? -1 : 180 (pCI1->crtime.minutes < pCI2->crtime.minutes) ? 1 : 181 (pCI1->crtime.minutes > pCI2->crtime.minutes) ? -1 : 182 (pCI1->crtime.seconds < pCI2->crtime.seconds) ? 1 : 183 (pCI1->crtime.seconds > pCI2->crtime.seconds) ? -1 : 0; 184 break; 167 185 } 168 186 169 187 if(!ret) 170 ret = (SHORT)stricmp(p ->szFileName,pp->szFileName);188 ret = (SHORT)stricmp(pCI1->szFileName,pCI2->szFileName); 171 189 172 190 if(ret && (SortFlags & SORT_REVERSE)) … … 175 193 return ret; 176 194 } 177 return (SHORT)stricmp(p ->szFileName,pp->szFileName);195 return (SHORT)stricmp(pCI1->szFileName,pCI2->szFileName); 178 196 } 179
Note:
See TracChangeset
for help on using the changeset viewer.
