xref: /titanic_52/usr/src/cmd/sgs/libconv/common/segments.c (revision 0eb822a1c0c2bea495647510b75f77f0e57633eb)
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 (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 #pragma ident	"%Z%%M%	%I%	%E% SMI"
27 
28 /*
29  * String conversion routine for segment flags.
30  */
31 #include	<string.h>
32 #include	<libld.h>
33 #include	"_conv.h"
34 #include	"segments_msg.h"
35 
36 #define	SEGSZ	CONV_EXPN_FIELD_DEF_PREFIX_SIZE + \
37 		MSG_FLG_SG_VADDR_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
38 		MSG_FLG_SG_PADDR_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
39 		MSG_FLG_SG_LENGTH_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
40 		MSG_FLG_SG_ALIGN_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
41 		MSG_FLG_SG_ROUND_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
42 		MSG_FLG_SG_FLAGS_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
43 		MSG_FLG_SG_TYPE_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
44 		MSG_FLG_SG_ORDER_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
45 		MSG_FLG_SG_NOHDR_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
46 		MSG_FLG_SG_EMPTY_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
47 		MSG_FLG_SG_KEY_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
48 		MSG_FLG_SG_DISABLED_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
49 		MSG_FLG_SG_PHREQ_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
50 		CONV_INV_STRSIZE + CONV_EXPN_FIELD_DEF_SUFFIX_SIZE
51 
52 const char *
53 conv_seg_flags(Half flags)
54 {
55 	static char	string[SEGSZ];
56 	static Val_desc vda[] = {
57 		{ FLG_SG_VADDR,		MSG_ORIG(MSG_FLG_SG_VADDR) },
58 		{ FLG_SG_PADDR,		MSG_ORIG(MSG_FLG_SG_PADDR) },
59 		{ FLG_SG_LENGTH,	MSG_ORIG(MSG_FLG_SG_LENGTH) },
60 		{ FLG_SG_ALIGN,		MSG_ORIG(MSG_FLG_SG_ALIGN) },
61 		{ FLG_SG_ROUND,		MSG_ORIG(MSG_FLG_SG_ROUND) },
62 		{ FLG_SG_FLAGS,		MSG_ORIG(MSG_FLG_SG_FLAGS) },
63 		{ FLG_SG_TYPE,		MSG_ORIG(MSG_FLG_SG_TYPE) },
64 		{ FLG_SG_ORDER,		MSG_ORIG(MSG_FLG_SG_ORDER) },
65 		{ FLG_SG_NOHDR,		MSG_ORIG(MSG_FLG_SG_NOHDR) },
66 		{ FLG_SG_EMPTY,		MSG_ORIG(MSG_FLG_SG_EMPTY) },
67 		{ FLG_SG_KEY,		MSG_ORIG(MSG_FLG_SG_KEY) },
68 		{ FLG_SG_DISABLED,	MSG_ORIG(MSG_FLG_SG_DISABLED) },
69 		{ FLG_SG_PHREQ,		MSG_ORIG(MSG_FLG_SG_PHREQ) },
70 		{ 0,			0 }
71 	};
72 	static CONV_EXPN_FIELD_ARG conv_arg = { string, sizeof (string), vda };
73 
74 	if (flags == 0)
75 		return (MSG_ORIG(MSG_GBL_ZERO));
76 
77 	conv_arg.oflags = conv_arg.rflags = flags;
78 	(void) conv_expn_field(&conv_arg);
79 
80 	return ((const char *)string);
81 }
82