hexdump.h revision 96793
11590Srgrimes/*
21590Srgrimes * Copyright (c) 1989, 1993
31590Srgrimes *	The Regents of the University of California.  All rights reserved.
41590Srgrimes *
51590Srgrimes * Redistribution and use in source and binary forms, with or without
61590Srgrimes * modification, are permitted provided that the following conditions
71590Srgrimes * are met:
81590Srgrimes * 1. Redistributions of source code must retain the above copyright
91590Srgrimes *    notice, this list of conditions and the following disclaimer.
101590Srgrimes * 2. Redistributions in binary form must reproduce the above copyright
111590Srgrimes *    notice, this list of conditions and the following disclaimer in the
121590Srgrimes *    documentation and/or other materials provided with the distribution.
131590Srgrimes * 3. All advertising materials mentioning features or use of this software
141590Srgrimes *    must display the following acknowledgement:
151590Srgrimes *	This product includes software developed by the University of
161590Srgrimes *	California, Berkeley and its contributors.
171590Srgrimes * 4. Neither the name of the University nor the names of its contributors
181590Srgrimes *    may be used to endorse or promote products derived from this software
191590Srgrimes *    without specific prior written permission.
201590Srgrimes *
211590Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
221590Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
231590Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
241590Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
251590Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
261590Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
271590Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
281590Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
291590Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
301590Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
311590Srgrimes * SUCH DAMAGE.
321590Srgrimes *
331590Srgrimes *	@(#)hexdump.h	8.1 (Berkeley) 6/6/93
3480290Sobrien * $FreeBSD: head/usr.bin/hexdump/hexdump.h 96793 2002-05-17 06:32:00Z tjr $
351590Srgrimes */
361590Srgrimes
371590Srgrimestypedef struct _pr {
381590Srgrimes	struct _pr *nextpr;		/* next print unit */
391590Srgrimes#define	F_ADDRESS	0x001		/* print offset */
401590Srgrimes#define	F_BPAD		0x002		/* blank pad */
411590Srgrimes#define	F_C		0x004		/* %_c */
421590Srgrimes#define	F_CHAR		0x008		/* %c */
431590Srgrimes#define	F_DBL		0x010		/* %[EefGf] */
441590Srgrimes#define	F_INT		0x020		/* %[di] */
451590Srgrimes#define	F_P		0x040		/* %_p */
461590Srgrimes#define	F_STR		0x080		/* %s */
471590Srgrimes#define	F_U		0x100		/* %_u */
481590Srgrimes#define	F_UINT		0x200		/* %[ouXx] */
491590Srgrimes#define	F_TEXT		0x400		/* no conversions */
501590Srgrimes	u_int flags;			/* flag values */
511590Srgrimes	int bcnt;			/* byte count */
521590Srgrimes	char *cchar;			/* conversion character */
531590Srgrimes	char *fmt;			/* printf format */
541590Srgrimes	char *nospace;			/* no whitespace version */
551590Srgrimes} PR;
561590Srgrimes
571590Srgrimestypedef struct _fu {
581590Srgrimes	struct _fu *nextfu;		/* next format unit */
591590Srgrimes	struct _pr *nextpr;		/* next print unit */
601590Srgrimes#define	F_IGNORE	0x01		/* %_A */
611590Srgrimes#define	F_SETREP	0x02		/* rep count set, not default */
621590Srgrimes	u_int flags;			/* flag values */
631590Srgrimes	int reps;			/* repetition count */
641590Srgrimes	int bcnt;			/* byte count */
651590Srgrimes	char *fmt;			/* format string */
661590Srgrimes} FU;
671590Srgrimes
681590Srgrimestypedef struct _fs {			/* format strings */
691590Srgrimes	struct _fs *nextfs;		/* linked list of format strings */
701590Srgrimes	struct _fu *nextfu;		/* linked list of format units */
711590Srgrimes	int bcnt;
721590Srgrimes} FS;
731590Srgrimes
741590Srgrimesextern FS *fshead;			/* head of format strings list */
751590Srgrimesextern int blocksize;			/* data block size */
7696787Stjrextern int odmode;			/* are we acting as od(1)? */
7796793Stjrextern int length;			/* amount of data to read */
7896793Stjrextern off_t skip;			/* amount of data to skip at start */
791590Srgrimesenum _vflag { ALL, DUP, FIRST, WAIT };	/* -v values */
8096793Stjrextern enum _vflag vflag;
811590Srgrimes
8292920Simpvoid	 add(const char *);
8392920Simpvoid	 addfile(char *);
8492920Simpvoid	 badcnt(char *);
8592920Simpvoid	 badconv(char *);
8692920Simpvoid	 badfmt(const char *);
8792920Simpvoid	 badsfmt(void);
8892920Simpvoid	 bpad(PR *);
8992920Simpvoid	 conv_c(PR *, u_char *);
9092920Simpvoid	 conv_u(PR *, u_char *);
9192920Simpvoid	 display(void);
9292920Simpvoid	 doskip(const char *, int);
9392920Simpvoid	 escape(char *);
9492920Simpu_char	*get(void);
9592920Simpvoid	 newsyntax(int, char ***);
9692920Simpint	 next(char **);
9792920Simpvoid	 nomem(void);
9892920Simpvoid	 oldsyntax(int, char ***);
9992920Simpvoid	 rewrite(FS *);
10092920Simpint	 size(FS *);
10192920Simpvoid	 usage(void);
102