/* to64.p

   Base64 encodes an arbitrary file.

   Code by Andrew Maizels 2001

   This program is in the public domain and may be freely used, modified
   and re-distributed for any purpose. */

def input param pc-infile as char no-undo.
def input param pc-outfile as char no-undo.

def var lr-in as raw no-undo.

def stream binary-s.
def stream base64-s.

input stream binary-s from value(pc-infile).
output stream base64-s to value(pc-outfile).

length(lr-in) = 57.

repeat:
    import stream binary-s unformatted lr-in.
    if length(lr-in) = 0 then leave.
    put stream base64-s unformatted substr(string(lr-in),7,76) skip.
end.

input stream binary-s close.
output stream base64-s close.
