xref: /titanic_51/usr/src/cmd/sgs/libconv/common/segments.c (revision bdfc6d18da790deeec2e0eb09c625902defe2498)
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 2004 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	"segments_msg.h"
34 
35 #define	SEGSZ	MSG_GBL_OSQBRKT_SIZE + \
36 		MSG_FLG_SG_VADDR_SIZE + \
37 		MSG_FLG_SG_PADDR_SIZE + \
38 		MSG_FLG_SG_LENGTH_SIZE + \
39 		MSG_FLG_SG_ALIGN_SIZE + \
40 		MSG_FLG_SG_ROUND_SIZE + \
41 		MSG_FLG_SG_FLAGS_SIZE + \
42 		MSG_FLG_SG_TYPE_SIZE + \
43 		MSG_FLG_SG_ORDER_SIZE + \
44 		MSG_FLG_SG_EMPTY_SIZE + \
45 		MSG_FLG_SG_NOHDR_SIZE + \
46 		MSG_GBL_CSQBRKT_SIZE
47 
48 const char *
49 conv_segaflg_str(uint_t flags)
50 {
51 	static	char	string[SEGSZ] = { '\0' };
52 
53 	if (flags == 0)
54 		return (MSG_ORIG(MSG_GBL_ZERO));
55 	else {
56 		(void) strcpy(string, MSG_ORIG(MSG_GBL_OSQBRKT));
57 		if (flags & FLG_SG_VADDR)
58 			(void) strcat(string, MSG_ORIG(MSG_FLG_SG_VADDR));
59 		if (flags & FLG_SG_PADDR)
60 			(void) strcat(string, MSG_ORIG(MSG_FLG_SG_PADDR));
61 		if (flags & FLG_SG_LENGTH)
62 			(void) strcat(string, MSG_ORIG(MSG_FLG_SG_LENGTH));
63 		if (flags & FLG_SG_ALIGN)
64 			(void) strcat(string, MSG_ORIG(MSG_FLG_SG_ALIGN));
65 		if (flags & FLG_SG_ROUND)
66 			(void) strcat(string, MSG_ORIG(MSG_FLG_SG_ROUND));
67 		if (flags & FLG_SG_FLAGS)
68 			(void) strcat(string, MSG_ORIG(MSG_FLG_SG_FLAGS));
69 		if (flags & FLG_SG_TYPE)
70 			(void) strcat(string, MSG_ORIG(MSG_FLG_SG_TYPE));
71 		if (flags & FLG_SG_ORDER)
72 			(void) strcat(string, MSG_ORIG(MSG_FLG_SG_ORDER));
73 		if (flags & FLG_SG_EMPTY)
74 			(void) strcat(string, MSG_ORIG(MSG_FLG_SG_EMPTY));
75 		if (flags & FLG_SG_NOHDR)
76 			(void) strcat(string, MSG_ORIG(MSG_FLG_SG_NOHDR));
77 		(void) strcat(string, MSG_ORIG(MSG_GBL_CSQBRKT));
78 
79 		return ((const char *)string);
80 	}
81 }
82