-/* $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
*/
#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>
#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[] = "*";
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;
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