home *** CD-ROM | disk | FTP | other *** search
/ Online Praxis 1996 April / OP4_96.ISO / surfen / astro / earthv / xd.doc < prev    next >
Text File  |  1996-08-19  |  5KB  |  108 lines

  1. XD(1)                    USER COMMANDS                      XD(1)
  2.  
  3. NAME
  4.      xd - binary to hexadecimal filter
  5.  
  6. SYNOPSIS
  7.      xd [ -c -dlabel -l -s ] [ infile [ outfile ] ]
  8.  
  9. DESCRIPTION
  10.      xd dumps files in hexadecimal, optionally with  ISO  charac-
  11.      ters  side  by side.  Unlike od, file addresses are given in
  12.      hex, not octal.
  13.  
  14.      xd can read dump files in the  same  format  it  writes  and
  15.      create  binary files from the hex data therein.  This allows
  16.      you to dump a  binary  file  with  xd,  edit  it  with  your
  17.      favourite   text   editor,   then make  a  new  binary  file
  18.      containing whatever changes you've made.   When  creating  a
  19.      binary  file,  xd normally assumes you've only modified data
  20.      in place (neither expanding nor contracting  the  file)  and
  21.      verifies  file  addresses  to  guarantee  this.   However, a
  22.      ``stream'' option is available which ignores file  addresses
  23.      so  you're free to insert and delete bytes at will.  xd thus
  24.      turns your existing text editor into a  binary  file  editor
  25.      without requiring you to learn any new commands.
  26.  
  27.      Finally, xd can read a binary file and  emit  a  C  language
  28.      data  declaration  which  contains  the  data from the file.
  29.      This is handy when you wish to embed binary  data  within  C
  30.      programs.
  31.  
  32. OPTIONS
  33.      -c        Display ISO characters alongside  the  hexadecimal
  34.                dump.   Non-printing  characters (according to ISO
  35.                8859/1) are shown as periods.  The ISO  characters
  36.                are  separated from the hexadecimal dump by verti-
  37.                cal bar characters, which  xd  treats  as  comment
  38.                delimiters when loading a hex file.
  39.  
  40.      -dlabel   Dumps the file as a C language declaration  of  an
  41.                array  of unsigned char which, when compiled, will
  42.                contain the same data as the  binary  input  file.
  43.                The C array declaration is given the variable name
  44.                label, or xd_data if  no  label  specification  is
  45.                given.   Data  are declared as individual bytes to
  46.                guarantee portability  across  architectures  with
  47.                different   byte  ordering  conventions,  and  are
  48.                expressed as decimal numbers in lines of less than
  49.                80  characters  for maximum portability among com-
  50.                pilers.  The C operator sizeof may be  applied  to
  51.                the array label to obtain its length in bytes.
  52.  
  53.      -l        Load file from hexadecimal dump.  xd reads a  file
  54.                in  the  same  format it writes, creating a binary
  55.                output file.  Each line is assumed to begin with a
  56.                file  address  terminated  by  a colon.  Each data
  57.                byte must be two hexadecimal  characters  (letters
  58.                may  be  upper  or lower case), and any characters
  59.                after a vertical bar are ignored (thus  discarding
  60.                any  ISO  characters included in the dump with the
  61.                -c option).  If the -s option  is  not  specified,
  62.                each file address is checked against the number of
  63.                bytes written so far to guarantee  that  no  bytes
  64.                have been added or deleted.
  65.  
  66.      -s        Stream input when loading file.  If this option is
  67.                specified  in conjunction with the -l option, file
  68.                addresses are not verified  when  loading  a  file
  69.                and,  in fact, need not be specified at all.  This
  70.                option treats the input file as stream  of  bytes,
  71.                each  specified  by  two hexadecimal digits.  This
  72.                option allows you to create a dump with  xd,  edit
  73.                it as you wish with any text editor, inserting and
  74.                deleting bytes in the file wherever you like, then
  75.                create  a  binary file from the modified dump with
  76.                the command xd -l -s dumpfile outfile.
  77.  
  78.      -u        Print how-to-call information.
  79.  
  80. FILES
  81.      If no infile is specified, xd obtains its input  from  stan-
  82.      dard  input; if no outfile is given, output is sent to stan-
  83.      dard output.  The  input  and  output  are  processed  in  a
  84.      strictly  serial  manner regardless of options; consequently
  85.      xd may be used in pipelines without restrictions.
  86.  
  87. BUGS
  88.      Input error checking in load mode might be  improved.   Note
  89.      that each byte in load mode must be specified as exactly two
  90.      adjacent hexadecimal digits and bytes must be  separated  by
  91.      white  space.   While  these  restrictions  could  be easily
  92.      relaxed in the scanner, doing so would make xd more  vulner-
  93.      able to typos in its input file, potentially leading to very
  94.      difficult to find errors in the binary files it creates.
  95.  
  96. SEE ALSO
  97.      cc(1), od(1), iso_8859_1(7)
  98.  
  99. AUTHOR
  100.                   John Walker (kelvin@fourmilab.ch)
  101.                WWW home page: http://www.fourmilab.ch/
  102.  
  103.      Permission  to  use,  copy,  modify,  and  distribute   this
  104.      software  and  its documentation for any purpose and without
  105.      fee is hereby granted, without any  conditions  or  restric-
  106.      tions.   This software is provided ``as is'' without express
  107.      or implied warranty.
  108.