]> git.ipfire.org Git - thirdparty/util-linux.git/blame - text-utils/hexdump.h
wipefs: add --lock and LOCK_BLOCK_DEVICE
[thirdparty/util-linux.git] / text-utils / hexdump.h
CommitLineData
6dbe3af9
KZ
1/*
2 * Copyright (c) 1989 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * @(#)hexdump.h 5.4 (Berkeley) 6/1/90
34 */
dc626a75
KZ
35#ifndef UTIL_LINUX_HEXDUMP_H
36#define UTIL_LINUX_HEXDUMP_H
37
9db51207
OO
38#include "c.h"
39#include "list.h"
6dbe3af9 40
098ab077
OO
41struct hexdump_clr {
42 struct list_head colorlist; /* next color unit */
43 const char *fmt; /* the color, UL_COLOR_* */
44 off_t offt; /* offset where unit is valid... */
45 int range; /* ... and it's range */
46 int val; /* value ... */
47 char *str; /* ... or string to match */
48 int invert; /* invert condition? */
49};
50
4c73d29c 51struct hexdump_pr {
bbc8c153 52 struct list_head prlist; /* next print unit */
6dbe3af9
KZ
53#define F_ADDRESS 0x001 /* print offset */
54#define F_BPAD 0x002 /* blank pad */
55#define F_C 0x004 /* %_c */
56#define F_CHAR 0x008 /* %c */
57#define F_DBL 0x010 /* %[EefGf] */
58#define F_INT 0x020 /* %[di] */
59#define F_P 0x040 /* %_p */
60#define F_STR 0x080 /* %s */
61#define F_U 0x100 /* %_u */
62#define F_UINT 0x200 /* %[ouXx] */
63#define F_TEXT 0x400 /* no conversions */
95961ee2 64 unsigned int flags; /* flag values */
6dbe3af9
KZ
65 int bcnt; /* byte count */
66 char *cchar; /* conversion character */
098ab077 67 struct list_head *colorlist; /* color settings */
6dbe3af9
KZ
68 char *fmt; /* printf format */
69 char *nospace; /* no whitespace version */
4c73d29c 70};
6dbe3af9 71
046921da 72struct hexdump_fu {
bbc8c153
OO
73 struct list_head fulist; /* next format unit */
74 struct list_head prlist; /* next print unit */
6dbe3af9
KZ
75#define F_IGNORE 0x01 /* %_A */
76#define F_SETREP 0x02 /* rep count set, not default */
95961ee2 77 unsigned int flags; /* flag values */
6dbe3af9
KZ
78 int reps; /* repetition count */
79 int bcnt; /* byte count */
80 char *fmt; /* format string */
046921da 81};
6dbe3af9 82
bb8ae572 83struct hexdump_fs { /* format strings */
bbc8c153
OO
84 struct list_head fslist; /* linked list of format strings */
85 struct list_head fulist; /* linked list of format units */
6dbe3af9 86 int bcnt;
bb8ae572 87};
6dbe3af9 88
1f77e9c3
OO
89struct hexdump {
90 struct list_head fshead; /* head of format strings */
91 ssize_t blocksize; /* data block size */
92 int exitval; /* final exit value */
93 ssize_t length; /* max bytes to read */
94 off_t skip; /* bytes to skip */
95};
96
046921da 97extern struct hexdump_fu *endfu;
ffc43748 98
6dbe3af9 99enum _vflag { ALL, DUP, FIRST, WAIT }; /* -v values */
ffc43748 100extern enum _vflag vflag;
fd6b7a7f 101
bb8ae572 102int block_size(struct hexdump_fs *);
1f77e9c3
OO
103void add_fmt(const char *, struct hexdump *);
104void rewrite_rules(struct hexdump_fs *, struct hexdump *);
105void addfile(char *, struct hexdump *);
106void display(struct hexdump *);
86be6a32 107void __attribute__((__noreturn__)) usage(void);
4c73d29c
OO
108void conv_c(struct hexdump_pr *, u_char *);
109void conv_u(struct hexdump_pr *, u_char *);
1f77e9c3
OO
110int next(char **, struct hexdump *);
111int parse_args(int, char **, struct hexdump *);
dc626a75
KZ
112
113#endif /* UTIL_LINUX_HEXDUMP_H */