xref: /onnv-gate/usr/src/cmd/sgs/libconv/common/segments.c (revision 2352:9cdfed81bb1c)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
51618Srie  * Common Development and Distribution License (the "License").
61618Srie  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
211618Srie 
220Sstevel@tonic-gate /*
231618Srie  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
240Sstevel@tonic-gate  * Use is subject to license terms.
250Sstevel@tonic-gate  */
260Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
270Sstevel@tonic-gate 
280Sstevel@tonic-gate /*
290Sstevel@tonic-gate  * String conversion routine for segment flags.
300Sstevel@tonic-gate  */
310Sstevel@tonic-gate #include	<string.h>
321618Srie #include	<libld.h>
331618Srie #include	"_conv.h"
340Sstevel@tonic-gate #include	"segments_msg.h"
350Sstevel@tonic-gate 
36*2352Sab196087 #define	SEGSZ	CONV_EXPN_FIELD_DEF_PREFIX_SIZE + \
37*2352Sab196087 		MSG_FLG_SG_VADDR_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
38*2352Sab196087 		MSG_FLG_SG_PADDR_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
39*2352Sab196087 		MSG_FLG_SG_LENGTH_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
40*2352Sab196087 		MSG_FLG_SG_ALIGN_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
41*2352Sab196087 		MSG_FLG_SG_ROUND_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
42*2352Sab196087 		MSG_FLG_SG_FLAGS_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
43*2352Sab196087 		MSG_FLG_SG_TYPE_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
44*2352Sab196087 		MSG_FLG_SG_ORDER_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
45*2352Sab196087 		MSG_FLG_SG_NOHDR_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
46*2352Sab196087 		MSG_FLG_SG_EMPTY_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
47*2352Sab196087 		MSG_FLG_SG_KEY_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
48*2352Sab196087 		MSG_FLG_SG_DISABLED_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
49*2352Sab196087 		MSG_FLG_SG_PHREQ_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
50*2352Sab196087 		CONV_INV_STRSIZE + CONV_EXPN_FIELD_DEF_SUFFIX_SIZE
510Sstevel@tonic-gate 
520Sstevel@tonic-gate const char *
531618Srie conv_seg_flags(Half flags)
540Sstevel@tonic-gate {
551618Srie 	static char	string[SEGSZ];
561618Srie 	static Val_desc vda[] = {
571618Srie 		{ FLG_SG_VADDR,		MSG_ORIG(MSG_FLG_SG_VADDR) },
581618Srie 		{ FLG_SG_PADDR,		MSG_ORIG(MSG_FLG_SG_PADDR) },
591618Srie 		{ FLG_SG_LENGTH,	MSG_ORIG(MSG_FLG_SG_LENGTH) },
601618Srie 		{ FLG_SG_ALIGN,		MSG_ORIG(MSG_FLG_SG_ALIGN) },
611618Srie 		{ FLG_SG_ROUND,		MSG_ORIG(MSG_FLG_SG_ROUND) },
621618Srie 		{ FLG_SG_FLAGS,		MSG_ORIG(MSG_FLG_SG_FLAGS) },
631618Srie 		{ FLG_SG_TYPE,		MSG_ORIG(MSG_FLG_SG_TYPE) },
641618Srie 		{ FLG_SG_ORDER,		MSG_ORIG(MSG_FLG_SG_ORDER) },
651618Srie 		{ FLG_SG_NOHDR,		MSG_ORIG(MSG_FLG_SG_NOHDR) },
661618Srie 		{ FLG_SG_EMPTY,		MSG_ORIG(MSG_FLG_SG_EMPTY) },
671618Srie 		{ FLG_SG_KEY,		MSG_ORIG(MSG_FLG_SG_KEY) },
681618Srie 		{ FLG_SG_DISABLED,	MSG_ORIG(MSG_FLG_SG_DISABLED) },
691618Srie 		{ FLG_SG_PHREQ,		MSG_ORIG(MSG_FLG_SG_PHREQ) },
701618Srie 		{ 0,			0 }
711618Srie 	};
72*2352Sab196087 	static CONV_EXPN_FIELD_ARG conv_arg = { string, sizeof (string), vda };
730Sstevel@tonic-gate 
740Sstevel@tonic-gate 	if (flags == 0)
750Sstevel@tonic-gate 		return (MSG_ORIG(MSG_GBL_ZERO));
760Sstevel@tonic-gate 
77*2352Sab196087 	conv_arg.oflags = conv_arg.rflags = flags;
78*2352Sab196087 	(void) conv_expn_field(&conv_arg);
791618Srie 
801618Srie 	return ((const char *)string);
810Sstevel@tonic-gate }
82