1 /* $NetBSD: clnt_sperrno.c,v 1.1.1.3 2015/01/17 16:34:18 christos Exp $ */
2
3 /*
4 * Copyright (c) 1997-2014 Erez Zadok
5 * Copyright (c) 1990 Jan-Simon Pendry
6 * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
7 * Copyright (c) 1990 The Regents of the University of California.
8 * All rights reserved.
9 *
10 * This code is derived from software contributed to Berkeley by
11 * Jan-Simon Pendry at Imperial College, London.
12 *
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
15 * are met:
16 * 1. Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
18 * 2. Redistributions in binary form must reproduce the above copyright
19 * notice, this list of conditions and the following disclaimer in the
20 * documentation and/or other materials provided with the distribution.
21 * 3. Neither the name of the University nor the names of its contributors
22 * may be used to endorse or promote products derived from this software
23 * without specific prior written permission.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
26 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 * SUCH DAMAGE.
36 *
37 *
38 * File: am-utils/libamu/clnt_sperrno.c
39 *
40 */
41
42 /*
43 * Early RPC seems to be missing these..
44 * Extracted from the RPC 3.9 sources as indicated
45 */
46
47 /* @(#)clnt_perror.c 1.1 87/11/04 3.9 RPCSRC */
48 /*
49 * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
50 * unrestricted use provided that this legend is included on all tape
51 * media and as a part of the software program in whole or part. Users
52 * may copy or modify Sun RPC without charge, but are not authorized
53 * to license or distribute it to anyone else except as part of a product or
54 * program developed by the user.
55 *
56 * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
57 * WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
58 * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
59 *
60 * Sun RPC is provided with no support and without any obligation on the
61 * part of Sun Microsystems, Inc. to assist in its use, correction,
62 * modification or enhancement.
63 *
64 * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
65 * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
66 * OR ANY PART THEREOF.
67 *
68 * In no event will Sun Microsystems, Inc. be liable for any lost revenue
69 * or profits or other special, indirect and consequential damages, even if
70 * Sun has been advised of the possibility of such damages.
71 *
72 * Sun Microsystems, Inc.
73 * 2550 Garcia Avenue
74 * Mountain View, California 94043
75 */
76
77 #ifdef HAVE_CONFIG_H
78 # include <config.h>
79 #endif /* HAVE_CONFIG_H */
80 #include <am_defs.h>
81 #include <amu.h>
82
83
84 struct rpc_errtab {
85 enum clnt_stat status;
86 char *message;
87 };
88
89 static struct rpc_errtab rpc_errlist[] =
90 {
91 {RPC_SUCCESS,
92 "RPC: Success"},
93 {RPC_CANTENCODEARGS,
94 "RPC: Can't encode arguments"},
95 {RPC_CANTDECODERES,
96 "RPC: Can't decode result"},
97 {RPC_CANTSEND,
98 "RPC: Unable to send"},
99 {RPC_CANTRECV,
100 "RPC: Unable to receive"},
101 {RPC_TIMEDOUT,
102 "RPC: Timed out"},
103 {RPC_VERSMISMATCH,
104 "RPC: Incompatible versions of RPC"},
105 {RPC_AUTHERROR,
106 "RPC: Authentication error"},
107 {RPC_PROGUNAVAIL,
108 "RPC: Program unavailable"},
109 {RPC_PROGVERSMISMATCH,
110 "RPC: Program/version mismatch"},
111 {RPC_PROCUNAVAIL,
112 "RPC: Procedure unavailable"},
113 {RPC_CANTDECODEARGS,
114 "RPC: Server can't decode arguments"},
115 {RPC_SYSTEMERROR,
116 "RPC: Remote system error"},
117 {RPC_UNKNOWNHOST,
118 "RPC: Unknown host"},
119 /* { RPC_UNKNOWNPROTO,
120 * "RPC: Unknown protocol" }, */
121 {RPC_PMAPFAILURE,
122 "RPC: Port mapper failure"},
123 {RPC_PROGNOTREGISTERED,
124 "RPC: Program not registered"},
125 {RPC_FAILED,
126 "RPC: Failed (unspecified error)"}
127 };
128
129
130 /*
131 * This interface for use by clntrpc
132 */
133 char *
clnt_sperrno(enum clnt_stat stat)134 clnt_sperrno(enum clnt_stat stat)
135 {
136 int i;
137
138 for (i = 0; i < sizeof(rpc_errlist) / sizeof(struct rpc_errtab); i++) {
139 if (rpc_errlist[i].status == stat) {
140 return (rpc_errlist[i].message);
141 }
142 }
143 return ("RPC: (unknown error code)");
144 }
145