Update.
[glibc.git] / nis / nis_error.c
blobced0f716fd5efc1d81eef141bedc3693eb37ad5d
1 /* Copyright (c) 1997 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 Library General Public License as
7 published by the Free Software Foundation; either version 2 of the
8 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 Library General Public License for more details.
15 You should have received a copy of the GNU Library General Public
16 License along with the GNU C Library; see the file COPYING.LIB. If not,
17 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. */
20 #include <errno.h>
21 #include <syslog.h>
22 #include <string.h>
23 #include <rpcsvc/nis.h>
26 static const char *nis_errlist[] =
28 N_("Success"),
29 N_("Probable success"),
30 N_("Not found"),
31 N_("Probably not found"),
32 N_("Cache expired"),
33 N_("NIS+ servers unreachable"),
34 N_("Unknown object"),
35 N_("Server busy, try again"),
36 N_("Generic system error"),
37 N_("First/Next chain broken"),
38 N_("Permission denied"),
39 N_("Not owner"),
40 N_("Name not served by this server"),
41 N_("Server out of memory"),
42 N_("Object with same name exists"),
43 N_("Not master server for this domain"),
44 N_("Invalid Object for operation"),
45 N_("Malformed Name, or illegal name"),
46 N_("Unable to create callback"),
47 N_("Results Sent to callback proc"),
48 N_("Not Found, no such name"),
49 N_("Name/entry isn't unique"),
50 N_("Modification failed"),
51 N_("Database for table does not exist"),
52 N_("Entry/Table type mismatch"),
53 N_("Link Points to illegal name"),
54 N_("Partial Success"),
55 N_("Too Many Attributes"),
56 N_("Error in RPC subsystem"),
57 N_("Missing or malformed attribute"),
58 N_("Named object is not searchable"),
59 N_("Error while talking to callback proc"),
60 N_("Non NIS+ namespace encountered"),
61 N_("Illegal object type for operation"),
62 N_("Passed object is not the same object on server"),
63 N_("Modify operation failed"),
64 N_("Query illegal for named table"),
65 N_("Attempt to remove a non-empty table"),
66 N_("Error in accessing NIS+ cold start file. Is NIS+ installed?"),
67 N_("Full resync required for directory"),
68 N_("NIS+ operation failed"),
69 N_("NIS+ service is unavailable or not installed"),
70 N_("Yes, 42 is the meaning of life"),
71 N_("Unable to authenticate NIS+ server"),
72 N_("Unable to authenticate NIS+ client"),
73 N_("No file space on server"),
74 N_("Unable to create process on server"),
75 N_("Master server busy, full dump rescheduled.")
78 const char *
79 nis_sperrno (const nis_error status)
81 if (status >= (sizeof (nis_errlist) / sizeof (nis_errlist[0])))
82 return "???";
83 else
84 return gettext (nis_errlist[status]);
87 void
88 nis_perror (const nis_error status, const char *label)
90 fprintf (stderr, "%s: %s\n", label, nis_sperrno (status));
93 void
94 nis_lerror (const nis_error status, const char *label)
96 syslog (LOG_ERR, "%s: %s", label, nis_sperrno (status));
99 char *
100 nis_sperror_r (const nis_error status, const char *label,
101 char *buffer, size_t buflen)
103 const char *cptr;
105 cptr = nis_sperrno (status);
107 if ((strlen (cptr) + strlen (label) + 3) > buflen)
109 errno = ERANGE;
110 return NULL;
113 sprintf (buffer, "%s: %s", label, cptr);
115 return buffer;
118 char *
119 nis_sperror (const nis_error status, const char *label)
121 static char buffer[NIS_MAXNAMELEN +1];
123 return nis_sperror_r (status, label, buffer, sizeof (buffer));