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