2 * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
3 * Copyright (c) 1996,1999 by Internet Software Consortium.
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
9 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
15 * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 #if defined(LIBC_SCCS) && !defined(lint)
19 static const char rcsid[] = "$Id: getnetgrent.c,v 1.1.2.1.4.1 2004/03/09 08:33:36 marka Exp $";
20 #endif /* LIBC_SCCS and not lint */
24 #include "port_before.h"
26 #if !defined(__BIND_NOSTATIC)
28 #include <sys/types.h>
30 #include <netinet/in.h>
31 #include <arpa/nameser.h>
39 #include "port_after.h"
45 static struct net_data *init(void);
50 #ifndef SETNETGRENT_ARGS
51 #define SETNETGRENT_ARGS const char *netgroup
54 setnetgrent(SETNETGRENT_ARGS) {
55 struct net_data *net_data = init();
57 setnetgrent_p(netgroup, net_data);
62 struct net_data *net_data = init();
64 endnetgrent_p(net_data);
68 #define INNETGR_ARGS const char *netgroup, const char *host, \
69 const char *user, const char *domain
72 innetgr(INNETGR_ARGS) {
73 struct net_data *net_data = init();
75 return (innetgr_p(netgroup, host, user, domain, net_data));
79 getnetgrent(char **host, char **user, char **domain) {
80 struct net_data *net_data = init();
81 const char *ch, *cu, *cd;
84 ret = getnetgrent_p(&ch, &cu, &cd, net_data);
90 DE_CONST(cd, *domain);
97 setnetgrent_p(const char *netgroup, struct net_data *net_data) {
100 if ((net_data != NULL) && ((ng = net_data->ng) != NULL))
101 (*ng->rewind)(ng, netgroup);
105 endnetgrent_p(struct net_data *net_data) {
110 if ((ng = net_data->ng) != NULL)
116 innetgr_p(const char *netgroup, const char *host,
117 const char *user, const char *domain,
118 struct net_data *net_data) {
121 if (!net_data || !(ng = net_data->ng))
123 return ((*ng->test)(ng, netgroup, host, user, domain));
127 getnetgrent_p(const char **host, const char **user, const char **domain,
128 struct net_data *net_data ) {
131 if (!net_data || !(ng = net_data->ng))
133 return ((*ng->next)(ng, host, user, domain));
138 static struct net_data *
140 struct net_data *net_data;
142 if (!(net_data = net_data_init(NULL)))
145 net_data->ng = (*net_data->irs->ng_map)(net_data->irs);
156 #endif /*__BIND_NOSTATIC*/