import less(1)
[unleashed/tickless.git] / usr / src / lib / libc / port / nsl / getrpcent.c
blob502b3bdf83d57c3948b0250f96ae77e69a4bd892
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
7 * with the License.
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
20 * CDDL HEADER END
24 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
25 * Use is subject to license terms.
29 * Ye olde non-reentrant interface (MT-unsafe, caveat utor)
32 #pragma ident "%Z%%M% %I% %E% SMI"
34 #include "mt.h"
35 #include <rpc/rpcent.h>
36 #include <nss_dbdefs.h>
39 * Don't free this, even on an endrpcent(), because bitter experience shows
40 * that there's production code that does getXXXbyYYY(), then endXXXent(),
41 * and then continues to use the pointer it got back.
43 static nss_XbyY_buf_t *buffer;
44 #define GETBUF() \
45 NSS_XbyY_ALLOC(&buffer, sizeof (struct rpcent), NSS_BUFLEN_RPC)
46 /* === ?? set ENOMEM on failure? */
48 struct rpcent *
49 getrpcbyname(const char *nam)
51 nss_XbyY_buf_t *b;
53 if ((b = GETBUF()) == 0)
54 return (NULL);
55 return (getrpcbyname_r(nam, b->result, b->buffer, b->buflen));
58 struct rpcent *
59 getrpcbynumber(const int num)
61 nss_XbyY_buf_t *b;
63 if ((b = GETBUF()) == 0)
64 return (NULL);
65 return (getrpcbynumber_r(num, b->result, b->buffer, b->buflen));
68 struct rpcent *
69 getrpcent(void)
71 nss_XbyY_buf_t *b;
73 if ((b = GETBUF()) == 0)
74 return (NULL);
75 return (getrpcent_r(b->result, b->buffer, b->buflen));