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.4.672.1 2008/02/27 00:05:45 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(NGR_R_CONST
char **host
, NGR_R_CONST
char **user
,
80 NGR_R_CONST
char **domain
)
82 struct net_data
*net_data
= init();
83 const char *ch
, *cu
, *cd
;
86 ret
= getnetgrent_p(&ch
, &cu
, &cd
, net_data
);
92 DE_CONST(cd
, *domain
);
99 setnetgrent_p(const char *netgroup
, struct net_data
*net_data
) {
102 if ((net_data
!= NULL
) && ((ng
= net_data
->ng
) != NULL
))
103 (*ng
->rewind
)(ng
, netgroup
);
107 endnetgrent_p(struct net_data
*net_data
) {
112 if ((ng
= net_data
->ng
) != NULL
)
118 innetgr_p(const char *netgroup
, const char *host
,
119 const char *user
, const char *domain
,
120 struct net_data
*net_data
) {
123 if (!net_data
|| !(ng
= net_data
->ng
))
125 return ((*ng
->test
)(ng
, netgroup
, host
, user
, domain
));
129 getnetgrent_p(const char **host
, const char **user
, const char **domain
,
130 struct net_data
*net_data
) {
133 if (!net_data
|| !(ng
= net_data
->ng
))
135 return ((*ng
->next
)(ng
, host
, user
, domain
));
140 static struct net_data
*
142 struct net_data
*net_data
;
144 if (!(net_data
= net_data_init(NULL
)))
147 net_data
->ng
= (*net_data
->irs
->ng_map
)(net_data
->irs
);
158 #endif /*__BIND_NOSTATIC*/