xref: /titanic_50/usr/src/lib/libtnf/libtnf.h (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  *	Copyright (c) 1994, by Sun Microsytems, Inc.
24*7c478bd9Sstevel@tonic-gate  */
25*7c478bd9Sstevel@tonic-gate 
26*7c478bd9Sstevel@tonic-gate #ifndef _LIBTNF_H
27*7c478bd9Sstevel@tonic-gate #define	_LIBTNF_H
28*7c478bd9Sstevel@tonic-gate 
29*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
30*7c478bd9Sstevel@tonic-gate 
31*7c478bd9Sstevel@tonic-gate #include <stdio.h>
32*7c478bd9Sstevel@tonic-gate #include <stdlib.h>
33*7c478bd9Sstevel@tonic-gate #include <stdarg.h>
34*7c478bd9Sstevel@tonic-gate #include <string.h>
35*7c478bd9Sstevel@tonic-gate #include <unistd.h>
36*7c478bd9Sstevel@tonic-gate 
37*7c478bd9Sstevel@tonic-gate #include "tnf/tnf.h"
38*7c478bd9Sstevel@tonic-gate #include "machlibtnf.h"
39*7c478bd9Sstevel@tonic-gate 
40*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus
41*7c478bd9Sstevel@tonic-gate extern "C" {
42*7c478bd9Sstevel@tonic-gate #endif
43*7c478bd9Sstevel@tonic-gate 
44*7c478bd9Sstevel@tonic-gate /*
45*7c478bd9Sstevel@tonic-gate  * Info flags
46*7c478bd9Sstevel@tonic-gate  */
47*7c478bd9Sstevel@tonic-gate 
48*7c478bd9Sstevel@tonic-gate typedef unsigned long	tag_props_t;
49*7c478bd9Sstevel@tonic-gate 
50*7c478bd9Sstevel@tonic-gate #define	TAG_PROP_INLINE		(1<<0)
51*7c478bd9Sstevel@tonic-gate #define	TAG_PROP_TAGGED		(1<<1)
52*7c478bd9Sstevel@tonic-gate #define	TAG_PROP_SCALAR		(1<<2)
53*7c478bd9Sstevel@tonic-gate #define	TAG_PROP_DERIVED	(1<<3)
54*7c478bd9Sstevel@tonic-gate #define	TAG_PROP_ARRAY		(1<<4)
55*7c478bd9Sstevel@tonic-gate #define	TAG_PROP_STRING		(1<<5)
56*7c478bd9Sstevel@tonic-gate #define	TAG_PROP_STRUCT		(1<<6)
57*7c478bd9Sstevel@tonic-gate #define	TAG_PROP_TYPE		(1<<7)
58*7c478bd9Sstevel@tonic-gate 
59*7c478bd9Sstevel@tonic-gate /*
60*7c478bd9Sstevel@tonic-gate  * Type tag information
61*7c478bd9Sstevel@tonic-gate  */
62*7c478bd9Sstevel@tonic-gate 
63*7c478bd9Sstevel@tonic-gate struct taginfo {
64*7c478bd9Sstevel@tonic-gate 	struct taginfo	*link;		/* hash link */
65*7c478bd9Sstevel@tonic-gate #define	INFO_MEMBER_0	link
66*7c478bd9Sstevel@tonic-gate 	TNF		*tnf;		/* TNF handle */
67*7c478bd9Sstevel@tonic-gate 	tnf_ref32_t	*tag;		/* tag record in file */
68*7c478bd9Sstevel@tonic-gate 	char		*name;		/* chars in file */
69*7c478bd9Sstevel@tonic-gate 	tnf_kind_t	kind;		/* data classification */
70*7c478bd9Sstevel@tonic-gate 	tag_props_t	props;		/* tag property flags */
71*7c478bd9Sstevel@tonic-gate 	struct taginfo	*meta;		/* meta tag info */
72*7c478bd9Sstevel@tonic-gate 	struct taginfo	*base;		/* last derived base or elttype */
73*7c478bd9Sstevel@tonic-gate 	size_t		size;		/* storage size or -1 */
74*7c478bd9Sstevel@tonic-gate 	size_t		align;		/* slot alignment */
75*7c478bd9Sstevel@tonic-gate 	size_t		hdrsize;	/* array header size */
76*7c478bd9Sstevel@tonic-gate 	struct slotinfo {		/* aggregate slot information */
77*7c478bd9Sstevel@tonic-gate 		unsigned	slot_count;
78*7c478bd9Sstevel@tonic-gate 		/* Embedded array */
79*7c478bd9Sstevel@tonic-gate 		struct slot {
80*7c478bd9Sstevel@tonic-gate 			struct taginfo	*slot_type;
81*7c478bd9Sstevel@tonic-gate 			char		*slot_name;
82*7c478bd9Sstevel@tonic-gate 			unsigned	slot_offset;
83*7c478bd9Sstevel@tonic-gate 		} slots[1];
84*7c478bd9Sstevel@tonic-gate 	} *slotinfo;
85*7c478bd9Sstevel@tonic-gate };
86*7c478bd9Sstevel@tonic-gate 
87*7c478bd9Sstevel@tonic-gate #define	INFO_PROP(ip, p)	((ip)->props & (p))
88*7c478bd9Sstevel@tonic-gate 
89*7c478bd9Sstevel@tonic-gate #define	INFO_INLINE(ip)		INFO_PROP(ip, TAG_PROP_INLINE)
90*7c478bd9Sstevel@tonic-gate #define	INFO_TAGGED(ip)		INFO_PROP(ip, TAG_PROP_TAGGED)
91*7c478bd9Sstevel@tonic-gate #define	INFO_SCALAR(ip)		INFO_PROP(ip, TAG_PROP_SCALAR)
92*7c478bd9Sstevel@tonic-gate #define	INFO_DERIVED(ip)	INFO_PROP(ip, TAG_PROP_DERIVED)
93*7c478bd9Sstevel@tonic-gate #define	INFO_ARRAY(ip)		INFO_PROP(ip, TAG_PROP_ARRAY)
94*7c478bd9Sstevel@tonic-gate #define	INFO_STRING(ip)		INFO_PROP(ip, TAG_PROP_STRING)
95*7c478bd9Sstevel@tonic-gate #define	INFO_STRUCT(ip)		INFO_PROP(ip, TAG_PROP_STRUCT)
96*7c478bd9Sstevel@tonic-gate #define	INFO_TYPE(ip)		INFO_PROP(ip, TAG_PROP_TYPE)
97*7c478bd9Sstevel@tonic-gate 
98*7c478bd9Sstevel@tonic-gate #define	INFO_REF_SIZE(ip)	(INFO_TAGGED(ip)? 4: (ip)->size)
99*7c478bd9Sstevel@tonic-gate #define	INFO_ELEMENT_SIZE(ip)	INFO_REF_SIZE(ip)
100*7c478bd9Sstevel@tonic-gate 
101*7c478bd9Sstevel@tonic-gate /* Alignment is stored for all but records and derivations thereof */
102*7c478bd9Sstevel@tonic-gate #define	INFO_ALIGN(ip)		(INFO_TAGGED(ip)? 4: (ip)->align)
103*7c478bd9Sstevel@tonic-gate 
104*7c478bd9Sstevel@tonic-gate #define	ALIGN(n, a)		\
105*7c478bd9Sstevel@tonic-gate 	(((a) == 0) ? (n) : (((n) + (a) - 1) & ~((a) - 1)))
106*7c478bd9Sstevel@tonic-gate 
107*7c478bd9Sstevel@tonic-gate /*
108*7c478bd9Sstevel@tonic-gate  * Tag lookup
109*7c478bd9Sstevel@tonic-gate  */
110*7c478bd9Sstevel@tonic-gate 
111*7c478bd9Sstevel@tonic-gate /* Number of directory entries */
112*7c478bd9Sstevel@tonic-gate #define	TAGDIRCNT(x) 	((x) / sizeof (tnf_ref32_t))
113*7c478bd9Sstevel@tonic-gate 
114*7c478bd9Sstevel@tonic-gate /* Number of hash table buckets */
115*7c478bd9Sstevel@tonic-gate #define	TAGTABCNT	1024
116*7c478bd9Sstevel@tonic-gate #define	TAGTABMASK	(TAGTABCNT-1)
117*7c478bd9Sstevel@tonic-gate 
118*7c478bd9Sstevel@tonic-gate /* A tag is at least 32 bytes; with strings & props, assume 128 bytes */
119*7c478bd9Sstevel@tonic-gate #define	TAGTABSHIFT	7
120*7c478bd9Sstevel@tonic-gate 
121*7c478bd9Sstevel@tonic-gate /* Hash tag by bits 17:7 of offset within data area */
122*7c478bd9Sstevel@tonic-gate #define	TAGOFF(tnf, p)	((unsigned)((caddr_t)(p) - (tnf)->data_start))
123*7c478bd9Sstevel@tonic-gate #define	TAGHASH(tnf, p)	((TAGOFF(tnf, p) >> TAGTABSHIFT) & TAGTABMASK)
124*7c478bd9Sstevel@tonic-gate 
125*7c478bd9Sstevel@tonic-gate /*
126*7c478bd9Sstevel@tonic-gate  * TNF handle
127*7c478bd9Sstevel@tonic-gate  */
128*7c478bd9Sstevel@tonic-gate 
129*7c478bd9Sstevel@tonic-gate struct TNF {
130*7c478bd9Sstevel@tonic-gate 	/*
131*7c478bd9Sstevel@tonic-gate 	 * Client-supplied bounds
132*7c478bd9Sstevel@tonic-gate 	 */
133*7c478bd9Sstevel@tonic-gate 	caddr_t		file_start;
134*7c478bd9Sstevel@tonic-gate 	size_t		file_size;
135*7c478bd9Sstevel@tonic-gate 	caddr_t		file_end;	/* file_start + file_size */
136*7c478bd9Sstevel@tonic-gate 
137*7c478bd9Sstevel@tonic-gate 	/*
138*7c478bd9Sstevel@tonic-gate 	 * File information
139*7c478bd9Sstevel@tonic-gate 	 */
140*7c478bd9Sstevel@tonic-gate 	unsigned	file_magic;	/* magic number of file */
141*7c478bd9Sstevel@tonic-gate 	int		file_native;	/* endian flag */
142*7c478bd9Sstevel@tonic-gate 
143*7c478bd9Sstevel@tonic-gate 	/* file header */
144*7c478bd9Sstevel@tonic-gate 	tnf_ref32_t	*file_header;	/* first record in file */
145*7c478bd9Sstevel@tonic-gate 	size_t		block_size;	/* size of a block */
146*7c478bd9Sstevel@tonic-gate 	size_t		directory_size;	/* size of directory area */
147*7c478bd9Sstevel@tonic-gate 
148*7c478bd9Sstevel@tonic-gate 	unsigned	block_count;	/* number of data blocks */
149*7c478bd9Sstevel@tonic-gate 	caddr_t		data_start;	/* file_start + 64KB */
150*7c478bd9Sstevel@tonic-gate 
151*7c478bd9Sstevel@tonic-gate 	unsigned	generation_shift;
152*7c478bd9Sstevel@tonic-gate 	unsigned	address_mask;
153*7c478bd9Sstevel@tonic-gate 
154*7c478bd9Sstevel@tonic-gate 	/* block headers */
155*7c478bd9Sstevel@tonic-gate 	unsigned	block_shift;	/* index -> bhdr */
156*7c478bd9Sstevel@tonic-gate 	unsigned	block_mask;	/* ptr -> bhdr */
157*7c478bd9Sstevel@tonic-gate 	unsigned	block_generation_offset;
158*7c478bd9Sstevel@tonic-gate 	unsigned	block_bytes_valid_offset;
159*7c478bd9Sstevel@tonic-gate 
160*7c478bd9Sstevel@tonic-gate 	/* root tag */
161*7c478bd9Sstevel@tonic-gate 	tnf_ref32_t	*root_tag;
162*7c478bd9Sstevel@tonic-gate 
163*7c478bd9Sstevel@tonic-gate 	/* important taginfo */
164*7c478bd9Sstevel@tonic-gate 	struct taginfo	*file_header_info;
165*7c478bd9Sstevel@tonic-gate 	struct taginfo	*block_header_info;
166*7c478bd9Sstevel@tonic-gate 
167*7c478bd9Sstevel@tonic-gate 	/* tag lookup tables */
168*7c478bd9Sstevel@tonic-gate 	struct taginfo	**tag_table;	/* by address */
169*7c478bd9Sstevel@tonic-gate 	struct taginfo	**tag_directory; /* by index */
170*7c478bd9Sstevel@tonic-gate 
171*7c478bd9Sstevel@tonic-gate };
172*7c478bd9Sstevel@tonic-gate 
173*7c478bd9Sstevel@tonic-gate /*
174*7c478bd9Sstevel@tonic-gate  * File operations for reading integers
175*7c478bd9Sstevel@tonic-gate  */
176*7c478bd9Sstevel@tonic-gate 
177*7c478bd9Sstevel@tonic-gate #define	_GET_UINT32(tnf, ptr)				\
178*7c478bd9Sstevel@tonic-gate 	((tnf)->file_native ?				\
179*7c478bd9Sstevel@tonic-gate 		*(tnf_uint32_t *)(ptr) :		\
180*7c478bd9Sstevel@tonic-gate 		_tnf_swap32(*(tnf_uint32_t *)(ptr)))
181*7c478bd9Sstevel@tonic-gate 
182*7c478bd9Sstevel@tonic-gate #define	_GET_INT32(tnf, ptr)				\
183*7c478bd9Sstevel@tonic-gate 	((tnf_int32_t)_GET_UINT32(tnf, ptr))
184*7c478bd9Sstevel@tonic-gate 
185*7c478bd9Sstevel@tonic-gate #define	_GET_UINT16(tnf, ptr)				\
186*7c478bd9Sstevel@tonic-gate 	((tnf)->file_native ?				\
187*7c478bd9Sstevel@tonic-gate 		*(tnf_uint16_t *)(ptr) :		\
188*7c478bd9Sstevel@tonic-gate 		_tnf_swap16(*(tnf_uint16_t *)(ptr)))
189*7c478bd9Sstevel@tonic-gate 
190*7c478bd9Sstevel@tonic-gate #define	_GET_INT16(tnf, ptr)				\
191*7c478bd9Sstevel@tonic-gate 	((tnf_int16_t)_GET_UINT16(tnf, ptr))
192*7c478bd9Sstevel@tonic-gate 
193*7c478bd9Sstevel@tonic-gate /*
194*7c478bd9Sstevel@tonic-gate  * TNF reference-chasing operations
195*7c478bd9Sstevel@tonic-gate  */
196*7c478bd9Sstevel@tonic-gate 
197*7c478bd9Sstevel@tonic-gate tnf_ref32_t * _tnf_get_ref32(TNF *, tnf_ref32_t *);
198*7c478bd9Sstevel@tonic-gate tnf_ref32_t * _tnf_get_ref16(TNF *, tnf_ref32_t *);
199*7c478bd9Sstevel@tonic-gate 
200*7c478bd9Sstevel@tonic-gate #define	_GET_REF32(tnf, ptr)	_tnf_get_ref32(tnf, ptr)
201*7c478bd9Sstevel@tonic-gate #define	_GET_REF16(tnf, ptr)	_tnf_get_ref16(tnf, ptr)
202*7c478bd9Sstevel@tonic-gate 
203*7c478bd9Sstevel@tonic-gate /*
204*7c478bd9Sstevel@tonic-gate  * Block header record operations
205*7c478bd9Sstevel@tonic-gate  * Only applicable in data area
206*7c478bd9Sstevel@tonic-gate  */
207*7c478bd9Sstevel@tonic-gate 
208*7c478bd9Sstevel@tonic-gate #define	_GET_BLOCK(tnf, ptr)					\
209*7c478bd9Sstevel@tonic-gate 	((tnf_ref32_t *)((unsigned)(ptr) & (tnf)->block_mask))
210*7c478bd9Sstevel@tonic-gate 
211*7c478bd9Sstevel@tonic-gate #define	_GET_BLOCK_INDEX(tnf, bhdr)				\
212*7c478bd9Sstevel@tonic-gate 	(((caddr_t)(bhdr) - (tnf)->data_start) >> (tnf)->block_shift)
213*7c478bd9Sstevel@tonic-gate 
214*7c478bd9Sstevel@tonic-gate #define	_GET_INDEX_BLOCK(tnf, index)				\
215*7c478bd9Sstevel@tonic-gate 	((tnf_ref32_t *)((tnf)->data_start + ((index) << (tnf)->block_shift)))
216*7c478bd9Sstevel@tonic-gate 
217*7c478bd9Sstevel@tonic-gate #define	_GET_BLOCK_GENERATION(tnf, bhdr)			\
218*7c478bd9Sstevel@tonic-gate 	_GET_UINT32(tnf, (caddr_t)bhdr + tnf->block_generation_offset)
219*7c478bd9Sstevel@tonic-gate 
220*7c478bd9Sstevel@tonic-gate #define	_GET_BLOCK_BYTES_VALID(tnf, bhdr)			\
221*7c478bd9Sstevel@tonic-gate 	(!(bhdr) ? 0 : _GET_UINT16(tnf, (caddr_t)bhdr +		\
222*7c478bd9Sstevel@tonic-gate 				tnf->block_bytes_valid_offset))
223*7c478bd9Sstevel@tonic-gate 
224*7c478bd9Sstevel@tonic-gate /*
225*7c478bd9Sstevel@tonic-gate  * Datum operations
226*7c478bd9Sstevel@tonic-gate  */
227*7c478bd9Sstevel@tonic-gate 
228*7c478bd9Sstevel@tonic-gate #ifndef	_DATUM_MACROS
229*7c478bd9Sstevel@tonic-gate 
230*7c478bd9Sstevel@tonic-gate tnf_datum_t _tnf_datum(struct taginfo *, caddr_t);
231*7c478bd9Sstevel@tonic-gate struct taginfo * _tnf_datum_info(tnf_datum_t);
232*7c478bd9Sstevel@tonic-gate caddr_t	_tnf_datum_val(tnf_datum_t);
233*7c478bd9Sstevel@tonic-gate 
234*7c478bd9Sstevel@tonic-gate #define	DATUM(x, y)	_tnf_datum(x, y)
235*7c478bd9Sstevel@tonic-gate #define	DATUM_INFO(x)	_tnf_datum_info(x)
236*7c478bd9Sstevel@tonic-gate #define	DATUM_VAL(x)	_tnf_datum_val(x)
237*7c478bd9Sstevel@tonic-gate 
238*7c478bd9Sstevel@tonic-gate #else  /* _DATUM_MACROS */
239*7c478bd9Sstevel@tonic-gate 
240*7c478bd9Sstevel@tonic-gate /* Some degree of type safety: */
241*7c478bd9Sstevel@tonic-gate #define	DATUM(x, y)	_DATUM(&(x)->INFO_MEMBER_0, y)
242*7c478bd9Sstevel@tonic-gate #define	DATUM_INFO(d)	((struct taginfo *)_DATUM_HI(d))
243*7c478bd9Sstevel@tonic-gate #define	DATUM_VAL(d)	((caddr_t)_DATUM_LO(d))
244*7c478bd9Sstevel@tonic-gate 
245*7c478bd9Sstevel@tonic-gate #endif /* _DATUM_MACROS */
246*7c478bd9Sstevel@tonic-gate 
247*7c478bd9Sstevel@tonic-gate #define	_DATUM(hi, lo)	(((unsigned long long)(hi) << 32) | (unsigned)(lo))
248*7c478bd9Sstevel@tonic-gate #define	_DATUM_HI(x) 	((unsigned) ((x) >> 32))
249*7c478bd9Sstevel@tonic-gate #define	_DATUM_LO(x) 	((unsigned) (x))
250*7c478bd9Sstevel@tonic-gate 
251*7c478bd9Sstevel@tonic-gate #define	DATUM_RECORD(x)		\
252*7c478bd9Sstevel@tonic-gate 	((tnf_ref32_t *)DATUM_VAL(x))
253*7c478bd9Sstevel@tonic-gate 
254*7c478bd9Sstevel@tonic-gate #define	RECORD_DATUM(tnf, rec)	\
255*7c478bd9Sstevel@tonic-gate 	DATUM(_tnf_record_info(tnf, rec), (caddr_t)rec)
256*7c478bd9Sstevel@tonic-gate 
257*7c478bd9Sstevel@tonic-gate #define	DATUM_TNF(x)		DATUM_INFO(x)->tnf
258*7c478bd9Sstevel@tonic-gate #define	DATUM_TAG(x)		DATUM_INFO(x)->tag
259*7c478bd9Sstevel@tonic-gate 
260*7c478bd9Sstevel@tonic-gate /*
261*7c478bd9Sstevel@tonic-gate  * Type checking operations
262*7c478bd9Sstevel@tonic-gate  */
263*7c478bd9Sstevel@tonic-gate 
264*7c478bd9Sstevel@tonic-gate void _tnf_check_datum(tnf_datum_t);
265*7c478bd9Sstevel@tonic-gate #define	CHECK_DATUM(x)	_tnf_check_datum(x)
266*7c478bd9Sstevel@tonic-gate 
267*7c478bd9Sstevel@tonic-gate void _tnf_check_record(tnf_datum_t);
268*7c478bd9Sstevel@tonic-gate #define	CHECK_RECORD(x)	_tnf_check_record(x)
269*7c478bd9Sstevel@tonic-gate 
270*7c478bd9Sstevel@tonic-gate void _tnf_check_slots(tnf_datum_t);
271*7c478bd9Sstevel@tonic-gate #define	CHECK_SLOTS(x)	_tnf_check_slots(x)
272*7c478bd9Sstevel@tonic-gate 
273*7c478bd9Sstevel@tonic-gate void _tnf_check_array(tnf_datum_t);
274*7c478bd9Sstevel@tonic-gate #define	CHECK_ARRAY(x)	_tnf_check_array(x)
275*7c478bd9Sstevel@tonic-gate 
276*7c478bd9Sstevel@tonic-gate void _tnf_check_type(tnf_datum_t);
277*7c478bd9Sstevel@tonic-gate #define	CHECK_TYPE(x)	_tnf_check_type(x)
278*7c478bd9Sstevel@tonic-gate 
279*7c478bd9Sstevel@tonic-gate /*
280*7c478bd9Sstevel@tonic-gate  * Operations based on ABI layouts and bootstrap assumptions
281*7c478bd9Sstevel@tonic-gate  */
282*7c478bd9Sstevel@tonic-gate 
283*7c478bd9Sstevel@tonic-gate tnf_ref32_t * _tnf_get_tag(TNF *, tnf_ref32_t *);
284*7c478bd9Sstevel@tonic-gate tnf_ref32_t * _tnf_get_tag_arg(TNF *, tnf_ref32_t *);
285*7c478bd9Sstevel@tonic-gate size_t _tnf_get_self_size(TNF *, tnf_ref32_t *);
286*7c478bd9Sstevel@tonic-gate unsigned _tnf_get_element_count(TNF *, tnf_ref32_t *, unsigned);
287*7c478bd9Sstevel@tonic-gate caddr_t _tnf_get_elements(TNF *, tnf_ref32_t *);
288*7c478bd9Sstevel@tonic-gate char * _tnf_get_chars(TNF *, tnf_ref32_t *);
289*7c478bd9Sstevel@tonic-gate char * _tnf_get_name(TNF *, tnf_ref32_t *);
290*7c478bd9Sstevel@tonic-gate tnf_ref32_t * _tnf_get_properties(TNF *, tnf_ref32_t *);
291*7c478bd9Sstevel@tonic-gate tnf_ref32_t * _tnf_get_slot_types(TNF *, tnf_ref32_t *);
292*7c478bd9Sstevel@tonic-gate size_t _tnf_get_header_size(TNF *, tnf_ref32_t *);
293*7c478bd9Sstevel@tonic-gate tnf_ref32_t * _tnf_get_derived_base(TNF *, tnf_ref32_t *);
294*7c478bd9Sstevel@tonic-gate 
295*7c478bd9Sstevel@tonic-gate tnf_ref32_t * _tnf_get_root_tag(TNF *, tnf_ref32_t *);
296*7c478bd9Sstevel@tonic-gate tnf_ref32_t * _tnf_get_property(TNF *, tnf_ref32_t *, char *);
297*7c478bd9Sstevel@tonic-gate tnf_ref32_t * _tnf_get_element_named(TNF *, tnf_ref32_t *, char *);
298*7c478bd9Sstevel@tonic-gate tnf_ref32_t * _tnf_get_base_tag(TNF *, tnf_ref32_t *);
299*7c478bd9Sstevel@tonic-gate 
300*7c478bd9Sstevel@tonic-gate size_t _tnf_get_storage_size(TNF *, tnf_ref32_t *);
301*7c478bd9Sstevel@tonic-gate size_t _tnf_get_ref_size(TNF *, tnf_ref32_t *);
302*7c478bd9Sstevel@tonic-gate 
303*7c478bd9Sstevel@tonic-gate unsigned _tnf_get_align(TNF *, tnf_ref32_t *);
304*7c478bd9Sstevel@tonic-gate 
305*7c478bd9Sstevel@tonic-gate caddr_t	_tnf_get_slot_typed(TNF *, tnf_ref32_t *, char *);
306*7c478bd9Sstevel@tonic-gate caddr_t	_tnf_get_slot_named(TNF *, tnf_ref32_t *, char *);
307*7c478bd9Sstevel@tonic-gate 
308*7c478bd9Sstevel@tonic-gate #define	HAS_PROPERTY(tnf, tag, name)	\
309*7c478bd9Sstevel@tonic-gate 	(_tnf_get_property(tnf, tag, name) != TNF_NULL)
310*7c478bd9Sstevel@tonic-gate 
311*7c478bd9Sstevel@tonic-gate /*
312*7c478bd9Sstevel@tonic-gate  * Call the installed error handler with installed arg
313*7c478bd9Sstevel@tonic-gate  */
314*7c478bd9Sstevel@tonic-gate 
315*7c478bd9Sstevel@tonic-gate void _tnf_error(TNF *, tnf_errcode_t);
316*7c478bd9Sstevel@tonic-gate 
317*7c478bd9Sstevel@tonic-gate /*
318*7c478bd9Sstevel@tonic-gate  * Tag lookup operations
319*7c478bd9Sstevel@tonic-gate  */
320*7c478bd9Sstevel@tonic-gate 
321*7c478bd9Sstevel@tonic-gate struct taginfo * _tnf_get_info(TNF *, tnf_ref32_t *);
322*7c478bd9Sstevel@tonic-gate struct taginfo * _tnf_record_info(TNF *, tnf_ref32_t *);
323*7c478bd9Sstevel@tonic-gate 
324*7c478bd9Sstevel@tonic-gate tnf_errcode_t _tnf_init_tags(TNF *);
325*7c478bd9Sstevel@tonic-gate tnf_errcode_t _tnf_fini_tags(TNF *);
326*7c478bd9Sstevel@tonic-gate 
327*7c478bd9Sstevel@tonic-gate /*
328*7c478bd9Sstevel@tonic-gate  * Classify a tag into its props and data kind
329*7c478bd9Sstevel@tonic-gate  */
330*7c478bd9Sstevel@tonic-gate 
331*7c478bd9Sstevel@tonic-gate tag_props_t _tnf_get_props(TNF *, tnf_ref32_t *);
332*7c478bd9Sstevel@tonic-gate tnf_kind_t _tnf_get_kind(TNF *, tnf_ref32_t *);
333*7c478bd9Sstevel@tonic-gate 
334*7c478bd9Sstevel@tonic-gate caddr_t	_tnf_get_member(TNF *, caddr_t, struct taginfo *);
335*7c478bd9Sstevel@tonic-gate 
336*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus
337*7c478bd9Sstevel@tonic-gate }
338*7c478bd9Sstevel@tonic-gate #endif
339*7c478bd9Sstevel@tonic-gate 
340*7c478bd9Sstevel@tonic-gate #endif /* _LIBTNF_H */
341