1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate * CDDL HEADER START
3*0Sstevel@tonic-gate *
4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the
5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only
6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance
7*0Sstevel@tonic-gate * with the License.
8*0Sstevel@tonic-gate *
9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
11*0Sstevel@tonic-gate * See the License for the specific language governing permissions
12*0Sstevel@tonic-gate * and limitations under the License.
13*0Sstevel@tonic-gate *
14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
19*0Sstevel@tonic-gate *
20*0Sstevel@tonic-gate * CDDL HEADER END
21*0Sstevel@tonic-gate */
22*0Sstevel@tonic-gate /*
23*0Sstevel@tonic-gate * Copyright (c) 1994, by Sun Microsytems, Inc.
24*0Sstevel@tonic-gate */
25*0Sstevel@tonic-gate
26*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI"
27*0Sstevel@tonic-gate
28*0Sstevel@tonic-gate #include "libtnf.h"
29*0Sstevel@tonic-gate
30*0Sstevel@tonic-gate /*
31*0Sstevel@tonic-gate *
32*0Sstevel@tonic-gate */
33*0Sstevel@tonic-gate
34*0Sstevel@tonic-gate static struct ntop {
35*0Sstevel@tonic-gate char *name;
36*0Sstevel@tonic-gate tag_props_t prop;
37*0Sstevel@tonic-gate } ntop[] = {
38*0Sstevel@tonic-gate { TNF_N_INLINE, TAG_PROP_INLINE },
39*0Sstevel@tonic-gate { TNF_N_TAGGED, TAG_PROP_TAGGED },
40*0Sstevel@tonic-gate { TNF_N_SCALAR, TAG_PROP_SCALAR },
41*0Sstevel@tonic-gate { TNF_N_DERIVED, TAG_PROP_DERIVED },
42*0Sstevel@tonic-gate { TNF_N_ARRAY, TAG_PROP_ARRAY },
43*0Sstevel@tonic-gate { TNF_N_STRING, TAG_PROP_STRING },
44*0Sstevel@tonic-gate { TNF_N_STRUCT, TAG_PROP_STRUCT },
45*0Sstevel@tonic-gate { TNF_N_TYPE, TAG_PROP_TYPE },
46*0Sstevel@tonic-gate { NULL, 0}
47*0Sstevel@tonic-gate };
48*0Sstevel@tonic-gate
49*0Sstevel@tonic-gate static struct ntok {
50*0Sstevel@tonic-gate char *name;
51*0Sstevel@tonic-gate tnf_kind_t kind;
52*0Sstevel@tonic-gate } scalar_ntok[] = {
53*0Sstevel@tonic-gate { TNF_N_CHAR, TNF_K_CHAR },
54*0Sstevel@tonic-gate { TNF_N_INT8, TNF_K_INT8 },
55*0Sstevel@tonic-gate { TNF_N_INT16, TNF_K_INT16 },
56*0Sstevel@tonic-gate { TNF_N_INT32, TNF_K_INT32 },
57*0Sstevel@tonic-gate { TNF_N_UINT8, TNF_K_UINT8 },
58*0Sstevel@tonic-gate { TNF_N_UINT16, TNF_K_UINT16 },
59*0Sstevel@tonic-gate { TNF_N_UINT32, TNF_K_UINT32 },
60*0Sstevel@tonic-gate { TNF_N_INT64, TNF_K_INT64 },
61*0Sstevel@tonic-gate { TNF_N_UINT64, TNF_K_UINT64 },
62*0Sstevel@tonic-gate { TNF_N_FLOAT32, TNF_K_FLOAT32 },
63*0Sstevel@tonic-gate { TNF_N_FLOAT64, TNF_K_FLOAT64 },
64*0Sstevel@tonic-gate { NULL, 0 }
65*0Sstevel@tonic-gate };
66*0Sstevel@tonic-gate
67*0Sstevel@tonic-gate /*
68*0Sstevel@tonic-gate * Compute tag props
69*0Sstevel@tonic-gate */
70*0Sstevel@tonic-gate
71*0Sstevel@tonic-gate tag_props_t
_tnf_get_props(TNF * tnf,tnf_ref32_t * tag)72*0Sstevel@tonic-gate _tnf_get_props(TNF *tnf, tnf_ref32_t *tag)
73*0Sstevel@tonic-gate {
74*0Sstevel@tonic-gate tag_props_t props;
75*0Sstevel@tonic-gate struct ntop *p;
76*0Sstevel@tonic-gate
77*0Sstevel@tonic-gate props = 0;
78*0Sstevel@tonic-gate
79*0Sstevel@tonic-gate p = ntop;
80*0Sstevel@tonic-gate /* No need to get base tag for inherited properties */
81*0Sstevel@tonic-gate while (p->name) {
82*0Sstevel@tonic-gate if (HAS_PROPERTY(tnf, tag, p->name))
83*0Sstevel@tonic-gate props |= p->prop;
84*0Sstevel@tonic-gate p++;
85*0Sstevel@tonic-gate }
86*0Sstevel@tonic-gate
87*0Sstevel@tonic-gate return (props);
88*0Sstevel@tonic-gate }
89*0Sstevel@tonic-gate
90*0Sstevel@tonic-gate /*
91*0Sstevel@tonic-gate * Data kind depends on implementation properties of base tag
92*0Sstevel@tonic-gate */
93*0Sstevel@tonic-gate
94*0Sstevel@tonic-gate tnf_kind_t
_tnf_get_kind(TNF * tnf,tnf_ref32_t * tag)95*0Sstevel@tonic-gate _tnf_get_kind(TNF *tnf, tnf_ref32_t *tag)
96*0Sstevel@tonic-gate {
97*0Sstevel@tonic-gate tnf_ref32_t *base_tag;
98*0Sstevel@tonic-gate char *base_name;
99*0Sstevel@tonic-gate
100*0Sstevel@tonic-gate base_tag = _tnf_get_base_tag(tnf, tag);
101*0Sstevel@tonic-gate base_name = _tnf_get_name(tnf, base_tag);
102*0Sstevel@tonic-gate
103*0Sstevel@tonic-gate if (HAS_PROPERTY(tnf, base_tag, TNF_N_SCALAR)) {
104*0Sstevel@tonic-gate struct ntok *p;
105*0Sstevel@tonic-gate
106*0Sstevel@tonic-gate p = scalar_ntok;
107*0Sstevel@tonic-gate while (p->name) {
108*0Sstevel@tonic-gate if (strcmp(p->name, base_name) == 0)
109*0Sstevel@tonic-gate return (p->kind);
110*0Sstevel@tonic-gate p++;
111*0Sstevel@tonic-gate }
112*0Sstevel@tonic-gate return (TNF_K_SCALAR);
113*0Sstevel@tonic-gate
114*0Sstevel@tonic-gate } else if (HAS_PROPERTY(tnf, base_tag, TNF_N_ARRAY)) {
115*0Sstevel@tonic-gate if (strcmp(base_name, TNF_N_STRING) == 0)
116*0Sstevel@tonic-gate return (TNF_K_STRING);
117*0Sstevel@tonic-gate else
118*0Sstevel@tonic-gate return (TNF_K_ARRAY);
119*0Sstevel@tonic-gate
120*0Sstevel@tonic-gate } else if (HAS_PROPERTY(tnf, base_tag, TNF_N_TYPE)) {
121*0Sstevel@tonic-gate return (TNF_K_TYPE);
122*0Sstevel@tonic-gate
123*0Sstevel@tonic-gate } else if (HAS_PROPERTY(tnf, base_tag, TNF_N_STRUCT)) {
124*0Sstevel@tonic-gate return (TNF_K_STRUCT);
125*0Sstevel@tonic-gate
126*0Sstevel@tonic-gate } else { /* abstract */
127*0Sstevel@tonic-gate return (TNF_K_UNKNOWN);
128*0Sstevel@tonic-gate }
129*0Sstevel@tonic-gate }
130