From: deraadt Date: Wed, 1 May 1996 12:56:53 +0000 (+0000) Subject: from netbsd: X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=956952fb1b701c3b18dfe0c594286a4e5656c65a;p=openbsd from netbsd: - grab prototypes from netgroup.h - added _ng_print, netgroup pretty printing function --- 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