pflag = 1;
checkprint = 1;
main(argc, argv)	int argc;	char *argv[];{	extern char *optarg;	extern int optind;	DB *dbp;	DBC *dbcp;	DBT key, data;	DB_ENV *dbenv;	int ch, dflag, pflag;	char *home;	home = NULL;	dflag = pflag = 0;	while ((ch = getopt(argc, argv, "df:h:p")) != EOF)		switch (ch) {		case 'd':			dflag = 1;			break;		case 'f':			if (freopen(optarg, "w", stdout) == NULL)				err(1, "%s", optarg);			break;		case 'h':			home = optarg;			break;		case 'p':			pflag = 1;			break;		case '?':		default:			usage();		}	argc -= optind;	argv += optind;	if (argc != 1)		usage();	if (dflag) {		if (home != NULL)			errx(1,			    "the -d and -h options may not both be specified");		if (pflag)			errx(1,			    "the -d and -p options may not both be specified");	}	/* Initialize the environment. */	dbenv = dflag ? NULL : db_init(home);	/* Open the DB file. */	if ((errno =	    db_open(argv[0], DB_UNKNOWN, DB_RDONLY, 0, dbenv, NULL, &dbp)) != 0)		err(1, "%s", argv[0]);	/* DB dump. */	if (dflag) {		(void)__db_dump(dbp, NULL, 1);		if ((errno = dbp->close(dbp, 0)) != 0)			err(1, "close");		exit (0);	}	/* Get a cursor and step through the database. */	if ((errno = dbp->cursor(dbp, NULL, &dbcp)) != 0) {		(void)dbp->close(dbp, 0);		err(1, "cursor");	}	/* Print out the header. */	pheader(dbp, pflag);	/* Print out the key/data pairs. */	memset(&key, 0, sizeof(key));	memset(&data, 0, sizeof(data));	if (pflag)		while ((errno = dbcp->c_get(dbcp, &key, &data, DB_NEXT)) == 0) {			if (dbp->type != DB_RECNO)				dbt_print(&key);			dbt_print(&data);		}	else		while ((errno = dbcp->c_get(dbcp, &key, &data, DB_NEXT)) == 0) {			if (dbp->type != DB_RECNO)				dbt_dump(&key);			dbt_dump(&data);		}	if (errno != DB_NOTFOUND)		err(1, "cursor get");	if ((errno = dbp->close(dbp, 0)) != 0)		err(1, "close");	return (0);}