(void) fprintf(stderr, "#### Database\n"); ng_dump(ndb);
if (debug) { (void) fprintf(stderr, "#### Database\n"); ng_dump(ndb); }
main(argc, argv)	int		  argc;	char		**argv;{	DB		 *db, *ndb, *hdb, *udb;	int               ch;	char		  buf[MAXPATHLEN];	char		 *fname = _PATH_NETGROUP;	while ((ch = getopt(argc, argv, "o:")) != EOF)		switch (ch) {		case 'o':			dbname = optarg;			break;		case '?':		default:			usage();		}	argc -= optind;	argv += optind;	if (argc == 1)		fname = *argv;	else if (argc > 1)		usage();	if (atexit(cleanup))		err(1, "Cannot install exit handler");	/* Read and parse the netgroup file */	ndb = ng_load(fname);#ifdef DEBUG_NG	(void) fprintf(stderr, "#### Database\n");	ng_dump(ndb);#endif	/* Reverse the database by host */	hdb = ng_reverse(ndb, offsetof(struct netgroup, ng_host));#ifdef DEBUG_NG	(void) fprintf(stderr, "#### Reverse by host\n");	ng_rdump(hdb);#endif	/* Reverse the database by user */	udb = ng_reverse(ndb, offsetof(struct netgroup, ng_user));#ifdef DEBUG_NG	(void) fprintf(stderr, "#### Reverse by user\n");	ng_rdump(udb);#endif	(void) snprintf(buf, sizeof(buf), "%s.tmp", dbname);	db = dbopen(buf, O_RDWR | O_CREAT | O_EXCL,		    (S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH), DB_HASH, NULL);	if (!db)		err(1, buf);	ng_write(db, ndb, _NG_KEYBYNAME);	ng_rwrite(db, udb, _NG_KEYBYUSER);	ng_rwrite(db, hdb, _NG_KEYBYHOST);	if ((db->close)(db))		err(1, "Error closing database");	if (rename(buf, dbname) == -1)		err(1, "Cannot rename `%s' to `%s'", buf, dbname);	return 0;}