From 3761adc2833099367121aaa13f9905fe7180de61 Mon Sep 17 00:00:00 2001 From: Theo de Raadt Date: Wed, 1 May 1996 12:56:54 +0000 Subject: from netbsd: - grab prototypes from netgroup.h - added _ng_print, netgroup pretty printing function --- lib/libc/gen/getnetgrent.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'lib') 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 #include +#define _NETGROUP_PRIVATE #include #include #include @@ -45,6 +47,7 @@ static char *rcsid = "$NetBSD: getnetgrent.c,v 1.8 1995/02/25 08:51:19 cgd Exp $ #include #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 -- cgit v1.2.3