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.
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.
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]
22 * Copyright(c) 1988 AT&T
25 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
26 * Use is subject to license terms.
30 static const char *msg
[] = {
32 "%s: malloc memory allocation failure.\n",
34 "%s: multiple -n only allowed for -d option.\n",
36 "%s: elf_version() failed - libelf.a out of date.\n",
38 "%s: %s: cannot open file.\n",
40 "%s: libelf error.\n",
42 "%s: %s: cannot open temporary file\n",
44 "%s: %s: write system failure: %s: file not manipulated.\n",
46 "%s: %s: malformed archive at %ld\n",
48 "%s: %s: invalid file type\n",
49 /* NOT_MANIPULATED_ERROR */
50 "%s: %s: file not manipulated\n",
51 /* WRN_MANIPULATED_ERROR */
52 "%s: WARNING: %s: Cannot manipulate file.\n",
53 /* NO_SECT_TABLE_ERROR */
54 "%s: %s: no section header table.\n",
56 "%s: %s: trouble reading file\n",
58 "%s: %s: read system failure: %s: file not manipulated.\n",
59 /* WRITE_MANI_ERROR */
60 "%s: %s: write system failure: %s: file not manipulated.\n",
61 /* LSEEK_MANI_ERROR */
62 "%s: %s: lseek system failure: %s: file not manipulated.\n",
63 /* SYM_TAB_AR_ERROR */
64 "%s: WARNING: %s: symbol table deleted from archive \n",
66 "execute `ar -ts %s` to restore symbol table.\n",
68 "%s: %s: read system failure\n",
69 /* OPEN_WRITE_ERROR */
70 "%s: %s: can't open file for writing\n",
72 "%s: %s: Cannot print contents of a NOBITS section (%s)\n",
73 /* ACT_DELETE1_ERROR */
74 "%s: %s: Warning: Cannot delete section (%s)\n\t\tfrom a segment.\n",
75 /* ACT_DELETE2_ERROR */
76 "%s: %s: Warning: Cannot delete section (%s)\n"
77 "\t\tbecause its relocation section (%s) is in a segment\n",
78 /* ACT_APPEND1_ERROR */
79 "%s: %s: Cannot append to a NOBITS section (%s)\n",
80 /* ACT_APPEND2_ERROR */
81 "%s: %s: Warning: Cannot append to section (%s)\n\t\tin a segment\n",
82 /* ACT_COMPRESS1_ERROR */
83 "%s: %s: Cannot compress a NOBITS section (%s)\n",
84 /* ACT_COMPRESS2_ERROR */
85 "%s: %s: Warning: Cannot compress a section (%s)\n\t\tin a segment\n",
87 "%s: %s: access error.\n",
88 /* WRITE_MANI_ERROR2 */
89 "%s: /ftruncate/lseek/write system failure: %s: file may be destroyed.\n"
93 error_message(int args
, ...)
96 char *message
= gettext((char *)msg
[mes
]);
102 flag
= va_arg(ap
, int);
103 sys_mes
= va_arg(ap
, char *);
112 (void) fprintf(stderr
, message
, va_arg(ap
, char *));
116 case OPEN_TEMP_ERROR
:
117 case FILE_TYPE_ERROR
:
118 case NOT_MANIPULATED_ERROR
:
119 case WRN_MANIPULATED_ERROR
:
120 case NO_SECT_TABLE_ERROR
:
122 case SYM_TAB_AR_ERROR
:
124 case OPEN_WRITE_ERROR
:
126 (void) fprintf(stderr
, message
, va_arg(ap
, char *),
130 case READ_MANI_ERROR
:
131 case WRITE_MANI_ERROR
:
132 case LSEEK_MANI_ERROR
:
133 case ACT_PRINT_ERROR
:
134 case ACT_DELETE1_ERROR
:
135 case ACT_APPEND1_ERROR
:
136 case ACT_APPEND2_ERROR
:
137 case ACT_COMPRESS1_ERROR
:
138 case ACT_COMPRESS2_ERROR
: {
139 char *a
= va_arg(ap
, char *);
140 char *b
= va_arg(ap
, char *);
141 char *c
= va_arg(ap
, char *);
143 (void) fprintf(stderr
, message
, a
, b
, c
);
146 case ACT_DELETE2_ERROR
: {
147 char *a
= va_arg(ap
, char *);
148 char *b
= va_arg(ap
, char *);
149 char *c
= va_arg(ap
, char *);
150 char *d
= va_arg(ap
, char *);
152 (void) fprintf(stderr
, message
, a
, b
, c
, d
);
155 case GETARHDR_ERROR
: {
156 char *a
= va_arg(ap
, char *);
157 char *b
= va_arg(ap
, char *);
158 long c
= va_arg(ap
, long);
160 (void) fprintf(stderr
, message
, a
, b
, c
);
164 (void) fprintf(stderr
, "internal error: error_message(%d)\n",
169 if (flag
!= PLAIN_ERROR
)
170 (void) fprintf(stderr
, "\t%s\n", sys_mes
);