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