diff options
Diffstat (limited to 'lib/libc/gen/getnetgrent.c')
-rw-r--r-- | lib/libc/gen/getnetgrent.c | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/lib/libc/gen/getnetgrent.c b/lib/libc/gen/getnetgrent.c index 19e25321227..863f5516848 100644 --- a/lib/libc/gen/getnetgrent.c +++ b/lib/libc/gen/getnetgrent.c @@ -1,4 +1,4 @@ -/* $NetBSD: getnetgrent.c,v 1.8 1995/02/25 08:51:19 cgd Exp $ */ +/* $NetBSD: getnetgrent.c,v 1.9 1996/04/27 18:59:05 christos Exp $ */ /* * Copyright (c) 1994 Christos Zoulas @@ -32,10 +32,12 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char *rcsid = "$NetBSD: getnetgrent.c,v 1.8 1995/02/25 08:51:19 cgd Exp $"; +static char *rcsid = "$NetBSD: getnetgrent.c,v 1.9 1996/04/27 18:59:05 christos Exp $"; #endif /* LIBC_SCCS and not lint */ +#include <sys/types.h> #include <stdio.h> +#define _NETGROUP_PRIVATE #include <netgroup.h> #include <string.h> #include <fcntl.h> @@ -45,6 +47,7 @@ static char *rcsid = "$NetBSD: getnetgrent.c,v 1.8 1995/02/25 08:51:19 cgd Exp $ #include <db.h> #define _NG_STAR(s) (((s) == NULL || *(s) == '\0') ? _ngstar : s) +#define _NG_EMPTY(s) ((s) == NULL ? "" : s) #define _NG_ISSPACE(p) (isspace((unsigned char) (p)) || (p) == '\n') static const char _ngstar[] = "*"; @@ -218,9 +221,11 @@ getnetgroup(pp) goto baddomain; #ifdef DEBUG_NG - (void) fprintf(stderr, "netgroup(%s,%s,%s)\n", - _NG_STAR(ng->ng_host), _NG_STAR(ng->ng_user), - _NG_STAR(ng->ng_domain)); + { + char buf[1024]; + (void) fprintf(stderr, "netgroup %s\n", + _ng_print(buf, sizeof(buf), ng)); + } #endif return ng; @@ -538,6 +543,16 @@ _ng_makekey(s1, s2, len) return buf; } +void +_ng_print(buf, len, ng) + char *buf; + size_t len; + const struct netgroup *ng; +{ + (void) snprintf(buf, len, "(%s,%s,%s)", _NG_EMPTY(ng->ng_host), + _NG_EMPTY(ng->ng_user), _NG_EMPTY(ng->ng_domain)); +} + /* * in_lookup1(): Fast lookup for a key in the appropriate map |