xref: /freebsd/lib/libutil/hexdump.3 (revision 076ad2f836d5f49dc1375f1677335a48fe0d4b82)
1.\" -*- nroff -*-
2.\"
3.\" Copyright (c) 2003 Scott Long
4.\"
5.\" All rights reserved.
6.\"
7.\" This program is free software.
8.\"
9.\" Redistribution and use in source and binary forms, with or without
10.\" modification, are permitted provided that the following conditions
11.\" are met:
12.\" 1. Redistributions of source code must retain the above copyright
13.\"    notice, this list of conditions and the following disclaimer.
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\"    notice, this list of conditions and the following disclaimer in the
16.\"    documentation and/or other materials provided with the distribution.
17.\"
18.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
19.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21.\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
22.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28.\"
29.\" $FreeBSD$
30.\"
31.Dd February 8, 2017
32.Dt HEXDUMP 3
33.Os
34.Sh NAME
35.Nm hexdump
36.Nd "dump a block of bytes to standard out in hexadecimal form"
37.Sh SYNOPSIS
38.In libutil.h
39.Ft void
40.Fn hexdump "void *ptr" "int length" "const char *hdr" "int flags"
41.In sys/types.h
42.In sys/sbuf.h
43.Ft void
44.Fo sbuf_hexdump
45.Fa "struct sbuf *sb"
46.Fa "void *ptr"
47.Fa "int length"
48.Fa "const char *hdr"
49.Fa "int flags"
50.Fc
51.Sh DESCRIPTION
52The
53.Fn hexdump
54function prints an array of bytes to standard out in hexadecimal form,
55along with the
56.Tn ASCII
57representation of the bytes, if possible.
58By default, each line of
59output will start with an offset count, followed by 16 hexadecimal values,
60followed by 16
61.Tn ASCII
62characters.
63.Pp
64The
65.Fn sbuf_hexdump
66function prints the hexdump to the supplied
67.Xr sbuf 9 .
68.Bl -tag -width indent
69.It Fa ptr
70Pointer to the array of bytes to print.
71It does not need to be
72.Dv NUL Ns
73-terminated.
74.It Fa length
75Number of bytes to print.
76.It Fa hdr
77Pointer to a
78.Dv NUL Ns
79-terminated character string that will be prepended to each
80line of output.
81A value of
82.Dv NULL
83implies that no header will be printed.
84.It Fa flags
85Flags for controlling the formatting of the output.
86.Bl -tag -width ".Dv HD_OMIT_COUNT"
87.It Bits 0-7
88Integer value of the number of bytes to display on each line.
89A value of 0 implies that the default value of 16 will be used.
90.It Bits 8-15
91Character
92.Tn ASCII
93value to use as the separator for the hexadecimal output.
94A value of 0 implies that the default value of 32
95.Tn ( ASCII
96space) will be used.
97.It Dv HD_OMIT_COUNT
98Do not print the offset column at the beginning of each line.
99.It Dv HD_OMIT_HEX
100Do not print the hexadecimal values on each line.
101.It Dv HD_OMIT_CHARS
102Do not print the character values on each line.
103.El
104.El
105.Sh SEE ALSO
106.Xr ascii 7 ,
107.Xr sbuf 9
108.Sh AUTHORS
109This manual page was written by
110.An Scott Long .
111