(getrlimit): Set strong and weak names properly.
[glibc/history.git] / sunrpc / clnt_perr.c
blobd756cb12bab4e2e372405117003d00da91c06386
1 /* @(#)clnt_perror.c 2.1 88/07/29 4.0 RPCSRC */
2 /*
3 * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
4 * unrestricted use provided that this legend is included on all tape
5 * media and as a part of the software program in whole or part. Users
6 * may copy or modify Sun RPC without charge, but are not authorized
7 * to license or distribute it to anyone else except as part of a product or
8 * program developed by the user.
10 * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
11 * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
12 * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
14 * Sun RPC is provided with no support and without any obligation on the
15 * part of Sun Microsystems, Inc. to assist in its use, correction,
16 * modification or enhancement.
18 * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
19 * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
20 * OR ANY PART THEREOF.
22 * In no event will Sun Microsystems, Inc. be liable for any lost revenue
23 * or profits or other special, indirect and consequential damages, even if
24 * Sun has been advised of the possibility of such damages.
26 * Sun Microsystems, Inc.
27 * 2550 Garcia Avenue
28 * Mountain View, California 94043
30 #if !defined(lint) && defined(SCCSIDS)
31 static char sccsid[] = "@(#)clnt_perror.c 1.15 87/10/07 Copyr 1984 Sun Micro";
32 #endif
35 * clnt_perror.c
37 * Copyright (C) 1984, Sun Microsystems, Inc.
40 #include <stdio.h>
41 #include <string.h>
42 #include <rpc/types.h>
43 #include <rpc/auth.h>
44 #include <rpc/clnt.h>
46 #ifdef USE_IN_LIBIO
47 # include <libio/iolibio.h>
48 # define fputs(s, f) _IO_fputs (s, f)
49 #endif
51 static char *auth_errmsg (enum auth_stat stat) internal_function;
53 static char *buf;
55 static char *
56 _buf (void)
58 if (buf == NULL)
59 buf = (char *) malloc (256);
60 return buf;
64 * Print reply error info
66 char *
67 clnt_sperror (CLIENT * rpch, const char *msg)
69 char buf[1024];
70 struct rpc_err e;
71 char *err;
72 char *str = _buf ();
73 char *strstart = str;
74 int len;
76 if (str == NULL)
77 return NULL;
78 CLNT_GETERR (rpch, &e);
80 len = sprintf (str, "%s: ", msg);
81 str += len;
83 str = stpcpy (str, clnt_sperrno (e.re_status));
85 switch (e.re_status)
87 case RPC_SUCCESS:
88 case RPC_CANTENCODEARGS:
89 case RPC_CANTDECODERES:
90 case RPC_TIMEDOUT:
91 case RPC_PROGUNAVAIL:
92 case RPC_PROCUNAVAIL:
93 case RPC_CANTDECODEARGS:
94 case RPC_SYSTEMERROR:
95 case RPC_UNKNOWNHOST:
96 case RPC_UNKNOWNPROTO:
97 case RPC_PMAPFAILURE:
98 case RPC_PROGNOTREGISTERED:
99 case RPC_FAILED:
100 break;
102 case RPC_CANTSEND:
103 case RPC_CANTRECV:
104 len = sprintf (str, "; errno = %s", __strerror_r (e.re_errno,
105 buf, sizeof buf));
106 str += len;
107 break;
109 case RPC_VERSMISMATCH:
110 len= sprintf (str, _("; low version = %lu, high version = %lu"),
111 e.re_vers.low, e.re_vers.high);
112 str += len;
113 break;
115 case RPC_AUTHERROR:
116 err = auth_errmsg (e.re_why);
117 str = stpcpy (str, _ ("; why = "));
118 if (err != NULL)
120 str = stpcpy (str, err);
122 else
124 len = sprintf (str, _("(unknown authentication error - %d)"),
125 (int) e.re_why);
126 str += len;
128 break;
130 case RPC_PROGVERSMISMATCH:
131 len = sprintf (str, _("; low version = %lu, high version = %lu"),
132 e.re_vers.low, e.re_vers.high);
133 str += len;
134 break;
136 default: /* unknown */
137 len = sprintf (str, "; s1 = %lu, s2 = %lu", e.re_lb.s1, e.re_lb.s2);
138 str += len;
139 break;
141 *str = '\n';
142 *++str = '\0';
143 return (strstart);
146 void
147 clnt_perror (CLIENT * rpch, const char *msg)
149 (void) fputs (clnt_sperror (rpch, msg), stderr);
153 struct rpc_errtab
155 enum clnt_stat status;
156 const char *message;
159 static const struct rpc_errtab rpc_errlist[] =
161 {RPC_SUCCESS,
162 N_("RPC: Success")},
163 {RPC_CANTENCODEARGS,
164 N_("RPC: Can't encode arguments")},
165 {RPC_CANTDECODERES,
166 N_("RPC: Can't decode result")},
167 {RPC_CANTSEND,
168 N_("RPC: Unable to send")},
169 {RPC_CANTRECV,
170 N_("RPC: Unable to receive")},
171 {RPC_TIMEDOUT,
172 N_("RPC: Timed out")},
173 {RPC_VERSMISMATCH,
174 N_("RPC: Incompatible versions of RPC")},
175 {RPC_AUTHERROR,
176 N_("RPC: Authentication error")},
177 {RPC_PROGUNAVAIL,
178 N_("RPC: Program unavailable")},
179 {RPC_PROGVERSMISMATCH,
180 N_("RPC: Program/version mismatch")},
181 {RPC_PROCUNAVAIL,
182 N_("RPC: Procedure unavailable")},
183 {RPC_CANTDECODEARGS,
184 N_("RPC: Server can't decode arguments")},
185 {RPC_SYSTEMERROR,
186 N_("RPC: Remote system error")},
187 {RPC_UNKNOWNHOST,
188 N_("RPC: Unknown host")},
189 {RPC_UNKNOWNPROTO,
190 N_("RPC: Unknown protocol")},
191 {RPC_PMAPFAILURE,
192 N_("RPC: Port mapper failure")},
193 {RPC_PROGNOTREGISTERED,
194 N_("RPC: Program not registered")},
195 {RPC_FAILED,
196 N_("RPC: Failed (unspecified error)")}
201 * This interface for use by clntrpc
203 char *
204 clnt_sperrno (enum clnt_stat stat)
206 size_t i;
208 for (i = 0; i < sizeof (rpc_errlist) / sizeof (struct rpc_errtab); i++)
210 if (rpc_errlist[i].status == stat)
212 return _(rpc_errlist[i].message);
215 return _("RPC: (unknown error code)");
218 void
219 clnt_perrno (enum clnt_stat num)
221 (void) fputs (clnt_sperrno (num), stderr);
225 char *
226 clnt_spcreateerror (const char *msg)
228 char buf[1024];
229 char *str = _buf ();
230 char *cp;
231 int len;
233 if (str == NULL)
234 return NULL;
235 len = sprintf (str, "%s: ", msg);
236 cp = str + len;
237 cp = stpcpy (cp, clnt_sperrno (rpc_createerr.cf_stat));
238 switch (rpc_createerr.cf_stat)
240 case RPC_PMAPFAILURE:
241 cp = stpcpy (stpcpy (cp, " - "),
242 clnt_sperrno (rpc_createerr.cf_error.re_status));
243 break;
245 case RPC_SYSTEMERROR:
246 cp = stpcpy (stpcpy (cp, " - "),
247 __strerror_r (rpc_createerr.cf_error.re_errno,
248 buf, sizeof buf));
249 break;
250 default:
251 break;
253 *cp = '\n';
254 *++cp = '\0';
255 return str;
258 void
259 clnt_pcreateerror (const char *msg)
261 (void) fputs (clnt_spcreateerror (msg), stderr);
264 struct auth_errtab
266 enum auth_stat status;
267 const char *message;
270 static const struct auth_errtab auth_errlist[] =
272 {AUTH_OK,
273 N_("Authentication OK")},
274 {AUTH_BADCRED,
275 N_("Invalid client credential")},
276 {AUTH_REJECTEDCRED,
277 N_("Server rejected credential")},
278 {AUTH_BADVERF,
279 N_("Invalid client verifier")},
280 {AUTH_REJECTEDVERF,
281 N_("Server rejected verifier")},
282 {AUTH_TOOWEAK,
283 N_("Client credential too weak")},
284 {AUTH_INVALIDRESP,
285 N_("Invalid server verifier")},
286 {AUTH_FAILED,
287 N_("Failed (unspecified error)")},
290 static char *
291 internal_function
292 auth_errmsg (enum auth_stat stat)
294 size_t i;
296 for (i = 0; i < sizeof (auth_errlist) / sizeof (struct auth_errtab); i++)
298 if (auth_errlist[i].status == stat)
300 return _(auth_errlist[i].message);
303 return NULL;