]>
git.saurik.com Git - apple/libinfo.git/blob - rpc.subproj/clnt_perror.c
2 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
7 * Reserved. This file contains Original Code and/or Modifications of
8 * Original Code as defined in and that are subject to the Apple Public
9 * Source License Version 1.1 (the "License"). You may not use this file
10 * except in compliance with the License. Please obtain a copy of the
11 * License at http://www.apple.com/publicsource and read it before using
14 * The Original Code and all software distributed under the License are
15 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
19 * License for the specific language governing rights and limitations
22 * @APPLE_LICENSE_HEADER_END@
25 * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
26 * unrestricted use provided that this legend is included on all tape
27 * media and as a part of the software program in whole or part. Users
28 * may copy or modify Sun RPC without charge, but are not authorized
29 * to license or distribute it to anyone else except as part of a product or
30 * program developed by the user.
32 * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
33 * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
34 * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
36 * Sun RPC is provided with no support and without any obligation on the
37 * part of Sun Microsystems, Inc. to assist in its use, correction,
38 * modification or enhancement.
40 * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
41 * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
42 * OR ANY PART THEREOF.
44 * In no event will Sun Microsystems, Inc. be liable for any lost revenue
45 * or profits or other special, indirect and consequential damages, even if
46 * Sun has been advised of the possibility of such damages.
48 * Sun Microsystems, Inc.
50 * Mountain View, California 94043
53 #if defined(LIBC_SCCS) && !defined(lint)
54 /*static char *sccsid = "from: @(#)clnt_perror.c 1.15 87/10/07 Copyr 1984 Sun Micro";*/
55 /*static char *sccsid = "from: @(#)clnt_perror.c 2.1 88/07/29 4.0 RPCSRC";*/
56 static char *rcsid
= "$Id: clnt_perror.c,v 1.4 2003/06/23 17:24:59 majka Exp $";
62 * Copyright (C) 1984, Sun Microsystems, Inc.
69 #include <rpc/types.h>
73 static char *auth_errmsg();
82 buf
= (char *)malloc(256);
87 * Print reply error info
102 CLNT_GETERR(rpch
, &e
);
104 (void) sprintf(str
, "%s: ", s
);
107 (void) strcpy(str
, clnt_sperrno(e
.re_status
));
110 switch (e
.re_status
) {
112 case RPC_CANTENCODEARGS
:
113 case RPC_CANTDECODERES
:
115 case RPC_PROGUNAVAIL
:
116 case RPC_PROCUNAVAIL
:
117 case RPC_CANTDECODEARGS
:
118 case RPC_SYSTEMERROR
:
119 case RPC_UNKNOWNHOST
:
120 case RPC_UNKNOWNPROTO
:
121 case RPC_PMAPFAILURE
:
122 case RPC_PROGNOTREGISTERED
:
128 (void) sprintf(str
, "; errno = %s",
129 strerror(e
.re_errno
));
133 case RPC_VERSMISMATCH
:
135 "; low version = %lu, high version = %lu",
136 e
.re_vers
.low
, e
.re_vers
.high
);
141 err
= auth_errmsg(e
.re_why
);
142 (void) sprintf(str
,"; why = ");
145 (void) sprintf(str
, "%s",err
);
148 "(unknown authentication error - %d)",
154 case RPC_PROGVERSMISMATCH
:
156 "; low version = %lu, high version = %lu",
157 e
.re_vers
.low
, e
.re_vers
.high
);
161 default: /* unknown */
163 "; s1 = %lu, s2 = %lu",
164 e
.re_lb
.s1
, e
.re_lb
.s2
);
168 (void) sprintf(str
, "\n");
177 (void) fprintf(stderr
,"%s",clnt_sperror(rpch
,s
));
182 enum clnt_stat status
;
186 static struct rpc_errtab rpc_errlist
[] = {
189 { RPC_CANTENCODEARGS
,
190 "RPC: Can't encode arguments" },
192 "RPC: Can't decode result" },
194 "RPC: Unable to send" },
196 "RPC: Unable to receive" },
200 "RPC: Incompatible versions of RPC" },
202 "RPC: Authentication error" },
204 "RPC: Program unavailable" },
205 { RPC_PROGVERSMISMATCH
,
206 "RPC: Program/version mismatch" },
208 "RPC: Procedure unavailable" },
209 { RPC_CANTDECODEARGS
,
210 "RPC: Server can't decode arguments" },
212 "RPC: Remote system error" },
214 "RPC: Unknown host" },
216 "RPC: Unknown protocol" },
218 "RPC: Port mapper failure" },
219 { RPC_PROGNOTREGISTERED
,
220 "RPC: Program not registered"},
222 "RPC: Failed (unspecified error)"}
227 * This interface for use by clntrpc
235 for (i
= 0; i
< sizeof(rpc_errlist
)/sizeof(struct rpc_errtab
); i
++) {
236 if (rpc_errlist
[i
].status
== stat
) {
237 return (rpc_errlist
[i
].message
);
240 return ("RPC: (unknown error code)");
247 (void) fprintf(stderr
,"%s",clnt_sperrno(num
));
252 clnt_spcreateerror(s
)
259 (void) sprintf(str
, "%s: ", s
);
260 (void) strcat(str
, clnt_sperrno(rpc_createerr
.cf_stat
));
261 switch (rpc_createerr
.cf_stat
) {
262 case RPC_PMAPFAILURE
:
263 (void) strcat(str
, " - ");
265 clnt_sperrno(rpc_createerr
.cf_error
.re_status
));
268 case RPC_SYSTEMERROR
:
269 (void) strcat(str
, " - ");
270 if (rpc_createerr
.cf_error
.re_errno
> 0
271 && rpc_createerr
.cf_error
.re_errno
< sys_nerr
)
273 strerror(rpc_createerr
.cf_error
.re_errno
));
275 (void) sprintf(&str
[strlen(str
)], "Error %d",
276 rpc_createerr
.cf_error
.re_errno
);
280 (void) strcat(str
, "\n");
288 (void) fprintf(stderr
,"%s",clnt_spcreateerror(s
));
292 enum auth_stat status
;
296 static struct auth_errtab auth_errlist
[] = {
298 "Authentication OK" },
300 "Invalid client credential" },
302 "Server rejected credential" },
304 "Invalid client verifier" },
306 "Server rejected verifier" },
308 "Client credential too weak" },
310 "Invalid server verifier" },
312 "Failed (unspecified error)" },
321 for (i
= 0; i
< sizeof(auth_errlist
)/sizeof(struct auth_errtab
); i
++) {
322 if (auth_errlist
[i
].status
== stat
) {
323 return(auth_errlist
[i
].message
);