home *** CD-ROM | disk | FTP | other *** search
/ kermit.columbia.edu / kermit.columbia.edu.tar / kermit.columbia.edu / bin / msvv90sea.exe / MSBOOFLS.EXE / MSBOOFLS.DOC < prev    next >
Text File  |  1993-10-18  |  10KB  |  169 lines

  1.         THE PURPOSE AND USE OF ENCODED BINARY (BOO) FILES
  2.  
  3. Notes by R.N. Folsom                           17 October 1993
  4.     [Including material taken from Columbia University Kermit Documentation]
  5. Department of Economics
  6. San Jose State University
  7. San Jose, California  95192-0114
  8. Voice: (408)649-6383, 924-5418 or -5400
  9. Bitnet:  Folsom@SJSUvm1.bitnet             Internet: Folsom@SJSUvm1.SJSU.edu
  10.  
  11.         Binary files may include control codes and eight bit characters.  Binary 
  12. files include not only .EXE and .COM executable program files and supporting
  13. "overlay" program files, and files compressed using ARC, PAK, ZOO, ZIP, ARJ,
  14. LHA, or similar utilities, but also wordprocessing, spreadsheet, and database
  15. files that are formatted using control codes and other special characters.  To
  16. transmit such binary files electronically over a network usually requires some
  17. special network facility, such as the File Transfer Protocol (ftp).  But
  18. typically, not everyone on the network, indeed not all portions of the network,
  19. have access to every (or the same) file transmission facility.
  20.     As an alternative, it is tempting to send a binary file as part of an
  21. ordinary electronic mail ("E-mail") message.  But unfortunately, most electronic
  22. mail systems cannot transmit binary files.  Electronic mail typically transmits
  23. only ordinary "printable" characters:  alphabetic, numeric, and punctuation
  24. characters, --- no control codes, and only ASCII characters (described with only
  25. seven bits).  A file containing only such ordinary "printable" characters is
  26. often called a text file.
  27.     (Control characters have a numeric decimal value less than 32; special
  28. eight-bit characters have a numeric decimal value greater than 127.  Thus a text
  29. file's characters all have a numeric decimal value between 32 and 127,
  30. inclusive.)
  31.  
  32.         However, it is possible to electronically mail a binary file that has
  33. been "encoded" into a text file.  The encoded file is temporary:  after the
  34. transmission is complete, the encoded file is restored to its original binary
  35. form.
  36.     For example, Columbia University routinely distributes binary files ---
  37. particularly executable versions of its Kermit communication program --- over
  38. electronic mail networks (and using tape formats that do not allow binary files)
  39. by encoding the binary file into a ".boo" file, where boo is short for
  40. bootstrap.  A .boo file is a text file (no control codes and seven bit
  41. characters) which *is* suitable for electronic transmission.  Although
  42. Columbia's documentation does not say so explicitly, the .boo file technique can
  43. transmit as a text file not only Kermit programs but *any* binary file.
  44.  
  45.         The procedure is as follows:  The sender encodes the binary file into
  46. a .boo file using the program MSBMKB.EXE, with the syntax
  47.             MSBMKB filename.ext filename.boo,
  48. where the first filename is the input binary file and the second filename is the
  49. output .boo file which is suitable for electronic mail.  (Typically, the input
  50. binary file extension .ext will be .COM or .EXE if it is an executable file, or
  51. ARC, PAK, ZOO, ZIP, ARJ, LHA, or so forth if it is a compressed file.)  The
  52. sender then transmits the .boo file to its destination.  At the destination, the
  53. recipient decodes the .boo file into its original binary form using the program
  54. MSBPCT.EXE, with the syntax
  55.             MSBPCT filename.boo
  56. which recreates the original file filename.ext.  That's all there is to it.
  57.  
  58.     Of course, the sender needs MSBMKB.EXE, and the recipient needs
  59. MSBPCT.EXE --- or some substitute.  A substitute for MSBPCT.EXE is MSBPCT.BAS,
  60. an uncompiled "BASIC" program which (because it is uncompiled) is *not* a
  61. binary file and *can* be transmitted as is without any special treatment using 
  62. text-only electronic mail.  MSBPCT.BAS can be run by anyone with access to an
  63. MS-BASIC interpreter:  for example, assuming that MSBASIC.COM and MSBPCT.BAS
  64. both are available, the syntax
  65.             MSBASIC MSBPCT,
  66. with approopriate responses to the prompts that result, will decode the binary
  67. file encoded as  filename.boo  into the original  filename.ext.
  68.         Thus if the recipient does not have MSBPCT.EXE, the solution is to
  69. electronically mail him not only filename.boo but also MSBPCT.BAS, with
  70. which he can decode filename.boo into the original filename.ext.
  71.         However, because MSBPCT.BAS is not compiled, it will decode *very*
  72. slowly.  If several encoded binary files will be electronically mailed to
  73. this destination, the destination would undoubtedly appreciate having
  74. MSBPCT.EXE.  And if the destination will be mailing other binary files back,
  75. it will need MSBMKB.EXE.  Although these .EXE files could be sent on a floppy
  76. diskette using ordinary mail, a faster solution may be to encode MSBPCT.EXE into
  77. MSBPCT.BOO, and MSBMKB.EXE into MSBMKB.BOO, and electronically mail these
  78. encoded files, along with MSBPCT.BAS (to decode MSBPCT.BOO AND MSBMKB.BOO) to
  79. whomever doesn't have them.
  80.  
  81.         But an implication of the MSBMKB.BWR file, enclosed, is that MSBPCT.BAS
  82. will include extra characters in any .EXE file it creates;  thus the best
  83. procedure is to use MSBPCT.BAS to create a preliminary MSBPCT.EXE, rename it
  84. to, say, MSBPCT01.EXE, use MSBPCT01.EXE on MSBPCT.BOO to create a final
  85. MSBPCT.EXE, and use this final MSBPCT.EXE on MSBMKB.BOO to create MSBMKB.EXE
  86. and on  filename.boo  to create  filename.ext.
  87.  
  88.     MINIMIZING FILE SIZE.  The transmission will be more efficient the
  89. smaller the file, so the sender may wish first to compress the original (for
  90. example, using LHA or some similar program) before encoding it into a .boo file. 
  91. After the recipient has decoded the .boo file into the binary compressed file,
  92. he will need the appropriate utility to uncompress the binary file, unless it is
  93. self extracting.
  94. This "compress first" procedure is likely to be particularly useful if the
  95. original binary file is an executable .COM or .EXE file, a program overlay file,
  96. or a wordprocessing or spreadsheet or database file containing control codes or
  97. special characters.  But there is no point in compressing an already compressed
  98. file, unless the initial compression was inefficient --- and in that case, it
  99. makes more sense to undo the original compression and then do it over again with
  100. a more efficient compression routine.  (For example, if the original file were a
  101. Zip file, it could be UNZipped and then recompressed using LHA.)
  102.  
  103.  
  104.         COLUMBIA UNIVERSITY BOO FILE DOCUMENTATION
  105.  
  106.         For those interested in the rationale and technique underlying .boo
  107. files, the following edited explanation comes from Columbia's KERMIT USER
  108. GUIDE, eighth edition [for MS-Dos Kermit version 2.32/A], c1981-1989,
  109. Christine Gianone, editor:  Chapter 5, MS-DOS Kermit, section 5.14,
  110. "Installation of Kermit-MS", pages 135-136, distributed here under the
  111. permission granted by the title page notice.  This material seems to *not* be
  112. in Ms. Gianone's more recent book, USING MS-DOS KERMIT, Digital Press, either
  113. the first (1990) or second (1992) edition.
  114.  
  115.     "Binary files are generally not compatible with the common labeled tape
  116. formats (e.g. ANSI D), electronic mail, or raw downloading. . . .  A common
  117. [workaround] practice is to encode .EXE and other binary files into printable
  118. characters, such as hexadecimal digits, for transportability.  A simple 'hex'
  119. [hexadecimal] encoding results in two characters per 8-bit binary byte, plus
  120. CRLFs [carriage return (^M) followed by line feed (^L)], added every 80 (or
  121. less) hex characters to allow the file to pass through card-oriented links. 
  122. [Old `IBM' cards used to contain 80 characters.]  A hex file is therefore
  123. more than twice as large as the original binary file.
  124.     "A .BOO [*not* .B00] file is a more compact, but somewhat more
  125. complicated, encoding.  Every three binary bytes (24 bits) are split up into
  126. four 6-bit bytes with 48 (ASCII character '0') added to each, resulting in
  127. four ASCII characters ranging from '0' (ASCII 48) to 'o' (ASCII 111), with
  128. CRLFs added at or near 'column 76'.  The resulting file size would therefore
  129. be about 4/3 the .EXE file size.  This is still quite large, so .BOO files
  130. also compress consecutive null (zero) bytes.  Up to 78 consecutive nulls are
  131. compressed into two characters.  Tilde ('~') is the null-compression lead-in,
  132. and the following character indicates how many nulls are represented
  133. (subtract 48 from this character's ASCII value).  For instance, '~A' means 17
  134. consecutive nulls; '~~' means 78 of them.  Repeated nulls are very common in
  135. .EXE files.
  136.     "4-for-3 encoding combined with null compression reduces the size of the
  137. encoded file to approximately the same size as the original .EXE file, and
  138. sometimes even smaller.  The first line of a .BOO file is the name (in plain
  139. text) of the original file.  Here's what the first few lines of a typical
  140. .BOO file look like:
  141. MSVIBM.EXE
  142. CEYP0Id05@0P~3oomo2Y01FWeP8@007P000040HB4001'W~28bL005\W~2JBP00722V0ZHPYP:
  143. \8:H2]R2V0['PYP:68>H2S23V0YHPiP:Xg800;Qd~2UWD006Yg~20gl009]o~2L8000;20~~~~
  144. ~~~~~~~:R2H008TV?P761T410<H6@P40j4l6RRH0083l17@PP?'1M@?YSP20o0Ee0nUD0h3l
  145. 1WD3j0@3]0VjW03=8L?X4'N0o01h1\H6~20l>0i7n0o1]e7[@2\P0=8LH60@00Raj>04^97Xh0
  146. . . . . "
  147.  
  148.  
  149.         According to the MSKermit documentation above, the MSBMKB.EXE
  150. included here is written in assembly, and the MSBPCT.EXE included here is
  151. written in C.  But for both files, source code is available in a variety of
  152. languages:  Assembly, C, Turbo Pascal, and Fortran.  Thus instead of the
  153. BASIC program MSBPCT.BAS, any of the available source code MSBPCT.* programs
  154. could be electronically mailed to the destination, compiled there, and used
  155. to recreate the original filename.ext.
  156.  
  157.         Columbia distributes also the MSBHEX.C program, written in C, to
  158. produce and decode straight hex ASCII (seven bit character) files, which (as
  159. suggested above) although large, can be transmitted via electronic mail.
  160.  
  161.         For further information, contact
  162.                 Kermit Distribution, Department OP
  163.                 Columbia University Center for Computing Activities
  164.                 612 West 115th Street
  165.                 New York City, New York  10025
  166.                 (212)854-3703
  167.  
  168. End of MSBOOFLS.DOC.
  169.