1 /***********************************************************************
2 *                                                                      *
3 *               This software is part of the ast package               *
4 *          Copyright (c) 1996-2011 AT&T Intellectual Property          *
5 *                      and is licensed under the                       *
6 *                 Eclipse Public License, Version 1.0                  *
7 *                    by AT&T Intellectual Property                     *
8 *                                                                      *
9 *                A copy of the License is available at                 *
10 *          http://www.eclipse.org/org/documents/epl-v10.html           *
11 *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         *
12 *                                                                      *
13 *              Information and Software Systems Research               *
14 *                            AT&T Research                             *
15 *                           Florham Park NJ                            *
16 *                                                                      *
17 *                   Phong Vo <kpv@research.att.com>                    *
18 *                 Glenn Fowler <gsf@research.att.com>                  *
19 *                                                                      *
20 ***********************************************************************/
21 #pragma prototyped
22 
23 /*
24  * rskey internal interface
25  */
26 
27 #ifndef _RSKEYHDR_H
28 #define _RSKEYHDR_H	1
29 
30 #if _PACKAGE_ast
31 #include <ast.h>
32 #endif
33 
34 #include <ctype.h>
35 #include <ccode.h>
36 
37 #ifndef UCHAR_MAX
38 #define UCHAR_MAX	((unsigned char)(~0))
39 #endif
40 #ifndef SHRT_MAX
41 #define SHRT_MAX	((short)(~((unsigned short)0)) >> 1)
42 #endif
43 #ifndef INT_MAX
44 #define INT_MAX		((int)(~((unsigned int)0)) >> 1)
45 #endif
46 #ifndef LONG_MAX
47 #define LONG_MAX	((long)(~((unsigned long)0)) >> 1)
48 #endif
49 
50 #define INSIZE		PROCSIZE	/* default insize		*/
51 #define OUTSIZE		(64*1024)	/* default outsize		*/
52 #define PROCSIZE	(4*1024*1024)	/* default procsize		*/
53 
54 #define MAXFIELD	INT_MAX
55 
56 #define blank(c)	((c)==' '||(c)=='\t')
57 
58 typedef struct Position_s		/* field position		*/
59 {
60 	int		field;		/* field offset			*/
61 	int		index;		/* char offset			*/
62 } Position_t;
63 
64 #define _RSKEYFIELD_PRIVATE_ \
65 	unsigned char	aflag;		/* accumulate dups here		*/ \
66 	unsigned char	bflag;		/* skip initial blanks		*/ \
67 	unsigned char	eflag;		/* skip trailing blanks		*/ \
68 	unsigned char	standard;	/* 1:-k 0:+pos-pos		*/ \
69 	int		binary;		/* binary data			*/ \
70 	int		code;		/* coder ccode or conversion	*/ \
71 	int		index;		/* field definition index	*/ \
72 	int		freetrans;	/* free trans on close		*/ \
73 	unsigned char*	trans;		/* translation table		*/ \
74 	unsigned char*	keep;		/* deletion table		*/ \
75 	void*		data;		/* coder specific data		*/ \
76 	Position_t	begin;		/* key begins here		*/ \
77 	Position_t	end;		/* and ends here		*/
78 
79 typedef struct
80 {
81 	unsigned char	ident[UCHAR_MAX + 1];	/* identity transform	*/
82 	unsigned char	fold[UCHAR_MAX + 1];	/* fold case		*/
83 
84 	unsigned char	all[UCHAR_MAX + 1];	/* all significant	*/
85 	unsigned char	dict[UCHAR_MAX + 1];	/* dictionary order	*/
86 	unsigned char	print[UCHAR_MAX + 1];	/* printable significant*/
87 } State_t;
88 
89 #define _RSKEY_PRIVATE_ \
90 	State_t*	state;		/* readonly state		*/ \
91 	Rsdisc_t*	disctail;	/* rslib() disc stack tail	*/ \
92 	struct								   \
93 	{								   \
94 	Rskeyfield_t	global;		/* global field info		*/ \
95 	Rskeyfield_t*	prev;		/* previous field list tail	*/ \
96 	int		index;		/* last field index		*/ \
97 	int		maxfield;	/* max field position		*/ \
98 	unsigned char**	positions;	/* field start positions	*/ \
99 	}		field;		/* key field info		*/ \
100 	struct								   \
101 	{								   \
102 	Rskeyfield_t*	head;		/* accumulate list head		*/ \
103 	Rskeyfield_t*	tail;		/* accumulate list tail		*/ \
104 	}		accumulate;	/* accumulate field info	*/ \
105 	unsigned char*	xfrmbuf;	/* strxfrm buffer		*/ \
106 	unsigned int	xfrmsiz;	/* strxfrm buffer size		*/ \
107 	unsigned long	shuffle;	/* shuffle seed			*/ \
108 	unsigned char	coded;		/* coded keys specified		*/
109 
110 #include "rshdr.h"
111 
112 #if !__STD_C && !defined(const)
113 #define const
114 #endif
115 
116 #if !_PACKAGE_ast
117 #if __STD_C
118 #include <string.h>
119 #endif
120 #define elementsof(x)	(sizeof(x)/sizeof(x[0]))
121 #define roundof(x,y)	(((x)+(y)-1)&~((y)-1))
122 #define streq(a,b)	(*(a)==*(b)&&!strcmp(a,b))
123 #endif
124 
125 #endif
126