Imported Upstream version 15.8a
[platform/upstream/cscope.git] / src / invlib.h
1 /*===========================================================================
2  Copyright (c) 1998-2000, The Santa Cruz Operation 
3  All rights reserved.
4  
5  Redistribution and use in source and binary forms, with or without
6  modification, are permitted provided that the following conditions are met:
7
8  *Redistributions of source code must retain the above copyright notice,
9  this list of conditions and the following disclaimer.
10
11  *Redistributions in binary form must reproduce the above copyright notice,
12  this list of conditions and the following disclaimer in the documentation
13  and/or other materials provided with the distribution.
14
15  *Neither name of The Santa Cruz Operation nor the names of its contributors
16  may be used to endorse or promote products derived from this software
17  without specific prior written permission. 
18
19  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
20  IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
21  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22  PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
23  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  INTERRUPTION)
27  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29  OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
30  DAMAGE. 
31  =========================================================================*/
32
33 /* $Id: invlib.h,v 1.7 2004/02/12 18:14:05 broeker Exp $ */
34
35
36 #ifndef CSCOPE_INVLIB_H
37 #define CSCOPE_INVLIB_H
38
39 #include <stdio.h>              /* need definition of FILE* */
40 #include <limits.h>
41
42 /* inverted index definitions */
43
44 /* postings temporary file long number coding into characters */
45 /* FIXME HBB: where would these definitions come from ? */
46 #if CHAR_MAX==255
47 # define        BASE            223     /* 255 - ' ' */
48 # define        PRECISION       4       /* maximum digits after converting a long */
49 #else
50 # if CHAR_MAX==127      /* assume sign-extension of a char when converted to an int */
51 #  define       BASE            95      /* 127 - ' ' */
52 #  define       PRECISION       5       /* maximum digits after converting a long */
53 # else
54   #error Need a platform with 8 bits in a char value
55 # endif
56 #endif
57
58 /* inverted index access parameters */
59 #define INVAVAIL        0
60 #define INVBUSY         1
61 #define INVALONE        2
62
63 /* boolean set operations */
64 #define BOOL_OR         3
65 #define AND             4
66 #define NOT             5
67 #define REVERSENOT      6
68
69 /* note that the entire first block is for parameters */
70 typedef struct  {
71         long    version;        /* inverted index format version */
72         long    filestat;       /* file status word  */
73         long    sizeblk;        /* size of logical block in bytes */
74         long    startbyte;      /* first byte of superfinger */
75         long    supsize;        /* size of superfinger in bytes */
76         long    cntlsize;       /* size of max cntl space (should be a multiple of BUFSIZ) */
77         long    share;          /* flag whether to use shared memory */
78 } PARAM;
79
80 typedef struct {
81         FILE    *invfile;       /* the inverted file ptr */
82         FILE    *postfile;      /* posting file ptr */
83         PARAM   param;          /* control parameters for the file */
84         char    *iindex;        /* ptr to space for superindex */
85         union logicalblk *logblk;       /* ptr to space for a logical block */
86         long    numblk;         /* number of block presently at *logblk */
87         long    keypnt;         /* number item in present block found */
88 } INVCONTROL;
89
90 typedef        struct  {
91        short   offset;         /* offset in this logical block */
92        unsigned char size;     /* size of term */
93        unsigned char space;    /* number of longs of growth space */
94        long    post;           /* number of postings for this entry */
95 } ENTRY;
96
97 typedef struct {
98         long    lineoffset;     /* source line database offset */
99         long    fcnoffset;      /* function name database offset */
100         long    fileindex : 24; /* source file name index */
101         long    type : 8;       /* reference type (mark character) */
102 } POSTING;
103
104 extern  long    *srcoffset;     /* source file name database offsets */
105 extern  int     nsrcoffset;     /* number of file name database offsets */
106
107
108 void    boolclear(void);
109 POSTING *boolfile(INVCONTROL *invcntl, long *num, int boolarg);
110 void    invclose(INVCONTROL *invcntl);
111 void    invdump(INVCONTROL *invcntl, char *term);
112 long    invfind(INVCONTROL *invcntl, char *searchterm);
113 int     invforward(INVCONTROL *invcntl);
114 int     invopen(INVCONTROL *invcntl, char *invname, char *invpost, int status);
115 long    invmake(char *invname, char *invpost, FILE *infile);
116 long    invterm(INVCONTROL *invcntl, char *term);
117
118 #endif /* CSCOPE_INVLIB_H */