xref: /titanic_51/usr/src/common/ucode/mkerrno.sh (revision 2449e17f82f6097fd2c665b64723e31ceecbeca6)
1*2449e17fSsherrym#!/bin/sh
2*2449e17fSsherrym#
3*2449e17fSsherrym# CDDL HEADER START
4*2449e17fSsherrym#
5*2449e17fSsherrym# The contents of this file are subject to the terms of the
6*2449e17fSsherrym# Common Development and Distribution License (the "License").
7*2449e17fSsherrym# You may not use this file except in compliance with the License.
8*2449e17fSsherrym#
9*2449e17fSsherrym# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*2449e17fSsherrym# or http://www.opensolaris.org/os/licensing.
11*2449e17fSsherrym# See the License for the specific language governing permissions
12*2449e17fSsherrym# and limitations under the License.
13*2449e17fSsherrym#
14*2449e17fSsherrym# When distributing Covered Code, include this CDDL HEADER in each
15*2449e17fSsherrym# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*2449e17fSsherrym# If applicable, add the following below this CDDL HEADER, with the
17*2449e17fSsherrym# fields enclosed by brackets "[]" replaced with your own identifying
18*2449e17fSsherrym# information: Portions Copyright [yyyy] [name of copyright owner]
19*2449e17fSsherrym#
20*2449e17fSsherrym# CDDL HEADER END
21*2449e17fSsherrym#
22*2449e17fSsherrym# Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
23*2449e17fSsherrym# Use is subject to license terms.
24*2449e17fSsherrym#
25*2449e17fSsherrym#ident	"%Z%%M%	%I%	%E% SMI"
26*2449e17fSsherrym
27*2449e17fSsherrym
28*2449e17fSsherrymecho "/*
29*2449e17fSsherrym * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
30*2449e17fSsherrym * Use is subject to license terms.
31*2449e17fSsherrym */
32*2449e17fSsherrym
33*2449e17fSsherrym#include <locale.h>
34*2449e17fSsherrym#include <libintl.h>
35*2449e17fSsherrym#include <ucode/ucode_errno.h>
36*2449e17fSsherrym#include <stdlib.h>
37*2449e17fSsherrym
38*2449e17fSsherrymstatic const struct {
39*2449e17fSsherrym\tchar *uce_name;\t\t/* error name */
40*2449e17fSsherrym\tchar *uce_msg;\t\t/* error message */
41*2449e17fSsherrym} _ucode_errstr[] = {
42*2449e17fSsherrym/*
43*2449e17fSsherrym * TRANSLATION_NOTE
44*2449e17fSsherrym * The following message strings that begin with EM_ do not
45*2449e17fSsherrym * need to be translated.
46*2449e17fSsherrym */
47*2449e17fSsherrym"
48*2449e17fSsherrympattern='^	\(EM_[A-Z0-9_]*\),*'
49*2449e17fSsherrymreplace='	{ "\1", '
50*2449e17fSsherrymopen='	\/\* '
51*2449e17fSsherrymopenrepl='"'
52*2449e17fSsherrymclose=' \*\/$'
53*2449e17fSsherrymcloserepl='" },'
54*2449e17fSsherrym( sed -n "s/$pattern/$replace/p" < $1 | sed -n "s/$open/$openrepl/p" |
55*2449e17fSsherrym    sed -n "s/$close/$closerepl/p" ) || exit 1
56*2449e17fSsherrym
57*2449e17fSsherrymecho "\
58*2449e17fSsherrym};\n\
59*2449e17fSsherrym\n\
60*2449e17fSsherrymstatic int _ucode_nerrno = sizeof (_ucode_errstr) / sizeof (_ucode_errstr[0]);\n\
61*2449e17fSsherrym\n\
62*2449e17fSsherrymconst char *
63*2449e17fSsherrymucode_strerror(ucode_errno_t errno)
64*2449e17fSsherrym{
65*2449e17fSsherrym	return (errno < 0 || errno >= _ucode_nerrno ?
66*2449e17fSsherrym	     gettext(\"unknown error\") :
67*2449e17fSsherrym	     gettext(_ucode_errstr[errno].uce_msg));
68*2449e17fSsherrym}
69*2449e17fSsherrym
70*2449e17fSsherrymconst char *
71*2449e17fSsherrymucode_errname(ucode_errno_t errno)
72*2449e17fSsherrym{
73*2449e17fSsherrym	return (errno < 0 || errno >= _ucode_nerrno ? NULL :
74*2449e17fSsherrym	     gettext(_ucode_errstr[errno].uce_name));
75*2449e17fSsherrym}"
76*2449e17fSsherrym
77*2449e17fSsherrymexit 0
78