home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / rexxuuxx.zip / UUXXCODE.IPF < prev    next >
Text File  |  1997-05-13  |  16KB  |  245 lines

  1. :userdoc.
  2. :title.UU&slash.XX&slash.Base64 Encoders and Decoders
  3. :docprof toc=12.
  4. :h1.Copyrights and Notices
  5. :p.The following copyright information applies to the various components of this software.
  6. :h2.The PL/I Run&hyphen.Time Library
  7. :h3.IBM Supplied Software
  8. :p.I am contractually obliged by IBM to include the following, since you need a copy of the PL/I
  9. run&hyphen.time library in order to run this code&per.
  10. :p.CONTAINS
  11. .br
  12. IBM PL/I for OS/2 Professional Edition Version 1&per.2
  13. .br
  14. Runtime Modules
  15. .br
  16. (c) Copyright IBM Corporation 1994, 1996
  17. .br
  18. All rights reserved
  19. :h2.The OS&slash.2 Commands and REXX Extension DLL
  20. :h3.COPYRIGHT AND LICENSING INFORMATION
  21. :p.This suite of programs and subroutines is freeware, distributed as is, without any warranty
  22. of its usefulness for any purpose&per. You may use it freely&per. You may also redistribute it,
  23. provided no charge is levied beyond the price of its distribution medium&per.
  24. :p.However, the author retains all intellectual property rights&per.
  25. .br
  26. .ce Copyright (C) David W. Noon, 1995, 1997
  27. :h3.OBTAINING TECHNICAL SUPPORT
  28. :p.You can obtain technical support via Internet e-mail, Compuserve or FidoNet Netmail&per.
  29. My addresses are as follows&per.
  30. :font facename='System Monospaced' size=16x12.
  31. :parml compact tsize=15 break=none.
  32. :pt.Internet&colon.
  33. :pd.david_noon&atsign.donor2.demon.co.uk
  34. :pt.
  35. :pd.dwnoon&atsign.ibm.net
  36. :pt.
  37. :pd.dnoon&atsign.acm.org
  38. :pt.Compuserve&colon.
  39. :pd.72172,431
  40. :pt.FidoNet&colon.
  41. :pd.David Noon 2&colon.440&slash.4
  42. :eparml.
  43. :font facename=default size=0x0.
  44. :p.The FidoNet mailbox and the first listed Internet mailbox, which are the same place, I check almost every day&per.
  45. The others are checked less frequently, such as every third day or so&per.
  46. :p.Turn&hyphen.around time on problems might not be spectacular, especially if I have other issues
  47. to handle&per. This is freeware and you should expect no more than you pay for&per.
  48. :h1.The Encoding and Decoding Specifications
  49. :p.The following are &odq.table napkin specs&per.&cdq. for the various encoding schemes supported
  50. by this software&per.
  51. :h2.The UU and XX Encoding and Decoding Specifications
  52. :p.Condensed from a doc file for a UUENCODE&slash.DECODE program by&colon.
  53. :lm margin=20.
  54. .br
  55. Richard Marks
  56. .br
  57. 931 Sulgrave Lane
  58. .br
  59. Bryn Mawr, PA 19010
  60. :lm margin=1.
  61. :p.UU&hyphen.encoding is a way to code a file which may contain any characters into a standard character set that can be reliably sent over diverse networks.
  62. .br
  63. :h3.THE CHARACTER ENCODING&colon.
  64. :p.The basic scheme is to break groups of 3 eight bit characters &lpar.24 bits&rpar. into 4 six bit characters and then add 32 &lpar.a space&rpar.
  65. to each six bit character which maps it into the readily transmittable character&per.
  66. Another way of phrasing this is to say that the encoded 6 bit characters are mapped into the set&colon.
  67. :lm margin=5.:font facename=Courier size=16x12.
  68. .br
  69. `&xclm.&cdq.&numsign.&dollar.&percent.&.&apos.&lpar.&rpar.&asterisk.&plus.,&hyphen.&per.&slash.012356789&colon.;<.&eq.>.?&atsign.ABC&per.&per.&per.XYZ&lbrk.&bslash.&rbrk.&caret.&us.
  70. :lm margin=1.:font facename=default size=0x0.
  71. .br
  72. for transmission over communications lines&per.
  73. :p.As some transmission mechanisms compress or remove spaces, spaces are changed into back&hyphen.quote characters &lpar.a 96&rpar.&per.
  74. &lpar.A better scheme might be to use a bias of 33 so the space is not created, but this is not done&per.&rpar.
  75. :p.Another newer less popular encoding method, called XX&hyphen.encoding uses the set&colon.
  76. :lm margin=5.:font facename=Courier size=16x12.
  77. .br
  78. &plus.&hyphen.01&per.&per.&per.89ABC&per.&per.&per.XYZabc&per.&per.&per.xyz
  79. :lm margin=1.:font facename=default size=0x0.
  80. :p.In my opinion, XX&hyphen.encoding is superior to UU&hyphen.encoding because it uses more &odq.normal&cdq. characters that are less likely to get corrupted&per.
  81. In fact several of the special characters in the UU set do not get thru an EBCDIC to ASCII translation correctly&per.
  82. Conversely, an advantage of the UU set is that it does not use lower case characters&per.
  83. Now&hyphen.a&hyphen.days both upper and lower case are sent with no problems; maybe in the communications dark ages, there was a problem with lower case&per.
  84. .br
  85. :h3.COMPOSING A LINE OF ENCODED CHARACTERS&colon.
  86. :p.A small number of eight bit characters are encoded into a single line and a count is put at the start of the line&per.
  87. &lpar.Most lines in an encoded file have 45 encoded characters&per. When you look at a UU&hyphen.encoded file note that most lines start with the letter &odq.M&cdq.&per.  &odq.M&cdq. is decimal 77 which, minus the 32 bias, is 45&per.&rpar.
  88. :p.This encode program puts a check character at the end of each line&per. The check is the sum of all the encoded characters, before adding the mapping, modulo 64&per.
  89. :Note. Horton 9&slash.1&slash.87 UUENCODE has a bug in the line check algorithm; it uses the sum of the original, not the encoded characters&per.
  90. .br
  91. :h3.PACKAGING THE LINES INTO FILES&colon.
  92. :p.The lines of encoded data can be preceded by comments and by network addressing information.  The encoded data is directly preceded by a line containing&colon. begin <.file&hyphen.mode>. <.file&hyphen.name>.
  93. :p.The final end of encoded data is an encoded line with zero encoded characters &lpar.a back&hyphen.quote&rpar., followed by a line containing &odq.end&cdq.&per.
  94. .br
  95. :h3.SPLITING UP LONG FILES&colon.
  96. :p.Long files are broken into several sections before transmission&per. This is done because very large files are cumbersome to handle and because some networks require files to be less than 64K bytes&per.
  97. .br
  98. :h3.TABLE LINES&colon.
  99. :p.Some encoded files put the mapping used at the front of the encoded file, just in front of the &odq.begin&cdq. line&per. The format for this is&colon.
  100. :xmp.
  101. table
  102. first 32 characters
  103. second 32 characters
  104. :exmp.
  105. :p.All this starts in column 1&per.
  106. :h2.The Base64 Encoding and Decoding Specifications
  107. :p.Darned if I know where I put these, but they&apos.re real simple&per. Read the code&per.
  108. :h1.The Commands
  109. :p.The command syntax descriptions follow&per.
  110. :h2.The UUENCODE Command
  111. :h3.Syntax
  112. :p.The command is issued from an OS&slash.2 command prompt as follows&colon.
  113. :p.:lm margin=10.:font facename=Courier size=16x12.UUENCODE <.Output file>. <.Input file>. &lbrk.<.Input file>. &per.&per.&per.&rbrk.:font facename=default size=0x0.
  114. :lm margin=1.:p.The output file name is mandatory, as is at least one input file name&per. The input file&lpar.s&rpar. will be read as a binary byte stream&per. The output file will contain
  115. all the specified input files, each with its own &osq.begin&csq. record so that they will be separated when decoded&per.
  116. :h2.The UUDECODE Command
  117. :h3.Syntax
  118. :p.The command is issued from an OS&slash.2 command prompt as follows&colon.
  119. :p.:lm margin=10.:font facename=Courier size=16x12.UUDECODE &lbrk.HORTON&rbrk. <.Input file>. &lbrk.&plus.<.Input file>. &per.&per.&per.&rbrk.:font facename=default size=0x0.
  120. :lm margin=1.:p.At 1 least input file name is mandatory&per. Additional input files can be concatenated with a plus sign &lpar.&plus.&rpar. with no embedded spaces&per. All encoded files
  121. in the input concatenation will be decoded&per.
  122. The purpose of this is to allow for the download of multiple messages for a large file and have the decoder join them back together again&per.
  123. :p.The HORTON flag indicates that the decoder should allow for Horton's erroneous checksum algorithm&per. This option must be first and is case sensitive&per.
  124. If you get a lot of checksum warnings decoding a file &lpar.like on every line&rpar. this option might cure the problem&per.
  125. :h2.The XXENCODE Command
  126. :h3.Syntax
  127. :p.The command is issued from an OS&slash.2 command prompt as follows&colon.
  128. :p.:lm margin=10.:font facename=Courier size=16x12.XXENCODE <.Output file>. <.Input file>. &lbrk.<.Input file>. &per.&per.&per.&rbrk.:font facename=default size=0x0.
  129. :lm margin=1.:p.The output file name is mandatory, as is at least one input file name&per. The input file&lpar.s&rpar. will be read as a binary byte stream&per. The output file will contain
  130. all the specified input files, each with its own &osq.begin&csq. record so that they will be separated when decoded&per.
  131. :h2.The XXDECODE Command
  132. :h3.Syntax
  133. :p.The command is issued from an OS&slash.2 command prompt as follows&colon.
  134. :p.:lm margin=10.:font facename=Courier size=16x12.XXDECODE &lbrk.HORTON&rbrk. <.Input file>. &lbrk.&plus.<.Input file>. &per.&per.&per.&rbrk.:font facename=default size=0x0.
  135. :lm margin=1.:p.At 1 least input file name is mandatory&per. Additional input files can be concatenated with a plus sign &lpar.&plus.&rpar. with no embedded spaces&per. All encoded files
  136. in the input concatenation will be decoded&per.
  137. The purpose of this is to allow for the download of multiple messages for a large file and have the decoder join them back together again&per.
  138. :p.The HORTON flag indicates that the decoder should allow for Horton's erroneous checksum algorithm&per. This option must be first and is case sensitive&per.
  139. If you get a lot of checksum warnings decoding a file &lpar.like on every line&rpar. this option might cure the problem&per. However, this bug is more likely to
  140. manifest itself in a UU&hyphen.encoded file than an XX&hyphen.encoded file&per.
  141. :h1.The REXX Functions
  142. :p.The REXX extension functions are all in a library called REXXUUXX&per.DLL&per.
  143. :note.REXXUUXX is meant to rhyme with &odq.Gadzooks&cdq., not &odq.Shucks&cdq.&per.
  144. :p.Each function must be loaded as needed by the RxFuncAdd&lpar.&rpar. built&hyphen.in function of REXX&per.
  145. For example&colon.
  146. :xmp.
  147. CALL RxFuncAdd &osq.UUDecodeFiles&csq.,&osq.REXXUUXX&csq.,&osq.UUDecodeFiles&csq.
  148. :exmp.
  149. :p.The DLL has been linked as case insensitive, so the third parameter can be any mixture of lower
  150. case and capital letters&per.
  151. :h2.UUEncodeFiles
  152. :h3.DESCRIPTION
  153. :p.The UUEncodeFiles subroutine takes a list of input files and creates an output file that is the
  154. UU&hyphen.encoded form of those files&per. You must specify the name of the output file, and it must
  155. be the first parameter supplied&per. Each input file has its own &osq.begin&csq. statement so
  156. that the individual files will be separated again when decoded&per.
  157. .br
  158. :h3.Syntax
  159. :p.The calling sytax is as follows&colon.
  160. :p.:lm margin=15.:font facename=Courier size=16x12.
  161. CALL UUEncodeFiles &osq.OUTFILE&per.UUE&csq.,&osq.INFILE1&per.DAT&csq.&lbrk.,&osq.INFILE2&per.DAT&csq.&rbrk. &per.&per.&per.
  162. :font facename=default size=0x0.:lm margin=1.
  163. :h2.UUDecodeFiles
  164. :h3.DESCRIPTION
  165. :p.The UUDecodeFiles subroutine takes a list of input files and creates an output file that is the
  166. UU&hyphen.decoded form of those files&per. The output file&lpar.s&rpar. are determined by the
  167. &osq.begin&csq. record that are encountered in the encoded input&per.
  168. .br
  169. :h3.Syntax
  170. :p.The calling sytax is as follows&colon.
  171. :p.:lm margin=15.:font facename=Courier size=16x12.
  172. CALL UUDecodeFiles &osq.INFILE1&per.UUE&csq.&lbrk.,&osq.INFILE2&per.UUE&csq.&rbrk. &per.&per.&per.
  173. :font facename=default size=0x0.:lm margin=1.
  174. :p.The multiple input files facility is very useful if you have downloaded a file that spans
  175. multiple messages&per. They are simply concatenated back together by the subroutine, but you do need
  176. to code them in the correct order&per.
  177. :p.If you find that an encoded file does not decode properly, it is possible it was encoded using
  178. the invalid checksum algorithm, attributable to Horton&per. To overcome this, the first parameter
  179. can be the string &osq.HORTON&csq., in all capital letters&per. On seeing this, the decoder
  180. routine will use Horton&apos.s checksum algorithm instead&per. Use sparingly&per.
  181. :p.:lm margin=15.:font facename=Courier size=16x12.
  182. CALL UUDecodeFiles &osq.HORTON&csq.,&osq.INFILE1&per.UUE&csq.&lbrk.,&osq.INFILE2&per.UUE&csq.&rbrk. &per.&per.&per.
  183. :font facename=default size=0x0.:lm margin=1.
  184. :h2.XXEncodeFiles
  185. :h3.DESCRIPTION
  186. :p.The XXEncodeFiles subroutine takes a list of input files and creates an output file that is the
  187. XX&hyphen.encoded form of those files&per. You must specify the name of the output file, and it must
  188. be the first parameter supplied&per. Each input file has its own &osq.begin&csq. statement so
  189. that the individual files will be separated again when decoded&per.
  190. .br
  191. :h3.Syntax
  192. :p.The calling sytax is as follows&colon.
  193. :p.:lm margin=15.:font facename=Courier size=16x12.
  194. CALL XXEncodeFiles &osq.OUTFILE&per.XXE&csq.,&osq.INFILE1&per.DAT&csq.&lbrk.,&osq.INFILE2&per.DAT&csq.&rbrk. &per.&per.&per.
  195. :font facename=default size=0x0.:lm margin=1.
  196. :h2.XXDecodeFiles
  197. :h3.DESCRIPTION
  198. :p.The XXDecodeFiles subroutine takes a list of input files and creates an output file that is the
  199. XX&hyphen.decoded form of those files&per. The output file&lpar.s&rpar. are determined by the
  200. &osq.begin&csq. record that are encountered in the encoded input&per.
  201. .br
  202. :h3.Syntax
  203. :p.The calling sytax is as follows&colon.
  204. :p.:lm margin=15.:font facename=Courier size=16x12.
  205. CALL XXDecodeFiles &osq.INFILE1&per.XXE&csq.&lbrk.,&osq.INFILE2&per.XXE&csq.&rbrk. &per.&per.&per.
  206. :font facename=default size=0x0.:lm margin=1.
  207. :p.The multiple input files facility is very useful if you have downloaded a file that spans
  208. multiple messages&per. They are simply concatenated back together by the subroutine, but you do need
  209. to code them in the correct order&per.
  210. :p.If you find that an encoded file does not decode properly, it is possible it was encoded using
  211. the invalid checksum algorithm, attributable to Horton&per. To overcome this, the first parameter
  212. can be the string &osq.HORTON&csq., in all capital letters&per. On seeing this, the decoder
  213. routine will use Horton&apos.s checksum algorithm instead&per. Use sparingly&per.
  214. :p.:lm margin=15.:font facename=Courier size=16x12.
  215. CALL XXDecodeFiles &osq.HORTON&csq.,&osq.INFILE1&per.XXE&csq.&lbrk.,&osq.INFILE2&per.XXE&csq.&rbrk. &per.&per.&per.
  216. :font facename=default size=0x0.:lm margin=1.
  217. :p.This problem is very rare in XX&hyphen.encoded files&per. It is more typical of UU&hyphen.encoded
  218. files&per.
  219. :h2.Base64EncodeFiles
  220. :h3.DESCRIPTION
  221. :p.The Base64EncodeFiles subroutine takes an input file and creates an output file that is the
  222. Base64&hyphen.encoded form of those files&per. You must specify the name of the output file, and it must
  223. be the first parameter supplied&per. There only only 2 parameters for this subroutine&per.
  224. .br
  225. :h3.Syntax
  226. :p.The calling sytax is as follows&colon.
  227. :p.:lm margin=15.:font facename=Courier size=16x12.
  228. CALL Base64EncodeFiles &osq.OUTFILE&per.B64&csq.,&osq.INFILE&per.DAT&csq.
  229. :font facename=default size=0x0.:lm margin=1.
  230. :h2.Base64DecodeFiles
  231. :h3.DESCRIPTION
  232. :p.The Base64DecodeFiles subroutine takes a list of input files and creates an output file that is the
  233. Base64&hyphen.decoded form of those files&per. You must specify the name of the output file, since the
  234. Base64 encoding does not include the filename, and it must be the first parameter supplied&per.
  235. .br
  236. :h3.Syntax
  237. :p.The calling sytax is as follows&colon.
  238. :p.:lm margin=15.:font facename=Courier size=16x12.
  239. CALL Base64DecodeFiles &osq.OUTFILE&per.DAT&csq.,&osq.INFILE1&per.B64&csq.&lbrk.,&osq.INFILE2&per.B64&csq.&rbrk. &per.&per.&per.
  240. :font facename=default size=0x0.:lm margin=1.
  241. :p.The multiple input files facility is very useful if you have downloaded a file that spans
  242. multiple messages&per. They are simply concatenated back together by the subroutine, but you do need
  243. to code them in the correct order&per.
  244. :euserdoc.
  245.