4 * Copyright (C) 2004, 2005, 2008 Internet Systems Consortium, Inc. ("ISC")
5 * Copyright (C) 1996-1999, 2001, 2003 Internet Software Consortium.
7 * Permission to use, copy, modify, and/or distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
11 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
12 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
13 * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
14 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
15 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
16 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17 * PERFORMANCE OF THIS SOFTWARE.
20 #if defined(LIBC_SCCS) && !defined(lint)
21 static const char rcsid
[] = "Id: getnetgrent.c,v 1.6 2008/11/14 02:36:51 marka Exp";
22 #endif /* LIBC_SCCS and not lint */
26 #include "port_before.h"
28 #if !defined(__BIND_NOSTATIC)
30 #include <sys/types.h>
32 #include <netinet/in.h>
33 #include <arpa/nameser.h>
41 #include "port_after.h"
47 static struct net_data
*init(void);
52 #ifndef SETNETGRENT_ARGS
53 #define SETNETGRENT_ARGS const char *netgroup
56 setnetgrent(SETNETGRENT_ARGS
) {
57 struct net_data
*net_data
= init();
59 setnetgrent_p(netgroup
, net_data
);
64 struct net_data
*net_data
= init();
66 endnetgrent_p(net_data
);
70 #define INNETGR_ARGS const char *netgroup, const char *host, \
71 const char *user, const char *domain
74 innetgr(INNETGR_ARGS
) {
75 struct net_data
*net_data
= init();
77 return (innetgr_p(netgroup
, host
, user
, domain
, net_data
));
81 getnetgrent(NGR_R_CONST
char **host
, NGR_R_CONST
char **user
,
82 NGR_R_CONST
char **domain
)
84 struct net_data
*net_data
= init();
85 const char *ch
, *cu
, *cd
;
88 ret
= getnetgrent_p(&ch
, &cu
, &cd
, net_data
);
94 DE_CONST(cd
, *domain
);
101 setnetgrent_p(const char *netgroup
, struct net_data
*net_data
) {
104 if ((net_data
!= NULL
) && ((ng
= net_data
->ng
) != NULL
))
105 (*ng
->rewind
)(ng
, netgroup
);
109 endnetgrent_p(struct net_data
*net_data
) {
114 if ((ng
= net_data
->ng
) != NULL
)
120 innetgr_p(const char *netgroup
, const char *host
,
121 const char *user
, const char *domain
,
122 struct net_data
*net_data
) {
125 if (!net_data
|| !(ng
= net_data
->ng
))
127 return ((*ng
->test
)(ng
, netgroup
, host
, user
, domain
));
131 getnetgrent_p(const char **host
, const char **user
, const char **domain
,
132 struct net_data
*net_data
) {
135 if (!net_data
|| !(ng
= net_data
->ng
))
137 return ((*ng
->next
)(ng
, host
, user
, domain
));
142 static struct net_data
*
144 struct net_data
*net_data
;
146 if (!(net_data
= net_data_init(NULL
)))
149 net_data
->ng
= (*net_data
->irs
->ng_map
)(net_data
->irs
);
160 #endif /*__BIND_NOSTATIC*/