tseq.c revision 8870
1249259Sdim/*-
2249259Sdim * Copyright (c) 1991, 1993
3249259Sdim *	The Regents of the University of California.  All rights reserved.
4249259Sdim *
5249259Sdim * This code is derived from software contributed to Berkeley by
6249259Sdim * Margo Seltzer.
7249259Sdim *
8249259Sdim * Redistribution and use in source and binary forms, with or without
9249259Sdim * modification, are permitted provided that the following conditions
10249259Sdim * are met:
11249259Sdim * 1. Redistributions of source code must retain the above copyright
12249259Sdim *    notice, this list of conditions and the following disclaimer.
13249259Sdim * 2. Redistributions in binary form must reproduce the above copyright
14249259Sdim *    notice, this list of conditions and the following disclaimer in the
15249259Sdim *    documentation and/or other materials provided with the distribution.
16249259Sdim * 3. All advertising materials mentioning features or use of this software
17249259Sdim *    must display the following acknowledgement:
18249259Sdim *	This product includes software developed by the University of
19263509Sdim *	California, Berkeley and its contributors.
20263509Sdim * 4. Neither the name of the University nor the names of its contributors
21263509Sdim *    may be used to endorse or promote products derived from this software
22263509Sdim *    without specific prior written permission.
23263509Sdim *
24263509Sdim * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25263509Sdim * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26263509Sdim * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27263509Sdim * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28263509Sdim * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29263509Sdim * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30263509Sdim * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31263509Sdim * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32263509Sdim * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33263509Sdim * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34263509Sdim * SUCH DAMAGE.
35263509Sdim */
36263509Sdim
37263509Sdim#ifndef lint
38263509Sdimstatic char copyright[] =
39263509Sdim"@(#) Copyright (c) 1991, 1993\n\
40263509Sdim	The Regents of the University of California.  All rights reserved.\n";
41263509Sdim#endif /* not lint */
42263509Sdim
43263509Sdim#ifndef lint
44263509Sdimstatic char sccsid[] = "@(#)tseq.c	8.1 (Berkeley) 6/4/93";
45263509Sdim#endif /* not lint */
46263509Sdim
47263509Sdim#include <sys/types.h>
48263509Sdim#include <sys/file.h>
49263509Sdim#include <stdio.h>
50263509Sdim#include <db.h>
51263509Sdim
52263509Sdim#define INITIAL	25000
53263509Sdim#define MAXWORDS    25000	       /* # of elements in search table */
54263509Sdim
55263509Sdim
56263509Sdimchar	wp[8192];
57263509Sdimchar	cp[8192];
58249259Sdimmain(argc, argv)
59249259Sdimchar **argv;
60249259Sdim{
61249259Sdim	DBT item, key, res;
62249259Sdim	DB	*dbp;
63263509Sdim	FILE *fp;
64263509Sdim	int	stat;
65263509Sdim
66263509Sdim	if (!(dbp = dbopen( "hashtest", O_RDONLY, 0400, DB_HASH, NULL))) {
67263509Sdim		/* create table */
68249259Sdim		fprintf(stderr, "cannot open: hash table\n" );
69249259Sdim		exit(1);
70249259Sdim	}
71249259Sdim
72249259Sdim/*
73263509Sdim* put info in structure, and structure in the item
74263509Sdim*/
75263509Sdim	for ( stat = (dbp->seq) (dbp, &res, &item, 1 );
76263509Sdim	      stat == 0;
77252723Sdim	      stat = (dbp->seq) (dbp, &res, &item, 0 ) ) {
78249259Sdim
79249259Sdim	      bcopy ( res.data, wp, res.size );
80249259Sdim	      wp[res.size] = 0;
81249259Sdim	      bcopy ( item.data, cp, item.size );
82249259Sdim	      cp[item.size] = 0;
83249259Sdim
84249259Sdim	      printf ( "%s %s\n", wp, cp );
85249259Sdim	}
86249259Sdim	(dbp->close)(dbp);
87263509Sdim	exit(0);
88263509Sdim}
89263509Sdim