home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / c-kermit / ckipct.rexx < prev    next >
OS/2 REXX Batch file  |  2020-01-01  |  2KB  |  66 lines

  1. /*
  2.  * CKIPCT.REXX
  3.  *
  4.  * This program is a de-boo'er for the Amiga, written in Amiga REXX.  It is
  5.  * intended for use as a decoder for a BOO file of Amiga Kermit.
  6.  *
  7.  * Written by Stephen Walton, 20 October 1990.  Based on MSBPCT.C
  8.  *
  9.  */
  10.  
  11. parse arg InName
  12. if InName = '' then do
  13.   say 'usage: rx ckipct boo-file'
  14.   exit 10
  15. end
  16.  
  17. if ~open(InFile,InName,'Read') then do
  18.   say 'Can''t open file' InName
  19.   exit 10
  20. end
  21.  
  22. OutName = readln(InFile)
  23. if Outname = '' then do
  24.    say 'Illegal BOO file'
  25.    exit
  26. end
  27.  
  28. call open OutFile, OutName,'Write'
  29.  
  30. say 'Creating file' OutName 'from input BOO file' InName
  31.  
  32. NULLCHAR = fixchar('~')
  33. line = readln(InFile)
  34.  
  35. do while ~eof(InFile)
  36.    do while length(line) >= 2
  37.       if fixchar(left(line,1)) = NULLCHAR then do /* Handle null compress */
  38.          line = substr(line,2)
  39.          do fixchar(left(line,1))        /* For repeat count... */
  40.             call writech(OutFile,d2c(0))    /* ...output nulls */
  41.          end
  42.          line = substr(line,2)            /* Trim off output count */
  43.       end
  44.       else do                    /* Decode a quad */
  45.          a = fixchar(left(line,1))
  46.          b = fixchar(substr(line,2,1))
  47.          c = fixchar(substr(line,3,1))
  48.          d = fixchar(substr(line,4,1))
  49.          call writech(OutFile,d2c(((a*4) + (b%16))//256))
  50.          call writech(OutFile,d2c(((b*16) + int(c/4))//256))
  51.          call writech(OutFile,d2c((c*64 + d)//256))
  52.          line = substr(line,5)            /* Trim off the quad */
  53.       end
  54.    end
  55.    line = readln(InFile)
  56. end
  57.  
  58. call close(InFile)
  59. call close(OutFile)
  60. exit
  61.  
  62. fixchar: procedure
  63.    parse arg c
  64.  
  65.    return c2d(c) - c2d('0')
  66.