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