110217Sphk/*
215284Snate * Copyright (c) 1995 Andrew McRae.  All rights reserved.
315284Snate *
415284Snate * Redistribution and use in source and binary forms, with or without
515284Snate * modification, are permitted provided that the following conditions
615284Snate * are met:
715284Snate * 1. Redistributions of source code must retain the above copyright
815284Snate *    notice, this list of conditions and the following disclaimer.
915284Snate * 2. Redistributions in binary form must reproduce the above copyright
1015284Snate *    notice, this list of conditions and the following disclaimer in the
1115284Snate *    documentation and/or other materials provided with the distribution.
1215284Snate * 3. The name of the author may not be used to endorse or promote products
1315284Snate *    derived from this software without specific prior written permission.
1415284Snate *
1515284Snate * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
1615284Snate * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
1715284Snate * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
1815284Snate * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
1915284Snate * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
2015284Snate * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2115284Snate * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2215284Snate * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2315284Snate * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
2415284Snate * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2515284Snate *
2650479Speter * $FreeBSD$
2710217Sphk */
2815284Snate
2915177Snatestruct tuple {
3010217Sphk	struct tuple *next;
3110217Sphk	unsigned char code;
3215177Snate	int     length;
3310217Sphk	unsigned char *data;
3415177Snate};
3510217Sphk
3615177Snatestruct tuple_list {
3710217Sphk	struct tuple_list *next;
3810217Sphk	struct tuple *tuples;
3915177Snate	off_t   offs;
4015177Snate	int     flags;
4115177Snate};
4210217Sphk
4315177Snatestruct tuple_info {
44185033Simp	const char   *name;
4510217Sphk	unsigned char code;
4615177Snate	unsigned char length;		/* 255 means variable length */
4715177Snate};
4815177Snate
4959656Siwasaki#define	tpl32(tp)	((*((tp) + 3) << 24) | \
5059656Siwasaki			 (*((tp) + 2) << 16) | \
5159656Siwasaki			 (*((tp) + 1) << 8)  | *(tp))
5259656Siwasaki#define	tpl24(tp)	((*((tp) + 2) << 16) | \
5359656Siwasaki			 (*((tp) + 1) << 8)  | *(tp))
5459656Siwasaki#define	tpl16(tp)	((*((tp) + 1) << 8)  | *(tp))
5559656Siwasaki
56185121Simpvoid    dumpcis(struct tuple_list *);
57185121Simpvoid    freecis(struct tuple_list *);
58185121Simpstruct tuple_list *readcis(int);
5916484Snate
60185033Simpconst char *tuple_name(unsigned char);
6159656Siwasakiu_int   parse_num(int, u_char *, u_char **, int);
62