[net.sources] Manual page for ansitar

thomas@utah-gr.UUCP (Spencer W. Thomas) (07/22/83)

Note: I added the option for producing/decoding the Files-11 format, it
is not in the distributed version.  Other than that, I think this manual
page accurately describes the program.

=Spencer

.TH ANSITAR 1 7/11/83
.UC 4
.SH NAME
ansitar \- ANSI format tape archiver
.SH SYNOPSIS
.B ansitar
[ key ] [ name ... ]
.SH DESCRIPTION
.PP
.I Ansitar
saves and restores files
on magtape in ANSI format.
Its actions are controlled by the
.I key
argument.
The
.I key
is a string of characters containing
at most one function letter and possibly
one or more function modifiers.
Other arguments to the command are file or directory
names specifying which files are to be dumped or restored.
Only files explicitly given on the command line will be dumped or restored.
The file name field is only 17 characters long.
.PP
The function portion of
the key is specified by one of the following letters:
.TP 8
.B  r
The named files
are written
on the end of the tape.
The
.B c
function implies this.
.TP 8
.B  x
The named files are extracted from the tape.
If no file argument is given, the entire content of the
tape is extracted.
Note that if multiple entries specifying the same file
are on the tape, the last one overwrites
all earlier.
.TP 8
.B  t
The names of the specified files are listed each time they occur
on the tape.
If no file argument is given,
all of the names on the tape are listed.
.TP 8
.B  c
Create a new tape; writing begins on the beginning
of the tape instead of after the last file.
This command implies
.B  r.
.TP 10
.B  0,...,7
This
modifier selects an alternate drive on which the tape is mounted.
(The default is drive 0 at 1600 bpi, which is normally /dev/rmt8.)
.TP 10
.B  w
causes
.I ansitar
to print the action to be taken followed by file name, then
wait for user confirmation. If a word beginning with `y'
is given, the action is performed. Any other input means
don't do it.
.TP 10
.B  v
Normally
.I ansitar
does its work silently.
The
.B v
(verbose)
option causes it to type the name of each file it treats
preceded by the function letter.
With the
.B t
function,
.B v
gives more information about the
tape entries than just the name.
.TP 10
.B b
causes
.I ansitar
to use the next argument as the block size for tape
records. The default is 512.
.TP 10
.B B
is used to specify a block size and a line size for fixed length records.
The first argument following is the block size and the next is the line
size.  The line size must divide the block size evenly.
.TP 10
.B l
causes the next argument to be used as a label size.
.TP 10
.B U
forces file names to be translated to upper case when writing the tape, and
to lower case when reading it.
.TP 10
.B R
causes
.I ansitar
to use RT-11 label and name conventions.
.TP 10
.B S
uses RSTS label and name conventions (same as RT11 except it uses 80 byte
labels).
.TP 10
.B P
causes translation to and from "pip" format.  This format is really the
FILES-11 text file variable-blocked format, and is useful when transferring
text files to/from a VMS or RSX system.  When using P format, lines longer
than 508 bytes will not be handled properly.  Also, the blocksize must be a
multiple of 512 bytes (should really be 512 bytes).
.PP
.SH FILES
/dev/rmt?
.SH DIAGNOSTICS
Complaints about bad key characters and tape read/write errors.
.SH BUGS
There is no way to ask for the
.IR n -th
occurrence of a file.
.br
Tape errors are handled ungracefully.
.br
The current limit on file name length is
17 characters.

pct@vaxine.UUCP (Pierre Trepagnier) (07/26/83)

I am interested in getting the source for your Files-11 addition to ansitar.
I tried the "r" option, but it failed [ihnp4 says "system utah-cs unknown"].

thomas@utah-gr.UUCP (Spencer W. Thomas) (08/02/83)

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 */
  }