TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: Mike Ruskai
from: Geert Bosch
date: 1995-01-04 02:04:00
subject: UU algorithm

Mike Ruskai wrote in a message to All:

 MR> Anyone have the algorithm for uuen/decoding files?  I'd like
 MR> to write  en/decoders in REXX.
Here's a decoder with rather decent speed for Rexx: over 3000 lines per
minute on my 486DX33. I don't think it is possible to go much higher
without using external libraries.

I'd challenge anyone to write one that is at least 25% faster without using
external libraries / programs (except the 'ERASE' command, which doesn't
have a standard Rexx counterpart).

Groetjes, Geert 

The decoder:

/* REXX Decoder for UUEncoded files. Takes encoded filename as a parameter */
   signal on NOVALUE
/* Based on original by Stefan Haubenthal 1992/94 */
/* Hacked for OS/2 by Graham Bingham (grahamb{at}iacces.za), Dec 1994 */
/* Optimized for speed (130 lpm -> 3000 lpm)
      by Geert Bosch (g.r.bosch{at}student.utwente.nl), Dec 1994 */

   in_range  = xrange("20"x,"7f"x)
   out_range = xrange("00"x,"5f"x)

   parse arg input
   say 'input: 'input
   do forever
      do until datatype(mode)='NUM'
         line=linein(input)
         if stream( input,'S')'READY' then 
            exit(1)
         parse value line with "begin" mode dest .
      end
      say "uudecoding "dest"..."
      if stream(dest,'C','QUERY EXISTS')'' then
         '{at}ERASE' dest
      /*call stream dest, 'C', 'OPEN WRITE'*/

      call time('e')
      do lines=1
         line=linein( input)
         if line="end" then 
            leave
         len = (c2d(left(line, 1)) - 32) // 64 * 4 % 3
         if len>0 then 
            call charout dest,decode( substr( line,2,trunc(len)))
      end
      say trunc( lines/time('e')*60)" lines per minute"
      call stream dest,'C','CLOSE'
   end
exit

/* xx765432 xx107654 xx321076 xx543210 -> 76543210 76543210 76543210 */
DECODE:
   a = x2b(c2x(translate(arg(1),out_range,in_range)))
   bin = ''
   do n=3 to length(a) by 32
      bin = bin || b2x(substr(a, n, 6) || substr(a, n + 8, 6) || substr(a,
n + 16, 6) || substr(a, n + 24, 6))
   end
return x2c(bin)


--- timEd/2 1.01+
* Origin: OS/2: Hot, Cool and Clickable... (2:283/307.40)
SEEN-BY: 12/2442 620/243 624/50 632/348 640/820 690/660 711/409 410 413 430
SEEN-BY: 711/807 808 809 934 942 949 712/353 515 713/888 800/1 7877/2809
@PATH: 283/307 7 35 512 280/801 24/24 396/1 3615/50 229/2 12/2442 711/409 808
@PATH: 711/809 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.