1*4887Schin /*********************************************************************** 2*4887Schin * * 3*4887Schin * This software is part of the ast package * 4*4887Schin * Copyright (c) 1985-2007 AT&T Knowledge Ventures * 5*4887Schin * and is licensed under the * 6*4887Schin * Common Public License, Version 1.0 * 7*4887Schin * by AT&T Knowledge Ventures * 8*4887Schin * * 9*4887Schin * A copy of the License is available at * 10*4887Schin * http://www.opensource.org/licenses/cpl1.0.txt * 11*4887Schin * (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) * 12*4887Schin * * 13*4887Schin * Information and Software Systems Research * 14*4887Schin * AT&T Research * 15*4887Schin * Florham Park NJ * 16*4887Schin * * 17*4887Schin * Glenn Fowler <gsf@research.att.com> * 18*4887Schin * David Korn <dgk@research.att.com> * 19*4887Schin * Phong Vo <kpv@research.att.com> * 20*4887Schin * * 21*4887Schin ***********************************************************************/ 22*4887Schin #pragma prototyped 23*4887Schin /* 24*4887Schin * fast find private interface 25*4887Schin */ 26*4887Schin 27*4887Schin #ifndef _FINDLIB_H 28*4887Schin #define _FINDLIB_H 29*4887Schin 30*4887Schin #include <ast.h> 31*4887Schin #include <cdt.h> 32*4887Schin #include <ctype.h> 33*4887Schin #include <error.h> 34*4887Schin #include <ls.h> 35*4887Schin #include <regex.h> 36*4887Schin #include <vmalloc.h> 37*4887Schin 38*4887Schin #define FF_old 1 /* old format - 7 bit bigram */ 39*4887Schin #define FF_gnu 2 /* gnu 8 bit no bigram */ 40*4887Schin #define FF_dir 3 /* FF_gnu, dirs have trailing / */ 41*4887Schin #define FF_typ 4 /* FF_dir with types */ 42*4887Schin 43*4887Schin #define FF_gnu_magic "LOCATE02" 44*4887Schin #define FF_dir_magic "FIND-DIR-02" 45*4887Schin #define FF_typ_magic "FIND-DIR-TYPE-03" 46*4887Schin 47*4887Schin #define FF_ESC 0036 48*4887Schin #define FF_MAX 0200 49*4887Schin #define FF_MIN 0040 50*4887Schin #define FF_OFF 0016 51*4887Schin 52*4887Schin #define FF_SET_TYPE(p,i) ((p)->decode.bigram1[((i)>>3)&((1<<CHAR_BIT)-1)]|=(1<<((i)&07))) 53*4887Schin #define FF_OK_TYPE(p,i) (!(p)->types||((p)->decode.bigram1[((i)>>3)&((1<<CHAR_BIT)-1)]&(1<<((i)&07)))) 54*4887Schin 55*4887Schin typedef struct 56*4887Schin { 57*4887Schin char* end; 58*4887Schin char* type; 59*4887Schin char* restore; 60*4887Schin int count; 61*4887Schin int found; 62*4887Schin int ignorecase; 63*4887Schin int match; 64*4887Schin int peek; 65*4887Schin int swap; 66*4887Schin regex_t re; 67*4887Schin char bigram1[(1<<(CHAR_BIT-1))]; 68*4887Schin char bigram2[(1<<(CHAR_BIT-1))]; 69*4887Schin char path[PATH_MAX]; 70*4887Schin char temp[PATH_MAX]; 71*4887Schin char pattern[1]; 72*4887Schin } Decode_t; 73*4887Schin 74*4887Schin typedef struct 75*4887Schin { 76*4887Schin Dtdisc_t namedisc; 77*4887Schin Dtdisc_t indexdisc; 78*4887Schin Dt_t* namedict; 79*4887Schin Dt_t* indexdict; 80*4887Schin int prefix; 81*4887Schin unsigned char bigram[2*FF_MAX]; 82*4887Schin unsigned short code[FF_MAX][FF_MAX]; 83*4887Schin unsigned short hits[USHRT_MAX+1]; 84*4887Schin char path[PATH_MAX]; 85*4887Schin char mark[PATH_MAX]; 86*4887Schin char file[PATH_MAX]; 87*4887Schin char temp[PATH_MAX]; 88*4887Schin } Encode_t; 89*4887Schin 90*4887Schin typedef union 91*4887Schin { 92*4887Schin Decode_t code_decode; 93*4887Schin Encode_t code_encode; 94*4887Schin } Code_t; 95*4887Schin 96*4887Schin typedef struct 97*4887Schin { 98*4887Schin Dtlink_t byname; 99*4887Schin Dtlink_t byindex; 100*4887Schin unsigned long index; 101*4887Schin char name[1]; 102*4887Schin } Type_t; 103*4887Schin 104*4887Schin #define _FIND_PRIVATE_ \ 105*4887Schin Finddisc_t* disc; \ 106*4887Schin Vmalloc_t* vm; \ 107*4887Schin char** dirs; \ 108*4887Schin int* lens; \ 109*4887Schin Sfio_t* fp; \ 110*4887Schin Findverify_f verifyf; \ 111*4887Schin int generate; \ 112*4887Schin int method; \ 113*4887Schin int secure; \ 114*4887Schin int types; \ 115*4887Schin int verify; \ 116*4887Schin Code_t code; 117*4887Schin 118*4887Schin #define decode code.code_decode 119*4887Schin #define encode code.code_encode 120*4887Schin 121*4887Schin #include <find.h> 122*4887Schin 123*4887Schin #endif 124