home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / sys / cbm / 5286 < prev    next >
Encoding:
Internet Message Format  |  1993-01-02  |  3.5 KB

  1. Path: sparky!uunet!dtix!darwin.sura.net!zaphod.mps.ohio-state.edu!moe.ksu.ksu.edu!crcnis1.unl.edu!crcnis1.unl.edu!manager
  2. From: jbettis@cse.unl.edu (Jeremy Bettis)
  3. Newsgroups: comp.sys.cbm
  4. Subject: Re: uuencoder
  5. Message-ID: <1i3cvnINN7lt@crcnis1.unl.edu>
  6. Date: 2 Jan 93 06:33:27 GMT
  7. References: <1993Jan02.043134.492137@sue.cc.uregina.ca>
  8. Organization: University of Nebraska--Lincoln
  9. Lines: 106
  10. NNTP-Posting-Host: cse.unl.edu
  11.  
  12. YOUCKR@Meena.CC.URegina.CA (192503133) writes:
  13.  
  14. >Can anyone tell me where I can get a UUENCODER or a UUDECODER for the c64 or
  15. >c128?
  16. >Perhaps on a FTP site?
  17. >Thanks!
  18. >BTW this is the first time I have been able to post a msg on usenet.
  19.  
  20. Here is a uudecode program I wrote in Turbo Pascal on an IBM PC.  I think
  21. you ought to be able to see the algorthim from it anyhopw.  It really is
  22. quite simple to write your own decoder program.  I suppose you copuld write
  23. in in C-64 Basic, although there is no Bit-Shift-Left/Bit-Shift_Right operations
  24. yoiu always could use *2 /2 i suppose.
  25.  
  26. Program UUdecode;
  27.  
  28. Type
  29.     String255=String[255];
  30.  
  31. Procedure ReadIn(Var InFile : Text; Var TheLine : String255 );
  32.     {Just readin one line of text and return it}
  33.     Var
  34.     Index : Integer;
  35.     TheChar : Char;
  36.  
  37.     Begin
  38.     Read(InFile,TheChar);
  39.     While TheChar In [#10,#13] Do
  40.         Read(InFile,TheChar);
  41.     Index := 1;
  42.     While Not Eof(InFile) And (Index < 255) And Not (TheChar In [#10,#13])
  43.       Do Begin
  44.         TheLine[Index] := TheChar;
  45.         Index := Index + 1;
  46.         Read(InFile,TheChar);
  47.     End;
  48.     TheLine[0] := Chr(Index - 1) ; {Pascal strings.... sheez}
  49.     End;
  50.  
  51. Var
  52.     PIndex : Word;
  53.     InFile, OutFile : Text;
  54.     TheLine, FileName : String255;
  55.     Index, Len, OutIndex : Integer;
  56.     Out : String[3];
  57.  
  58. Begin
  59.     FileName := '';
  60.     Assign(OutFile,FileName);
  61.     ReWrite(OutFIle);
  62.     For PIndex := 1 To ParamCount Do Begin
  63.     Assign(InFile,ParamStr(PIndex)); {Turbo Pascal Oddities}
  64.     {$I-}
  65.     ReSet(InFile);
  66.     {$I+}
  67.     If IOResult = 0 Then Begin
  68.         While Not Eof(InFile) Do Begin
  69.         ReadIn(InFile,TheLine);
  70.         If Copy(TheLine,1,5) = 'begin' Then Begin
  71.             FileName := Copy(TheLine,11,12);
  72.             Close(OutFile);
  73.             Assign(OutFile,FileName);
  74.             {$I-}
  75.             ReWrite(OutFile);
  76.             {$I+}
  77.             If IOResult <> 0 Then Begin
  78.             Assign(OutFile,'');
  79.             ReWrite(OutFile);
  80.             End;
  81.         End
  82.         Else If Copy(TheLine,1,3) = 'end' Then Begin
  83.             FileName := '';
  84.             Close(OutFile);
  85.             Assign(OutFile,'');
  86.             ReWrite(OutFile);
  87.         End Else Begin
  88.             OutIndex := Ord(TheLine[1]) AND 63 XOR 32;
  89.             Len := Length(TheLine);
  90.             If ((OutIndex + 2) Div 3)*4 = (Len - 1) Then Begin
  91.             Index := 2;
  92.             While OutIndex > 0 Do Begin
  93.                 If OutIndex >2 Then Out[0]:=#3
  94.                 Else Out[0]:=Chr(OutIndex);
  95. {SHL = Shift Left}        Out[1]:=Chr((Ord(TheLine[Index]) AND 63 SHL 2
  96. {SHR = Shift Right}         OR Ord(TheLine[Index+1]) AND 48 SHR 4) XOR 130);
  97. {x SHL n = x * 2^n }        Out[2]:=Chr((Ord(TheLine[Index+1]) AND 15 SHL 4
  98. {x SHR n = x / 2^n }         OR Ord(TheLine[Index+2]) AND 60 SHR 2) XOR 8);
  99.                 Out[3]:=Chr((Ord(TheLine[Index+2]) AND 3 SHL 6
  100.                  OR Ord(TheLine[Index+3]) AND 63) XOR 32);
  101.                 Index := Index + 4;
  102.                 OutIndex := OutIndex -3;
  103.                 Write(OutFile,Out);
  104.             End;
  105.             End; {If it is of improper length, skip it}
  106.         End;
  107.         End;
  108.     End;
  109.     Close(InFile);
  110.     End;
  111.     Close(OutFile);
  112. End.
  113. --
  114. Jeremy Bettis   -*-   Jerbo Jehoshaphat   -*-   University of Nebraska
  115. INET:    jbettis@cse.unl.edu        "Those who stand in the middle of the
  116.     bt757@Cleveland.Freenet.Edu     road are often hit by passing cars."
  117.  BBS:    The Dew Drop Inn (402)476-8807 3/12/24
  118.