1 /* $Id: attrfind.c,v 1.1 2006-05-19 13:49:38 adam Exp $
2 Copyright (C) 2005-2006
5 This file is part of the Zebra server.
7 Zebra is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
12 Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 You should have received a copy of the GNU General Public License
18 along with Zebra; see the file LICENSE.zebra. If not, write to the
19 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
27 void attr_init_APT(AttrType *src, Z_AttributesPlusTerm *zapt, int type)
29 src->attributeList = zapt->attributes->attributes;
30 src->num_attributes = zapt->attributes->num_attributes;
36 void attr_init_AttrList(AttrType *src, Z_AttributeList *list, int type)
38 src->attributeList = list->attributes;
39 src->num_attributes = list->num_attributes;
45 int attr_find_ex(AttrType *src, oid_value *attributeSetP,
46 const char **string_value)
50 num_attributes = src->num_attributes;
51 while (src->major < num_attributes)
53 Z_AttributeElement *element;
55 element = src->attributeList[src->major];
56 if (src->type == *element->attributeType)
58 switch (element->which)
60 case Z_AttributeValue_numeric:
62 if (element->attributeSet && attributeSetP)
66 attrset = oid_getentbyoid(element->attributeSet);
67 *attributeSetP = attrset->value;
69 return *element->value.numeric;
71 case Z_AttributeValue_complex:
72 if (src->minor >= element->value.complex->num_list)
74 if (element->attributeSet && attributeSetP)
78 attrset = oid_getentbyoid(element->attributeSet);
79 *attributeSetP = attrset->value;
81 if (element->value.complex->list[src->minor]->which ==
82 Z_StringOrNumeric_numeric)
86 *element->value.complex->list[src->minor-1]->u.numeric;
88 else if (element->value.complex->list[src->minor]->which ==
89 Z_StringOrNumeric_string)
95 element->value.complex->list[src->minor-1]->u.string;
109 int attr_find(AttrType *src, oid_value *attributeSetP)
111 return attr_find_ex(src, attributeSetP, 0);
118 * indent-tabs-mode: nil
120 * vim: shiftwidth=4 tabstop=8 expandtab