1 /* 2 * CDDL HEADER START 3 * 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. 8 * 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. 13 * 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] 19 * 20 * CDDL HEADER END 21 */ 22 23 /* 24 * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 25 * Use is subject to license terms. 26 */ 27 28 /* 29 * Ye olde non-reentrant interface (MT-unsafe, caveat utor) 30 */ 31 32 #include "mt.h" 33 #include <rpc/rpcent.h> 34 #include <nss_dbdefs.h> 35 36 #ifdef NSS_INCLUDE_UNSAFE 37 38 /* 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. 42 */ 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? */ 47 48 struct rpcent * 49 getrpcbyname(const char *nam) 50 { 51 nss_XbyY_buf_t *b; 52 53 if ((b = GETBUF()) == 0) 54 return (NULL); 55 return (getrpcbyname_r(nam, b->result, b->buffer, b->buflen)); 56 } 57 58 struct rpcent * 59 getrpcbynumber(const int num) 60 { 61 nss_XbyY_buf_t *b; 62 63 if ((b = GETBUF()) == 0) 64 return (NULL); 65 return (getrpcbynumber_r(num, b->result, b->buffer, b->buflen)); 66 } 67 68 struct rpcent * 69 getrpcent(void) 70 { 71 nss_XbyY_buf_t *b; 72 73 if ((b = GETBUF()) == 0) 74 return (NULL); 75 return (getrpcent_r(b->result, b->buffer, b->buflen)); 76 } 77 #endif /* NSS_INCLUDE_UNSAFE */ 78