xref: /illumos-gate/usr/src/cmd/sgs/libelf/misc/nplist.c (revision 03100a6332bd4edc7a53091fcf7c9a7131bcdaa7)
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) 1988 AT&T
24  *	  All Rights Reserved
25  *
26  *
27  *	Copyright (c) 1999 by Sun Microsystems, Inc.
28  *	All rights reserved.
29  */
30 #pragma ident	"%Z%%M%	%I%	%E% SMI" 	/* SVr4.0 1.2	*/
31 
32 #include	"elf_dem.h"
33 #include	<string.h>
34 #include	"msg.h"
35 
36 struct name_pair {
37 #ifdef __lint
38 	char	* s1, * s2;
39 #else
40 	int	s1, s2;
41 #endif
42 };
43 
44 struct name_pair nplist[100] = {
45 	/* MSG_ORIG(MSG_STR_LT)		MSG_ORIG(MSG_STR_OPNANGBRAK) */
46 	{ MSG_STR_LT,	MSG_STR_OPNANGBRAK },
47 	/* MSG_ORIG(MSG_STR_LS)		MSG_ORIG(MSG_STR_DBLOPNANGBRAK) */
48 	{ MSG_STR_LS,	MSG_STR_DBLOPNANGBRAK },
49 	/* MSG_ORIG(MSG_STR_DV)		MSG_ORIG(MSG_STR_SLASH) */
50 	{ MSG_STR_DV,	MSG_STR_SLASH },
51 	/* MSG_ORIG(MSG_STR_GT)		MSG_ORIG(MSG_STR_CLOANGBRAK) */
52 	{ MSG_STR_GT,	MSG_STR_CLOANGBRAK },
53 	/* MSG_ORIG(MSG_STR_RS)		MSG_ORIG(MSG_STR_DBLCLOANGBRAK) */
54 	{ MSG_STR_RS,	MSG_STR_DBLCLOANGBRAK },
55 	/* MSG_ORIG(MSG_STR_MD)		MSG_ORIG(MSG_STR_PERCENT) */
56 	{ MSG_STR_MD,	MSG_STR_PERCENT },
57 	/* MSG_ORIG(MSG_STR_LE)		MSG_ORIG(MSG_STR_OPNANGBRAKEQU) */
58 	{ MSG_STR_LE,	MSG_STR_OPNANGBRAKEQU },
59 	/* MSG_ORIG(MSG_STR_ML)		MSG_ORIG(MSG_STR_STAR) */
60 	{ MSG_STR_ML,	MSG_STR_STAR },
61 	/* MSG_ORIG(MSG_STR_PL)		MSG_ORIG(MSG_STR_PLUS) */
62 	{ MSG_STR_PL,	MSG_STR_PLUS },
63 	/* MSG_ORIG(MSG_STR_GE)		MSG_ORIG(MSG_STR_CLOANGBRAKEQU) */
64 	{ MSG_STR_GE,	MSG_STR_CLOANGBRAKEQU },
65 	/* MSG_ORIG(MSG_STR_AD)		MSG_ORIG(MSG_STR_AMP) */
66 	{ MSG_STR_AD,	MSG_STR_AMP },
67 	/* MSG_ORIG(MSG_STR_MI)		MSG_ORIG(MSG_STR_MINUS) */
68 	{ MSG_STR_MI,	MSG_STR_MINUS },
69 	/* MSG_ORIG(MSG_STR_NE)		MSG_ORIG(MSG_STR_BANGEQU) */
70 	{ MSG_STR_NE,	MSG_STR_BANGEQU },
71 	/* MSG_ORIG(MSG_STR_OR)		MSG_ORIG(MSG_STR_PIPE) */
72 	{ MSG_STR_OR,	MSG_STR_PIPE },
73 	/* MSG_ORIG(MSG_STR_ER)		MSG_ORIG(MSG_STR_CARAT) */
74 	{ MSG_STR_ER,	MSG_STR_CARAT },
75 	/* MSG_ORIG(MSG_STR_AA)		MSG_ORIG(MSG_STR_DBLAMP) */
76 	{ MSG_STR_AA,	MSG_STR_DBLAMP },
77 	/* MSG_ORIG(MSG_STR_OO)		MSG_ORIG(MSG_STR_DBLPIPE) */
78 	{ MSG_STR_OO,	MSG_STR_DBLPIPE },
79 	/* MSG_ORIG(MSG_STR_AS)		MSG_ORIG(MSG_STR_EQU) */
80 	{ MSG_STR_AS,	MSG_STR_EQU },
81 	/* MSG_ORIG(MSG_STR_APL)	MSG_ORIG(MSG_STR_PLUSEQU) */
82 	{ MSG_STR_APL,	MSG_STR_PLUSEQU },
83 	/* MSG_ORIG(MSG_STR_AMI)	MSG_ORIG(MSG_STR_MINUSEQU) */
84 	{ MSG_STR_AMI,	MSG_STR_MINUSEQU },
85 	/* MSG_ORIG(MSG_STR_AMU)	MSG_ORIG(MSG_STR_STARTEQU) */
86 	{ MSG_STR_AMU,	MSG_STR_STARTEQU },
87 	/* MSG_ORIG(MSG_STR_ADV)	MSG_ORIG(MSG_STR_SLASHEQU) */
88 	{ MSG_STR_ADV,	MSG_STR_SLASHEQU },
89 	/* MSG_ORIG(MSG_STR_AMD)	MSG_ORIG(MSG_STR_PERCENTEQU) */
90 	{ MSG_STR_AMD,	MSG_STR_PERCENTEQU },
91 	/* MSG_ORIG(MSG_STR_AAD)	MSG_ORIG(MSG_STR_AMPEQU) */
92 	{ MSG_STR_AAD,	MSG_STR_AMPEQU },
93 	/* MSG_ORIG(MSG_STR_AOR)	MSG_ORIG(MSG_STR_PIPEEQU) */
94 	{ MSG_STR_AOR,	MSG_STR_PIPEEQU },
95 	/* MSG_ORIG(MSG_STR_AER)	MSG_ORIG(MSG_STR_CARATEQU) */
96 	{ MSG_STR_AER,	MSG_STR_CARATEQU },
97 	/* MSG_ORIG(MSG_STR_ALS)	MSG_ORIG(MSG_STR_DBLOPENABKEQU) */
98 	{ MSG_STR_ALS,	MSG_STR_DBLOPENABKEQU },
99 	/* MSG_ORIG(MSG_STR_ARS)	MSG_ORIG(MSG_STR_DBLCLOSABKEQU) */
100 	{ MSG_STR_ARS,	MSG_STR_DBLCLOSABKEQU },
101 	/* MSG_ORIG(MSG_STR_PP)		MSG_ORIG(MSG_STR_DBLPLUS) */
102 	{ MSG_STR_PP,	MSG_STR_DBLPLUS },
103 	/* MSG_ORIG(MSG_STR_MM)		MSG_ORIG(MSG_STR_DBLMINUS) */
104 	{ MSG_STR_MM,	MSG_STR_DBLMINUS },
105 	/* MSG_ORIG(MSG_STR_VC)		MSG_ORIG(MSG_STR_OPENCLOBRAK) */
106 	{ MSG_STR_VC,	MSG_STR_OPENCLOBRAK },
107 	/* MSG_ORIG(MSG_STR_CL)		MSG_ORIG(MSG_STR_OPENCLOSEPAR) */
108 	{ MSG_STR_CL,	MSG_STR_OPENCLOSEPAR },
109 	/* MSG_ORIG(MSG_STR_RF)		MSG_ORIG(MSG_STR_MINUSCLOANGBK) */
110 	{ MSG_STR_RF,	MSG_STR_MINUSCLOANGBK },
111 	/* MSG_ORIG(MSG_STR_EQ)		MSG_ORIG(MSG_STR_DBLEQU) */
112 	{ MSG_STR_EQ,	MSG_STR_DBLEQU },
113 	/* MSG_ORIG(MSG_STR_CO)		MSG_ORIG(MSG_STR_TILDE) */
114 	{ MSG_STR_CO,	MSG_STR_TILDE },
115 	/* MSG_ORIG(MSG_STR_NT)		MSG_ORIG(MSG_STR_BANG) */
116 	{ MSG_STR_NT,	MSG_STR_BANG },
117 	/* MSG_ORIG(MSG_STR_NW)		MSG_ORIG(MSG_STR_NEW) */
118 	{ MSG_STR_NW,	MSG_STR_NEW },
119 	/* MSG_ORIG(MSG_STR_DL)		MSG_ORIG(MSG_STR_DELETE) */
120 	{ MSG_STR_DL,	MSG_STR_DELETE },
121 	{ 0,		0 }
122 };
123 
124 /* This routine demangles an overloaded operator function */
125 const char *
126 findop(char * c, int * oplen)
127 {
128 	register int i, opl;
129 
130 	for (opl = 0; c[opl] && c[opl] != '_'; opl++)
131 		;
132 	*oplen = opl;
133 
134 	for (i = 0; nplist[i].s1; i++) {
135 		if (strncmp(MSG_ORIG(nplist[i].s1), c, opl) == 0)
136 			return (MSG_ORIG(nplist[i].s2));
137 	}
138 	return (0);
139 }
140