home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 9 Archive / 09-Archive.zip / xbin21.zip / original.zip / xbinunix.rme < prev   
Text File  |  1989-03-04  |  4KB  |  91 lines

  1. This is version 2.3 of xbin.  The major changes include
  2. perfomance improvements from Dan LaLiberte of UIUC, fixes
  3. for 16-bit machines from Jim Budler of AMD, and a fix for
  4. a bug in the run-length encoding code.
  5.  
  6. This version of "xbin" can handle all three BinHex formats
  7. (so far).  Thanks to Darin Adler at TMQ Software for providing
  8. the code to compute and check the CRC values for all three formats.
  9. (There are no plans to support binhex5.0, as its use of binary
  10. encoding makes it useless for sending programs through e-mail).
  11.  
  12. Other new features include "list" and "verbose" modes, the
  13. ability to convert several binhex files at one time, the ability
  14. to read standard input, somewhat better error handling, and a
  15. manual page.
  16.  
  17. Any extraneous mail or news headers are ignored, but xbin relies
  18. on finding a line which starts with "(This file" to know when
  19. the header ends and the good stuff begins.  You can add one
  20. of these by hand if it's been lost.
  21.  
  22. To compile it on USG systems, type:
  23.     cc -o xbin xbin.c
  24.  
  25. or on Berkeley systems:
  26.     cc -o xbin xbin.c -DBSD
  27.  
  28. As usual, please report any problems, suggestions, or
  29. improvements to me.
  30.  
  31.     Dave Johnson
  32.     Brown University Computer Science
  33.     ddj%brown@csnet-relay.ARPA
  34.     {ihnp4,decvax,allegra,ulysses,linus}!brunix!ddj
  35.  
  36. ===================
  37. Here's an informal description of the HQX format as I understand it:
  38. -----
  39. The first and last characters are each a ':'.  After the first ':',
  40. the rest of the file is just string of 6 bit encoded characters.
  41. All newlines and carriage returns are to be ignored.
  42.  
  43. The tricky part is that there are holes in the translation string
  44. so you have to look up each file character to get its binary 6 bit
  45. value.  I found the string by looking at a hex dump of BinHex:
  46.  
  47.     !"#$%&'()*+,-012345689@ABCDEFGHIJKLMNPQRSTUVXYZ[`abcdefhijklmpqr
  48.  
  49. I can't see how this aids or abets any kind of error recovery, but
  50. if you ran into a char not in the list, you would know something's
  51. wrong and give up.
  52.  
  53. There is some run length encoding, where the character to be repeated
  54. is followed by a 0x90 byte then the repeat count.  For example, ff9004
  55. means repeat 0xff 4 times.  The special case of a repeat count of zero
  56. means it's not a run, but a literal 0x90.  2b9000 => 2b90.
  57.  
  58. *** Note: the 9000 can be followed by a run, which means to repeat the
  59. 0x90 (not the character previous to that).  That is, 2090009003 means
  60. a 0x20 followed by 3 0x90's.
  61.  
  62. Once you've turned the 6 bit chars into 8, you can parse the header.
  63. The header format consists of a one byte name length, then the mac
  64. file name, then a null.  The rest of the header is 20 bytes long,
  65. and contains the usual file type, creator/author, file flags, data
  66. and resource lengths, and the two byte crc value for the header.
  67.  
  68. The data fork and resource fork contents follow in that order.
  69. There is a two byte file crc at the end of each fork.  If a fork
  70. is empty, there will be no bytes of contents and the checksum
  71. will be two bytes of zero.
  72.  
  73. So the decoded data between the first and last ':' looks like:
  74.  
  75.      1       n       4    4    2    4    4   2    (length)
  76.     +-+---------+-+----+----+----+----+----+--+
  77.     |n| name... |0|TYPE|AUTH|FLAG|DLEN|RLEN|HC|    (contents)
  78.     +-+---------+-+----+----+----+----+----+--+
  79.  
  80.             DLEN             2    (length)
  81.     +--------------------------------------+--+
  82.     |    DATA FORK               |DC|    (contents)
  83.     +--------------------------------------+--+
  84.  
  85.             RLEN             2    (length)
  86.     +--------------------------------------+--+
  87.     |    RESOURCE FORK               |RC|    (contents)
  88.     +--------------------------------------+--+
  89.  
  90. ------
  91.