xref: /netbsd/lib/libc/yp/yperr_string.c (revision 76caf643)
1*76caf643Schristos /*	$NetBSD: yperr_string.c,v 1.9 2015/06/17 00:15:26 christos Exp $	 */
23b32f2c7Sjtc 
33b32f2c7Sjtc /*
43b32f2c7Sjtc  * Copyright (c) 1992, 1993 Theo de Raadt <deraadt@fsa.ca>
53b32f2c7Sjtc  * All rights reserved.
63b32f2c7Sjtc  *
73b32f2c7Sjtc  * Redistribution and use in source and binary forms, with or without
83b32f2c7Sjtc  * modification, are permitted provided that the following conditions
93b32f2c7Sjtc  * are met:
103b32f2c7Sjtc  * 1. Redistributions of source code must retain the above copyright
113b32f2c7Sjtc  *    notice, this list of conditions and the following disclaimer.
123b32f2c7Sjtc  * 2. Redistributions in binary form must reproduce the above copyright
133b32f2c7Sjtc  *    notice, this list of conditions and the following disclaimer in the
143b32f2c7Sjtc  *    documentation and/or other materials provided with the distribution.
153b32f2c7Sjtc  *
163b32f2c7Sjtc  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
173b32f2c7Sjtc  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
183b32f2c7Sjtc  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
193b32f2c7Sjtc  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
203b32f2c7Sjtc  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
213b32f2c7Sjtc  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
223b32f2c7Sjtc  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
233b32f2c7Sjtc  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
243b32f2c7Sjtc  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
253b32f2c7Sjtc  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
263b32f2c7Sjtc  * SUCH DAMAGE.
273b32f2c7Sjtc  */
283b32f2c7Sjtc 
29e7cc5503Schristos #include <sys/cdefs.h>
303b32f2c7Sjtc #if defined(LIBC_SCCS) && !defined(lint)
31*76caf643Schristos __RCSID("$NetBSD: yperr_string.c,v 1.9 2015/06/17 00:15:26 christos Exp $");
323b32f2c7Sjtc #endif
333b32f2c7Sjtc 
3443fa6fe3Sjtc #include "namespace.h"
35e7cc5503Schristos #include <stdio.h>
363b32f2c7Sjtc #include <rpc/rpc.h>
373b32f2c7Sjtc #include <rpcsvc/yp_prot.h>
383b32f2c7Sjtc #include <rpcsvc/ypclnt.h>
393b32f2c7Sjtc 
4043fa6fe3Sjtc #ifdef __weak_alias
__weak_alias(yperr_string,_yperr_string)4160549036Smycroft __weak_alias(yperr_string,_yperr_string)
4243fa6fe3Sjtc #endif
4343fa6fe3Sjtc 
443b32f2c7Sjtc char *
4590275da6Sabs yperr_string(int incode)
463b32f2c7Sjtc {
473b32f2c7Sjtc 	static char     err[80];
483b32f2c7Sjtc 
493b32f2c7Sjtc 	switch (incode) {
503b32f2c7Sjtc 	case 0:
5103256c6eSchristos 		return __UNCONST("Success");
523b32f2c7Sjtc 	case YPERR_BADARGS:
5303256c6eSchristos 		return __UNCONST("Request arguments bad");
543b32f2c7Sjtc 	case YPERR_RPC:
5503256c6eSchristos 		return __UNCONST("RPC failure");
563b32f2c7Sjtc 	case YPERR_DOMAIN:
5703256c6eSchristos 		return __UNCONST(
5803256c6eSchristos 		    "Can't bind to server which serves this domain");
593b32f2c7Sjtc 	case YPERR_MAP:
6003256c6eSchristos 		return __UNCONST("No such map in server's domain");
613b32f2c7Sjtc 	case YPERR_KEY:
6203256c6eSchristos 		return __UNCONST("No such key in map");
633b32f2c7Sjtc 	case YPERR_YPERR:
6403256c6eSchristos 		return __UNCONST("YP server error");
653b32f2c7Sjtc 	case YPERR_RESRC:
6603256c6eSchristos 		return __UNCONST("Local resource allocation failure");
673b32f2c7Sjtc 	case YPERR_NOMORE:
6803256c6eSchristos 		return __UNCONST("No more records in map database");
693b32f2c7Sjtc 	case YPERR_PMAP:
7003256c6eSchristos 		return __UNCONST("Can't communicate with portmapper");
713b32f2c7Sjtc 	case YPERR_YPBIND:
7203256c6eSchristos 		return __UNCONST("Can't communicate with ypbind");
733b32f2c7Sjtc 	case YPERR_YPSERV:
7403256c6eSchristos 		return __UNCONST("Can't communicate with ypserv");
753b32f2c7Sjtc 	case YPERR_NODOM:
7603256c6eSchristos 		return __UNCONST("Local domain name not set");
773b32f2c7Sjtc 	case YPERR_BADDB:
7803256c6eSchristos 		return __UNCONST("Server data base is bad");
793b32f2c7Sjtc 	case YPERR_VERS:
8003256c6eSchristos 		return __UNCONST(
8103256c6eSchristos 		    "YP server version mismatch - server can't supply service."
8203256c6eSchristos 		    );
833b32f2c7Sjtc 	case YPERR_ACCESS:
8403256c6eSchristos 		return __UNCONST("Access violation");
853b32f2c7Sjtc 	case YPERR_BUSY:
8603256c6eSchristos 		return __UNCONST("Database is busy");
873b32f2c7Sjtc 	}
88*76caf643Schristos 	(void) snprintf(err, sizeof(err), "YP unknown error %d", incode);
893b32f2c7Sjtc 	return err;
903b32f2c7Sjtc }
91