1330449Seadler/*-
2330449Seadler * SPDX-License-Identifier: BSD-3-Clause
3330449Seadler *
415284Snate * Copyright (c) 1995 Andrew McRae.  All rights reserved.
515284Snate *
615284Snate * Redistribution and use in source and binary forms, with or without
715284Snate * modification, are permitted provided that the following conditions
815284Snate * are met:
915284Snate * 1. Redistributions of source code must retain the above copyright
1015284Snate *    notice, this list of conditions and the following disclaimer.
1115284Snate * 2. Redistributions in binary form must reproduce the above copyright
1215284Snate *    notice, this list of conditions and the following disclaimer in the
1315284Snate *    documentation and/or other materials provided with the distribution.
1415284Snate * 3. The name of the author may not be used to endorse or promote products
1515284Snate *    derived from this software without specific prior written permission.
1615284Snate *
1715284Snate * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
1815284Snate * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
1915284Snate * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
2015284Snate * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
2115284Snate * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
2215284Snate * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2315284Snate * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2415284Snate * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2515284Snate * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
2615284Snate * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2715284Snate *
2850479Speter * $FreeBSD: stable/11/usr.sbin/dumpcis/readcis.h 330449 2018-03-05 07:26:05Z eadler $
2910217Sphk */
3015284Snate
3115177Snatestruct tuple {
3210217Sphk	struct tuple *next;
3310217Sphk	unsigned char code;
3415177Snate	int     length;
3510217Sphk	unsigned char *data;
3615177Snate};
3710217Sphk
3815177Snatestruct tuple_list {
3910217Sphk	struct tuple_list *next;
4010217Sphk	struct tuple *tuples;
4115177Snate	off_t   offs;
4215177Snate	int     flags;
4315177Snate};
4410217Sphk
4515177Snatestruct tuple_info {
46185033Simp	const char   *name;
4710217Sphk	unsigned char code;
4815177Snate	unsigned char length;		/* 255 means variable length */
4915177Snate};
5015177Snate
5159656Siwasaki#define	tpl32(tp)	((*((tp) + 3) << 24) | \
5259656Siwasaki			 (*((tp) + 2) << 16) | \
5359656Siwasaki			 (*((tp) + 1) << 8)  | *(tp))
5459656Siwasaki#define	tpl24(tp)	((*((tp) + 2) << 16) | \
5559656Siwasaki			 (*((tp) + 1) << 8)  | *(tp))
5659656Siwasaki#define	tpl16(tp)	((*((tp) + 1) << 8)  | *(tp))
5759656Siwasaki
58185121Simpvoid    dumpcis(struct tuple_list *);
59185121Simpvoid    freecis(struct tuple_list *);
60185121Simpstruct tuple_list *readcis(int);
6116484Snate
62185033Simpconst char *tuple_name(unsigned char);
6359656Siwasakiu_int   parse_num(int, u_char *, u_char **, int);
64