10 rem demimer - a c64/128 program to decode mime (base64) files. 20 rem program by rod gasson. freeware. 30 rem this can be greatly improved. enjoy! 40 input "Enter source file to decode";in$ : if in$="" then 40 50 input "Enter source drive";d$ : dv=val(d$) : if dv<8 or dv>16 then 50 60 input "Enter destination drive";d$ : d2=val(d$) : if d2<8 or d2>16 then 60 70 : 80 t$="base64" : gosub350 : bl=li : rem save line number of base64 text 90 t$="name=" : gosub350 : n$=mid$(a$,l+5) : rem filename for output. 100 : 110 open 8,dv,8,in$ : li=0 120 get#8,x$ : if x$<>chr$(13) then 120 : rem skip lines to base64 line 130 li=li+1 : if li<>bl then 120 140 get#8,a$ : ifa$=chr$(10) then 140 : rem then read data 150 if a$<>chr$(13) then 140 : rem until two consequtive 160 get#8,a$ : if a$=chr$(10) then 160 : rem carriage returns are found 170 if a$<>chr$(13) then 140 : rem ignore linefeeds 180 print : print : print "Decoding file ("n$")" : print : print 190 : 200 open15,d2,15 : open 9,d2,9,(n$+",p,w") : get#15,e : if e then print "write file error" : close 8 : close9 : close15 : end 210 for i=1 to 4 220 get#8,a$(i) : if st then a$(i)=chr$(0) 230 if a$(i)=chr$(10) or a$(i)=chr$(13) then 220 240 if asc(a$(i))<43 or asc(a$(i))>122 then close 8 : close9 : close15 : end 250 if asc(a$(i))=43 then a(i)=62 : goto320 260 if asc(a$(i))=47 then a(i)=63 : goto320 270 if asc(a$(i))=61 then a(i)=64 : goto320 280 if asc(a$(i))<47 then a$(i)=chr$(0) : goto 240 290 if asc(a$(i))<62 then a(i)=asc(a$(i))+4 : goto320 300 if asc(a$(i))<97 then a(i)=asc(a$(i))-65 : goto320 310 a(i)=asc(a$(i))-71 320 br=br+1 : print chr$(145);"Bytes read";br;" Bytes written"bw : next 330 print#9,chr$(a(1)*4+(a(2)and48)/16)+chr$((a(2)and15)*16+(a(3)and60)/4)+chr$((a(3)and3)*64+a(4)); : bw=bw+3 : goto210 340 : 350 open15,dv,15 : open 8,dv,8,in$ : get#15,e : if e then print "read file error" : close8 : close15 : end 360 li=0 : print"checking for :";t$ 370 a$="" : f=0 : 380 get#8,x$ : s=st : if x$= chr$(13) then li=li+1 : goto 420 390 if x$=chr$(34) then 380 400 if asc(x$)>96 and asc(x$)<123 then x$=chr$(asc(x$)-32) 410 a$=a$+x$ : if s=0 then 380 420 fori=1tolen(a$) : if mid$(a$,i,len(t$))=t$ then f=1 : l=i : s=1 : i=len(a$) 430 next : : if s=0 then 370 440 close8 : close15 : if f=0 then print " Not a recognised MIME file" : end 450 return