🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.unisys
Article #163

QIC archive from CTOS to UNIX

#163
From: John Bowler
Date: Thu, 01 Oct 1992 18:14
91 lines
3397 bytes
In article <BvE9LD.4Ax@do.raet.nl> rdekker@do.raet.nl writes:

 >         I am looking for a way to convert a 150 QIC archive, made on a
 > CTOS SG5000 machine, to a UNIX readeble format.
 > It's possible to read the tape with te 'dd' command.
 > But the archive has a certain internal structure, it appears that
 > it's build on blocks of 64 K with some control delimiters and within that
 > blocks you see a sort of 'tar' format.
 > Question: has someone out there a program that can read such a archive
 >           or is there a C-structure which gives me the layout of the
 >           archive so that I can make a program on myself.
 
We had a similar problem transferring a tar archive from a ROCC 2848 BSD Unix 
System to our U6000/65. There were control blocks inserted after every A000 
data bytes. These always began with the byte sequence A1 FE 00, and we 
searched for this rather than using a counter as these bytes were unlikely 
to occur in our ASCII data. All you need to do with the following C prog is
to add a counter to omit a block every 64K bytes. Use your tape device as the
input file, and a temporary file as the output file, and then use 
  tar -xvf <temp-file-name>
to extract the data.

-- CUT HERE --
 
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <memory.h>


int main(int argc,char *argv[])
{
	FILE *fp1, *fp2;
	char buf[512], searchstr[3];
	long block;
	

    searchstr[0]= 0xa1;
    searchstr[1]= 0xfe;
    searchstr[2]= 0;

    if (argc != 3) {
	printf("This program copies the input file to the output file in blocks \n");
	printf("of 512 bytes, omitting any blocks beginning with the sequence\n");
	printf("0xa1 0xfe 0x00.\n");
        printf("Usage: %s infile outfile\n", argv[0]);
        exit(2);
    }

    if ( (fp1=fopen(argv[1], "r"))==NULL) {
        printf("Error opening %s for reading\n", argv[1]);
        exit(2);
    }
    if ( (fp2=fopen(argv[2], "w"))==NULL) {
        printf("Error opening %s for writing\n", argv[2]);
        exit(2);
    }

    block=0;
    printf("Searching %s ...\n",argv[1]);
    while ( fread( buf, 512, 1, fp1 ) ) {
	block++;
        if (!(block % 100)) printf("%d ", block);
        fflush( stdout );
        if ( !memcmp(buf, searchstr, 3)) {   /* ignore this block */
	        continue;
	}
	if (! fwrite( buf,512,1, fp2)) {
		printf("Error Writing to file %s\n", argv[2]);
		exit(2);
	}
    }

    if (!feof(fp1)) {
        printf("Error reading %s\n", argv[1]);
        exit(2);
    }
    printf("\n%ld blocks written\n", ftell(fp2)/512);
    fclose(fp2);
    printf("Total read : %x bytes %ld blocks\n", ftell(fp1), block);
    fclose(fp1);
    printf("\nDone\n");
    return(0);
}

-- CUT HERE --

  +---------------------------------------------------------------------------+
  | No one is totally useless, he can always serve as a bad example to others |
  +---------------------------------------------------------------------------+
Technical Details
Message-ID: <717963293snx@fexco.ie>
Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!ieunet!fexco!johnb
References: <BvE9LD.4Ax@do.raet.nl>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!ieunet!fexco!johnb
From: johnb@fexco.ie (John Bowler)
Newsgroups: comp.sys.unisys
Subject: QIC archive from CTOS to UNIX
Distribution: world
Message-ID: <717963293snx@fexco.ie>
References: <BvE9LD.4Ax@do.raet.nl>
Date: Thu, 01 Oct 92 18:14:53 GMT
Organization: Foreign Exchange Co. Ltd.
Reply-To: johnb@fexco.ie
Lines: 93