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
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.
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]
24 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
25 * Use is subject to license terms.
28 /* Copyright (c) 1988 AT&T */
29 /* All Rights Reserved */
32 #pragma ident "%Z%%M% %I% %E% SMI"
35 * Routines to print and adjust options on
47 * Internal form, to handle both errtext() and _errmsg()
51 __errtext(int severity
, char *format
, va_list ap
)
53 int puterrno
= 0; /* true if an errno msg was printed */
55 Err
.severity
= severity
;
56 errverb(getenv("ERRVERB"));
57 errbefore(Err
.severity
, format
, ap
);
59 if (Err
.severity
== EIGNORE
)
63 (void) fputc('\07', stderr
);
64 if (Err
.vprefix
&& Err
.prefix
) {
65 (void) fputs(Err
.prefix
, stderr
);
66 (void) fputc(' ', stderr
);
70 (Err
.envsource
= getenv("ERRSOURCE"))) {
71 (void) fprintf(stderr
, "%s: ", Err
.envsource
);
74 if (Err
.vsource
&& Err
.source
) {
75 (void) fprintf(stderr
, "%s: ", Err
.source
);
80 for (e
= Err
.sevmsg
; *e
; e
++)
82 if (Err
.severity
< (e
- Err
.sevmsg
))
83 (void) fputs(Err
.sevmsg
[Err
.severity
], stderr
);
85 (void) fputs("<UNKNOWN>", stderr
);
89 if (Err
.vsyserr
&& ((int)format
== EERRNO
)) {
90 (void) fflush(stderr
);
94 (void) vfprintf(stderr
, format
, ap
);
95 (void) fputs("\n", stderr
);
99 if ((errno
&& ((int)format
!= EERRNO
)) &&
100 (Err
.vsyserr
== EYES
|| (Err
.vsyserr
== EDEF
&&
101 (Err
.severity
== EHALT
|| Err
.severity
== EERROR
)))) {
102 (void) fputc('\t', stderr
);
103 (void) fflush(stderr
);
110 (void) fputc('\t', stderr
);
112 (void) fputs("HELP FACILITY KEY: ", stderr
);
114 (void) fputs(Err
.tagstr
, stderr
);
116 (void) fprintf(stderr
, ", line %d", Err
.tagnum
);
118 (void) fprintf(stderr
, "\tUXerrno%d", errno
);
119 (void) fputc('\n', stderr
);
122 if ((Err
.vtext
|| Err
.vtag
) &&
123 Err
.vfix
&& Err
.tofix
&& !Err
.tagnum
)
124 (void) fprintf(stderr
, "To Fix:\t%s\n", Err
.tofix
);
126 erraction(errafter(Err
.severity
, format
, ap
));
131 * external form, used by errmsg() macro, when tag is not permanently
135 errtext(int severity
, char *format
, ...)
139 va_start(ap
, format
);
140 __errtext(severity
, format
, ap
);
146 * external form, used when tag is permanently assigned.
149 _errmsg(char *tag
, int severity
, char *format
, ...)
155 va_start(ap
, format
);
156 __errtext(severity
, format
, ap
);
165 static char space
[] = ",\t\n";
169 (void) strcpy(buf
, s
);
170 for (token
= errstrtok(buf
, space
); token
;
171 token
= errstrtok((char *)0, space
)) {
172 if (strcmp(token
, "nochange") == 0) {
180 } else if (strcmp(token
, "silent") == 0) {
189 } else if (strcmp(token
, "verbose") == 0) {
198 } else if (strcmp(token
, "expert") == 0) {
207 } else if (strcmp(token
, "bell") == 0) {
209 } else if (strcmp(token
, "nobell") == 0) {
211 } else if (strcmp(token
, "tag") == 0) {
213 } else if (strcmp(token
, "notag") == 0) {
215 } else if (strcmp(token
, "text") == 0) {
217 } else if (strcmp(token
, "notext") == 0) {
219 } else if (strcmp(token
, "tofix") == 0) {
221 } else if (strcmp(token
, "notofix") == 0) {
223 } else if (strcmp(token
, "syserr") == 0) {
225 } else if (strcmp(token
, "nosyserr") == 0) {
227 } else if (strcmp(token
, "defsyserr") == 0) {
229 } else if (strcmp(token
, "source")) {
231 } else if (strcmp(token
, "nosource") == 0) {
233 } else if (strcmp(token
, "sevmsg") == 0) {
235 } else if (strcmp(token
, "nosevmsg") == 0) {
237 } else if (strcmp(token
, "prefix") == 0) {
239 } else if (strcmp(token
, "noprefix") == 0) {