# KERMIT - This is a D.G. AOS version of a gerenal KERMIT version 1, # - it supports both local and remote mode with the connect # - feature, IBM flags is also supported. This program does # - not have all the critical function like set SET BAUD RATE # - and set PARITY because of the local area network which # - handle the conversion. This AOS-KERMIT is a simplify # - VERSION which handles all the necessary function to do # - file transfer with other KEMRIT. Credit should be given to # - Fred Brehm who installed RATFOR translator onto D.G. machines # - for RCA and it make my implemntation of AOS-KERMIT from the # - C listing found in the PROTOCOL manual much simplier. # - Permission is granted to any individual or institution to copy # - or use this program, except for explicitly commercial purpose. # # # include ratdef include mdef include kerdef include kercom define(APPEND,3) # integer resw,x,status,getlin,temp,aopen,aone,bone,a1,z1 integer atwo,findln integer flag1,flag2,flag3,flag4,flag5,flag6,flag7,flag8,flag9 integer bell # character alin(MAXLINE) character blin(MAXLINE) character dlin(MAXLINE) character slin(MAXLINE) # character apat(MAXPAT) character bpat(MAXPAT) character cpat(MAXPAT) character dpat(MAXPAT) character epat(MAXPAT) character fpat(MAXPAT) character gpat(MAXPAT) character hpat(MAXPAT) character ipat(MAXPAT) # string xrec "RECEIVE" string con "@CONSOLE" string con4 "@CON4" string con11 "@CON11" string ssend "SEND" string help "HELP" string sexit "EXIT" string quit "QUIT" string stat "STATUS" string ibmon "SET IBM ON" string ibmoff "SET IBM OFF" string helpfile "HELP_KERMIT" string value " local off # 94 ^M @con " string morefile "morefile" string sconnect "CONNECT" # call stdopen morefd=-1 state=BIGC bell='' ibm=FALSE host=TRUE aone=1 bone=1 atwo=2 # open terminal for I/O; this is the terminal one used in activiated KERMIT localinfd=aopen(con,READ) if(localinfd==ERR)call cant(con) localoutfd=aopen(con,APPEND) if(localoutfd==ERR)call cant(con) # call scopy(help,aone,apat,bone) call scopy(sexit,aone,bpat,bone) call scopy(quit,aone,cpat,bone) call scopy(stat,aone,dpat,bone) call scopy(ibmon,aone,epat,bone) call scopy(ibmoff,aone,fpat,bone) call scopy(ssend,aone,gpat,bone) call scopy(xrec,aone,hpat,bone) call scopy(sconnect,aone,ipat,bone) call scopy(value,aone,slin,bone) # # local KERMIT mode mean you are using your computer to dial out to other # system and logged into to that system in order to activated the remote # KERMIT # # remote KERMIT mode mean you are dialing in from other KERMIT and you are # to perform I/O using the line you are loggon under. call remark("Remote or Local KERMIT mode R/L ??") status=getlin(alin,localinfd) call upper(alin,blin) if(blin(1)==BIGR){ call remark("Remote kermit now in effect") rmtinfd=localinfd rmtoutfd=localoutfd } else if(blin(1)==BIGL){ host=FALSE call remark("Local kermit now in effect") call remark("9600 or 1200 Baud (9/1) ??") # pending on whether the user wants to use a 9600 or 1200 baud # line, open the respective TTY line for I/O status=getlin(alin,localinfd) if(alin(1)==DIG9){ # the value of speed let the TTYRAW and TTYCOOK routine which # TTY to turn echo on/off and lower/upper case coversion on/off speed=TRUE rmtinfd=aopen(con4,READ) if(rmtinfd==ERR)call cant(con4) rmtoutfd=aopen(con4,APPEND) if(rmtoutfd==ERR)call cant(con4) } else { speed=FALSE rmtinfd=aopen(con11,READ) if(rmtinfd==ERR)call cant(con11) rmtoutfd=aopen(con11,APPEND) if(rmtoutfd==ERR)call cant(con11) } } else { # the user didnot give the right answer, let him start from scratch call remark ("Unknown mode, try again") call exit } istat=YES while(istat==YES){ call wrseq(localoutfd,"KERMIT-AOS >",12,ier) fd=ERR # find out what the user wants to do status=getlin(alin,localinfd) # convert the line to upper case call upper(alin,blin) # the value of a1 is the starting point and z1 is the ending point # return from the findln subroutine # # the parsing done here is at the very basic level, nothing fancy # a1=1 flag1=findln(blin,apat,a1,z1) a1=1 flag2=findln(blin,bpat,a1,z1) a1=1 flag3=findln(blin,cpat,a1,z1) a1=1 flag4=findln(blin,dpat,a1,z1) a1=1 flag5=findln(blin,epat,a1,z1) a1=1 flag6=findln(blin,fpat,a1,z1) a1=1 flag7=findln(blin,gpat,a1,z1) a1=1 flag8=findln(blin,hpat,a1,z1) a1=1 flag9=findln(blin,ipat,a1,z1) # # parse the command # if(flag1==YES){ # user have type the "HELP" request, type out the help file temp=aopen(helpfile,READ) while((getlin(alin,temp)^=EOF))call putlin(alin,localoutfd) call close(temp) } else if((flag2==YES)|(flag3==YES)){ # user type "EXIT" or "QUIT", do it call remark("Kermit now terminated") call exit } else if(flag4==YES){ # user have type the "STATUS" request call remark(" PACKET ") call remark(" MODE IBM QUOTE SIZE EOL TTY SPEED STATE") call remark(" ") if(host==TRUE){ slin(1)=LETR slin(2)=LETE slin(3)=LETM slin(4)=LETO slin(5)=LETT slin(6)=LETE } else { slin(1)=BLANK slin(2)=LETL slin(3)=LETO slin(4)=LETC slin(5)=LETA slin(6)=LETL } if(ibm==TRUE){ slin(8)=LETO slin(9)=LETN slin(10)=BLANK slin(11)=BLANK } else { slin(8)=LETO slin(9)=LETF slin(10)=LETF slin(11)=BLANK } if(host==TRUE){ slin(33)=BLANK slin(34)=BLANK } else { if(speed==TRUE){ slin(33)=DIG4 slin(34)=BLANK slin(35)=BLANK slin(36)=DIG9 slin(37)=DIG6 slin(38)=DIG0 slin(39)=DIG0 slin(40)=BLANK } else { slin(33)=DIG1 slin(34)=DIG1 slin(35)=BLANK slin(36)=DIG1 slin(37)=DIG2 slin(38)=DIG0 slin(39)=DIG0 slin(40)=BLANK } } slin(41)=BLANK slin(42)=BLANK slin(43)=BLANK slin(44)=state slin(45)=BLANK slin(46)=BLANK slin(47)=NEWLINE slin(48)=EOS call putlin(slin,localoutfd) call remark(" ") } else if(flag5==YES){ # user type the "SET IBM ON" request if(host==TRUE){ # local kermit does not permit dial out to IBM system call remark("Not supported in host kermit mode") } else ibm=TRUE } else if(flag6==YES)ibm=FALSE else if(flag7==YES){ #user have type out the "SEND" request itemp=0 # filename by itself mean that send that one file # @filename mean each line in that filename is in turn # a file to the send over, it simulate the wildcard # feature of other system i.e. *.doc;*. call remark("enter filename or @filename") status=getlin(alin,localinfd) call remove(morefile) morefd=aopen(morefile,APPEND) if(alin(1)^=ATSIGN){ call putlin(alin,morefd) } else { call scopy(alin,atwo,dlin,aone) itemp=aopen(dlin,READ) if(itemp==ERR){ call remark("Source file not found") } else { while(getlin(alin,itemp)^=EOF)call putlin(alin,morefd) call close(itemp) } } call close(morefd) if(itemp^=ERR){ # if we are in local mode, wait 15 seconds sending # the first packet, this give the user time to get # back to the other kermit and issue the receive command if(host==TRUE)call wait(15,2,ier) # send those file(s) to the other KERMIT status=sendsw(x) # when done transmitted or error detected, ring the bell if(host==FALSE)call wrseq(localoutfd,bell,2,ier) if(host==FALSE)call remark(" ") if((status==TRUE)&(host==FALSE))call remark("COMPLETED") if((status^=TRUE)&(host==FALSE))call remark("FAILED") if(fd^=ERR)call close(fd) } } else if(flag8==YES){ # user have type the "RECEIVE" REQUEST status=recsw(x) # wait the bell when all files have been obtain or if # error have occurred if(host==FALSE)call wrseq(localoutfd,bell,2,ier) if(host==FALSE)call remark(" ") if((status==TRUE)&(host==FALSE))call remark("COMPLETED") if((status^=TRUE)&(host==FALSE))call remark("FAILED") if(fd^=ERR)call close(fd) } else if(flag9==YES){ # user have type the "CONNECT" request if(host==TRUE){ call remark("Connect is not supported in Host mode") } else { # put remote TTY into raw mode call ttyraw # from now on what ever the user type on the local # keyboard, transmit that char over to the other SYSTEM # and whatever is send from the SYSTEM, related it to # the local TTY, repeat until you see the CNTR-] char. call connect # put remote TTY back into cook mode call ttycook } } else call remark("Invalid command, please type HELP") } return end