2 * Copyright (C) 2004, 2005, 2008 Internet Systems Consortium, Inc. ("ISC")
3 * Copyright (C) 1996-1999, 2001, 2003 Internet Software Consortium.
5 * Permission to use, copy, modify, and/or 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 WITH
10 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11 * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
12 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
14 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15 * PERFORMANCE OF THIS SOFTWARE.
20 #include "port_before.h"
22 #if !defined(__BIND_NOSTATIC)
24 #include <sys/types.h>
26 #include <netinet/in.h>
27 #include <arpa/nameser.h>
35 #include "port_after.h"
41 static struct net_data
*init(void);
46 #ifndef SETNETGRENT_ARGS
47 #define SETNETGRENT_ARGS const char *netgroup
50 setnetgrent(SETNETGRENT_ARGS
) {
51 struct net_data
*net_data
= init();
53 setnetgrent_p(netgroup
, net_data
);
58 struct net_data
*net_data
= init();
60 endnetgrent_p(net_data
);
64 #define INNETGR_ARGS const char *netgroup, const char *host, \
65 const char *user, const char *domain
68 innetgr(INNETGR_ARGS
) {
69 struct net_data
*net_data
= init();
71 return (innetgr_p(netgroup
, host
, user
, domain
, net_data
));
75 getnetgrent(NGR_R_CONST
char **host
, NGR_R_CONST
char **user
,
76 NGR_R_CONST
char **domain
)
78 struct net_data
*net_data
= init();
79 const char *ch
, *cu
, *cd
;
82 ret
= getnetgrent_p(&ch
, &cu
, &cd
, net_data
);
88 DE_CONST(cd
, *domain
);
95 setnetgrent_p(const char *netgroup
, struct net_data
*net_data
) {
98 if ((net_data
!= NULL
) && ((ng
= net_data
->ng
) != NULL
))
99 (*ng
->rewind
)(ng
, netgroup
);
103 endnetgrent_p(struct net_data
*net_data
) {
108 if ((ng
= net_data
->ng
) != NULL
)
114 innetgr_p(const char *netgroup
, const char *host
,
115 const char *user
, const char *domain
,
116 struct net_data
*net_data
) {
119 if (!net_data
|| !(ng
= net_data
->ng
))
121 return ((*ng
->test
)(ng
, netgroup
, host
, user
, domain
));
125 getnetgrent_p(const char **host
, const char **user
, const char **domain
,
126 struct net_data
*net_data
) {
129 if (!net_data
|| !(ng
= net_data
->ng
))
131 return ((*ng
->next
)(ng
, host
, user
, domain
));
136 static struct net_data
*
138 struct net_data
*net_data
;
140 if (!(net_data
= net_data_init(NULL
)))
143 net_data
->ng
= (*net_data
->irs
->ng_map
)(net_data
->irs
);
154 #endif /*__BIND_NOSTATIC*/