Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!linus!decvax!microsoft!uw-beaver!cornell!vax135!floyd!harpo!utah-cs!utah-gr!thomas
From: thomas@utah-gr.UUCP (Spencer W. Thomas)
Newsgroups: net.sources
Subject: Re: Manual page for ansitar
Message-ID: <852@utah-gr.UUCP>
Date: Tue, 2-Aug-83 00:27:08 EDT
Article-I.D.: utah-gr.852
Posted: Tue Aug  2 00:27:08 1983
Date-Received: Tue, 26-Jul-83 11:12:39 EDT
References: vaxine.272
Lines: 179

Here is a diff listing from the distributed version.  The line numbers will
not match exactly, since I took out the error message comments.  Anybody who
doesn't have the original, and can't find a neighbor who does, should send
me a message and I will try to mail you the whole source.
=Spencer

RCS file: RCS/ansitar.c,v
retrieving revision 1.1
diff -c1 -r1.1 ansitar.c
*** /tmp/,RCSt1012419	Mon Jul 25 03:39:50 1983
--- ansitar.c	Thu Jul 21 22:34:30 1983
***************
*** 26,27
   *	S - use RSTS conventions (==RT11 except 80-byte labels)
   *

--- 26,28 -----
   *	S - use RSTS conventions (==RT11 except 80-byte labels)
+  *	P - create/read files in "pip" (FILES-11) counted format.
   *
***************
*** 98,100
  
! char *tapefile = "/dev/rmt0";
  char *buffer, *linebuffer, *malloc(), *index();

--- 99,101 -----
  
! char *tapefile = "/dev/rmt8";
  char *buffer, *linebuffer, *malloc(), *index();
***************
*** 114,116
  
! int create, replace, xtract, table, verbose, confirm;
  int blocking;

--- 115,117 -----
  
! int create, replace, xtract, table, verbose, confirm, pipfile;
  int blocking;
***************
*** 195,196
  
  			default:

--- 196,201 -----
  
+ 			case 'P':
+ 				pipfile++;
+ 				break;
+ 
  			default:
***************
*** 329,330
  					lunblock(fp, buffer, n, linesize);
  				else

--- 332,335 -----
  					lunblock(fp, buffer, n, linesize);
+ 				else if (pipfile)
+ 					pipunblock(fp, buffer, n);
  				else
***************
*** 406,407
  				}
  		else

--- 411,419 -----
  				}
+ 		else if (pipfile)
+ 			while ((n = pipblock(fp, buffer, blocksize)) > 0)
+ 			{
+ 				n = write(tf, buffer, n);
+ 				blocks++;
+ 				bytes += n;
+ 			}
  		else
***************
*** 445,446
  		}
  	if (n != labelsize ||

--- 457,463 -----
  		}
+ 	if (n<0)
+ 	{
+ 	    perror("Tape read error");
+ 	    exit(1);
+ 	}
  	if (n != labelsize ||
***************
*** 1098,1099
  	exit(1);
  }

--- 1103,1189 -----
  	exit(1);
+ }
+ 
+ /*****************************************************************
+  * TAG( pipunblock )
+  * 
+  * Unblock pip records.  These are in a counted format with a 4 byte
+  * count, followed by the record.  (Count includes the length of the
+  * count).  Blank space at the end of a block is filled with '^'
+  * characters.
+  */
+ 
+ pipunblock(fp, buffer, n)
+ FILE *fp;
+ char *buffer;
+ {
+     register char *cp;
+     int len, i;
+ 
+     for (cp=buffer; cp 0; len--)
+ 	    putc(*cp++, fp);
+ 	putc('\n', fp);
+ 	while (*cp == '^' && cp (508 - (cp-buffer)%512) ||
+ 	    (nline < 0 && (cp-buffer)%512 != 0))
+ 	    while ( (cp-buffer)%512 != 0 )
+ 		*cp++ = '^';
+ 
+ 	if (cp-buffer >= blocksize || nline < 0)
+ 	    return cp-buffer;
+ 
+ 	sprintf(cp, "%04d", nline+4);
+ 	cp += 4;
+ 	strncpy(cp, linebuf, 508);
+ 	cp += nline;
+ 	nline = 0;
+     }
+ 
+     return cp-buffer;	       /* should never get here, but you never know */
  }