home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional / OS2PRO194.ISO / os2 / packer / vv097exe / vvintro.asc < prev    next >
Text File  |  1993-01-07  |  24KB  |  334 lines

  1.  
  2. Introduction to VVencode/VVdecode
  3.  
  4.  
  5. Table  of  Contents
  6.  
  7. 1     Introduction  to  VVcode .....................: 2
  8.           1.1   The Aston Archive........................... 2
  9.           1.2   Specification for a Coding Scheme ..................: 3
  10.           1.3   The Search Commences ........................ 6
  11.                     1.3.1   Portable Coding Schemes .................. 6
  12.                     1.3.2   Platform Specific Coding Schemes .............: 7
  13.           1.4   VVcode is Born............................: 7
  14.                     1.4.1   A Production VVcode .................... 7
  15.                     1.4.2   Arguments against VVcode ................. 8
  16.           1.5   Availability of VVcode ........................: 8
  17.  
  18.  
  19.  
  20.                           1
  21.  
  22.  
  23. 1   Introduction  to  VVcode
  24.  
  25.     Reliable and faithful exchange of binary files between computers over networks is a well-known
  26. problem, especially if the computers use different operating systems and are connected to different
  27. networks via a gateway.  Unfortunately inter-networking and electronic mail are very much children
  28. of the 1960s:  they might have had to wait until the 1970s for their naissance, but their progenitors
  29. were mentally locked-in to the concept of the 7-bit ASCII code for conveying textual information.
  30. The  TEX  community  has  long  been  aware  of  this  problem  when  trying  to  exchange  "machine-
  31. independent"  `.dvi'  files  and  font-related  data  such  as  `.tfm'  and  `.pk'  files.  It  has  sometimes
  32. been possible to exchange this binary data by using encoding schemes that allow the data to be
  33. represented using a subset of the seven-bit ASCII character set.
  34.     Academics  and  authors  in  many  fields  have  hitherto  been  able  to  pass  `.tex'  files  back-and-
  35. forth  by  electronic  mail_apart  from  a  few  minor  quirks  and  blemishes,  such  TEX  source  files
  36. pass unharmed across the planet's networks.  Problems are encountered when mail passes through
  37. certain gateway machines which introduce irreversible character corruptions.  Particularly notorious
  38. is the Janet/Bitnet gateway which has the unfortunate habit of converting `^' to `"' and `"' to `%':
  39. since it leaves `%' itself unaffected, this makes recovery of the original file a non-trivial exercise.  It
  40. sometimes also changes the brace characters `-"' into odd characters above 128:  this is particularly
  41. embarrassing, of course, for `.tex' files!
  42.     For some years many TEX users,  particularly those working in languages other than English,
  43. and thus familiar with character set encodings containing other than the basic ASCII set, have been
  44. agitating for TEX to be able to handle input in their mother tongues, using their own languages'
  45. character sets.  In 1989, Knuth announced TEX V3, and implementors world-wide beavered away
  46. to  bring  each  implementation  up-to-date.  TEX  V3  now  supports  eight-bit  character  sets  and  so
  47. `.tex' source files are now effectively `binary' files and will therefore suffer from the same exchange
  48. problems experienced with `.dvi' files.
  49.     All those authors that had previously been able to cooperate, despite being separated by hun-
  50. dreds or thousands of miles, might once again be forced to entrust floppy disks to the vagaries of
  51. the world's postal systems (although one shouldn't underestimate the bandwidth of the Royal [or
  52. other] Mail system).
  53.     Unless or until the various e-mail protocols, networks and software are converted to support un-
  54. corrupted transmission of characters codes 0x20 : : :0x7e and 0xa1 : : :0xfe, it will have to become
  55. the norm for `.tex' sources to be encoded for transmission by e-mail.
  56.     This problem is of course well known outside the TEX community.
  57.  
  58. 1.1   The  Aston  Archive
  59.  
  60.     The author is a volunteer assistant to Peter Abbott in running the world's principal repository
  61. of TEX-related material at Aston University in Birmingham.  The archive (host:  TeX.Ac.Uk) holds
  62. several hundred megabytes of text and binary files including:
  63.    o  program sources for TEX, METAFONT, DVI drivers and many other utilities;
  64.  
  65.  
  66.    o  binary executables for a variety of popular operating systems (e.g.  Atari, Macintosh, MS-DOS,
  67.       Unix, VAX/VMS and VM/CMS);
  68.    o  METAFONT sources for Computer Modern and other fonts;
  69.    o  binary font files (mainly `.tfm' and `.pk') for a number of different output devices;
  70.    o  text macro and style files.
  71.     The archive provides access to these files via the following services:
  72.    o  NIFTP1  from Janet hosts_typically 300 megabytes of data are transferred every month; this
  73.       would  probably  be  much  greater  if  we  were  not  limited  by  the  bandwidth  of  our  9600Bd
  74.       connection to Janet.
  75.    o  FTP and Telnet access from Internet hosts.
  76.    o  Interactive browsing service via Janet PAD, including the facility to send files out using NIFTP
  77.       (and later FTP).
  78.    o  Interactive  browsing  service  via  dialup  modem  lines,  including  the  facility  to  download  files
  79.       using Kermit and similar protocols.
  80.    o  An e-mail file server which typically sends 150 megabytes of data per month to sites all over
  81.       the world (though predominantly to EARN/Bitnet sites).
  82.    o  A magnetic media distribution service via surface carriers.  Copies of the entire archive have
  83.       been sent to embryonic TEX communities in Czechoslovakia, Hungary and Poland.
  84.     We have experienced many problems trying to support all of these file types, operating systems
  85. and access methods.  The e-mail file server clearly needs a reliable method of encoding files if its
  86. many customers are not to be denied access to the non-text files in the archive.
  87.     Binary files such as `.pk' font files are stored in different ways to accommodate the requirements
  88. of the different operating systems supported.  Currently we maintain multiple font directory trees for
  89. the Macintosh, MS-DOS, Unix and VAX/VMS with all the attendant problems of synchronization,
  90. disk space and archivists' time.  We need a single storage format which allows export to all of our
  91. supported operating systems.
  92.  
  93. 1.2   Specification  for  a  Coding  Scheme
  94.  
  95.     In mid-1990, the archivists came to the conclusion that a universal encoding scheme was required
  96. to accommodate the many different kinds of file and file organizations that needed to be supported
  97. by the archive.
  98. _________________________________________
  99.  
  100.   1 Network Independent File Transfer Protocol _ in the UK, one does not perform the pseudo-
  101.     login that Internet users are accustomed to using with the FTP protocol:  instead, one issues a
  102.     "transfer request" for a file to be sent to or from the remote machine _ the transfer itself takes
  103.     place asynchronously.  One nice consequence is that such transfers can be queued for overnight
  104.     execution, leaving daytime bandwidth free for e-mail and true remote interactive logins.
  105.  
  106.  
  107.     Niel Kempson formulated the first draft of this specification in mid-1990;  the requirements of
  108. the encoding scheme may be summarized as follows:
  109. Preserving File Structure
  110.                 It is insufficient, especially for an archive holding text and binary files for a variety of
  111.                 machine types, merely to encode data simply as a stream of bytes:
  112.                    o   Virtually all operating systems (except Unix) make a distinction between binary
  113.                        and text files, so the coding system should recognize and maintain this distinction.
  114.                    o   Unix  and  most  PC-based  operating  systems  treat  files  as  streams  of  bytes  with
  115.                        no further structure imposed.  On the other hand, certain widely-used operating
  116.                        systems (e.g.  VAX/VMS and VM/CMS) have record-oriented file systems where
  117.                        different types of file are stored in a format appropriate to the type of file2 .
  118.                        For  these  operating  systems,  we  consider  it  essential  that  the  encoding  scheme
  119.                        should  identify,  preserve  and  record  the  most  commonly  used  file  organizations.
  120.                        The decoding program should be able to use this information to create the output
  121.                        file  using  the  organization  appropriate  to  the  operating  system  in  use.   If  the
  122.                        information is of no consequence to the receiving system, the default file structure
  123.                        (if  any)  should  be  created.   If  the  encoding  system  does  not  have  structure  in
  124.                        its files, the receiving system may provide suitable defaults automatically.  In all
  125.                        cases the programs should permit the user to override or supplement file structure
  126.                        information.
  127.                    o   Whenever possible, these details of structure should be determined automatically
  128.                        by the encoding program; at the very least, an indication of whether the file is text
  129.                        or binary shall be provided, even under an operating system such as Unix that need
  130.                        make no such distinction for its own use, to allow decoding to an appropriate file
  131.                        organization on those systems that do make such a distinction.
  132. Coding Scheme
  133.                 Whatever method is used must allow encoded data to be e-mailed:
  134.                    o   It should be possible to specify the coding table to be used to encode the data.
  135.                        The coding table used shall be recorded with each part of the encoded data.
  136.                    o   If a recorded coding table is found while decoding, it should be used to construct
  137.                        an appropriate decoding table.  Simple one-to-one character corruptions should be
  138.                        corrected as long as only one of the input characters is mapped to any one output
  139.                        character.
  140.                    o   The recommended encoding uses only the following characters:
  141.                                +-0123456789
  142.                                abcdefghijklmnopqrstuvwxyz
  143.                                ABCDEFGHIJKLMNOPQRSTUVWXYZ
  144. _________________________________________
  145.  
  146.   2 It is often argued that the increase in efficiency more than offsets the increase in complexity.
  147.  
  148.  
  149.                        Such an encoding as originally used for XXcode has been shown to pass successfully
  150.                        through all the gateways which are known to corrupt characters.
  151. Integrity of Encoded Data
  152.                 We want to ensure that the whole encoded file passes through the e-mail network.
  153.                    o   Encoded lines should be prefixed by an appropriate character string to distinguish
  154.                        them from unwanted lines such as mail headers and trailers.  Whilst not essential,
  155.                        this feature does assist the decoding program in ignoring these spurious data.
  156.                    o   Lines should not end with whitespace characters as some mailers and operating
  157.                        systems strip off trailing whitespace.
  158.                    o   The encoding program should calculate parameters of the input file such as the
  159.                        number of bytes and CRC and record them at the end of the encoded data.
  160.                        The  decoding  program  should  calculate  the  same  parameters  from  the  decoded
  161.                        data and compare the values obtained from those recorded at the end of the en-
  162.                        coded data.
  163. Making Files Mailable
  164.                 A mechanism is needed to overcome some gateways' refusal to handle large files.
  165.                    o   The encoding program should be able to split the encoded output into parts, each
  166.                        no larger than a maximum specified size.  Splitting the output into smaller parts
  167.                        is  useful  if  the  encoded  data  is  to  be  transmitted  using  electronic  mail  or  over
  168.                        unreliable network links that do not stay up long enough to transmit a large file.
  169.                        The recommended default maximum part size is 30kB.
  170.                    o   The  decoding  program  should  be  able  to  decode  a  multi-part  encoded  file  very
  171.                        flexibly.  It should not be necessary to:
  172.                         1.   strip out mail headers and trailers;
  173.                         2.   combine all of the parts into one file in the correct order;
  174.                         3.   process each part of the encoded data as a separate file.
  175.                    o   In addition any file specifications from the operating system on which the VVE
  176.                        file was created must not prevent the file from being decoded.
  177. Miscellaneous
  178.                 Further considerations include:
  179.                    o   Support for character sets other than ASCII is essential if the encoding scheme is to
  180.                        be useful to IBM hosts.  The encoding program should label the character set used
  181.                        by the encoded data, and both encoder and decoder should enable the conversion
  182.                        between the local character set and another character set.  For example a user on
  183.                        an EBCDIC host should be able to encode text files for transmission to another
  184.                        EBCDIC host, or to convert them to ASCII before encoding and transmission to
  185.                        an ASCII host.  Similarly, that user should be able to decode text files from ASCII
  186.                        and EBCDIC machines, creating EBCDIC output files.
  187.  
  188.  
  189.                    o   Where possible, the original file's timestamp should be encoded and used by the
  190.                        decoding program when recreating the file:  this will permit archives to retain the
  191.                        originator's time of creation for files, and thus permit the users (not to mention
  192.                        the archivists) to identify more clearly when a new version of a file has been made
  193.                        available.  Timezones should be supported where possible.
  194.                    o   The encoding and decoding schemes should be able to read and write files that are
  195.                        compatible with one or more of the well established coding schemes (e.g.  UUcode,
  196.                        XXcode).
  197.                    o   The  source  code  for  the  programs  should  be  freely  available.   It  should  also  be
  198.                        portable and usable with as many computers, operating systems and compilers as
  199.                        possible.
  200.  
  201. 1.3   The  Search  Commences
  202.  
  203.     Naturally, the first step was to examine the existing coding schemes in comparison with the above
  204. ideal specification.  Such schemes fell into two broad classes:  portable schemes, which were intended
  205. to permit the encoding of files on any computer architecture into a form that could be transmitted
  206. electronically, and decoded on the same or a different architecture; and platform-specific schemes,
  207. which provided rather better support for transferring files between two computers using the same
  208. architecture and operating system.
  209.  
  210. 1.3.1  Portable  Coding  Schemes
  211.  
  212.     The most commonly used coding schemes supported by a variety of platforms are:
  213.    o  BOO
  214.    o  UU
  215.    o  XX
  216.     Most implementations of these schemes known to the authors are designed for use with stream
  217. file  systems.  These  programs  have  no  means  of  recording,  let  alone  preserving,  record  structure
  218. and  are  thus  unsuitable  for  our  purposes.  This  is  not  surprising  since  UUcode  and  its  mutation
  219. XXcode were developed specifically for exchanging files between Unix systems.  In fairness to these
  220. schemes, they are well suited to the transmission of text files and certain unstructured binary files.
  221.     Standard  UUcode  encodes  files  using  characters  ` '  : :`:_'  of  ASCII.  This  can  result  in  one  or
  222. more spaces appearing at the ends of lines:  some mailers decide that this is information not worth
  223. transmitting, with consequent inability to reconstruct the original file.
  224.     Files containing characters such as `^' are often irreversibly corrupted by mail gateways;  this
  225. problem led to the development of XXcode which uses a rather more robust character set, namely:
  226.         +-0123456789
  227.         abcdefghijklmnopqrstuvwxyz
  228.         ABCDEFGHIJKLMNOPQRSTUVWXYZ
  229.  
  230.  
  231.     The encoding table used is recorded with the encoded data to allow the detection of character
  232. corruptions, and the correction of reversible character transpositions.  Whilst superficially a step
  233. forward, XXcode offered little more than most existing versions of UUcode, which already supported
  234. coding tables.  Its major contribution was in formalizing the encoding table, and in particular its
  235. default table was proof against all the known gateway-induced corruptions.
  236.  
  237. 1.3.2  Platform  Specific  Coding  Schemes
  238.  
  239.     Encoding  schemes  have  been  developed  to  support  transfer  of  files  possessing  some  structure
  240. which therefore cannot be reconstructed correctly when encoded by the portable schemes.  When
  241. the encoding and decoding programs of such a platform specific scheme are each used on the same
  242. computer  and  operating  system  type,  files  may  be  encoded  and  transmitted  with  a  great  deal
  243. of confidence that the decoded file will reproduce the original's structure and attributes in their
  244. entirety.
  245.     Examples of such programs are TELCODE and MFTU for VMS, NETDATA for IBM mainframes, and
  246. Stuffit and MacBinary for the Macintosh.  But these programs have the major disadvantage that
  247. they  have  each  been  implemented  only  on  the  single  architecture  for  which  they  were  designed:
  248. thus the only two of these schemes that could be used on the VMS-based Aston Archive would be
  249. of minimal interest elsewhere!
  250.     The Archive's content is in some respects artificially inflated by the presence of `.hqx' files for
  251. Macintoshes, `.boo' for MS-DOS, etc., which have to be held in pre-encoded form for transfer by
  252. those requiring them.
  253.  
  254. 1.4   VVcode  is  Born
  255.  
  256.     Realizing that none of the existing portable schemes were close enough to our ideal,  an early
  257. version of our specification was circulated on various mailing lists by Niel Kempson towards the
  258. end of 1990.  When the anticipated "nil return" was all that resulted, Brian Hamilton Kelly went
  259. ahead and created a rudimentary VVencode by modifying an existing VAX Pascal implementation
  260. of uuencode.  After generating the companion VVdecode, he then re-implemented the programs in
  261. Turbo C under the MS-DOS operating system on the IBM-PC, and thereby was able to prove that
  262. the new scheme was both viable and sufficient.
  263.     This  version  didn't  support  file  formats,  time  stamping,  file  splitting,  character  sets  or  CRC
  264. checking.
  265.  
  266. 1.4.1  A  Production  VVcode
  267.  
  268.     Following  the  minor  feasibility  study,  Niel  Kempson  re-engineered  the  pair  of  programs  from
  269. scratch (adding certain features of the evolving specification), paying particular attention to making
  270. the code portable across a wide variety of operating systems.  Particular care was taken to avoid
  271. the use of supposedly "standard" C functions that experience had shown behaved differently under
  272.  
  273.  
  274. individual manufacturer's implementations, or were even non-existent in some.  Therefore the code
  275. may sometimes appear to be performing certain operations in a very long-winded way;  it's very
  276. easy to look at it and say "why didn't the author use the foo() function, which does this much
  277. more  efficiently?",  but  this  function  may  not  even  exist  under  another  implementation  of  C,  or
  278. behave in a subtly different manner.
  279.     The core functions of VVcode are implemented as a collection of routines written in as portable
  280. a  fashion  as  possible,  and  a  separate  module  of  a  few  operating  system  specific  routines  for  file
  281. I/O, timestamping, command-line or other interface, etc.  Porting VVcode to a new platform should
  282. require only that this latter module be re-implemented, in most cases by adapting an existing one.
  283.     VVcode implements all of the features listed in the specification, apart from the ability to generate
  284. UUcode and XXcode compatible files.  However, the decoding program is backwards compatible and
  285. can decode files generated by UUcode and XXcode.
  286.  
  287. 1.4.2  Arguments  against  VVcode
  288.  
  289.     When  the  advent  of  the  VVcode  system  was  first  aired  in  the  various  electronic  digests,
  290. some heated debate followed along the lines that a new encoding scheme was unnecessary,  since
  291. UUcode/XXcode  sufficed  for  them.   However,  all  these  correspondents  were  Unix  users  who  had
  292. interpreted  the  `VV'  as  meaning  "Vax-to-Vax"  by  analogy  with  `uu'3  and  who  felt  that  such  a
  293. scheme should be private to VAXen.  The authors' reply was to the effect that the encoding scheme
  294. was intended to support the needs of archives like Aston's, and as such, had to provide
  295.   1.  an automated tool (it would be somewhat difficult to expect our users to be able to tell the
  296.       encoder  what  sort  of  file  structure  it  was  handling,  when  this  concept  was  entirely  alien  to
  297.       many of them);
  298.   2.  facilities to encode binaries for many operating systems;
  299.   3.  mail server features, such as splitting of large files;
  300.   4.  operation across the widest possible combination of platforms.
  301.     The  overhead  of  using  the  VVcode  system  is  at  most  a  couple  of  hundred  bytes  over  using
  302. UUcode,  and  the  extra  functionality  and  universality  with  respect  to  UUcode  or  XXcode  thereby
  303. comes almost for free.
  304.  
  305. 1.5   Availability  of  VVcode
  306.  
  307.     At present, the VVcode system is only available in C, but it has been shown to run successfully
  308. on the following combinations of hardware, operating system and compiler:
  309. _________________________________________
  310.  
  311.   3 `V' was chosen simply because it followed `U';  at one time, we'd seriously considered calling it
  312.     YAFES _ Yet Another File Encoding Scheme!
  313.  
  314.  
  315. Macintosh       At the time of writing (May 1991) John Rawnsley of the University of Warwick had
  316.                 commenced development of a Macintosh port, which will encode the resource and data
  317.                 forks in a manner that will permit the former to be ignored by non-Macintosh systems.
  318. MS-DOS
  319.                    o   IBM PS/2, PC (and clones); MS-DOS 3.3, 4.01, 5.00; Borland Turbo C 1.5, 2.0,
  320.                        Borland C++ 1.0, 2.0, 3.0 and Microsoft C 5.1, 6.0
  321. OS/2
  322.                    o   IBM PS/2, PC (and clones); OS/2 2.0; Microsoft C 6.0 and GNU C 2.1
  323. Unix
  324.                    o   Sun 3; SunOS 3.x and 4.0.3; native C and GNU C
  325.                    o   Sun Sparcstation 1; SunOS 4.1; native C and GNU C
  326.                    o   SCO Unix V/386 v3.2.2, Microsoft C compiler
  327. VAX/VMS
  328.                    o   All VAXen; VMS 5.2-5.4-1; VAX C V3.0-V3.2 and GNU C 1.40
  329. VM/CMS
  330.                    o   VM/CMS;  Whitesmith  C  compiler  v1.0  (This  implementation  was  ported  by
  331.                        Rainer Sch"opf; basing it upon the Unix implementation, this took him about one
  332.                        day.)
  333.  
  334.