home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Online Praxis 1996 April
/
OP4_96.ISO
/
surfen
/
astro
/
earthv
/
xd.doc
< prev
next >
Wrap
Text File
|
1996-08-19
|
5KB
|
108 lines
XD(1) USER COMMANDS XD(1)
NAME
xd - binary to hexadecimal filter
SYNOPSIS
xd [ -c -dlabel -l -s ] [ infile [ outfile ] ]
DESCRIPTION
xd dumps files in hexadecimal, optionally with ISO charac-
ters side by side. Unlike od, file addresses are given in
hex, not octal.
xd can read dump files in the same format it writes and
create binary files from the hex 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
-c Display ISO characters alongside the hexadecimal
dump. Non-printing characters (according to ISO
8859/1) are shown as periods. The ISO characters
are separated from the hexadecimal dump by verti-
cal bar characters, which xd treats as comment
delimiters when loading a hex 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 com-
pilers. The C operator sizeof may be applied to
the array label to obtain its length in bytes.
-l Load file from hexadecimal 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. Each data
byte must be two hexadecimal characters (letters
may be upper or lower case), 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.
-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. This
option treats the input file as stream of bytes,
each specified by two hexadecimal digits. 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 stan-
dard input; if no outfile is given, output is sent to stan-
dard 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 exactly two
adjacent hexadecimal digits and bytes must be separated by
white space. While these restrictions could be easily
relaxed in the scanner, doing so would make xd more vulner-
able to typos in its input file, potentially leading to very
difficult to find errors in the binary files it creates.
SEE ALSO
cc(1), od(1), iso_8859_1(7)
AUTHOR
John Walker (kelvin@fourmilab.ch)
WWW home page: http://www.fourmilab.ch/
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 restric-
tions. This software is provided ``as is'' without express
or implied warranty.