Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!burl!ulysses!mhuxr!mhuxt!houxm!whuxl!whuxlm!akgua!gatech!seismo!mcvax!unido!coma!axel From: axel@coma.UUCP Newsgroups: net.micro.atari16 Subject: GEM-Kermit (Part 6 of 6) Message-ID: <600015@coma.UUCP> Date: Thu, 19-Jun-86 23:07:00 EDT Article-I.D.: coma.600015 Posted: Thu Jun 19 23:07:00 1986 Date-Received: Sat, 28-Jun-86 04:03:12 EDT Sender: notes@unido.UUCP Lines: 1581 Nf-ID: #N:coma:600015:000:59999 Nf-From: coma!axel Jun 20 04:07:00 1986 #! /bin/sh # This is a shell archive, meaning: # 1. Remove everything above the #! /bin/sh line. # 2. Save the resulting text in a file. # 3. Execute the file with /bin/sh (not csh) to create: # stkrec.c # stksen.c # stkutl.c # stkrsc.uuc # This archive created: Fri Jun 20 02:38:07 1986 export PATH; PATH=/bin:/usr/bin:$PATH if test -f 'stkrec.c' then echo shar: "will not over-write existing file 'stkrec.c'" else cat << \SHAR_EOF > 'stkrec.c' /* * stkrec.c receive file routines for ATARI ST kermit */ #include #include #include "stkobj.h" #include "stkinc.h" extern FILE *fopen(),*fopenb(); /* * r e c s w * * This is the state table switcher for receiving files. */ recsw() { char rinit(), rfile(), rdata(); /* Use these procedures */ start_timer(&starttrans); state = 'R'; n = 0; /* Initialize message number */ numtry = 0; /* Say no tries yet */ /* * We are commenting out code that automatically NAKed * in case the sender started first; this may be the reason * that this Kermit gets out of whack. The original code * said * if (gflg == FALSE) * spack('N', n, 0, NIL); */ for (;;) { msgdeb(MSGDSTAT,state,n); bps = ((timer(starttrans) != 0) ? (bytecnt/timer(starttrans)) : 0); dt_packets(TRUE); switch(state) { /* Do until done */ case 'R': state = rinit(); break; /* Receive-Init */ case 'F': state = rfile(); break; /* Receive-File */ case 'D': state = rdata(); break; /* Receive-Data */ case 'C': return(TRUE); /* Complete state */ case 'A': spack('E', n, 5, "Abort"); return (FALSE); /* "Abort" */ case 'E': return(FALSE); /* "Error Abort" */ default: msgdeb(MSGSTATE); return (FALSE); /* Unknown, fail */ } } } /* * r i n i t * * Receive Initialization */ char rinit() { int i, len, num; /* Packet length, number */ char sfile(); /* routine used for get command */ if (numtry++ > maxtry) {msgall(KRTRAERR,MSGTRAER); return('A');}; ebq = TRUE; /* assume 7-bit transfer for init */ switch(rpack(&len, &num, packet)) { /* Get a packet */ case 'S': /* Send-Init */ for (i=len;i<10;i++) packet[i] = '\0'; rpar(packet); /* Get the other side's init data */ spar(packet); /* Fill up packet with my init info */ spack('Y', n, 7, packet); /* ACK with my parameters */ oldtry = numtry; /* Save old try count */ numtry = 0; /* Start a new counter */ n = (n + 1) % 64; /* Bump packet number, mod 64 */ n_total++; return('F'); /* Enter File-Receive state */ case 'E': /* Error packet received */ prerrpkt(packet); /* Print it out and */ return('E'); /* abort */ case FALSE: /* Didn't get packet */ case 'N': /* or got a NAK */ nakcnt++; if (!getfile) spack('N', n, 0, NIL); /* Return a NAK */ else spack('R',n,strlen(filnam1),filnam1); return(state); /* Keep trying */ case 'Y': return(state); /* Ignore leftover ACK */ /* (or incorrect ACK of 'R' packet) */ case 'A': return('A'); /* user abort */ default: msgall(KRPROERR,MSGPROER); return('A'); /* Some other packet type, "abort" */ } } /* * r f i l e * * Receive File Header */ char rfile() { int num, len; /* Packet number, length */ int f1x, fx; /* index to filnam1 and filnam */ int extx; /* start of extension */ int tryix; /* trying numbers for extension */ char convc; /* converted char in filename */ if (numtry++ > maxtry) {msgall(KRTRAERR,MSGTRAER); return('A');}; switch (rpack(&len, &num, packet)) { /* Get a packet */ case 'S': /* Send-Init, maybe our ACK lost */ nakcnt++; if (oldtry++ > maxtry) {msgall(KRTRAERR,MSGTRAER); return('A');}; if (num != ((n == 0) ? 63 : n - 1)) {msgall(KRPROERR,MSGPROER); return('A'); /* Not previous packet, "abort" */ }; /* Previous packet, mod 64; ack with our */ /* Send-Init parameters */ spar(packet); spack('Y', num, 7, packet); numtry = 0; /* Reset try counter */ return(state); /* Stay in this state */ case 'Z': /* End-Of-File */ nakcnt++; if (oldtry++ > maxtry) {msgall(KRTRAERR,MSGTRAER); return('A');}; if (num != ((n==0) ? 63:n-1)) {msgall(KRPROERR,MSGPROER); return('A'); /* Not previous packet, "abort" */ }; spack('Y',num,0,NIL); numtry = 0; return(state); /* Stay in this state */ case 'F': /* File Header (just what we want) */ if (num != n) {msgall(KRPROERR,MSGPROER); return('A'); /* The packet number must be right */ }; strcpy(filnam1, packet); /* Copy the file name */ /* convert filename to valid TOS file name*/ fx = 0; extx = -1; if (filnam[0] == '\0') {for (f1x = 0; filnam1[f1x] != '\0'; f1x++) {convc = filnam1[f1x]; if ((convc >= 'a') && (convc <= 'z')) convc ^= 040; if (convc == ' ') convc = '.'; if (!((convc == '.') || ((convc >= 'A') && (convc <= 'Z')) || ((convc >= '0') && (convc <= '9')))) convc = ']'; if (convc == '.') if (extx >= 0) convc = ']'; else extx = fx; if ((fx < 8) || ((extx >= 0) && ((fx - extx) < 4))) filnam[fx++] = convc; }; filnam[fx] = '\0'; if (filnamwarn) {tryix = 0; while ((!access(filnam,4)) && (tryix < 50)) {msgdeb(MSGERSNA,filnam1,filnam); if (extx < 0) {extx = fx; filnam[fx++] = '.'; filnam[fx] = '\0'; }; sprintf(&filnam[extx+1],"K%02d",tryix++); }; }; }; /* Try to open a new file */ if (image) fp = fopenb(filnam,"w"); else fp = fopen(filnam,"w"); if (fp == NULL) { msgall(KRWOPERR,MSGWOPER, filnam); return('A'); /* Give up */ } /* OK, give message */ msgall(-1,MSGFRASF, filnam1, filnam); dt_files(TRUE); spack('Y', n, 0, NIL); /* Acknowledge the file header */ n_total++; oldtry = numtry; /* Reset try counters */ numtry = 0; /* ... */ n = (n + 1) % 64; /* Bump packet number, mod 64 */ return('D'); /* Switch to Data state */ case 'B': /* Break transmission (EOT) */ if (num != n) {msgall(KRPROERR,MSGPROER); return ('A'); /* Need right packet number here */ }; spack('Y', n, 0, NIL); /* Say OK */ n_total++; return('C'); /* Go to complete state */ case 'E': /* Error packet received */ prerrpkt(packet); /* Print it out and */ return('E'); /* abort */ case FALSE: /* Didn't get packet */ spack('N', n, 0, NIL); /* Return a NAK */ nakcnt++; return(state); /* Keep trying */ case 'A': return('A'); /* user abort */ default: msgall(KRPROERR,MSGPROER); return ('A'); /* Some other packet, "abort" */ } } /* * r d a t a * * Receive Data */ char rdata() { int num, len; /* Packet number, length */ if (numtry++ > maxtry) {msgall(KRTRAERR,MSGTRAER); return('A');}; switch (rpack(&len, &num, packet)) { /* Get packet */ case 'D': /* Got Data packet */ if (num != n) { /* Right packet? */ /* No! */ if (num != ((n==0) ? 63:n-1)) /* not prev. packet */ {msgall(KRPROERR,MSGPROER); return('A'); }; if (oldtry++ > maxtry) {msgall(KRTRAERR,MSGTRAER); return('A'); }; spack('Y', num, 0, NIL); /* Yes, re-ACK it */ nakcnt++; numtry = 0; /* Reset try counter */ return(state); /* Don't write data! */ } /* Got data with right packet number */ #ifdef nooverlap /* Cannot handle concurrent disk and serial i/o, so delay ACK */ /* until file written */ bufemp(packet, len); /* Write the data to the file */ spack('Y', n, 0, NIL); /* Acknowledge the packet */ #else /* ACK before file write to overlap disk and serial i/o */ spack('Y', n, 0, NIL); /* Acknowledge the packet */ bufemp(packet, len); /* Write the data to the file */ #endif oldtry = numtry; /* Reset the try counters */ numtry = 0; /* ... */ n = (n + 1) % 64; /* Bump packet number, mod 64 */ n_total++; if (ferror(fp)) {msgall(KRFATFER,MSGFATFE); return('A'); }; return('D'); /* Remain in data state */ case 'F': /* Got a File Header */ if (num != ((n==0) ? 63:n-1)) /* not prev. packet */ {msgall(KRPROERR,MSGPROER); return('A'); }; if (oldtry++ > maxtry) {msgall(KRTRAERR,MSGTRAER); return('A'); }; spack('Y', num, 0, NIL); /* ACK it again */ nakcnt++; numtry = 0; /* Reset try counter */ return(state); /* Stay in Data state */ case 'Z': /* End-Of-File */ if (num != n) {msgall(KRPROERR,MSGPROER); return('A'); /* Must have right packet number */ }; if (ferror(fp)) {msgall(KRFATFER,MSGFATFE); return('A'); }; #ifdef nooverlap /* can't handle disk and serial i/o at the same time */ fclose(fp); /* close the file */ spack('Y', n, 0, NIL); /* Ack the 'Z' packet */ #else /* ACK before close to allow i/o overlap */ spack('Y', n, 0, NIL); /* OK, ACK it. */ fclose(fp); /* Close the file */ #endif n = (n + 1) % 64; /* Bump packet number */ msgall(-1,MSGTREOF,filnam); n_total++; filecnt++; dt_files(TRUE); filnam[0] = '\0'; return('F'); /* Go back to Receive File state */ case 'E': /* Error packet received */ prerrpkt(packet); /* Print it out and */ return('E'); /* abort */ case FALSE: /* Didn't get packet */ spack('N', n, 0, NIL); /* Return a NAK */ nakcnt++; return(state); /* Keep trying */ case 'A': return('A'); /* user abort */ default: msgall(KRPROERR,MSGPROER); return('A'); /* Some other packet, "abort" */ } } SHAR_EOF fi if test -f 'stksen.c' then echo shar: "will not over-write existing file 'stksen.c'" else cat << \SHAR_EOF > 'stksen.c' /* * stksen.c send file routines of ATARI ST kermit */ #include #include #include "stkobj.h" #include "stkinc.h" extern FILE *fopen(), *fopenb(); /* * s e n d s w * * Sendsw is the state table switcher for sending files. It loops until * either it finishes, or an error is encountered. The routines called * by sendsw are responsible for changing the state. * */ sendsw() { char sinit(), sfile(), sdata(), seof(), sbreak(); start_timer(&starttrans); state = 'S'; /* Send initiate is the start state */ n = 0; /* Initialize message number */ numtry = 0; /* Say no tries yet */ for (;;) { /* Do this as long as necessary */ msgdeb(MSGDSTAT,state,n); bps = ((timer(starttrans) != 0) ? (bytecnt/timer(starttrans)) : 0); dt_packets(TRUE); switch(state) { case 'S': state = sinit(); break; /* Send-Init */ case 'F': state = sfile(); break; /* Send-File */ case 'D': state = sdata(); break; /* Send-Data */ case 'Z': state = seof(); break; /* Send-End-of-File */ case 'B': state = sbreak(); break;/* Send-Break */ case 'C': return (TRUE); /* Complete */ case 'A': spack('E', n, 5, "Abort"); /* error packet */ return (FALSE); /* "Abort" */ case 'E': return(FALSE); /* "Error Abort" */ default: msgdeb(MSGSTATE); return (FALSE); /* Unknown, fail */ } } } /* * s i n i t * * Send Initiate: send this host's parameters and get other side's back. */ char sinit() { int num, len; /* Packet number, length */ int i; if (numtry++ > maxtry) {msgall(KRTRAERR,MSGTRAER); return('A');}; ebq = TRUE; /* assume 7 bit transfer for init */ spar(packet); /* Fill up init info packet */ flushinput(); /* Flush pending input */ spack('S', n, 7, packet); /* Send an S packet */ for (i = 0; i <= 10; i++) recpkt[i] = 0; switch(rpack(&len, &num, recpkt)) { /* What was the reply? */ case 'N': nakcnt ++; return(state); /* NAK, try it again */ case 'Y': /* ACK */ if (n != num) /* If wrong ACK, stay in S state */ { nakcnt++; return(state); /* and try again */ }; n_total++; rpar(recpkt); /* Get other side's init info */ numtry = 0; /* Reset try counter */ n = (n + 1) % 64; /* Bump packet count */ return('F'); /* OK, switch state to F */ case 'E': /* Error packet received */ prerrpkt(recpkt); /* Print it out and */ return('E'); /* abort */ case FALSE: nakcnt++; return(state); /* Receive failure, try again */ case 'A': return('A'); /* user abort */ default: msgall(KRPROERR,MSGPROER); return('A'); /* Anything else, just "abort" */ } } /* * s f i l e * * Send File Header. */ char sfile() { int num, len; /* Packet number, length */ char *newfilnam, /* Pointer to file name to send */ *cp; /* char pointer */ if (numtry++ > maxtry) {msgall(KRTRAERR,MSGTRAER);return('A');}; if (fp == NULL) { /* If not already open, */ filnam1[0] = '\0'; dt_files(TRUE); msgdeb(MSGFOPN,filnam); /* open the file to be sent */ if (image) fp = fopenb(filnam,"r"); else fp = fopen(filnam,"r"); if (fp == NULL) { /* bad file pointer, give up */ msgall(KERRFOPN,MSGERRFO); return('A'); }; }; strcpy(filnam1, filnam); /* Copy file name */ newfilnam = cp = filnam1; len = strlen(filnam1); /* Compute length of new filename */ spack('F', n, len, newfilnam); /* Send an F packet */ switch(rpack(&len, &num, recpkt)) { /* What was the reply? */ case 'N': /* NAK, just stay in this state, */ num = (--num<0 ? 63:num); /* unless it's NAK for next packet */ if (n != num) /* which is just like an ACK for */ {nakcnt++;return(state);}; case 'Y': /* ACK */ if (n != num) { nakcnt++; return(state); /* and try again */ }; msgall(-1,MSGSFASF,filnam, newfilnam); dt_files(TRUE); n_total++; numtry = 0; /* Reset try counter */ n = (n + 1) % 64; /* Bump packet count */ size = bufill(packet); /* Get first data from file */ return('D'); /* Switch state to D */ case 'E': /* Error packet received */ prerrpkt(recpkt); /* Print it out and */ return('E'); /* abort */ case FALSE: nakcnt++; return(state); /* Receive failure, stay in F state */ case 'A': return('A'); /* user abort */ default: msgall(KRPROERR,MSGPROER); return('A'); /* Something else, just "abort" */ } } /* * s d a t a * * Send File Data */ char sdata() { int num, len; /* Packet number, length */ if (numtry++ > maxtry) {msgall(KRTRAERR,MSGTRAER);return('A');}; spack('D', n, size, packet); /* Send a D packet */ switch (rpack(&len, &num, recpkt)) { /* What was the reply? */ case 'N': /* NAK, just stay in this state, */ num = (--num<0 ? 63:num); /* unless it's next packet's NAK */ if (n != num) /* which is just like an ACK for */ { nakcnt++; return(state); /* and try again */ }; case 'Y': /* ACK */ if (n != num) { nakcnt++; return(state); /* and try again */ }; n_total++; numtry = 0; /* Reset try counter */ n = (n+1)%64; /* Bump packet count */ if ((size = bufill(packet)) == EOF) /* Get data from file */ return('Z'); /* If EOF set state to that */ if (ferror(fp)) {msgall(KRFATFER,MSGFATFE); return('A'); }; return('D'); /* Got data, stay in state D */ case 'E': /* Error packet received */ prerrpkt(recpkt); /* Print it out and */ return('E'); /* abort */ case FALSE: nakcnt++; return(state); /* Receive failure, stay in D */ case 'A': return('A'); /* user abort */ default: msgall(KRPROERR,MSGPROER); return('A'); /* Anything else, "abort" */ } } /* * s e o f * * Send End-Of-File. */ char seof() { int num, len; /* Packet number, length */ if (numtry++ > maxtry) {msgall(KRTRAERR,MSGTRAER);return('A');}; spack('Z', n, 0, packet); /* Send a 'Z' packet */ switch(rpack(&len, &num, recpkt)) { /* What was the reply? */ case 'N': /* NAK, just stay in this state, */ num = (--num<0 ? 63:num); /* unless it's next packet's NAK, */ if (n != num) /* which is just like an ACK for */ { nakcnt++; return(state); /* and try again */ }; case 'Y': /* ACK */ if (n != num) { nakcnt++; return(state); /* and try again */ }; n_total++; filecnt++; numtry = 0; /* Reset try counter */ n = (n+1)%64; /* and bump packet count */ msgall(-1,MSGTREOF,filnam); fclose(fp); /* Close the input file */ fp = NULL; /* Set flag indicating no file open */ msgdeb(MSGFNEXT); if (fnxtfil() == FALSE) /* No more files go? */ return('B'); /* if not, break, EOT, all done */ msgdeb(MSGNEWFI,filnam); return('F'); /* More files, switch state to F */ case 'E': /* Error packet received */ prerrpkt(recpkt); /* Print it out and */ return('E'); /* abort */ case FALSE: nakcnt++; return(state); /* Receive failure, stay in Z */ case 'A': return('A'); /* user abort */ default: msgall(KRPROERR,MSGPROER); return('A'); /* Something else, "abort" */ } } /* * s b r e a k * * Send Break (EOT) */ char sbreak() { int num, len; /* Packet number, length */ if (numtry++ > maxtry) {msgall(KRTRAERR,MSGTRAER);return('A');}; spack('B', n, 0, packet); /* Send a B packet */ switch (rpack(&len, &num, recpkt)) { /* What was the reply? */ case 'N': /* NAK, just stay in this state, */ num = (--num<0 ? 63:num); /* unless previous packet's NAK, */ if (n != num) /* which is just like an ACK for */ { nakcnt++; return(state); /* and try again */ }; case 'Y': /* ACK */ if (n != num) { nakcnt++; return(state); /* and try again */ }; n_total++; numtry = 0; /* Reset try counter */ n = (n+1)%64; /* and bump packet count */ return('C'); /* Switch state to Complete */ case 'E': /* Error packet received */ prerrpkt(recpkt); /* Print it out and */ return('E'); /* abort */ case FALSE: nakcnt++; return(state); /* Receive failure, stay in B */ case 'A': return('A'); /* user abort */ default: msgall(KRPROERR,MSGPROER); return ('A'); /* Other, "abort" */ } } SHAR_EOF fi if test -f 'stkutl.c' then echo shar: "will not over-write existing file 'stkutl.c'" else cat << \SHAR_EOF > 'stkutl.c' /* * stkutl.c Packet handling and misc. routines for ATARI ST kermit */ #include #include #include "stkinc.h" #include "stkobj.h" extern *msg_string(); /* * KERMIT utilities. */ /* * s p a c k * * Send a Packet */ spack(type,num,len,data) char type, *data; int num, len; { int i; /* Character loop counter */ char chksum, buffer[100]; /* Checksum, packet buffer */ register char *bufp; /* Buffer pointer */ if (ibmmode) wait_handshake(); /* if ibm mode wait for handshake */ if(type != 'Y' && type != 'N') flushinput(); /* dump any leftovers */ len=len & 0x7f; /* Make sure len is not > 127 */ if (len > MAXPACKSIZ ) /* Make sure not larger than buffer */ len = MAXPACKSIZ-4; /* IF so limit it */ msgdeb(MSGTLNPS,type,len,num); /* Display outgoing packet */ if (data != NIL) data[len] = '\0'; /* Null-terminate data to print it */ if (data != NIL) msgdeb(MSGDATPS,data); bufp = buffer; /* Set up buffer pointer */ if (padding) /* Do padding */ for (i=1; i<=spad; i++) Cauxout(spadc); if (debug && (debug > 1)) msgdeb(MSGCHPAD,spad,spadc); *bufp++ = spcks; /* Packet marker, usally SOH */ *bufp++ = tochar(len+3); /* Send the character count */ chksum = tochar(len+3); /* Initialize the checksum */ *bufp++ = tochar(num); /* Packet number */ chksum += tochar(num); /* Update checksum */ *bufp++ = type; /* Packet type */ chksum += type; /* Update checksum */ for (i=0; i> 6)+chksum)&077; /* Compute final checksum */ *bufp++ = tochar(chksum); /* Put it in the packet */ *bufp++ = seol; /* Extra-packet line terminator */ *bufp = '\0'; auxsend(buffer); /* Send the packet */ return(TRUE); } /* * r p a c k * * Read a Packet */ char rpack(len,num,data) int *len, *num; /* Packet length, number */ char *data; /* Packet data */ { int i,j, eolwc, done; /* Data character number, loop exit */ int read_abort; /* 0 = timeout, 'A' = abort requested */ int abort; /* restart current packet */ char t, /* Current input character */ type, /* Packet type */ cchksum, /* Our (computed) checksum */ rchksum; /* Checksum received from other host */ start_timer(&startpckt); if (testat(&read_abort)) return(read_abort); do { if (readtimed(&t,&read_abort)) return(read_abort); } while ((t&127) != rpcks); /* Wait for packet header */ done = FALSE; /* Got SOH, init loop */ while (!done) /* Loop to get a packet */ { if(readtimed(&t,&read_abort)) return(read_abort); /* read character, or timeout */ /* if (!image) I guess, that's nonsense! */ t &= 0177; /* Handle parity */ if (t == rpcks) continue; /* Resynchronize if SOH */ cchksum = t; /* Start the checksum */ *len = unchar(t)-3; /* Character count */ if(readtimed(&t, &read_abort)) return(read_abort); /* read character, or timeout */ /* if (!image) nonsense ? */ t &= 0177; /* Handle parity */ if (t == rpcks) continue; /* Resynchronize if SOH */ cchksum = cchksum + t; /* Update checksum */ *num = unchar(t); /* Packet number */ if(readtimed(&t, &read_abort)) return(read_abort); /* read character, or timeout */ /* if (!image) nonsense ? */ t &= 0177; /* Handle parity */ if (t == rpcks) continue; /* Resynchronize if SOH */ cchksum = cchksum + t; /* Update checksum */ type = t; /* Packet type */ abort=FALSE; for (i=0; i<*len; i++) /* The data itself, if any */ { /* Loop for character count */ if(readtimed(&t, &read_abort)) return(read_abort); /* read character, or timeout */ if (!image || ebq) t &= 0177; /* Handle parity */ if (t == rpcks) { /* Resynch if SOH */ abort=TRUE; break; } cchksum = cchksum + t; /* Update checksum */ data[i] = t; /* Put it in the data buffer */ } if(abort)continue; data[*len] = 0; /* Mark the end of the data */ if(readtimed(&t, &read_abort)) return(read_abort); /* read character, or timeout */ t &= 0177; /* do not use parity bit of checksum */ rchksum = unchar(t); /* Convert to numeric */ if (t == rpcks) continue; /* Resynchronize if SOH */ done = TRUE; /* Got checksum, done */ } if (data != NIL) data[*len] = '\0'; /* Null-terminate data to print it */ msgdeb(MSGTLNPR,type,*len,*num); if (data != NIL) msgdeb(MSGDATPR,data); /* Fold in bits 7,8 to compute */ cchksum = (((cchksum&0300) >> 6)+cchksum)&077; /* final checksum */ if (cchksum != rchksum) { msgdeb(MSGCHKERR,rchksum,cchksum); return(FALSE); } /* wait for eol to avoid lost packages */ for (eolwc=0; eolwc<100; eolwc++) if (Cauxis()) break; else evnt_timer(1,0); return(type); /* All OK, return packet type */ } /* * compute 'universal time' */ long univ_time(t) int t; { long int res; res = 60 * ((t >> 11) & 0x1FL); res = 60 * (res + ((t >> 5) & 0x3FL)); res = res + ((t & 0x1FL) << 1); return (res); } /* * start timer */ start_timer(t0) long int *t0; {*t0 = univ_time(Tgettime()); } /* * compute difference to start time */ int timer(t0) long int t0; {long int t1; t1 = univ_time(Tgettime()); if (t1 < t0) return ((int) (t1+(24*60*69)-t0)); else return ((int) max((t1 - t0),1)); } /* readtimed: read a character or timeout * timeout is relative to start of waiting for packet */ readtimed(c,flag) char *c; /* character received */ int *flag; /* flag showing reason for abort: 0=timeout,'A'=user aborted */ { while(!Cauxis()) { *flag = sleepwait(50); if (*flag == 'A') /* abort requested */ { msgdeb(MSGUSRABO); return(TRUE); }; if (state == 'W') start_timer(&startpckt); /* no timeout in server wait */ if ((*flag == 'T') || (stimint && dotimout && (timer(startpckt) >= stimint))) { msgdeb(MSGTIMOUT); timcnt += 1; *flag = 0; return(TRUE); }; }; *c = Cauxin(); if (debug && (deblevel > 1)) msgdeb(MSGCHRD,timer(startpckt),*c,(*c & 0x7F)); return(FALSE); } /* * test for abort or timeout request */ int testat(flag) int *flag; { *flag = sleepwait(0); if (*flag == 'A') /* abort requested */ { msgdeb(MSGUSRABO); return(TRUE); }; if (*flag == 'T') { msgdeb(MSGTIMOUT); timcnt += 1; *flag = FALSE; return(TRUE); }; return(FALSE); } /* * b u f i l l * * Get a bufferful of data from the file that's being sent. * Only control-quoting is done; 8-bit & repeat count prefixes are * not handled. */ bufill(buffer) char buffer[]; /* Buffer */ { int i, /* Loop index */ t; /* Char read from file */ char t7; /* 7-bit version of above */ char t9; /* dup of data char t */ char b8; /* 8th bit */ i = 0; /* Init data buffer pointer */ while(TRUE) { t = getc(fp); /* Get the next character */ bytecnt++; if (feof(fp)) break; t9=t; /* Keep original pattern */ t7 = t & 0177; /* Get low order 7 bits */ b8 = t & 0200; /* Get MSB */ if (ebq && b8 && image) buffer[i++] = ebq; if ((t7 < SP) || (t7==DEL) || (t7==squote) || ((t7 == ebq) && ebq)) /* Does this char require */ { /* special handling? */ if (t=='\n' && !image) { /* Do LF->CRLF mapping if !image */ buffer[i++] = squote; buffer[i++] = ctl('\r'); } buffer[i++] = squote; /* Quote the character */ if ((t7 != squote) && ((t7 != ebq) || !ebq)) { t = ctl(t); /* and uncontrolify */ t7 = ctl(t7); }; }; if (image && !ebq) buffer[i++] = t; /* Deposit the character itself */ else buffer[i++] = t7; if (i >= spsiz-8) return(i); /* Check length */ } if (i==0) return(EOF); /* Wind up here only on EOF */ return(i); /* Handle partial buffer */ } /* * b u f e m p * * Put data from an incoming packet into a file. */ bufemp(buffer,len) char buffer[]; /* Buffer */ int len; /* Length */ { int i; /* Counter */ char t; /* Character holder */ int b8; /* 8th bit flag */ for (i=0; i 1)) msgdeb(MSGCHFLU,c,(c & 0x7F)); }; } /* * send one string to the aux port */ auxsend(str) char *str; { while (*str != '\0') {if (debug && (deblevel > 1)) msgdeb(MSGCHSND,*str,(*str & 0x7F)); Cauxout(*str++); }; } /* * wait for handshake character */ wait_handshake() /* * wait for turnchar * if received wait another 100 msecs and if no char received return. * if no char received within 1000 msecs assume we missed turnchar * otherwise return after a maximum of 4 secs */ { int waitc; /* wait counter */ char c; /* last char read */ int nochrec; /* no char received */ long int starthw; /* start time for wait */ waitc = 0; start_timer(&starthw); while (TRUE) {if (timer(starthw) >= 4) break; if ((waitc >= 10) && !Cauxis()) break; if (Cauxis()) {waitc = 0; while (Cauxis()) {c = Cauxin() & 0x7F; if (debug && (deblevel > 1)) msgdeb(MSGCHWHC,c,c); }; }; evnt_timer(100,0); if ((c == rturnchar) && !Cauxis()) {msgdeb(MSGHNDOK); return(FALSE); }; waitc++; }; msgdeb(MEGHNDFA); return(FALSE); } /* * Kermit printing routines: * */ /* * Print message on DEBUG file * First arg is object index of the KRMESSS object */ msgdeb(fmtix, a1, a2, a3, a4, a5) int fmtix; long a1,a2,a3,a4,a5; { if (debug) { fprintf(deb,msg_string(fmtix),a1,a2,a3,a4,a5); putc('\n',deb); }; } /* * Print message on LOG file * if first arg >= 0 then display an alert box too */ msglog(alertix,fmtix,a1,a2,a3,a4,a5) int fmtix, alertix; long a1, a2, a3, a4, a5; { if (translog) { fprintf(log,msg_string(fmtix),a1,a2,a3,a4,a5); putc('\n',log); }; if (alertix >= 0) displ_alert(1,alertix); } /* * Print message on DEBUG and LOG file * and perhaps display an alert box */ msgall(alertix,fmtix,a1,a2,a3,a4,a5) int fmtix, alertix; { msgdeb(fmtix,a1,a2,a3,a4,a5); msglog(alertix,fmtix,a1,a2,a3,a4,a5); } /* * p r e r r p k t * * Print contents of error packet received from remote host. */ prerrpkt(msg) char *msg; { msgall(-1,MSGERRPK,msg); displ_pckerr(msg); } SHAR_EOF fi if test -f 'stkrsc.uuc' then echo shar: "will not over-write existing file 'stkrsc.uuc'" else cat << \SHAR_EOF > 'stkrsc.uuc' begin 777 stkobj.rsc M <8A36%-84UA1^ "04?@ ,*( V 4 $4 !8 ##R($1EBXN+@ @(%-E;F1E+BXN " @16UP9F%N9V4N+BX ("!396YD92]3 M97)V97(N+BX +2TM+2TM+2TM+2TM+2TM+2TM+0 @($5M<&9A;F=E+U-E&-O9&4I 7U\ 7U\ 3DX 4&%D9&EN9RA,A&YG M92D !?7P!?7P Y.0!086-K971S=&%R="A(97AC;V1E*0 %]? %]? $Y. M %]? %]? $Y. $AA;F1S:&%K92A(97AC;V1E*0 %]? %]? $Y. %%U;W1E M*%IE:6-H96XI 7P!? %@ 7P!? %@ 3TL 04)"4E5#2 !396YD96X !% M;7!F86YG96X !?7U]?7U]?7U]?7U]?7U]?7U]?7U\ 7U]?7U]?7U]?7U]? M7U]?7U]?7U]? %A86%A86%A86%A86%A86%A86%A86 !$871E:3H !?7U]? M7U]?7U]?7U]?7U]?7U]?7U\ 7U]?7U]?7U]?7U]?7U]?7U]?7U]? %A86%A8 M6%A86%A86%A86%A86%A86 "!8BX@3F%M93H !?7U]?7U]? %]?7U]?7U\ M6%A86%A86 !$871E:65N((%B97)T'AX> !697)S:6]N7U\N7U\ .3DY.0!X>'AX>'@ M7U\M7U\M7U\ .3DY.3DY $1I97-EF5U9W0@ M=V5R9&5N+@!$871E:2 G)7,G(&5X:7-T:65R="X@3F5U97(@3F%M93H@)R5S M)RX 16UP9F%N9V5N(&5R9F]L9W)E:6-H(&)E96YD970N "HJ*D9A=&%L97(@ M1&%T96EF96AL97(N $1A=&5I(""4P,G@^('PE8WP 2V5I;B!(86YD#X@?"5C? !"96=I;FX@9&5S($5M<&9A;F"4P,G@^('PE8WP (" M/B!P861D:6YG.B E9" J(#PP>"4P,G@^ " @ M+3X@:&%N9'-H86ME('=A#X@?"5C? @("T^($AA;F1S M:&%K92!:96EC:&5N(&5M<&9A;F=E;BX ($1A=&5I("5S(&%N9V5F;W)D97)T M("A09F%D/25S+$1A=&5I/25S*0!%;7!F86YG96XH4V5R=F5R*2!EF5I8VAE;G=E M:7-E70!;,%U;5')A;G-A:W1I;VYS(%!R;RU\=&]K;VQL(&)E9V]N;F5N75M/ M2UT 6S-=6T9A=&%L97(@1F5H;&5R?&EM(%!R;W1O:V]L;%U;04)"4E5#2%T M6S-=6T1I92!$871E:2!K86YN(&YI8VAT?&5R>F5U9W0@=V5R9&5N75M!0D)2 M54-(70!;,UU;1F%T86QE 7U %]@ # 8 !& #__P 5 $ 7_ M &!P !@\ P & $1@ __\ " ( &%P !BL 8L , !@ $8 M /__ !0 0 !BT 8^ &/P # 8 A& #__@ 1 $ 9 &3@ M!D\ P & (1@ __X #@ ! &8 !FP 9M , !@ "$8 /_^ P M 0 !FX 9\ &?0 # 8 A& #__@ . $ 9^ &?P !H P & M 1@ __\ 0 ! &A !IH :; 4 !@ "$8 /__ !8 0 !IP M :K &K % 8 A& #__P / $ :M &NP !KP P & (0< M__\ #@ ! &O0 !L( ;/ , !@ "$8 /__ 4 #0 !M0 ;; & MY # 8 A& #__P ' D ;K '#0 !PX !0 & 1@ __\ (@ ! M '#P !S4 '7P % 8 M !& #__P G $ =@ '@P !X0 !0 & 1@ __\ (P ! 'A0 M!ZT >N , !@ $8 /__ "@ 0 !Z\ ?. 'SP # 8 !& #_ M_P ? $ ?0 'T0 !]( P & 1@ __\ 0 ! 'TP !_P @E M , !@ !$8 /__ "D *0 #P, \% /*0 # 8 !& #__P " "0 M \K /- #T, P & $1@ __\ "0 / /3P #V ]A , !@ M$8 /_^ !$ 0 #V( ^+ /M # 8 !& #__P I "D _= 0 M!0 $ 8 P & (1@ __\ * !__\ 0 ' !D 4 9 M < @ " !0 1 4 (! $ P & !D " M)@,! 3_____ " ) "P,! 7_____ " , + M !P,! ;_____ " . 2 "@,! +_____ " M0P < "@,! " A !D P$ 4 3 !$ "0 0 !0 M /\1 " % ( K_____ !P 3@ % ! O_____ !P M ( 7 $ % ! S_____ !P <0 ( % ! W_____ M !P A@ , % ! [_____ !P FP 0 % ! __ M____ !P L 4 % ! !#_____ !P Q0 8 % ! M C_____ !P V@ < % ! !@ $@ 7 !0 /\1 - M$@ & !/_____ !P [P $@ ! !3_____ !P _ M $ $@ ! !7_____ !P !# 4 $@ ! !;_____ !P ( ! M$P 0 $@ ! !?_____ !P !)@ ( $@ ! !'_____ !P M !- , $@ ! "$ &0 @ !0 /\1 4 $P ( !K_____ !P M !1@ $P ! !O_____ !P !40 $ $P ! !S_____ M !P !7P , $P ! !W_____ !P ( !<0 ( $P ! ![_ M____ !P !A0 0 $P ! !______ !P !F0 8 $P ! M "#_____ !P !IP < $P ! !C_____ !P ( !MP 4 M$P ! < (@ M !0 /\1 > &@ , "/_____ !P !RP M &@ ! "3_____ !P !WP 8 &@ ! "7_____ !P ( ! M]@ @ &@ ! ";_____ !P "$0 < &@ ! "?_____ !P M ")@ H &@ ! "C_____ !P ( ".@ 4 &@ ! "G_____ !P M "50 $ &@ ! "K_____ !P ";@ , &@ ! "O_____ M !P "> ( &@ ! "S_____ !P "A D &@ ! "W_ M____ !P "F@ L &@ ! "'_____ !P ( "K0 0 &@ ! M__\ 0 ! !0 0 (1 &%@8! #_____ !P ( "OP$! P M%0 !__\ 0 ! !0 0 (1 & D! #_____ !P ( "U0 ! M! %@ !__\ 0 ! !0 0 (1 '#P@ 7 @ ! !, $@ 2 !8 6E@ & D (@ ! !'_____ !X M" 6L@ 7 @ ! !8 % 5 !8 6S@ & H (@ ! !7_____ M !X " 6Z@ 7 @ ! !/_____ !X " 7!@ @ @ ! !@ M%P 7 !8 7(@ & L (@ ! !;_____ !X " 7/@ @ @ ! M !L &0 : !8 76@ & P (@ ! !K_____ !X " 7=@ 8 M 0 ! !C_____ !X " 7D@ A 0 ! !S_____ !H !P $4 & M X " ! #_____ !H )0 $4P @ X " !__\ 0 D !0 0 (1 M )@ 2 +_____ !8 @ @ 7K@ ' $ %P ! /_____ !8 @ @ M 7R@ ' $ %P ! 8 ! % !0 /\1 # , ( ! 7_____ !T M" 7Y@ + %0 ! /_____ !4 8 @ !@ ! D !P ( M !0 /\1 # 0 ( ! C_____ !T " 8'@ + %0 ! ;_ M____ !4 8.@ "0 ! P "@ + !0 /\1 # 8 ( ! M O_____ !T " 85@ 9 !P ! G_____ !4 8<@ M$P ! \ #0 . !0 /\1 # H ( ! [_____ !T " 8C@ ; M !0 ! S_____ !4 8J@ "P ! !( $ 1 !0 /\1 M # L ( ! !'_____ !T " 8Q@ ; !0 ! ______ !4 M 8X@ $P ! !4 $P 4 !0 /\1 # P ( ! !3_____ !T M" 8_@ ; !0 ! !+_____ !4 9&@ %0 ! !@ %@ 7 M !0 /\1 # @ ( ! !?_____ !T " 9-@ 9 !P ! !7_ M____ !4 94@ $P ! !L &0 : !0 /\1 # T ( ! M !K_____ !T " 9;@ > @ ! !C_____ !4 9B@ M% ! !S_____ !H 0 %]P : \ "0 ! !\ '0 > !0 /\1 # M < ( ! ![_____ !T " 9I@ 9 !P ! !S_____ !4 9 MP@ $P ! "#_____ !8 @ @ 9W@ ' $ %P ! "'_____ !8 @ @ M 9^@ ' $ %P ! "+_____ !H 0 &4 / \ "0 ! "/_____ !H M!P ( &60 # \ "0 ! "3_____ !8 @ @ :%@ ' $ %P ! #_____ M !8 H @ :,@ ' $ %P !__\ 0 - !0 0 (1 $(0L. +_ M____ !T " :3@ * , "P ! /_____ !H !P &@00,"PP " ! M 3_____ !4 ::@ @ (0 ! 7_____ !4 :A@ < M(0 ! < !@ & !0 0 ,1\0 ' $ $P " 7_____ !4 :H@ # M" #0 ! C_____ !T :O@( !@0$( (! G_____ !T : MV@, "04#( (! K_____ !D 0 (1 0$# ,!& 8% O_____ !4 M :]@$$"@D&& 8 S_____ !4 ;$@$$! H&&P8 W_____ !4 M ;+@$$#0H$' 8 #_____ !4 ( ;2@$$!@L$&08 __\ 0 % M !0 0 (1 ,@ * +_____ !4 ;9@ % $ )P ! /_ M____ !4 ;@@ * ( '@ ! 3_____ !T " ;G@ * , "P ! M 7_____ !X " ;N@ % 4 * ! #_____ !H )P (3@ 4 @ M" !__\ 0 ! !0 0 (1 & 0(! M P '0 !__\ 0 ! !0 0 (1 $(08! #_____ !P ( . MEP8 P ( !__\ 0 ! !0 0 (1 &(@