]> git.ipfire.org Git - thirdparty/util-linux.git/blame - text-utils/hexdump.h
libfdisk: (dos) accept start for log.partitions on template
[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 */
9db51207
OO
35#include "c.h"
36#include "list.h"
6dbe3af9 37
098ab077
OO
38struct hexdump_clr {
39 struct list_head colorlist; /* next color unit */
40 const char *fmt; /* the color, UL_COLOR_* */
41 off_t offt; /* offset where unit is valid... */
42 int range; /* ... and it's range */
43 int val; /* value ... */
44 char *str; /* ... or string to match */
45 int invert; /* invert condition? */
46};
47
4c73d29c 48struct hexdump_pr {
bbc8c153 49 struct list_head prlist; /* next print unit */
6dbe3af9
KZ
50#define F_ADDRESS 0x001 /* print offset */
51#define F_BPAD 0x002 /* blank pad */
52#define F_C 0x004 /* %_c */
53#define F_CHAR 0x008 /* %c */
54#define F_DBL 0x010 /* %[EefGf] */
55#define F_INT 0x020 /* %[di] */
56#define F_P 0x040 /* %_p */
57#define F_STR 0x080 /* %s */
58#define F_U 0x100 /* %_u */
59#define F_UINT 0x200 /* %[ouXx] */
60#define F_TEXT 0x400 /* no conversions */
95961ee2 61 unsigned int flags; /* flag values */
6dbe3af9
KZ
62 int bcnt; /* byte count */
63 char *cchar; /* conversion character */
098ab077 64 struct list_head *colorlist; /* color settings */
6dbe3af9
KZ
65 char *fmt; /* printf format */
66 char *nospace; /* no whitespace version */
4c73d29c 67};
6dbe3af9 68
046921da 69struct hexdump_fu {
bbc8c153
OO
70 struct list_head fulist; /* next format unit */
71 struct list_head prlist; /* next print unit */
6dbe3af9
KZ
72#define F_IGNORE 0x01 /* %_A */
73#define F_SETREP 0x02 /* rep count set, not default */
95961ee2 74 unsigned int flags; /* flag values */
6dbe3af9
KZ
75 int reps; /* repetition count */
76 int bcnt; /* byte count */
77 char *fmt; /* format string */
046921da 78};
6dbe3af9 79
bb8ae572 80struct hexdump_fs { /* format strings */
bbc8c153
OO
81 struct list_head fslist; /* linked list of format strings */
82 struct list_head fulist; /* linked list of format units */
6dbe3af9 83 int bcnt;
bb8ae572 84};
6dbe3af9 85
1f77e9c3
OO
86struct hexdump {
87 struct list_head fshead; /* head of format strings */
88 ssize_t blocksize; /* data block size */
89 int exitval; /* final exit value */
90 ssize_t length; /* max bytes to read */
91 off_t skip; /* bytes to skip */
92};
93
046921da 94extern struct hexdump_fu *endfu;
ffc43748 95
6dbe3af9 96enum _vflag { ALL, DUP, FIRST, WAIT }; /* -v values */
ffc43748 97extern enum _vflag vflag;
fd6b7a7f 98
bb8ae572 99int block_size(struct hexdump_fs *);
1f77e9c3
OO
100void add_fmt(const char *, struct hexdump *);
101void rewrite_rules(struct hexdump_fs *, struct hexdump *);
102void addfile(char *, struct hexdump *);
103void display(struct hexdump *);
85bf44b7 104void __attribute__((__noreturn__)) usage(FILE *out);
4c73d29c
OO
105void conv_c(struct hexdump_pr *, u_char *);
106void conv_u(struct hexdump_pr *, u_char *);
1f77e9c3
OO
107int next(char **, struct hexdump *);
108int parse_args(int, char **, struct hexdump *);