2023-07-27 14:04:50 -04:00
|
|
|
/*===========================================================================
|
2023-08-04 14:34:51 -04:00
|
|
|
Copyright (c) 1998-2000, The Santa Cruz Operation
|
2023-07-27 14:04:50 -04:00
|
|
|
All rights reserved.
|
2023-08-04 14:34:51 -04:00
|
|
|
|
2023-07-27 14:04:50 -04:00
|
|
|
Redistribution and use in source and binary forms, with or without
|
|
|
|
modification, are permitted provided that the following conditions are met:
|
|
|
|
|
|
|
|
*Redistributions of source code must retain the above copyright notice,
|
|
|
|
this list of conditions and the following disclaimer.
|
|
|
|
|
|
|
|
*Redistributions in binary form must reproduce the above copyright notice,
|
|
|
|
this list of conditions and the following disclaimer in the documentation
|
|
|
|
and/or other materials provided with the distribution.
|
|
|
|
|
|
|
|
*Neither name of The Santa Cruz Operation nor the names of its contributors
|
|
|
|
may be used to endorse or promote products derived from this software
|
2023-08-04 14:34:51 -04:00
|
|
|
without specific prior written permission.
|
2023-07-27 14:04:50 -04:00
|
|
|
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
|
2023-08-04 15:09:58 -04:00
|
|
|
IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT falseT LIMITED TO,
|
2023-07-27 14:04:50 -04:00
|
|
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
2023-08-04 15:19:25 -04:00
|
|
|
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
|
2023-07-27 14:04:50 -04:00
|
|
|
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
2023-08-04 15:09:58 -04:00
|
|
|
CONSEQUENTIAL DAMAGES (INCLUDING, BUT falseT LIMITED TO, PROCUREMENT OF
|
2023-07-27 14:04:50 -04:00
|
|
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
INTERRUPTION)
|
|
|
|
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
2023-08-04 14:34:51 -04:00
|
|
|
DAMAGE.
|
2023-07-27 14:04:50 -04:00
|
|
|
=========================================================================*/
|
|
|
|
|
|
|
|
#ifndef CSCOPE_INVLIB_H
|
|
|
|
#define CSCOPE_INVLIB_H
|
|
|
|
|
2023-08-13 05:21:52 -04:00
|
|
|
#include <stdio.h> /* need definition of FILE* */
|
|
|
|
#include <limits.h> /* need definition of CHAR_MAX */
|
2023-07-27 14:04:50 -04:00
|
|
|
|
|
|
|
/* inverted index definitions */
|
|
|
|
|
|
|
|
/* postings temporary file long number coding into characters */
|
2023-08-13 05:21:52 -04:00
|
|
|
#if CHAR_MAX == 255
|
|
|
|
# define BASE 223 /* 255 - ' ' */
|
|
|
|
# define PRECISION 4 /* maximum digits after converting a long */
|
2023-07-27 14:04:50 -04:00
|
|
|
#else
|
2023-08-13 05:21:52 -04:00
|
|
|
# if CHAR_MAX == 127 /* assume sign-extension of a char when converted to an int */
|
|
|
|
# define BASE 95 /* 127 - ' ' */
|
|
|
|
# define PRECISION 5 /* maximum digits after converting a long */
|
2023-07-27 14:04:50 -04:00
|
|
|
# else
|
2023-08-13 05:21:52 -04:00
|
|
|
# error Need a platform with 8 bits in a char value
|
2023-07-27 14:04:50 -04:00
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* inverted index access parameters */
|
2023-08-13 05:21:52 -04:00
|
|
|
#define INVAVAIL 0
|
|
|
|
#define INVBUSY 1
|
|
|
|
#define INVALONE 2
|
2023-07-27 14:04:50 -04:00
|
|
|
|
|
|
|
/* boolean set operations */
|
2023-08-13 05:21:52 -04:00
|
|
|
#define bool_OR 3
|
|
|
|
#define AND 4
|
|
|
|
#define falseT 5
|
|
|
|
#define REVERSEfalseT 6
|
2023-07-27 14:04:50 -04:00
|
|
|
|
|
|
|
/* note that the entire first block is for parameters */
|
2023-08-13 05:21:52 -04:00
|
|
|
typedef struct {
|
|
|
|
long version; /* inverted index format version */
|
|
|
|
long filestat; /* file status word */
|
|
|
|
long sizeblk; /* size of logical block in bytes */
|
|
|
|
long startbyte; /* first byte of superfinger */
|
|
|
|
long supsize; /* size of superfinger in bytes */
|
|
|
|
long cntlsize; /* size of max cntl space (should be a multiple of BUFSIZ) */
|
|
|
|
long share; /* flag whether to use shared memory */
|
2023-07-27 14:04:50 -04:00
|
|
|
} PARAM;
|
|
|
|
|
2023-08-13 05:21:52 -04:00
|
|
|
typedef struct {
|
|
|
|
FILE *invfile; /* the inverted file ptr */
|
|
|
|
FILE *postfile; /* posting file ptr */
|
|
|
|
PARAM param; /* control parameters for the file */
|
|
|
|
char *iindex; /* ptr to space for superindex */
|
|
|
|
union logicalblk *logblk; /* ptr to space for a logical block */
|
|
|
|
long numblk; /* number of block presently at *logblk */
|
|
|
|
long keypnt; /* number item in present block found */
|
2023-07-27 14:04:50 -04:00
|
|
|
} INVCONTROL;
|
|
|
|
|
2023-08-13 05:21:52 -04:00
|
|
|
typedef struct {
|
|
|
|
short offset; /* offset in this logical block */
|
|
|
|
unsigned char size; /* size of term */
|
|
|
|
unsigned char space; /* number of longs of growth space */
|
|
|
|
long post; /* number of postings for this entry */
|
2023-07-27 14:04:50 -04:00
|
|
|
} ENTRY;
|
|
|
|
|
2023-08-13 05:21:52 -04:00
|
|
|
typedef struct {
|
|
|
|
long lineoffset; /* source line database offset */
|
|
|
|
long fcnoffset; /* function name database offset */
|
|
|
|
long fileindex : 24; /* source file name index */
|
|
|
|
long type : 8; /* reference type (mark character) */
|
2023-07-27 14:04:50 -04:00
|
|
|
} POSTING;
|
|
|
|
|
2023-08-13 05:21:52 -04:00
|
|
|
extern long *srcoffset; /* source file name database offsets */
|
|
|
|
extern int nsrcoffset; /* number of file name database offsets */
|
2023-07-27 14:04:50 -04:00
|
|
|
|
|
|
|
|
2023-08-13 05:21:52 -04:00
|
|
|
void boolclear(void);
|
|
|
|
POSTING *boolfile(INVCONTROL *invcntl, long *num, int boolarg);
|
|
|
|
void invclose(INVCONTROL *invcntl);
|
|
|
|
void invdump(INVCONTROL *invcntl, char *term);
|
|
|
|
long invfind(INVCONTROL *invcntl, char *searchterm);
|
|
|
|
int invforward(INVCONTROL *invcntl);
|
|
|
|
int invopen(INVCONTROL *invcntl, char *invname, char *invpost, int status);
|
|
|
|
long invmake(char *invname, char *invpost, FILE *infile);
|
|
|
|
long invterm(INVCONTROL *invcntl, char *term);
|
2023-07-27 14:04:50 -04:00
|
|
|
|
|
|
|
#endif /* CSCOPE_INVLIB_H */
|