1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*	Copyright (c) 1988 AT&T	*/
23*7c478bd9Sstevel@tonic-gate /*	  All Rights Reserved  	*/
24*7c478bd9Sstevel@tonic-gate 
25*7c478bd9Sstevel@tonic-gate 
26*7c478bd9Sstevel@tonic-gate /*
27*7c478bd9Sstevel@tonic-gate  * Copyright 1999, 2003 Sun Microsystems, Inc.  All rights reserved.
28*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
29*7c478bd9Sstevel@tonic-gate  */
30*7c478bd9Sstevel@tonic-gate 
31*7c478bd9Sstevel@tonic-gate /* inverted index definitions */
32*7c478bd9Sstevel@tonic-gate 
33*7c478bd9Sstevel@tonic-gate /* postings temporary file long number coding into characters */
34*7c478bd9Sstevel@tonic-gate #define	BASE		95	/* 127 - ' ' */
35*7c478bd9Sstevel@tonic-gate #define	PRECISION	5	/* maximum digits after converting a long */
36*7c478bd9Sstevel@tonic-gate 
37*7c478bd9Sstevel@tonic-gate /* inverted index access parameters */
38*7c478bd9Sstevel@tonic-gate #define	INVAVAIL	0
39*7c478bd9Sstevel@tonic-gate #define	INVBUSY		1
40*7c478bd9Sstevel@tonic-gate #define	INVALONE	2
41*7c478bd9Sstevel@tonic-gate 
42*7c478bd9Sstevel@tonic-gate /* boolean set operations */
43*7c478bd9Sstevel@tonic-gate #define	OR		3
44*7c478bd9Sstevel@tonic-gate #define	AND		4
45*7c478bd9Sstevel@tonic-gate #define	NOT		5
46*7c478bd9Sstevel@tonic-gate #define	REVERSENOT	6
47*7c478bd9Sstevel@tonic-gate 
48*7c478bd9Sstevel@tonic-gate /* note that the entire first block is for parameters */
49*7c478bd9Sstevel@tonic-gate typedef	struct	{
50*7c478bd9Sstevel@tonic-gate 	long	version;	/* inverted index format version */
51*7c478bd9Sstevel@tonic-gate 	long	filestat;	/* file status word  */
52*7c478bd9Sstevel@tonic-gate 	long	sizeblk;	/* size of logical block in bytes */
53*7c478bd9Sstevel@tonic-gate 	long	startbyte;	/* first byte of superfinger */
54*7c478bd9Sstevel@tonic-gate 	long	supsize;	/* size of superfinger in bytes */
55*7c478bd9Sstevel@tonic-gate 	long	cntlsize;	/* size of max cntl space (should be a */
56*7c478bd9Sstevel@tonic-gate 				/* multiple of BUFSIZ) */
57*7c478bd9Sstevel@tonic-gate 	long	share;		/* flag whether to use shared memory */
58*7c478bd9Sstevel@tonic-gate } PARAM;
59*7c478bd9Sstevel@tonic-gate 
60*7c478bd9Sstevel@tonic-gate typedef	struct {
61*7c478bd9Sstevel@tonic-gate 	FILE	*invfile;	/* the inverted file ptr */
62*7c478bd9Sstevel@tonic-gate 	FILE	*postfile;	/* posting file ptr */
63*7c478bd9Sstevel@tonic-gate 	PARAM	param;		/* control parameters for the file */
64*7c478bd9Sstevel@tonic-gate 	char	*iindex;	/* ptr to space for superindex */
65*7c478bd9Sstevel@tonic-gate 	char	*logblk;	/* ptr to space for a logical block */
66*7c478bd9Sstevel@tonic-gate 	long	numblk;		/* number of block presently at *logblk */
67*7c478bd9Sstevel@tonic-gate 	long	keypnt;		/* number item in present block found */
68*7c478bd9Sstevel@tonic-gate 	int	swap;		/* file endian mistmatch? */
69*7c478bd9Sstevel@tonic-gate } INVCONTROL;
70*7c478bd9Sstevel@tonic-gate 
71*7c478bd9Sstevel@tonic-gate typedef	struct	{
72*7c478bd9Sstevel@tonic-gate 	short	offset;		/* offset in this logical block */
73*7c478bd9Sstevel@tonic-gate 	unsigned char size;	/* size of term */
74*7c478bd9Sstevel@tonic-gate 	unsigned char space;	/* number of longs of growth space */
75*7c478bd9Sstevel@tonic-gate 	long	post;		/* number of postings for this entry */
76*7c478bd9Sstevel@tonic-gate } ENTRY;
77*7c478bd9Sstevel@tonic-gate 
78*7c478bd9Sstevel@tonic-gate typedef	struct {
79*7c478bd9Sstevel@tonic-gate 	long	lineoffset;	/* source line database offset */
80*7c478bd9Sstevel@tonic-gate 	long	fcnoffset;	/* function name database offset */
81*7c478bd9Sstevel@tonic-gate 	long	fileindex : 24;	/* source file name index */
82*7c478bd9Sstevel@tonic-gate 	long	type : 8;	/* reference type (mark character) */
83*7c478bd9Sstevel@tonic-gate } POSTING;
84*7c478bd9Sstevel@tonic-gate 
85*7c478bd9Sstevel@tonic-gate extern	long	*srcoffset;	/* source file name database offsets */
86*7c478bd9Sstevel@tonic-gate extern	int	nsrcoffset;	/* number of file name database offsets */
87*7c478bd9Sstevel@tonic-gate 
88*7c478bd9Sstevel@tonic-gate extern void	boolclear(void);
89*7c478bd9Sstevel@tonic-gate extern POSTING	*boolfile(INVCONTROL *invcntl, long *num, int bool);
90*7c478bd9Sstevel@tonic-gate extern void	invclose(INVCONTROL *invcntl);
91*7c478bd9Sstevel@tonic-gate extern long	invfind(INVCONTROL *invcntl, char *searchterm);
92*7c478bd9Sstevel@tonic-gate extern int	invforward(INVCONTROL *invcntl);
93*7c478bd9Sstevel@tonic-gate extern int	invopen(INVCONTROL *invcntl, char *invname, char *invpost,
94*7c478bd9Sstevel@tonic-gate 		    int stat);
95*7c478bd9Sstevel@tonic-gate extern int	invterm(INVCONTROL *invcntl, char *term);
96*7c478bd9Sstevel@tonic-gate extern long	invmake(char *invname, char *invpost, FILE *infile);
97