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 * 4. Neither the name of the University nor the names of its contributors
141590Srgrimes *    may be used to endorse or promote products derived from this software
151590Srgrimes *    without specific prior written permission.
161590Srgrimes *
171590Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
181590Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
191590Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
201590Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
211590Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
221590Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
231590Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
241590Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
251590Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
261590Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
271590Srgrimes * SUCH DAMAGE.
281590Srgrimes *
291590Srgrimes *	@(#)hexdump.h	8.1 (Berkeley) 6/6/93
3080290Sobrien * $FreeBSD$
311590Srgrimes */
321590Srgrimes
33131954Stjr#include <wchar.h>
34131954Stjr
351590Srgrimestypedef struct _pr {
361590Srgrimes	struct _pr *nextpr;		/* next print unit */
371590Srgrimes#define	F_ADDRESS	0x001		/* print offset */
381590Srgrimes#define	F_BPAD		0x002		/* blank pad */
391590Srgrimes#define	F_C		0x004		/* %_c */
401590Srgrimes#define	F_CHAR		0x008		/* %c */
411590Srgrimes#define	F_DBL		0x010		/* %[EefGf] */
421590Srgrimes#define	F_INT		0x020		/* %[di] */
431590Srgrimes#define	F_P		0x040		/* %_p */
441590Srgrimes#define	F_STR		0x080		/* %s */
451590Srgrimes#define	F_U		0x100		/* %_u */
461590Srgrimes#define	F_UINT		0x200		/* %[ouXx] */
471590Srgrimes#define	F_TEXT		0x400		/* no conversions */
481590Srgrimes	u_int flags;			/* flag values */
491590Srgrimes	int bcnt;			/* byte count */
501590Srgrimes	char *cchar;			/* conversion character */
511590Srgrimes	char *fmt;			/* printf format */
521590Srgrimes	char *nospace;			/* no whitespace version */
53131954Stjr	int mbleft;			/* bytes left of multibyte char. */
54131954Stjr	mbstate_t mbstate;		/* conversion state */
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 */
75102944Sdwmaloneextern FU *endfu;			/* format at end-of-data */
761590Srgrimesextern int blocksize;			/* data block size */
77102944Sdwmaloneextern int exitval;			/* final exit value */
7896787Stjrextern int odmode;			/* are we acting as od(1)? */
7996793Stjrextern int length;			/* amount of data to read */
8096793Stjrextern off_t skip;			/* amount of data to skip at start */
811590Srgrimesenum _vflag { ALL, DUP, FIRST, WAIT };	/* -v values */
8296793Stjrextern enum _vflag vflag;
831590Srgrimes
8492920Simpvoid	 add(const char *);
8592920Simpvoid	 addfile(char *);
8692920Simpvoid	 badcnt(char *);
8792920Simpvoid	 badconv(char *);
8892920Simpvoid	 badfmt(const char *);
8992920Simpvoid	 badsfmt(void);
9092920Simpvoid	 bpad(PR *);
91131954Stjrvoid	 conv_c(PR *, u_char *, size_t);
9292920Simpvoid	 conv_u(PR *, u_char *);
9392920Simpvoid	 display(void);
9492920Simpvoid	 doskip(const char *, int);
9592920Simpvoid	 escape(char *);
9692920Simpu_char	*get(void);
9792920Simpvoid	 newsyntax(int, char ***);
9892920Simpint	 next(char **);
9992920Simpvoid	 nomem(void);
10092920Simpvoid	 oldsyntax(int, char ***);
101131954Stjrsize_t	 peek(u_char *, size_t);
10292920Simpvoid	 rewrite(FS *);
10392920Simpint	 size(FS *);
10492920Simpvoid	 usage(void);
105