xref: /titanic_50/usr/src/lib/libtnf/record.c (revision c77a61a72b5ecdc507d6cf104142edd371a16c84)
1 /*
2  * CDDL HEADER START
3  *
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
7  * with the License.
8  *
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.
13  *
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]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  *	Copyright (c) 1994, by Sun Microsytems, Inc.
24  */
25 
26 #pragma	ident	"%Z%%M%	%I%	%E% SMI"
27 
28 #include "libtnf.h"
29 
30 /*
31  * Check a record datum
32  */
33 
34 void
35 _tnf_check_record(tnf_datum_t datum)
36 {
37 	CHECK_DATUM(datum);
38 
39 	/* All records must be tagged */
40 	if (!INFO_TAGGED(DATUM_INFO(datum)))
41 		_tnf_error(DATUM_TNF(datum), TNF_ERR_TYPEMISMATCH);
42 }
43 
44 /*
45  * Retrieve the tag arg, encoded in low 16 bits of tag word
46  */
47 
48 tnf_datum_t
49 tnf_get_tag_arg(tnf_datum_t datum)
50 {
51 	TNF		*tnf;
52 	tnf_ref32_t	*arg;
53 
54 	CHECK_RECORD(datum);
55 
56 	tnf = DATUM_TNF(datum);
57 
58 	/* Should not give an error if not found */
59 	/* LINTED pointer cast may result in improper alignment */
60 	arg = _tnf_get_tag_arg(tnf, DATUM_RECORD(datum));
61 
62 	if (arg == TNF_NULL)
63 		return (TNF_DATUM_NULL);
64 	else			/* repackage the tag arg with its taginfo */
65 		return (RECORD_DATUM(tnf, arg));
66 }
67