hexdump.h revision 131954
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 131954 2004-07-11 01:11:12Z tjr $ 351590Srgrimes */ 361590Srgrimes 37131954Stjr#include <wchar.h> 38131954Stjr 391590Srgrimestypedef struct _pr { 401590Srgrimes struct _pr *nextpr; /* next print unit */ 411590Srgrimes#define F_ADDRESS 0x001 /* print offset */ 421590Srgrimes#define F_BPAD 0x002 /* blank pad */ 431590Srgrimes#define F_C 0x004 /* %_c */ 441590Srgrimes#define F_CHAR 0x008 /* %c */ 451590Srgrimes#define F_DBL 0x010 /* %[EefGf] */ 461590Srgrimes#define F_INT 0x020 /* %[di] */ 471590Srgrimes#define F_P 0x040 /* %_p */ 481590Srgrimes#define F_STR 0x080 /* %s */ 491590Srgrimes#define F_U 0x100 /* %_u */ 501590Srgrimes#define F_UINT 0x200 /* %[ouXx] */ 511590Srgrimes#define F_TEXT 0x400 /* no conversions */ 521590Srgrimes u_int flags; /* flag values */ 531590Srgrimes int bcnt; /* byte count */ 541590Srgrimes char *cchar; /* conversion character */ 551590Srgrimes char *fmt; /* printf format */ 561590Srgrimes char *nospace; /* no whitespace version */ 57131954Stjr int mbleft; /* bytes left of multibyte char. */ 58131954Stjr mbstate_t mbstate; /* conversion state */ 591590Srgrimes} PR; 601590Srgrimes 611590Srgrimestypedef struct _fu { 621590Srgrimes struct _fu *nextfu; /* next format unit */ 631590Srgrimes struct _pr *nextpr; /* next print unit */ 641590Srgrimes#define F_IGNORE 0x01 /* %_A */ 651590Srgrimes#define F_SETREP 0x02 /* rep count set, not default */ 661590Srgrimes u_int flags; /* flag values */ 671590Srgrimes int reps; /* repetition count */ 681590Srgrimes int bcnt; /* byte count */ 691590Srgrimes char *fmt; /* format string */ 701590Srgrimes} FU; 711590Srgrimes 721590Srgrimestypedef struct _fs { /* format strings */ 731590Srgrimes struct _fs *nextfs; /* linked list of format strings */ 741590Srgrimes struct _fu *nextfu; /* linked list of format units */ 751590Srgrimes int bcnt; 761590Srgrimes} FS; 771590Srgrimes 781590Srgrimesextern FS *fshead; /* head of format strings list */ 79102944Sdwmaloneextern FU *endfu; /* format at end-of-data */ 801590Srgrimesextern int blocksize; /* data block size */ 81102944Sdwmaloneextern int exitval; /* final exit value */ 8296787Stjrextern int odmode; /* are we acting as od(1)? */ 8396793Stjrextern int length; /* amount of data to read */ 8496793Stjrextern off_t skip; /* amount of data to skip at start */ 851590Srgrimesenum _vflag { ALL, DUP, FIRST, WAIT }; /* -v values */ 8696793Stjrextern enum _vflag vflag; 871590Srgrimes 8892920Simpvoid add(const char *); 8992920Simpvoid addfile(char *); 9092920Simpvoid badcnt(char *); 9192920Simpvoid badconv(char *); 9292920Simpvoid badfmt(const char *); 9392920Simpvoid badsfmt(void); 9492920Simpvoid bpad(PR *); 95131954Stjrvoid conv_c(PR *, u_char *, size_t); 9692920Simpvoid conv_u(PR *, u_char *); 9792920Simpvoid display(void); 9892920Simpvoid doskip(const char *, int); 9992920Simpvoid escape(char *); 10092920Simpu_char *get(void); 10192920Simpvoid newsyntax(int, char ***); 10292920Simpint next(char **); 10392920Simpvoid nomem(void); 10492920Simpvoid oldsyntax(int, char ***); 105131954Stjrsize_t peek(u_char *, size_t); 10692920Simpvoid rewrite(FS *); 10792920Simpint size(FS *); 10892920Simpvoid usage(void); 109