/* * Gets the content from hashes */ static void get_hv_content(TALLOC_CTX *ctx, REQUEST *request, HV *my_hv, VALUE_PAIR **vps, const char *hash_name, const char *list_name) { SV *res_sv, **av_sv; AV *av; char *key; I32 key_len, len, i, j; *vps = NULL; for (i = hv_iterinit(my_hv); i > 0; i--) { res_sv = hv_iternextsv(my_hv,&key,&key_len); if (SvROK(res_sv) && (SvTYPE(SvRV(res_sv)) == SVt_PVAV)) { av = (AV*)SvRV(res_sv); len = av_len(av); for (j = 0; j <= len; j++) { av_sv = av_fetch(av, j, 0); pairadd_sv(ctx, request, vps, key, *av_sv, T_OP_ADD, hash_name, list_name); } } else { pairadd_sv(ctx, request, vps, key, res_sv, T_OP_EQ, hash_name, list_name); } } if (*vps) VERIFY_LIST(*vps, "perl"); }
/** Find the pair with the matching attribute * * @todo should take DAs and do a pointer comparison. */ VALUE_PAIR *pairfind(VALUE_PAIR *vp, unsigned int attr, unsigned int vendor, int8_t tag) { vp_cursor_t cursor; /* List head may be NULL if it contains no VPs */ if (!vp) return NULL; VERIFY_LIST(vp); (void) fr_cursor_init(&cursor, &vp); return fr_cursor_next_by_num(&cursor, attr, vendor, tag); }