xref: /original-bsd/lib/libc/db/test/hash.tests/tseq.c (revision 2cb1372a)
1 /*-
2  * Copyright (c) 1991, 1993
3  *	The Regents of the University of California.  All rights reserved.
4  *
5  * This code is derived from software contributed to Berkeley by
6  * Margo Seltzer.
7  *
8  * %sccs.include.redist.c%
9  */
10 
11 #ifndef lint
12 static char copyright[] =
13 "@(#) Copyright (c) 1991, 1993\n\
14 	The Regents of the University of California.  All rights reserved.\n";
15 #endif /* not lint */
16 
17 #ifndef lint
18 static char sccsid[] = "@(#)tseq.c	8.1 (Berkeley) 06/04/93";
19 #endif /* not lint */
20 
21 #include <sys/types.h>
22 #include <sys/file.h>
23 #include <stdio.h>
24 #include <db.h>
25 
26 #define INITIAL	25000
27 #define MAXWORDS    25000	       /* # of elements in search table */
28 
29 
30 char	wp[8192];
31 char	cp[8192];
32 main(argc, argv)
33 char **argv;
34 {
35 	DBT item, key, res;
36 	DB	*dbp;
37 	FILE *fp;
38 	int	stat;
39 
40 	if (!(dbp = dbopen( "hashtest", O_RDONLY, 0400, DB_HASH, NULL))) {
41 		/* create table */
42 		fprintf(stderr, "cannot open: hash table\n" );
43 		exit(1);
44 	}
45 
46 /*
47 * put info in structure, and structure in the item
48 */
49 	for ( stat = (dbp->seq) (dbp, &res, &item, 1 );
50 	      stat == 0;
51 	      stat = (dbp->seq) (dbp, &res, &item, 0 ) ) {
52 
53 	      bcopy ( res.data, wp, res.size );
54 	      wp[res.size] = 0;
55 	      bcopy ( item.data, cp, item.size );
56 	      cp[item.size] = 0;
57 
58 	      printf ( "%s %s\n", wp, cp );
59 	}
60 	(dbp->close)(dbp);
61 	exit(0);
62 }
63