2 * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
3 * Copyright (c) 1998-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_r.c,v 1.5.2.3 2004/04/13 04:49:01 marka Exp $";
20 #endif /* LIBC_SCCS and not lint */
22 #include <port_before.h>
23 #if !defined(_REENTRANT) || !defined(DO_PTHREADS)
24 static int getnetgrent_r_not_required
= 0;
29 #include <sys/types.h>
30 #include <netinet/in.h>
34 #include <port_after.h>
39 copy_protoent(char **, char **, char **, const char *, const char *,
40 const char *, NGR_R_COPY_ARGS
);
43 innetgr_r(const char *netgroup
, const char *host
, const char *user
,
45 char *ng
, *ho
, *us
, *dom
;
47 DE_CONST(netgroup
, ng
);
50 DE_CONST(domain
, dom
);
52 return (innetgr(ng
, ho
, us
, dom
));
56 * These assume a single context is in operation per thread.
57 * If this is not the case we will need to call irs directly
58 * rather than through the base functions.
62 getnetgrent_r(char **machinep
, char **userp
, char **domainp
, NGR_R_ARGS
) {
64 int res
= getnetgrent(&mp
, &up
, &dp
);
69 return (copy_protoent(machinep
, userp
, domainp
,
70 mp
, up
, dp
, NGR_R_COPY
));
75 setnetgrent_r(const char *netgroup
, NGR_R_ENT_ARGS
)
77 setnetgrent_r(const char *netgroup
)
81 DE_CONST(netgroup
, tmp
);
86 #ifdef NGR_R_SET_RESULT
87 return (NGR_R_SET_RESULT
);
93 endnetgrent_r(NGR_R_ENT_ARGS
)
104 NGR_R_END_RESULT(NGR_R_OK
);
110 copy_protoent(char **machinep
, char **userp
, char **domainp
,
111 const char *mp
, const char *up
, const char *dp
,
117 /* Find out the amount of space required to store the answer. */
119 if (mp
!= NULL
) len
+= strlen(mp
) + 1;
120 if (up
!= NULL
) len
+= strlen(up
) + 1;
121 if (dp
!= NULL
) len
+= strlen(dp
) + 1;
130 if (len
> (int)buflen
) {
164 #else /* NGR_R_RETURN */
165 static int getnetgrent_r_unknown_system
= 0;
166 #endif /* NGR_R_RETURN */
167 #endif /* !defined(_REENTRANT) || !defined(DO_PTHREADS) */