xref: /titanic_41/usr/src/cmd/sgs/libconv/common/group.c (revision aa59c4cb15a6ac5d4e585dadf7a055b580abf579)
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 2007 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 #pragma ident	"%Z%%M%	%I%	%E% SMI"
27 
28 #include	<string.h>
29 #include	"rtld.h"
30 #include	"_conv.h"
31 #include	"group_msg.h"
32 
33 #define	HDLSZ	CONV_EXPN_FIELD_DEF_PREFIX_SIZE + \
34 		MSG_GPH_ZERO_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
35 		MSG_GPH_LDSO_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
36 		MSG_GPH_FIRST_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
37 		MSG_GPH_PARENT_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
38 		MSG_GPH_FILTEE_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
39 		MSG_GPH_INITIAL_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
40 		CONV_INV_STRSIZE	+ CONV_EXPN_FIELD_DEF_SUFFIX_SIZE
41 
42 /*
43  * String conversion routine for Grp_hdl flags.
44  */
45 const char *
46 conv_grphdl_flags(uint_t flags)
47 {
48 	static char	string[HDLSZ];
49 	static Val_desc vda[] = {
50 		{ GPH_ZERO,		MSG_ORIG(MSG_GPH_ZERO) },
51 		{ GPH_LDSO,		MSG_ORIG(MSG_GPH_LDSO) },
52 		{ GPH_FIRST,		MSG_ORIG(MSG_GPH_FIRST) },
53 		{ GPH_PARENT,		MSG_ORIG(MSG_GPH_PARENT) },
54 		{ GPH_FILTEE,		MSG_ORIG(MSG_GPH_FILTEE) },
55 		{ GPH_INITIAL,		MSG_ORIG(MSG_GPH_INITIAL) },
56 		{ 0,			0 }
57 	};
58 	static CONV_EXPN_FIELD_ARG conv_arg = { string, sizeof (string), vda };
59 
60 	if (flags == 0)
61 		return (MSG_ORIG(MSG_GBL_NULL));
62 
63 	conv_arg.oflags = conv_arg.rflags = flags;
64 	(void) conv_expn_field(&conv_arg);
65 
66 	return ((const char *)string);
67 }
68 
69 #define	DESCSZ	CONV_EXPN_FIELD_DEF_PREFIX_SIZE + \
70 		MSG_GPD_AVAIL_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
71 		MSG_GPD_ADDEPS_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
72 		MSG_GPD_PARENT_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
73 		MSG_GPD_FILTER_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
74 		MSG_GPD_REMOVE_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
75 		CONV_INV_STRSIZE	+ CONV_EXPN_FIELD_DEF_SUFFIX_SIZE
76 /*
77  * String conversion routine for Grp_desc flags.
78  */
79 const char *
80 conv_grpdesc_flags(uint_t flags)
81 {
82 	static char	string[DESCSZ];
83 	static Val_desc vda[] = {
84 		{ GPD_AVAIL,		MSG_ORIG(MSG_GPD_AVAIL) },
85 		{ GPD_ADDEPS,		MSG_ORIG(MSG_GPD_ADDEPS) },
86 		{ GPD_PARENT,		MSG_ORIG(MSG_GPD_PARENT) },
87 		{ GPD_FILTER,		MSG_ORIG(MSG_GPD_FILTER) },
88 		{ GPD_REMOVE,		MSG_ORIG(MSG_GPD_REMOVE) },
89 		{ 0,			0 }
90 	};
91 	static CONV_EXPN_FIELD_ARG conv_arg = { string, sizeof (string), vda };
92 
93 	if (flags == 0)
94 		return (MSG_ORIG(MSG_GBL_NULL));
95 
96 	conv_arg.oflags = conv_arg.rflags = flags;
97 	(void) conv_expn_field(&conv_arg);
98 
99 	return ((const char *)string);
100 }
101