From:	CRDGW2::CRDGW2::MRGATE::"SMTP::CRVAX.SRI.COM::RELAY-INFO-VAX" 25-OCT-1990 22:33:02.76
To:	MRGATE::"ARISIA::EVERHART"
CC:	
Subj:	Program to read tapes from Dec-20

Received:  by crdgw1.ge.com (5.57/GE 1.76)
	 id AA07706; Thu, 25 Oct 90 22:19:41 EDT
Received: From UCBVAX.BERKELEY.EDU by CRVAX.SRI.COM with TCP; Thu, 25 OCT 90 14:51:15 PDT
Received: by ucbvax.Berkeley.EDU (5.63/1.42)
	id AA05635; Thu, 25 Oct 90 14:28:56 -0700
Received: from USENET by ucbvax.Berkeley.EDU with netnews
	for info-vax@kl.sri.com (info-vax@kl.sri.com)
	(contact usenet@ucbvax.Berkeley.EDU if you have questions)
Date: 25 Oct 90 10:40:57 GMT
From: eru!hagbard!sunic!mcsun!ukc!tcdcs!swift.cs.tcd.ie!vax1.tcd.ie!jsoye@bloom-beacon.mit.edu
Organization: Computer Laboratory, Trinity College Dublin
Subject: Program to read tapes from Dec-20
Message-Id: <7122.2726c13a@vax1.tcd.ie>
Sender: info-vax-request@kl.sri.com
To: info-vax@kl.sri.com

A problem arose, whereby a user who had written files to
tape on the Dec-20 wanted to read that tape from the VAX, as
the Dec-20 was no longer available to him.
  He used the copy command from the Dec-20 originally, to put the file on
tape. Therefore if he copied it back to the Dec-20 it is
in ASCII format.
  However, if you copy to the VAX/VMS from that tape, it's
not in ASCII format but core dump format. Here is a little C
program which will read it in that format.

                                               


---------------------------------------------------------------------

/* Program to read tapes in Core dump format   */
/* By : Tom Killalea (pkilllea@vax1.tcd.ie)     */

#include <stdio.h>
#include <string.h>

unsigned char ch[2], inbytes[6];  	/* bytes 0 thru 5 */
char fname[12];
FILE *instream,*outfi;
main()
{
  printf("File to open...\n");
  gets(fname);
  if ((instream=fopen(fname, "rb"))==NULL)
	{
	printf("cannot open input file\n");
	exit(1);
	}
  if ((outfi=fopen("tape.out", "wb"))==NULL) 
	{
	printf("cannot open output file\n");
	exit(1);
	}
  while (! feof(instream))
	{
	/* read binary stream from MTAx: giving 5 bytes in inbytes */
        register int i;
	for(i=0;i<5;i++)
  	{
        fgets(&inbytes[i], 2, instream);
	}
	/*fifth byte */
	inbytes[4]<<=4;
	inbytes[4]>>=5;
	strncpy(ch, &inbytes[3], 1);
	ch[0]<<=4;
	ch[0]>>=1;
	inbytes[4]=inbytes[4]|ch[0];
        /* fourth byte */
	inbytes[3]>>=4;
	strncpy(ch, &inbytes[2], 1);
	ch[0]<<=5;
	ch[0]>>=1;
	inbytes[3]=inbytes[3]|ch[0];
        /* third byte */
	inbytes[2]>>=3;
	strncpy(ch, &inbytes[1], 1);
	ch[0]<<=6;
	ch[0]>>=1;
	inbytes[2]=inbytes[2]|ch[0];
	/* 2nd byte */
	inbytes[1]>>=2;
	strncpy(ch, &inbytes[0], 1);
	ch[0]<<=7;
	ch[0]>>=1;
	inbytes[1]=inbytes[1]|ch[0];
        inbytes[0]>>=1;
	fputs(inbytes, outfi);
	}
        if (fclose(outfi)) printf("file close error\n");
  
}

