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