/* GET: routine to get a file from a remote kermit in server mode also includes BYE and FINISH cmds. */ $compact $optimize(3) get$module: do; $include(:INC:LTKSEL.LIT) declare true literally '0FFH'; declare false literally '00H'; declare null literally '00'; declare cr literally '0DH'; declare lf literally '0AH'; declare crlf literally 'cr,lf,null'; declare myquote literally '023H'; declare chrmsk literally '07FH'; declare state byte; declare tries byte; declare msgnum byte; declare maxtry literally '5'; declare eol byte; declare debug byte external; declare iobuff(1024) byte external; declare status word external; declare pksize literally '94'; declare send$packet(pksize) byte external; declare recv$packet(pksize) byte external; declare count word; declare oldtry byte; declare byte$in dword; declare file$conn token external; declare filename structure (len byte, name(80) byte) external; declare qopen byte external; declare dummy byte; $include(:INC:USWBF.EXT) $include(:INC:UGTARG.EXT) check$error: procedure(mode) byte external; declare mode byte; end check$error; file$open: procedure(mode) external; declare mode byte; end file$open; file$close: procedure external; end file$close; co: procedure(char)external; declare char byte; end co; print: procedure(string)external; declare string pointer; end print; nout: procedure(num)external; declare num word; end nout; noutd: procedure(num)external; declare num dword; end noutd; newline: procedure external; end newline; ctl: procedure(char) byte external; declare char byte; end ctl; putc: procedure (c,conn) external; declare c byte; declare conn token; end putc; do$put: procedure (conn) external; declare conn token; end do$put; spack: procedure(type, pknum, length, packet) external; declare (type, pknum, length) byte; declare packet address; end spack; rpack: procedure(length, pknum, packet) byte external; declare (length, pknum, packet) address; end rpack; spar: procedure (a) external; declare a address; end spar; rpar: procedure (a) external; declare a address; end rpar; rinit: procedure byte external; end rinit; rfile: procedure byte external; end rfile; rdata: procedure byte external; end rdata; recv$setup: procedure external; end recv$setup; ginit: procedure byte; call spack('R',msgnum,filename.len,.filename.name); state=rinit; return state; end ginit; get: procedure byte public; if debug then call print(@('Get a file',crlf)); state = 'R'; msgnum = 0; call recv$setup; do while true; if state = 'D' then state = rdata; else if state = 'F' then state = rfile; else if state = 'R' then state = ginit; else if state = 'C' then return true; else return false; end; end get; bye: procedure byte public; declare (num,length,retc) byte; tries=0; retc='N'; msgnum=0; do while (retc<>'Y'); if tries>maxtry then return false; call spack('G',msgnum,1,.('L')); retc = rpack(.length, .num, .recv$packet); tries=tries+1; end; return true; end bye; finish: procedure byte public; declare (num,length,retc) byte; tries=0; retc='N'; msgnum=0; do while (retc<>'Y'); if tries>maxtry then return false; call spack('G',msgnum,1,.('F')); retc = rpack(.length, .num, .recv$packet); tries=tries+1; end; return true; end finish; end get$module;