xref: /onnv-gate/usr/src/lib/libnsl/nss/getrpcent.c (revision 1219:f89f56c2d9ac)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
50Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
60Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
70Sstevel@tonic-gate  * with the License.
80Sstevel@tonic-gate  *
90Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
100Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
110Sstevel@tonic-gate  * See the License for the specific language governing permissions
120Sstevel@tonic-gate  * and limitations under the License.
130Sstevel@tonic-gate  *
140Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
150Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
160Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
170Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
180Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
190Sstevel@tonic-gate  *
200Sstevel@tonic-gate  * CDDL HEADER END
210Sstevel@tonic-gate  */
22132Srobinson 
230Sstevel@tonic-gate /*
24*1219Sraf  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
250Sstevel@tonic-gate  * Use is subject to license terms.
260Sstevel@tonic-gate  */
270Sstevel@tonic-gate 
280Sstevel@tonic-gate /*
290Sstevel@tonic-gate  * Ye olde non-reentrant interface (MT-unsafe, caveat utor)
300Sstevel@tonic-gate  */
310Sstevel@tonic-gate 
320Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
330Sstevel@tonic-gate 
34*1219Sraf #include "mt.h"
350Sstevel@tonic-gate #include <rpc/rpcent.h>
360Sstevel@tonic-gate #include <nss_dbdefs.h>
370Sstevel@tonic-gate 
380Sstevel@tonic-gate #ifdef	NSS_INCLUDE_UNSAFE
390Sstevel@tonic-gate 
400Sstevel@tonic-gate /*
410Sstevel@tonic-gate  * Don't free this, even on an endrpcent(), because bitter experience shows
420Sstevel@tonic-gate  * that there's production code that does getXXXbyYYY(), then endXXXent(),
430Sstevel@tonic-gate  * and then continues to use the pointer it got back.
440Sstevel@tonic-gate  */
450Sstevel@tonic-gate static nss_XbyY_buf_t *buffer;
460Sstevel@tonic-gate #define	GETBUF()	\
470Sstevel@tonic-gate 	NSS_XbyY_ALLOC(&buffer, sizeof (struct rpcent), NSS_BUFLEN_RPC)
480Sstevel@tonic-gate 	/* === ?? set ENOMEM on failure?  */
490Sstevel@tonic-gate 
500Sstevel@tonic-gate struct rpcent *
getrpcbyname(const char * nam)51132Srobinson getrpcbyname(const char *nam)
520Sstevel@tonic-gate {
530Sstevel@tonic-gate 	nss_XbyY_buf_t	*b;
540Sstevel@tonic-gate 
55132Srobinson 	if ((b = GETBUF()) == 0)
56132Srobinson 		return (NULL);
57132Srobinson 	return (getrpcbyname_r(nam, b->result, b->buffer, b->buflen));
580Sstevel@tonic-gate }
590Sstevel@tonic-gate 
600Sstevel@tonic-gate struct rpcent *
getrpcbynumber(const int num)61132Srobinson getrpcbynumber(const int num)
620Sstevel@tonic-gate {
630Sstevel@tonic-gate 	nss_XbyY_buf_t	*b;
640Sstevel@tonic-gate 
65132Srobinson 	if ((b = GETBUF()) == 0)
66132Srobinson 		return (NULL);
67132Srobinson 	return (getrpcbynumber_r(num, b->result, b->buffer, b->buflen));
680Sstevel@tonic-gate }
690Sstevel@tonic-gate 
700Sstevel@tonic-gate struct rpcent *
getrpcent(void)71132Srobinson getrpcent(void)
720Sstevel@tonic-gate {
730Sstevel@tonic-gate 	nss_XbyY_buf_t	*b;
740Sstevel@tonic-gate 
75132Srobinson 	if ((b = GETBUF()) == 0)
76132Srobinson 		return (NULL);
77132Srobinson 	return (getrpcent_r(b->result, b->buffer, b->buflen));
780Sstevel@tonic-gate }
790Sstevel@tonic-gate #endif	/* NSS_INCLUDE_UNSAFE */
80