** c:\nbj\ca\aws2tape.ctl *** L=002 --- 2007/04/12 17:32:36 (L05) * * Title: AWSTAPE_CTL.TXT * Type: SELCOPY control statement input. * * Version: SELCOPY 2.08 Build 898 * Execution: At a system command prompt or from within a script.. * * selcopy -ctl awstape.ctl * * Description: Convert AWSTAPE format file to real TAPE. * * Notes: 1. UNIX tape output device *must* be non-rewinding. * 2. Tape device driver automatically writes a Load point * tape mark. * 3. Tape device driver automatically writes a Tape Mark * when output file is closed. * 4. The tape is not rewound at end of job. * ** Level History ** * * * 2007/04/12 L=002 -nbj- New Bus-Tech flags & records spanning mult AWSTAPE blocks. * 2007/03/07 L=001 -nbj- written. ** EQUate values *** * equ AWSTAPE "/home/nbj/test.aws" * Input AWS tape fileid. * equ OUTTAPE "/dev/ntibm0" * Output tape device. equ AWSTAPE "%1" * Input AWS tape fileid. equ OUTTAPE "%2" * Output tape device. equ inb 1 * Input AWSTAPE block header (6 bytes) equ obc 0 * Offset - Current block length (Little Endian) equ obp 2 * Offset - Previous block length (Little Endian) equ of1 4 * Offset - Flag byte 1. equ f1s x'80' * Flag - Start of Record. equ f1m x'40' * Flag - Tape Mark. equ f1e x'20' * Flag - End of Record. equ f1g x'10' * Flag - Segmented Record. equ of2 5 * Offset - Flag byte 2. equ f2c x'80' * Flag - Bus-Tech Compression (zlib 1.1.14). equ f2h x'40' * Flag - Bus-Tech Hardware Compression. equ f2e x'40' * Flag - Bus-Tech Encryted block. equ inbL 6 * Input AWSTAPE block header length. equ otd inb+inbL * Output data area. equ otdL 65535 * Output data area length. (Max Block size.) equ ben otd+otdL * Big Endian value Binary value. equ benL 2 * Big Endian value Binary value length. equ mtc ben+benL * Tape Write Tape Mark "mt eof 1" command. equ mtcL 100 * Tape Write Tape Mark "mt eof 1" command length. opt worklen=mtc+mtcL * User work area. ** Establish Tape mt Command and Output data pointer. *** (1st time only) pos mtc+0 = "mt -f eof 1" stopaft 1 pos mtc+6 = OUTTAPE stopaft 1 @out = otd stopaft 1 ** Read Block Headers ** lrecl = inbL * Length of Block Header. read inaws dsn=AWSTAPE into inb eol=no blksize=otdL * Read Block Header from input file. * Blksize=otdL defines an input buffer * big enough to contain maximum size block. * EOL=NO => Ignore CRLF/LF characters. ** Process Tape Mark (TM) Block Header ** if pos inb+of1 ones f1m * TM Block Header ? then if pos inb+obp = x'0000' * No previous data block? (Previous Length=0) then system from mtc, mtc+mtcL-1 * Write a TM. then goto get * Get next Block Header. else close otape * Close the tape output. (Automatically writes a TM.) then goto get * Get next Block Header. ** Process Data Block Header ** move 1 at inb+obc+0 to ben+1 * Convert to 2-byte Big Endian.. move 1 at inb+obc+1 to ben+0 * ..for SELCOPY. lrecl = benL at ben type=b * Length of Data in current block. ** Verify Output data area will not been exceeded by next READ. ** if @out+lrecl > otd+otdL-1 then plog "Error.. Output Area too small. (Cannot contain next input data block.)" then plog " Increase EQUated value for 'otdL', rewind the tape and re-run." then cancel * Cancel the job run. ** Process Data Block and Set output record length. ** read inaws into @out eol=no * Read data block into output pointer position. if @out = otd * If new output record. then @outL = lrecl * Initialise output record length. else @outL = lrecl+@outL * Increment the output record length. ** Write output record to tape only if end of data record. (Records may span data blocks.) ** if pos inb+of1 ones f1e * End of Record ? then lrecl = @outL * Output record length. then wr otape dsn=OUTTAPE from otd eol=no blksize=otdL * Write to output buffer. then flush otape * Write contents of output buffer to file. then @out = otd * Reset the output pointer. else @out = lrecl+@out * Increment the output pointer. /* ** End of SELCOPY statements. **