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.
29 #pragma ident "%Z%%M% %I% %E% SMI"
31 #include <sys/types.h>
42 typedef struct TNF TNF
;
48 typedef unsigned long long tnf_datum_t
;
50 #define TNF_DATUM_NULL ((tnf_datum_t)0)
53 * Reader data classification
57 TNF_K_UNKNOWN
, /* unknown or error */
58 TNF_K_SCALAR
, /* unclassified scalar */
59 TNF_K_CHAR
, /* char */
60 TNF_K_INT8
, /* int8 */
61 TNF_K_INT16
, /* int16 */
62 TNF_K_INT32
, /* int32 */
63 TNF_K_UINT8
, /* uint8 */
64 TNF_K_UINT16
, /* uint16 */
65 TNF_K_UINT32
, /* uint32 */
66 TNF_K_INT64
, /* int64 */
67 TNF_K_UINT64
, /* uint64 */
68 TNF_K_FLOAT32
, /* float32 */
69 TNF_K_FLOAT64
, /* float64 */
70 TNF_K_ARRAY
, /* array */
71 TNF_K_STRING
, /* string */
72 TNF_K_STRUCT
, /* struct */
83 /* 1 through 1023 reserved for errno values */
84 #define TNF_ERRNO_MAX 1023
86 TNF_ERR_NOTTNF
= 1024, /* not TNF file */
87 TNF_ERR_BADDATUM
= 1025, /* bad or NULL data handle */
88 TNF_ERR_TYPEMISMATCH
= 1026, /* type mismatch */
89 TNF_ERR_BADINDEX
= 1027, /* array index out of bounds */
90 TNF_ERR_BADSLOT
= 1028, /* slot missing */
91 TNF_ERR_BADREFTYPE
= 1029, /* invalid reference type */
92 TNF_ERR_ALLOCFAIL
= 1030, /* memory allocation failure */
93 TNF_ERR_BADTNF
= 1031, /* bad TNF file */
94 TNF_ERR_INTERNAL
= 1032 /* internal error */
97 typedef void tnf_error_handler_t(void *, TNF
*, tnf_errcode_t
);
103 tnf_errcode_t
tnf_reader_begin(caddr_t
, size_t, TNF
**);
104 tnf_errcode_t
tnf_reader_end(TNF
*);
110 void tnf_set_error_handler(tnf_error_handler_t
*, void *);
111 char * tnf_error_message(tnf_errcode_t
);
113 tnf_error_handler_t tnf_default_error_handler
;
119 unsigned tnf_get_block_count(TNF
*);
120 tnf_datum_t
tnf_get_block_absolute(TNF
*, unsigned);
121 tnf_datum_t
tnf_get_block_relative(tnf_datum_t
, int);
122 int tnf_is_block_header(tnf_datum_t
);
128 tnf_datum_t
tnf_get_next_record(tnf_datum_t
);
129 tnf_datum_t
tnf_get_block_header(tnf_datum_t
);
130 tnf_datum_t
tnf_get_file_header(TNF
*);
133 * Data classification predicates
136 int tnf_is_inline(tnf_datum_t
);
137 int tnf_is_scalar(tnf_datum_t
);
138 int tnf_is_record(tnf_datum_t
);
139 int tnf_is_array(tnf_datum_t
);
140 int tnf_is_string(tnf_datum_t
);
141 int tnf_is_struct(tnf_datum_t
);
142 int tnf_is_type(tnf_datum_t
);
148 tnf_kind_t
tnf_get_kind(tnf_datum_t
);
149 size_t tnf_get_size(tnf_datum_t
);
150 tnf_datum_t
tnf_get_type(tnf_datum_t
);
151 char * tnf_get_type_name(tnf_datum_t
);
152 caddr_t
tnf_get_raw(tnf_datum_t
);
158 tnf_datum_t
tnf_get_tag_arg(tnf_datum_t
);
164 unsigned tnf_get_element_count(tnf_datum_t
);
165 tnf_datum_t
tnf_get_element(tnf_datum_t
, unsigned);
166 tnf_datum_t
tnf_get_element_type(tnf_datum_t
);
167 caddr_t
tnf_get_elements(tnf_datum_t
);
168 char * tnf_get_chars(tnf_datum_t
);
174 unsigned tnf_get_slot_count(tnf_datum_t
);
175 char * tnf_get_slot_name(tnf_datum_t
, unsigned);
176 unsigned tnf_get_slot_index(tnf_datum_t
, char *);
177 tnf_datum_t
tnf_get_slot_named(tnf_datum_t
, char *);
178 tnf_datum_t
tnf_get_slot_indexed(tnf_datum_t
, unsigned);
181 * Scalar data conversions
184 char tnf_get_char(tnf_datum_t
);
185 tnf_int8_t
tnf_get_int8(tnf_datum_t
);
186 tnf_int16_t
tnf_get_int16(tnf_datum_t
);
187 tnf_int32_t
tnf_get_int32(tnf_datum_t
);
188 tnf_int64_t
tnf_get_int64(tnf_datum_t
);
189 tnf_float32_t
tnf_get_float32(tnf_datum_t
);
190 tnf_float64_t
tnf_get_float64(tnf_datum_t
);
193 * Type (tag) record operations
196 tnf_kind_t
tnf_type_get_kind(tnf_datum_t
);
197 char * tnf_type_get_name(tnf_datum_t
);
198 size_t tnf_type_get_size(tnf_datum_t
);
199 tnf_datum_t
tnf_type_get_property(tnf_datum_t
, char *);
200 tnf_datum_t
tnf_type_get_base(tnf_datum_t
);
206 #endif /* _TNF_TNF_H */