Extended Dump and Load Utility
This page describes, in Unix manual page style,
xd, a utility which dumps files in hexadecimal,
decimal, or octal, with file addresses shown in any of
those formats. xd can read files in any of the
formats it writes, recreating binary files, including
modifications made by editing the dump with any text
editor. In addition, xd can transform a binary
file into a C data declaration which permits embedding
its contents into a program. xd is available as
C source code compatible with most Unix systems and
as a ready-to-run 32-bit Windows executable.
NAME
xd - extended dump and load utility
SYNOPSIS
xd [ -aaddrfmt -c
-dlabel -l -ndatafmt
-s ] [ infile [ outfile ] ]
DESCRIPTION
xd dumps files in hexadecimal, decimal, or octal, optionally with
ISO characters side by side. File addresses can likewise be
displayed in hex, decimal, or octal notation.
xd can read dump files in the same formats it writes and create
binary files from the data therein. This allows you to dump a
binary file with xd, edit it with your favourite text editor,
then make a new binary file containing whatever changes you've
made. When creating a binary file, xd normally assumes you've
only modified data in place (neither expanding nor contracting
the file) and verifies file addresses to guarantee this.
However, a "stream" option is available which ignores file
addresses so you're free to insert and delete bytes at will. xd
thus turns your existing text editor into a binary file editor
without requiring you to learn any new commands.
Finally, xd can read a binary file and emit a C language data
declaration which contains the data from the file. This is handy
when you wish to embed binary data within C programs.
OPTIONS
- -aaddrfmt
- Displays addresses in the dumped file as specified
by addrfmt: d for decimal, h or x for hexadecimal, and
o for octal. By default, addresses are shown in
hexadecimal.
- -c
- Display ISO characters alongside the numeric
dump. Non-printing characters (according to ISO
8859/1) are shown as periods. The ISO characters are
separated from the dump by vertical bar characters,
which xd treats as comment delimiters when loading a
file.
- -dlabel
- Dumps the file as a C language declaration of an
array of unsigned char which, when compiled, will
contain the same data as the binary input file. The C
array declaration is given the variable name label, or
xd_data if no label specification is given. Data are
declared as individual bytes to guarantee portability
across architectures with different byte ordering
conventions, and are expressed as decimal numbers in
lines of less than 80 characters for maximum
portability among compilers. The C operator sizeof may
be applied to the array label to obtain its length in
bytes.
- -l
- Load file from dump. xd reads a file in the same
format it writes, creating a binary output file. Each
line is assumed to begin with a file address terminated
by a colon. Data bytes are separated by white space,
and any characters after a vertical bar are ignored
(thus discarding any ISO characters included in the
dump with the -c option). If the -s option is not
specified, each file address is checked against the
number of bytes written so far to guarantee that no
bytes have been added or deleted. Files must be loaded
with the -a and -n options set the same as when the
file was dumped.
- -ndatafmt
- Edits bytes in the dumped file as specified by
datafmt: d for decimal, h or
x for hexadecimal, and o for octal. By
default, bytes are shown in hexadecimal.
- -s
- Stream input when loading file. If this option
is specified in conjunction with the -l option, file
addresses are not verified when loading a file and, in
fact, need not be specified at all. The input file is
treated as a stream of byte values separated by white
space. This option allows you to create a dump with
xd, edit it as you wish with any text editor, inserting
and deleting bytes in the file wherever you like, then
create a binary file from the modified dump with the
command xd -l -s dumpfile outfile.
- -u
- Print how-to-call information.
FILES
If no infile is specified, xd obtains its input from standard
input; if no outfile is given, output is sent to standard output.
The input and output are processed in a strictly serial manner
regardless of options; consequently xd may be used in pipelines
without restrictions.
BUGS
Input error checking in load mode might be improved. Note that
each byte in load mode must be specified as a number in the same
format selected by the -n option when the file was dumped,
separated by white space, and that the -a and -n options must be
set the same when loading a file as when it was dumped.
SEE ALSO
cc(1), od(1), iso_8859_1(7)
The release archive contains source code, a Makefile
for building the program, and documentation in manual page and
HTML form. A ready-to-run WIN32 executable,
xd.exe is included, along with the workspace
and project definition files used to build it with Microsoft
Visual C 5.0.
COPYING
This software is in the public domain. Permission to use, copy,
modify, and distribute this software and its documentation for
any purpose and without fee is hereby granted, without any
conditions or restrictions. This software is provided "as is"
without express or implied warranty.
by John Walker
Version 1.3
September, MM