1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
|
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright (c) 1994, by Sun Microsytems, Inc.
*/
#ifndef _TNF_TNF_H
#define _TNF_TNF_H
#pragma ident "%Z%%M% %I% %E% SMI"
#include <sys/types.h>
#include <tnf/com.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* Opaque TNF handle
*/
typedef struct TNF TNF;
/*
* Opaque data handle
*/
typedef unsigned long long tnf_datum_t;
#define TNF_DATUM_NULL ((tnf_datum_t)0)
/*
* Reader data classification
*/
typedef enum {
TNF_K_UNKNOWN, /* unknown or error */
TNF_K_SCALAR, /* unclassified scalar */
TNF_K_CHAR, /* char */
TNF_K_INT8, /* int8 */
TNF_K_INT16, /* int16 */
TNF_K_INT32, /* int32 */
TNF_K_UINT8, /* uint8 */
TNF_K_UINT16, /* uint16 */
TNF_K_UINT32, /* uint32 */
TNF_K_INT64, /* int64 */
TNF_K_UINT64, /* uint64 */
TNF_K_FLOAT32, /* float32 */
TNF_K_FLOAT64, /* float64 */
TNF_K_ARRAY, /* array */
TNF_K_STRING, /* string */
TNF_K_STRUCT, /* struct */
TNF_K_TYPE /* type */
} tnf_kind_t;
/*
* Error codes
*/
typedef enum {
TNF_ERR_NONE = 0,
/* 1 through 1023 reserved for errno values */
#define TNF_ERRNO_MAX 1023
TNF_ERR_NOTTNF = 1024, /* not TNF file */
TNF_ERR_BADDATUM = 1025, /* bad or NULL data handle */
TNF_ERR_TYPEMISMATCH = 1026, /* type mismatch */
TNF_ERR_BADINDEX = 1027, /* array index out of bounds */
TNF_ERR_BADSLOT = 1028, /* slot missing */
TNF_ERR_BADREFTYPE = 1029, /* invalid reference type */
TNF_ERR_ALLOCFAIL = 1030, /* memory allocation failure */
TNF_ERR_BADTNF = 1031, /* bad TNF file */
TNF_ERR_INTERNAL = 1032 /* internal error */
} tnf_errcode_t;
typedef void tnf_error_handler_t(void *, TNF *, tnf_errcode_t);
/*
* TNF file interface
*/
tnf_errcode_t tnf_reader_begin(caddr_t, size_t, TNF **);
tnf_errcode_t tnf_reader_end(TNF *);
/*
* Error interface
*/
void tnf_set_error_handler(tnf_error_handler_t *, void *);
char * tnf_error_message(tnf_errcode_t);
tnf_error_handler_t tnf_default_error_handler;
/*
* Data block access
*/
unsigned tnf_get_block_count(TNF *);
tnf_datum_t tnf_get_block_absolute(TNF *, unsigned);
tnf_datum_t tnf_get_block_relative(tnf_datum_t, int);
int tnf_is_block_header(tnf_datum_t);
/*
* Record access
*/
tnf_datum_t tnf_get_next_record(tnf_datum_t);
tnf_datum_t tnf_get_block_header(tnf_datum_t);
tnf_datum_t tnf_get_file_header(TNF *);
/*
* Data classification predicates
*/
int tnf_is_inline(tnf_datum_t);
int tnf_is_scalar(tnf_datum_t);
int tnf_is_record(tnf_datum_t);
int tnf_is_array(tnf_datum_t);
int tnf_is_string(tnf_datum_t);
int tnf_is_struct(tnf_datum_t);
int tnf_is_type(tnf_datum_t);
/*
* Data operations
*/
tnf_kind_t tnf_get_kind(tnf_datum_t);
size_t tnf_get_size(tnf_datum_t);
tnf_datum_t tnf_get_type(tnf_datum_t);
char * tnf_get_type_name(tnf_datum_t);
caddr_t tnf_get_raw(tnf_datum_t);
/*
* Record operations
*/
tnf_datum_t tnf_get_tag_arg(tnf_datum_t);
/*
* Array operations
*/
unsigned tnf_get_element_count(tnf_datum_t);
tnf_datum_t tnf_get_element(tnf_datum_t, unsigned);
tnf_datum_t tnf_get_element_type(tnf_datum_t);
caddr_t tnf_get_elements(tnf_datum_t);
char * tnf_get_chars(tnf_datum_t);
/*
* Struct operations
*/
unsigned tnf_get_slot_count(tnf_datum_t);
char * tnf_get_slot_name(tnf_datum_t, unsigned);
unsigned tnf_get_slot_index(tnf_datum_t, char *);
tnf_datum_t tnf_get_slot_named(tnf_datum_t, char *);
tnf_datum_t tnf_get_slot_indexed(tnf_datum_t, unsigned);
/*
* Scalar data conversions
*/
char tnf_get_char(tnf_datum_t);
tnf_int8_t tnf_get_int8(tnf_datum_t);
tnf_int16_t tnf_get_int16(tnf_datum_t);
tnf_int32_t tnf_get_int32(tnf_datum_t);
tnf_int64_t tnf_get_int64(tnf_datum_t);
tnf_float32_t tnf_get_float32(tnf_datum_t);
tnf_float64_t tnf_get_float64(tnf_datum_t);
/*
* Type (tag) record operations
*/
tnf_kind_t tnf_type_get_kind(tnf_datum_t);
char * tnf_type_get_name(tnf_datum_t);
size_t tnf_type_get_size(tnf_datum_t);
tnf_datum_t tnf_type_get_property(tnf_datum_t, char *);
tnf_datum_t tnf_type_get_base(tnf_datum_t);
#ifdef __cplusplus
}
#endif
#endif /* _TNF_TNF_H */
|