VALUE_PAIR *vp, **list, *groups = NULL;
TALLOC_CTX *list_ctx, *value_ctx;
- vp_cursor_t list_cursor, groups_cursor;
+ fr_cursor_t list_cursor, groups_cursor;
int is_dn, i, count;
* once all group info has been gathered/resolved
* successfully.
*/
- fr_pair_cursor_init(&groups_cursor, &groups);
+ fr_cursor_init(&groups_cursor, &groups);
for (i = 0; (i < LDAP_MAX_CACHEABLE) && (i < count); i++) {
is_dn = fr_ldap_util_is_dn(values[i]->bv_val, values[i]->bv_len);
if (is_dn) {
MEM(vp = fr_pair_afrom_da(list_ctx, inst->cache_da));
fr_pair_value_bstrncpy(vp, values[i]->bv_val, values[i]->bv_len);
- fr_pair_cursor_append(&groups_cursor, vp);
+ fr_cursor_append(&groups_cursor, vp);
/*
* We were told to cache DNs but we got a name, we now need to resolve
* this to a DN. Store all the group names in an array so we can do one query.
if (!is_dn) {
MEM(vp = fr_pair_afrom_da(list_ctx, inst->cache_da));
fr_pair_value_bstrncpy(vp, values[i]->bv_val, values[i]->bv_len);
- fr_pair_cursor_append(&groups_cursor, vp);
+ fr_cursor_append(&groups_cursor, vp);
/*
* We were told to cache names but we got a DN, we now need to resolve
* this to a name.
MEM(vp = fr_pair_afrom_da(list_ctx, inst->cache_da));
fr_pair_value_bstrncpy(vp, name, talloc_array_length(name) - 1);
- fr_pair_cursor_append(&groups_cursor, vp);
+ fr_cursor_append(&groups_cursor, vp);
talloc_free(name);
}
}
if (rcode != RLM_MODULE_OK) return rcode;
- fr_pair_cursor_init(&list_cursor, list);
+ fr_cursor_init(&list_cursor, list);
RDEBUG("Adding cacheable user object memberships");
RINDENT();
if (RDEBUG_ENABLED) {
- for (vp = fr_pair_cursor_first(&groups_cursor);
+ for (vp = fr_cursor_first(&groups_cursor);
vp;
- vp = fr_pair_cursor_next(&groups_cursor)) {
+ vp = fr_cursor_next(&groups_cursor)) {
RDEBUG("&control:%s += \"%pV\"", inst->cache_da->name, &vp->data);
}
}
- fr_pair_cursor_merge(&list_cursor, groups);
+ fr_cursor_head(&groups_cursor);
+ fr_cursor_merge(&list_cursor, &groups_Cursor);
for (dn_p = group_dn; *dn_p; dn_p++) {
MEM(vp = fr_pair_afrom_da(list_ctx, inst->cache_da));
fr_pair_value_strcpy(vp, *dn_p);
- fr_pair_cursor_append(&list_cursor, vp);
+ fr_cursor_append(&list_cursor, vp);
RDEBUG("&control:%s += \"%pV\"", inst->cache_da->name, &vp->data);
ldap_memfree(*dn_p);
* We return RLM_MODULE_INVALID here as an indication
* the caller should try a dynamic group lookup instead.
*/
- vp = fr_cursor_talloc_iter_init(&cursor, &request->control,
- fr_pair_iter_next_by_da, inst->cache_da, VALUE_PAIR);
+ vp = fr_cursor_iter_by_da_init(&cursor, &request->control, inst->cache_da);
if (!vp) return RLM_MODULE_INVALID;
for (vp = fr_cursor_current(&cursor);
*/
static int _lua_pair_get(lua_State *L)
{
- vp_cursor_t cursor;
+ fr_cursor_t cursor;
fr_dict_attr_t const *da;
VALUE_PAIR *vp = NULL;
int index;
/*
* @fixme Packet list should be light user data too at some point
*/
- fr_pair_cursor_init(&cursor, &request->packet->vps);
+ fr_cursor_iter_by_da_init(&cursor, &request->packet->vps, da);
for (index = (int) lua_tointeger(L, -1); index >= 0; index--) {
- vp = fr_pair_cursor_next_by_da(&cursor, da, TAG_ANY);
- if (!vp) {
- return 0;
- }
+ vp = fr_cursor_next(&cursor);
+ if (!vp) return 0;
}
- if (rlm_lua_marshall(L, vp) < 0) {
- return -1;
- }
+ if (rlm_lua_marshall(L, vp) < 0) return -1;
return 1;
}
*/
static int _lua_pair_set(lua_State *L)
{
- vp_cursor_t cursor;
+ fr_cursor_t cursor;
fr_dict_attr_t const *da;
VALUE_PAIR *vp = NULL, *new;
int index;
/*
* @fixme Packet list should be light user data too at some point
*/
- fr_pair_cursor_init(&cursor, &request->packet->vps);
+ fr_cursor_iter_by_da_init(&cursor, &request->packet->vps, da);
for (index = (int) lua_tointeger(L, -2); index >= 0; index--) {
- vp = fr_pair_cursor_next_by_da(&cursor, da, TAG_ANY);
- if (vp) {
- break;
- }
+ vp = fr_cursor_next(&cursor);
+ if (vp) break;
}
/*
* attribute the cursor is currently positioned at.
*/
if (delete) {
- fr_pair_cursor_remove(&cursor);
+ fr_cursor_remove(&cursor);
return 0;
}
* else we add a new VP to the list.
*/
if (vp) {
- fr_pair_cursor_replace(&cursor, new);
+ fr_cursor_replace(&cursor, new);
} else {
- fr_pair_cursor_append(&cursor, new);
+ fr_cursor_append(&cursor, new);
}
return 0;
static int _lua_pair_iterator(lua_State *L)
{
- vp_cursor_t *cursor;
- fr_dict_attr_t const *da;
+ fr_cursor_t *cursor;
VALUE_PAIR *vp;
/*
cursor = lua_touserdata(L, lua_upvalueindex(1));
rad_assert(cursor);
- rad_assert(lua_isuserdata(L, lua_upvalueindex(2)));
-
- da = lua_touserdata(L, lua_upvalueindex(2));
- rad_assert(da);
-
/* Packet list should be light user data too at some point... */
- vp = fr_pair_cursor_next_by_da(cursor, da, TAG_ANY);
+ vp = fr_cursor_next(cursor);
if (!vp) {
lua_pushnil(L);
return 1;
static int _lua_pair_iterator_init(lua_State *L)
{
- vp_cursor_t *cursor;
+ fr_cursor_t *cursor;
fr_dict_attr_t const *da;
- fr_dict_attr_t *up;
REQUEST *request = rlm_lua_request;
/*
da = lua_touserdata(L, lua_upvalueindex(2));
rad_assert(da);
- memcpy(&up, &da, sizeof(up));
-
- cursor = (vp_cursor_t*) lua_newuserdata(L, sizeof(vp_cursor_t));
+ cursor = (fr_cursor_t*) lua_newuserdata(L, sizeof(fr_cursor_t));
if (!cursor) {
REDEBUG("Failed allocating user data to hold cursor");
return -1;
}
- fr_pair_cursor_init(cursor, &request->packet->vps); /* @FIXME: Shouldn't use list head */
+ fr_cursor_iter_by_da_init(cursor, &request->packet->vps, da); /* @FIXME: Shouldn't use list head */
- lua_pushlightuserdata(L, up);
- lua_pushcclosure(L, _lua_pair_iterator, 2);
+ lua_pushcclosure(L, _lua_pair_iterator, 1);
return 1;
}
static int _lua_list_iterator(lua_State *L)
{
- vp_cursor_t *cursor;
+ fr_cursor_t *cursor;
VALUE_PAIR *vp;
rad_assert(lua_isuserdata(L, lua_upvalueindex(1)));
rad_assert(cursor);
/* Packet list should be light user data too at some point... */
- vp = fr_pair_cursor_current(cursor);
+ vp = fr_cursor_current(cursor);
if(!vp) {
lua_pushnil(L);
return 1;
return -1;
}
- fr_pair_cursor_next(cursor);
+ fr_cursor_next(cursor);
return 2;
}
*/
static int _lua_list_iterator_init(lua_State *L)
{
- vp_cursor_t *cursor;
+ fr_cursor_t *cursor;
REQUEST *request = rlm_lua_request;
- cursor = (vp_cursor_t*) lua_newuserdata(L, sizeof(vp_cursor_t));
+ cursor = (fr_cursor_t*) lua_newuserdata(L, sizeof(fr_cursor_t));
if (!cursor) {
REDEBUG("Failed allocating user data to hold cursor");
return -1;
}
- fr_pair_cursor_init(cursor, &request->packet->vps); /* @FIXME: Shouldn't use list head */
+ fr_cursor_init(cursor, &request->packet->vps); /* @FIXME: Shouldn't use list head */
lua_pushlightuserdata(L, cursor);
lua_pushcclosure(L, _lua_list_iterator, 1);
int do_lua(rlm_lua_t const *inst, REQUEST *request, char const *funcname)
{
- vp_cursor_t cursor;
+ fr_cursor_t cursor;
lua_State *L;
rlm_lua_request = request;
RDEBUG2("Calling %s() in interpreter %p", funcname, L);
fr_pair_list_sort(&request->packet->vps, fr_pair_cmp_by_da_tag);
- fr_pair_cursor_init(&cursor, &request->packet->vps);
+ fr_cursor_init(&cursor, &request->packet->vps);
/*
* Setup the environment