home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional / OS2PRO194.ISO / os2 / packer / vv097exe / vvintro.tex < prev    next >
Text File  |  1992-12-28  |  24KB  |  487 lines

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