xref: /titanic_41/usr/src/lib/libast/common/include/recfmt.h (revision 2654012f83cec5dc15b61dfe3e4a4915f186e7a6)
1 /***********************************************************************
2 *                                                                      *
3 *               This software is part of the ast package               *
4 *           Copyright (c) 1985-2007 AT&T Knowledge Ventures            *
5 *                      and is licensed under the                       *
6 *                  Common Public License, Version 1.0                  *
7 *                      by AT&T Knowledge Ventures                      *
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  * Glenn Fowler
25  * AT&T Research
26  *
27  * record format interface
28  */
29 
30 #ifndef _RECFMT_H
31 #define _RECFMT_H		1
32 
33 #include <ast.h>
34 
35 typedef uint32_t Recfmt_t;
36 
37 #define REC_delimited		0
38 #define REC_fixed		1
39 #define REC_variable		2
40 #define REC_method		14
41 #define REC_none		15
42 
43 #define REC_M_path		0
44 #define REC_M_data		1
45 
46 #define RECTYPE(f)		(((f)>>28)&((1<<4)-1))
47 
48 #define REC_D_TYPE(d)		((REC_delimited<<28)|((d)&((1<<8)-1)))
49 #define REC_D_DELIMITER(f)	((f)&((1<<8)-1))
50 
51 #define REC_F_TYPE(s)		((REC_fixed<<28)|((s)&((1<<28)-1)))
52 #define REC_F_SIZE(f)		((f)&((1<<28)-1))
53 
54 #define REC_U_TYPE(t,a)		(((t)<<28)|((a)&((1<<28)-1)))
55 #define REC_U_ATTRIBUTES(f)	((f)&~((1<<28)-1))
56 
57 #define REC_V_TYPE(h,o,z,l,i)	((REC_variable<<28)|((h)<<23)|((o)<<19)|(((z)-1)<<18)|((l)<<17)|((i)<<16))
58 #define REC_V_RECORD(f,s)	(((f)&(((1<<16)-1)<<16))|(s))
59 #define REC_V_HEADER(f)		(((f)>>23)&((1<<5)-1))
60 #define REC_V_OFFSET(f)		(((f)>>19)&((1<<4)-1))
61 #define REC_V_LENGTH(f)		((((f)>>18)&1)+1)
62 #define REC_V_LITTLE(f)		(((f)>>17)&1)
63 #define REC_V_INCLUSIVE(f)	(((f)>>16)&1)
64 #define REC_V_SIZE(f)		((f)&((1<<16)-1))
65 #define REC_V_ATTRIBUTES(f)	((f)&~((1<<16)-1))
66 
67 #define REC_M_TYPE(i)		((REC_method<<28)|(i))
68 #define REC_M_INDEX(f)		((f)&((1<<28)-1))
69 
70 #define REC_N_TYPE()		0xffffffff
71 
72 #if _BLD_ast && defined(__EXPORT__)
73 #define extern		__EXPORT__
74 #endif
75 
76 extern char*		fmtrec(Recfmt_t, int);
77 extern Recfmt_t		recfmt(const void*, size_t, off_t);
78 extern Recfmt_t		recstr(const char*, char**);
79 extern ssize_t		reclen(Recfmt_t, const void*, size_t);
80 
81 #undef	extern
82 
83 #endif
84