#include <freeradius-devel/radiusd.h>
-char const *CF_IDENT_ANY = "<any>";
-
static inline int cf_ident2_cmp(void const *a, void const *b);
static int _cf_ident1_cmp(void const *a, void const *b);
static int _cf_ident2_cmp(void const *a, void const *b);
return NULL;
}
+#define IS_WILDCARD(_ident) ((_ident) && ((_ident == CF_IDENT_ANY) || (strcmp(_ident, CF_IDENT_ANY) == 0)))
+
/** Return the next child that's of the specified type with the specified identifiers
*
* @param[in] parent The section we're searching in.
memset(&cs_find, 0, sizeof(cs_find));
cs_find.item.type = CONF_ITEM_SECTION;
cs_find.name1 = ident1;
- if (ident2 != CF_IDENT_ANY) cs_find.name2 = ident2;
+ if (!IS_WILDCARD(ident2)) cs_find.name2 = ident2;
find = (CONF_ITEM *)&cs_find;
break;
case CONF_ITEM_PAIR:
- rad_assert((ident2 == NULL) || (ident2 == CF_IDENT_ANY));
+ rad_assert((ident2 == NULL) || IS_WILDCARD(ident2));
memset(&cp_find, 0, sizeof(cp_find));
cp_find.item.type = CONF_ITEM_PAIR;
memset(&cd_find, 0, sizeof(cd_find));
cd_find.item.type = CONF_ITEM_DATA;
cd_find.type = ident1;
- if (ident2 != CF_IDENT_ANY) cd_find.name = ident2;
+ if (!IS_WILDCARD(ident2)) cd_find.name = ident2;
find = (CONF_ITEM *)&cd_find;
break;
/*
* No ident1, iterate over the child list
*/
- if (ident1 == CF_IDENT_ANY) {
+ if (IS_WILDCARD(ident1)) {
CONF_ITEM *ci;
for (ci = parent->child;
/*
* No ident2, use the ident1 tree.
*/
- if (ident2 == CF_IDENT_ANY) return rbtree_finddata(parent->ident1, find);
+ if (IS_WILDCARD(ident2)) return rbtree_finddata(parent->ident1, find);
/*
* Both ident1 and ident2 use the ident2 tree.
memset(&cs_find, 0, sizeof(cs_find));
cs_find.item.type = CONF_ITEM_SECTION;
cs_find.name1 = ident1;
- if (ident2 != CF_IDENT_ANY) cs_find.name2 = ident2;
+ if (!IS_WILDCARD(ident2)) cs_find.name2 = ident2;
find = (CONF_ITEM *)&cs_find;
break;
case CONF_ITEM_PAIR:
- rad_assert((ident2 == NULL) || (ident2 == CF_IDENT_ANY));
+ rad_assert((ident2 == NULL) || IS_WILDCARD(ident2));
memset(&cp_find, 0, sizeof(cp_find));
cp_find.item.type = CONF_ITEM_PAIR;
memset(&cd_find, 0, sizeof(cd_find));
cd_find.item.type = CONF_ITEM_DATA;
cd_find.type = ident1;
- if (ident2 != CF_IDENT_ANY) cd_find.name = ident2;
+ if (!IS_WILDCARD(ident2)) cd_find.name = ident2;
find = (CONF_ITEM *)&cd_find;
break;
if (!rad_cond_assert(0)) return NULL;
}
- if (ident1 == CF_IDENT_ANY) {
+ if (IS_WILDCARD(ident1)) {
for (ci = prev->next;
ci && (cf_ident2_cmp(ci, find) != 0);
ci = ci->next);
return ci;
}
- if (ident2 == CF_IDENT_ANY) {
+ if (IS_WILDCARD(ident2)) {
for (ci = prev->next;
ci && (_cf_ident1_cmp(ci, find) != 0);
ci = ci->next);