4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright (c) 1994, by Sun Microsytems, Inc.
26 #pragma ident "%Z%%M% %I% %E% SMI"
34 #define DATUM_KIND(d) (DATUM_INFO(d)->kind)
40 static int has_prop(tnf_datum_t
, tag_props_t
);
43 * Datum operations: for more debuggability
49 _tnf_datum(struct taginfo
*info
, caddr_t val
)
51 return (_DATUM(info
, val
));
55 _tnf_datum_info(tnf_datum_t datum
)
57 return ((struct taginfo
*)_DATUM_HI(datum
));
61 _tnf_datum_val(tnf_datum_t datum
)
63 return ((caddr_t
)_DATUM_LO(datum
));
69 * Check for valid datum
73 _tnf_check_datum(tnf_datum_t datum
)
78 if (datum
== TNF_DATUM_NULL
)
79 _tnf_error(NULL
, TNF_ERR_BADTNF
);
81 val
= DATUM_VAL(datum
);
82 tnf
= DATUM_TNF(datum
);
84 if ((val
<= tnf
->file_start
) || (val
>= tnf
->file_end
))
85 _tnf_error(tnf
, TNF_ERR_BADDATUM
);
89 * Retrieve datum kind from cached information
93 tnf_get_kind(tnf_datum_t datum
)
96 /* The kind field is always completely initialized */
97 return (DATUM_KIND(datum
));
101 * Classification predicates: check the cached tag props
105 has_prop(tnf_datum_t datum
, tag_props_t prop
)
109 /* Note: No need to get base info because props inherited */
110 return (INFO_PROP(DATUM_INFO(datum
), prop
));
114 tnf_is_inline(tnf_datum_t datum
)
116 return (has_prop(datum
, TAG_PROP_INLINE
));
120 tnf_is_scalar(tnf_datum_t datum
)
122 return (has_prop(datum
, TAG_PROP_SCALAR
));
126 tnf_is_record(tnf_datum_t datum
) /* XXX was: tnf_is_tagged */
128 return (has_prop(datum
, TAG_PROP_TAGGED
));
132 tnf_is_array(tnf_datum_t datum
)
134 return (has_prop(datum
, TAG_PROP_ARRAY
));
138 tnf_is_string(tnf_datum_t datum
)
140 return (has_prop(datum
, TAG_PROP_STRING
));
144 tnf_is_struct(tnf_datum_t datum
)
146 return (has_prop(datum
, TAG_PROP_STRUCT
));
150 tnf_is_type(tnf_datum_t datum
)
152 return (has_prop(datum
, TAG_PROP_TYPE
));
156 * Get the type datum for any datum
160 tnf_get_type(tnf_datum_t datum
)
162 struct taginfo
*info
;
166 info
= DATUM_INFO(datum
);
167 return (DATUM(info
->meta
, (caddr_t
)info
->tag
));
171 * Get the type name for any datum
172 * XXX Beware: this is a pointer into the file
176 tnf_get_type_name(tnf_datum_t datum
)
179 return (DATUM_INFO(datum
)->name
); /* cached */
183 * Get the size of any datum
187 tnf_get_size(tnf_datum_t datum
)
189 struct taginfo
*info
;
194 info
= DATUM_INFO(datum
);
197 if (size
== (size_t)-1) /* self sized */
198 /* XXX tnf_get_slot_named(datum, TNF_N_SELF_SIZE) */
199 /* LINTED pointer cast may result in improper alignment */
200 return (_tnf_get_self_size(info
->tnf
, DATUM_RECORD(datum
)));
206 * Get raw pointer to any datum
210 tnf_get_raw(tnf_datum_t datum
)
213 return (DATUM_VAL(datum
));