1 /* Copyright (c) 1997-2013 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1997.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
23 #include <rpcsvc/nis.h>
26 #define MF(line) MF1 (line)
27 #define MF1(line) str##line
28 static const union msgstr_t
32 #define S(s) char MF(__LINE__)[sizeof (s)];
33 #include "nis_error.h"
41 #include "nis_error.h"
46 static const unsigned short int msgidx
[] =
48 #define S(s) offsetof (union msgstr_t, MF (__LINE__)),
49 #include "nis_error.h"
55 nis_sperrno (const nis_error status
)
57 if (status
>= sizeof (msgidx
) / sizeof (msgidx
[0]))
60 return gettext (msgstr
.str
+ msgidx
[status
]);
62 libnsl_hidden_def (nis_sperrno
)
65 nis_perror (const nis_error status
, const char *label
)
67 fprintf (stderr
, "%s: %s\n", label
, nis_sperrno (status
));
71 nis_lerror (const nis_error status
, const char *label
)
73 syslog (LOG_ERR
, "%s: %s", label
, nis_sperrno (status
));
77 nis_sperror_r (const nis_error status
, const char *label
,
78 char *buffer
, size_t buflen
)
80 if (snprintf (buffer
, buflen
, "%s: %s", label
, nis_sperrno (status
))
89 libnsl_hidden_def (nis_sperror_r
)
92 nis_sperror (const nis_error status
, const char *label
)
94 static char buffer
[NIS_MAXNAMELEN
+ 1];
96 return nis_sperror_r (status
, label
, buffer
, sizeof (buffer
));