1 /* $Id: attrfind.c,v 1.4 2007-05-08 12:50:06 adam Exp $
2 Copyright (C) 2005-2007
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, const Odr_oid **attribute_set_oid,
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 && attribute_set_oid)
63 *attribute_set_oid = element->attributeSet;
64 return *element->value.numeric;
66 case Z_AttributeValue_complex:
67 if (src->minor >= element->value.complex->num_list)
69 if (element->attributeSet && attribute_set_oid)
70 *attribute_set_oid = element->attributeSet;
71 if (element->value.complex->list[src->minor]->which ==
72 Z_StringOrNumeric_numeric)
76 *element->value.complex->list[src->minor-1]->u.numeric;
78 else if (element->value.complex->list[src->minor]->which ==
79 Z_StringOrNumeric_string)
85 element->value.complex->list[src->minor-1]->u.string;
99 int attr_find(AttrType *src, const Odr_oid **attribute_set_id)
101 return attr_find_ex(src, attribute_set_id, 0);
108 * indent-tabs-mode: nil
110 * vim: shiftwidth=4 tabstop=8 expandtab