mb/google/fatcat: Move CSE sync at payload
[coreboot.git] / util / nvramtool / hexdump.h
blob2a4e5633a9df11fb8a52cbf62f9688c524345d21
1 /* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0-only */
3 #ifndef _HEXDUMP_H
4 #define _HEXDUMP_H
6 #include <stdint.h>
7 #include <sys/types.h>
8 #include <stdio.h>
10 /*--------------------------------------------------------------------------
11 * hexdump_format_t
13 * This specifies how the output of the 'hexdump' function should look.
15 * fields:
16 * bytes_per_line: the number of data bytes to display per line of
17 * output
18 * addrprint_width: Each line of output begins with the address of the
19 * first data byte displayed on that line. This
20 * specifies the number of bytes wide the address
21 * should be displayed as. This value must be from 1
22 * to 8.
23 * indent: This is a string to display at the start of each
24 * output line. Its purpose is to indent the output.
25 * sep1: This is a string to display between the address and
26 * the bytes of data displayed in hex. It serves as a
27 * separator.
28 * sep2: This is a string to display between individual hex
29 * values. It serves as a separator.
30 * sep3: This is a string to display between the bytes of
31 * data in hex and the bytes of data displayed as
32 * characters. It serves as a separator.
33 * nonprintable: This is a substitute character to display in place
34 * of nonprintable characters.
35 *--------------------------------------------------------------------------*/
36 typedef struct {
37 int bytes_per_line;
38 int addrprint_width;
39 const char *indent;
40 const char *sep1;
41 const char *sep2;
42 const char *sep3;
43 unsigned char nonprintable;
44 } hexdump_format_t;
46 /*--------------------------------------------------------------------------
47 * hexdump
49 * Write a hex dump of 'mem' to 'outfile'.
51 * parameters:
52 * mem: a pointer to the memory to display
53 * bytes: the number of bytes of data to display
54 * addrprint_start: The address to associate with the first byte of
55 * data. For instance, a value of 0 indicates that the
56 * first byte displayed should be labeled as byte 0.
57 * outfile: The place where the hex dump should be written.
58 * For instance, stdout or stderr may be passed here.
59 * format: A structure specifying how the hex dump should be
60 * formatted.
61 *--------------------------------------------------------------------------*/
62 void hexdump(const void *mem, int bytes, uint64_t addrprint_start,
63 FILE * outfile, const hexdump_format_t * format);
65 #endif /* _HEXDUMP_H */