Manual page for ansitar

Spencer W. Thomas thomas at utah-gr.UUCP
Tue Aug 2 14:27:08 AEST 1983


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<buffer+n; )
+     {
+ 	for (i=0, len=0; i<4; i++)
+ 	    len = len*10 + *cp++ - '0';
+ 	for (len -= 4; len > 0; len--)
+ 	    putc(*cp++, fp);
+ 	putc('\n', fp);
+ 	while (*cp == '^' && cp<buffer+n)
+ 	    cp++;
+     }
+ }
+ 
+ /*****************************************************************
+  * TAG( pipblock )
+  * 
+  * Read lines from the input file and block them pip-style into the
+  * buffer.  Make logical blocks of 512 bytes and fill space at the end
+  * of the logical blocks with '^' characters.
+  */
+ 
+ pipblock(fp, buffer, blocksize)
+ FILE *fp;
+ char *buffer;
+ {
+     register char *cp;
+     static char linebuf[512];	     /* lines not allowed longer than this? */
+     static int nline = 0;
+     int n;
+ 
+     if (blocksize%512)
+     {
+ 	fprintf(stderr, "Blocksize must be a multiple of 512 for pip tapes\n");
+ 	exit(1);
+     }
+     for (cp=buffer; cp<(buffer+blocksize); )
+     {
+ 	if (nline <= 0)
+ 	    if (fgets(linebuf, 508, fp) == NULL)
+ 		nline = -1;
+ 	    else
+ 	    {
+ 		linebuf[508] = '\0';
+ 		nline = strlen(linebuf);
+ 		if (linebuf[nline-1] == '\n')
+ 		    linebuf[--nline] = '\0';
+ 	    }
+ 
+ 	if (nline > (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 */
  }



More information about the Comp.sources.unix mailing list