Mercurial > hg > freeDiameter
comparison libfreeDiameter/dictionary.c @ 602:0b5d21c87855
Added new AVP search criteria in the dictionary: AVP_BY_NAME_ALL_VENDORS
author | Sebastien Decugis <sdecugis@nict.go.jp> |
---|---|
date | Thu, 25 Nov 2010 16:27:54 +0900 |
parents | 66f58cecf3cd |
children |
comparison
equal
deleted
inserted
replaced
601:73d7588870b9 | 602:0b5d21c87855 |
---|---|
589 #define SEARCH_string( str, sentinel, datafield, isindex ) { \ | 589 #define SEARCH_string( str, sentinel, datafield, isindex ) { \ |
590 char * __str = (char *) str; \ | 590 char * __str = (char *) str; \ |
591 int __cmp; \ | 591 int __cmp; \ |
592 struct fd_list * __li; \ | 592 struct fd_list * __li; \ |
593 ret = 0; \ | 593 ret = 0; \ |
594 for (__li = (sentinel); __li->next != (sentinel); __li = __li->next) { \ | 594 for (__li = (sentinel)->next; __li != (sentinel); __li = __li->next) { \ |
595 __cmp = strcmp(__str, _O(__li->next->o)->data. datafield ); \ | 595 __cmp = strcmp(__str, _O(__li->o)->data. datafield ); \ |
596 if (__cmp == 0) { \ | 596 if (__cmp == 0) { \ |
597 if (result) \ | 597 if (result) \ |
598 *result = _O(__li->next->o); \ | 598 *result = _O(__li->o); \ |
599 goto end; \ | 599 goto end; \ |
600 } \ | 600 } \ |
601 if ((isindex) && (__cmp < 0)) \ | 601 if ((isindex) && (__cmp < 0)) \ |
602 break; \ | 602 break; \ |
603 } \ | 603 } \ |
971 SEARCH_scalar( _what->avp_code, &vendor->list[1], avp.avp_code, 1, (struct dict_object *)NULL ); | 971 SEARCH_scalar( _what->avp_code, &vendor->list[1], avp.avp_code, 1, (struct dict_object *)NULL ); |
972 } | 972 } |
973 } | 973 } |
974 break; | 974 break; |
975 | 975 |
976 case AVP_BY_NAME_ALL_VENDORS: | |
977 { | |
978 struct fd_list * li; | |
979 | |
980 /* First, search for vendor 0 */ | |
981 SEARCH_string( what, &dict->dict_vendors.list[2], avp.avp_name, 1); | |
982 | |
983 /* If not found, loop for all vendors, until found */ | |
984 for (li = dict->dict_vendors.list[0].next; li != &dict->dict_vendors.list[0]; li = li->next) { | |
985 SEARCH_string( what, &_O(li->o)->list[2], avp.avp_name, 1); | |
986 } | |
987 } | |
988 break; | |
989 | |
976 default: | 990 default: |
977 /* Invalid criteria */ | 991 /* Invalid criteria */ |
978 CHECK_PARAMS( criteria = 0 ); | 992 CHECK_PARAMS( criteria = 0 ); |
979 } | 993 } |
980 end: | 994 end: |