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 #pragma ident "%Z%%M% %I% %E% SMI" 27*7c478bd9Sstevel@tonic-gate 28*7c478bd9Sstevel@tonic-gate #include "libtnf.h" 29*7c478bd9Sstevel@tonic-gate 30*7c478bd9Sstevel@tonic-gate /* 31*7c478bd9Sstevel@tonic-gate * 32*7c478bd9Sstevel@tonic-gate */ 33*7c478bd9Sstevel@tonic-gate 34*7c478bd9Sstevel@tonic-gate static struct ntop { 35*7c478bd9Sstevel@tonic-gate char *name; 36*7c478bd9Sstevel@tonic-gate tag_props_t prop; 37*7c478bd9Sstevel@tonic-gate } ntop[] = { 38*7c478bd9Sstevel@tonic-gate { TNF_N_INLINE, TAG_PROP_INLINE }, 39*7c478bd9Sstevel@tonic-gate { TNF_N_TAGGED, TAG_PROP_TAGGED }, 40*7c478bd9Sstevel@tonic-gate { TNF_N_SCALAR, TAG_PROP_SCALAR }, 41*7c478bd9Sstevel@tonic-gate { TNF_N_DERIVED, TAG_PROP_DERIVED }, 42*7c478bd9Sstevel@tonic-gate { TNF_N_ARRAY, TAG_PROP_ARRAY }, 43*7c478bd9Sstevel@tonic-gate { TNF_N_STRING, TAG_PROP_STRING }, 44*7c478bd9Sstevel@tonic-gate { TNF_N_STRUCT, TAG_PROP_STRUCT }, 45*7c478bd9Sstevel@tonic-gate { TNF_N_TYPE, TAG_PROP_TYPE }, 46*7c478bd9Sstevel@tonic-gate { NULL, 0} 47*7c478bd9Sstevel@tonic-gate }; 48*7c478bd9Sstevel@tonic-gate 49*7c478bd9Sstevel@tonic-gate static struct ntok { 50*7c478bd9Sstevel@tonic-gate char *name; 51*7c478bd9Sstevel@tonic-gate tnf_kind_t kind; 52*7c478bd9Sstevel@tonic-gate } scalar_ntok[] = { 53*7c478bd9Sstevel@tonic-gate { TNF_N_CHAR, TNF_K_CHAR }, 54*7c478bd9Sstevel@tonic-gate { TNF_N_INT8, TNF_K_INT8 }, 55*7c478bd9Sstevel@tonic-gate { TNF_N_INT16, TNF_K_INT16 }, 56*7c478bd9Sstevel@tonic-gate { TNF_N_INT32, TNF_K_INT32 }, 57*7c478bd9Sstevel@tonic-gate { TNF_N_UINT8, TNF_K_UINT8 }, 58*7c478bd9Sstevel@tonic-gate { TNF_N_UINT16, TNF_K_UINT16 }, 59*7c478bd9Sstevel@tonic-gate { TNF_N_UINT32, TNF_K_UINT32 }, 60*7c478bd9Sstevel@tonic-gate { TNF_N_INT64, TNF_K_INT64 }, 61*7c478bd9Sstevel@tonic-gate { TNF_N_UINT64, TNF_K_UINT64 }, 62*7c478bd9Sstevel@tonic-gate { TNF_N_FLOAT32, TNF_K_FLOAT32 }, 63*7c478bd9Sstevel@tonic-gate { TNF_N_FLOAT64, TNF_K_FLOAT64 }, 64*7c478bd9Sstevel@tonic-gate { NULL, 0 } 65*7c478bd9Sstevel@tonic-gate }; 66*7c478bd9Sstevel@tonic-gate 67*7c478bd9Sstevel@tonic-gate /* 68*7c478bd9Sstevel@tonic-gate * Compute tag props 69*7c478bd9Sstevel@tonic-gate */ 70*7c478bd9Sstevel@tonic-gate 71*7c478bd9Sstevel@tonic-gate tag_props_t 72*7c478bd9Sstevel@tonic-gate _tnf_get_props(TNF *tnf, tnf_ref32_t *tag) 73*7c478bd9Sstevel@tonic-gate { 74*7c478bd9Sstevel@tonic-gate tag_props_t props; 75*7c478bd9Sstevel@tonic-gate struct ntop *p; 76*7c478bd9Sstevel@tonic-gate 77*7c478bd9Sstevel@tonic-gate props = 0; 78*7c478bd9Sstevel@tonic-gate 79*7c478bd9Sstevel@tonic-gate p = ntop; 80*7c478bd9Sstevel@tonic-gate /* No need to get base tag for inherited properties */ 81*7c478bd9Sstevel@tonic-gate while (p->name) { 82*7c478bd9Sstevel@tonic-gate if (HAS_PROPERTY(tnf, tag, p->name)) 83*7c478bd9Sstevel@tonic-gate props |= p->prop; 84*7c478bd9Sstevel@tonic-gate p++; 85*7c478bd9Sstevel@tonic-gate } 86*7c478bd9Sstevel@tonic-gate 87*7c478bd9Sstevel@tonic-gate return (props); 88*7c478bd9Sstevel@tonic-gate } 89*7c478bd9Sstevel@tonic-gate 90*7c478bd9Sstevel@tonic-gate /* 91*7c478bd9Sstevel@tonic-gate * Data kind depends on implementation properties of base tag 92*7c478bd9Sstevel@tonic-gate */ 93*7c478bd9Sstevel@tonic-gate 94*7c478bd9Sstevel@tonic-gate tnf_kind_t 95*7c478bd9Sstevel@tonic-gate _tnf_get_kind(TNF *tnf, tnf_ref32_t *tag) 96*7c478bd9Sstevel@tonic-gate { 97*7c478bd9Sstevel@tonic-gate tnf_ref32_t *base_tag; 98*7c478bd9Sstevel@tonic-gate char *base_name; 99*7c478bd9Sstevel@tonic-gate 100*7c478bd9Sstevel@tonic-gate base_tag = _tnf_get_base_tag(tnf, tag); 101*7c478bd9Sstevel@tonic-gate base_name = _tnf_get_name(tnf, base_tag); 102*7c478bd9Sstevel@tonic-gate 103*7c478bd9Sstevel@tonic-gate if (HAS_PROPERTY(tnf, base_tag, TNF_N_SCALAR)) { 104*7c478bd9Sstevel@tonic-gate struct ntok *p; 105*7c478bd9Sstevel@tonic-gate 106*7c478bd9Sstevel@tonic-gate p = scalar_ntok; 107*7c478bd9Sstevel@tonic-gate while (p->name) { 108*7c478bd9Sstevel@tonic-gate if (strcmp(p->name, base_name) == 0) 109*7c478bd9Sstevel@tonic-gate return (p->kind); 110*7c478bd9Sstevel@tonic-gate p++; 111*7c478bd9Sstevel@tonic-gate } 112*7c478bd9Sstevel@tonic-gate return (TNF_K_SCALAR); 113*7c478bd9Sstevel@tonic-gate 114*7c478bd9Sstevel@tonic-gate } else if (HAS_PROPERTY(tnf, base_tag, TNF_N_ARRAY)) { 115*7c478bd9Sstevel@tonic-gate if (strcmp(base_name, TNF_N_STRING) == 0) 116*7c478bd9Sstevel@tonic-gate return (TNF_K_STRING); 117*7c478bd9Sstevel@tonic-gate else 118*7c478bd9Sstevel@tonic-gate return (TNF_K_ARRAY); 119*7c478bd9Sstevel@tonic-gate 120*7c478bd9Sstevel@tonic-gate } else if (HAS_PROPERTY(tnf, base_tag, TNF_N_TYPE)) { 121*7c478bd9Sstevel@tonic-gate return (TNF_K_TYPE); 122*7c478bd9Sstevel@tonic-gate 123*7c478bd9Sstevel@tonic-gate } else if (HAS_PROPERTY(tnf, base_tag, TNF_N_STRUCT)) { 124*7c478bd9Sstevel@tonic-gate return (TNF_K_STRUCT); 125*7c478bd9Sstevel@tonic-gate 126*7c478bd9Sstevel@tonic-gate } else { /* abstract */ 127*7c478bd9Sstevel@tonic-gate return (TNF_K_UNKNOWN); 128*7c478bd9Sstevel@tonic-gate } 129*7c478bd9Sstevel@tonic-gate } 130