Google
 

Trailing-Edge - PDP-10 Archives - integ_tools_tops20_v7_30-apr-86_dumper - tools/10backup/bio.bas
There are 2 other files named bio.bas in the archive. Click here to see a list.
10999	sub bio_ident
  %title 'BIO - 10BACKUP IO Routines'
  %ident 'BIO v1.0'
	option type = explicit, inactive = (setup)
  !
  ! This module is part of 10BACKUP - a program to read DECsystem-10
  ! BACKUP tapes in INTERCHANGE mode on a VAX.
  !
  ! The source modules that make up the 10BACKUP program are:-
  !
  !	10BACKUP.BAS	the main line program.
  !	BIO.BAS		contains tape and file IO routines.
  !	BUR.MAR		is a set of macro utility routines.
  !	C36.MAR		contains 36 bit conversion routines.
  !	BMS.MSG		contains the error message definitions.
  !	10BACKUP.RNH	Runoff input to build the help library.
  !
  !
	end sub




11000	function long tape_init( string tape_name, long tape_type )
	option type = explicit
	map (tape_control) long tape_blocksize, long tape_status,	&
		word tape_iosb(3), word tape_chan,			&
		byte tape_mode, byte tape_marks
	map (tape_buffer) string tape_buffer = 32767
	external long constant					&
		io$_readlblk,	io$_skipfile,	io$_rewind,	&
		io$m_nowait,	ss$_normal,	ss$_endoffile,	&
		ss$_endofvolume,bms_notape,	bms_moderr,	&
		bms_endofile
	external long function sys$assign, sys$qiow, sys$dassgn
	!
	if tape_mode > 0% then
	    call tape_close
	end if
	!
	select tape_type
	    case 1%
		open tape_name for input as file 2%,			&
			organization undefined,				&
			access read, recordtype any,			&
			norewind, map tape_buffer
		tape_mode = 1%			! Using file mode.
		tape_status = ss$_normal	! All OK.
	    case 2%
		tape_status = sys$assign( tape_name, tape_chan by ref, , )
		if tape_status and 1% then
		    tape_mode = 2%		! Using tape mode.
		end if
	    case else
		tape_status = bms_notape
	end select
	tape_marks = 0%			! No tape marks.
	!
	tape_init = tape_status
	end function


11010	function long tape_read
	option type = explicit
	map (tape_control) long tape_blocksize, long tape_status,	&
		word tape_iosb(3), word tape_chan,			&
		byte tape_mode, byte tape_marks
	map (tape_buffer) string tape_buffer = 32767
	external long constant					&
		io$_readlblk,	io$_skipfile,	io$_rewind,	&
		io$m_nowait,	ss$_normal,	ss$_endoffile,	&
		ss$_endofvolume,bms_notape,	bms_moderr,	&
		bms_endofile
	external long function sys$assign, sys$qiow, sys$dassgn
	!
	select tape_mode
	    case 1%
		on error goto 11015
		get #2%
		tape_blocksize = RECOUNT	! Tape block size.
		tape_status = ss$_normal	! Block read OK.
	    case 2%
		tape_status = sys$qiow( 2% by value, tape_chan by value, &
		    io$_readlblk by value, tape_iosb(0%), , ,		&
		    tape_buffer by ref, 32767% by value , , , , )
		if tape_status and 1% then
		    tape_status = tape_iosb(0%)
		end if
		if tape_status and 1% then
		    tape_marks = 0%			! No tape mark!
		    tape_blocksize = tape_iosb(1%)	! Size of tape block.
		else
		    if tape_status = ss$_endoffile then
			tape_marks = tape_marks + 1%	! Tape mark detected.
			if tape_marks >= 2% then
			    tape_status = bms_endofile	! End of input.
			else
			    tape_status = ss$_normal	! Pass back as tape mark.
			    tape_blocksize = 0%		! Tape mark.
			end if
		    end if
		end if
	    case else
		tape_status = bms_notape
	end select
	!
	tape_read = tape_status
	exit function


11015	if err = 11% then
	    tape_status = bms_endofile			! End of tape.
	    resume 11019
	else
	    on error goto 0
	    stop
	end if
11019	!
	tape_read = tape_status
	end function


11020	function long tape_skip_file( long skip_count )
	option type = explicit
	map (tape_control) long tape_blocksize, long tape_status,	&
		word tape_iosb(3), word tape_chan,			&
		byte tape_mode, byte tape_marks
	external long constant					&
		io$_readlblk,	io$_skipfile,	io$_rewind,	&
		io$m_nowait,	ss$_normal,	ss$_endoffile,	&
		ss$_endofvolume,bms_notape,	bms_moderr,	&
		bms_endofile
	external long function sys$assign, sys$qiow, sys$dassgn
	declare long skip
	!
	select tape_mode
	    case 1%
		on error goto 11025
		for skip = 1% to skip_count
		get #2%
		tape_blocksize = RECOUNT
		    until tape_blocksize = 0%
		    get #2%
		    tape_blocksize = RECOUNT
		    next
		next skip
		tape_status = ss$_normal
	    case 2%
		tape_status = sys$qiow( 1% by value, tape_chan by value, &
			io$_skipfile by value, tape_iosb(0%), , ,	&
			skip_count by value, , , , , )
		if tape_status and 1% then
		    tape_status = tape_iosb(0%)
		end if
		if tape_status and 1% then
		    if skip_count >= 0% then
			tape_marks = 1%		! One tape mark.
		    else
			tape_marks = 0%		! Positioned before tape mark.
		    end if
		else
		    if tape_status = ss$_endofvolume then
			tape_status = bms_endofile	! End of tape.
		    end if
		end if
	    case else
		tape_status = bms_notape
	end select
	!
	tape_skip_file = tape_status
	exit function

11025	if err = 11% then
	    tape_status = bms_endofile		! End of tape.
	    resume 11029
	else
	    on error goto 0
	    stop
	end if
11029	!
	tape_skip_file = tape_status
	end function


11030	function long tape_rewind
	option type = explicit, inactive = (setup)
	map (tape_control) long tape_blocksize, long tape_status,	&
		word tape_iosb(3), word tape_chan,			&
		byte tape_mode, byte tape_marks
	external long constant					&
		io$_readlblk,	io$_skipfile,	io$_rewind,	&
		io$m_nowait,	ss$_normal,	ss$_endoffile,	&
		ss$_endofvolume,bms_notape,	bms_moderr,	&
		bms_endofile
	external long function sys$assign, sys$qiow, sys$dassgn
	!
	select tape_mode
	    case 1%
		restore #2%
		tape_status = ss$_normal	! Nothing read yet.
		tape_marks = 0%			! No tape marks.
	    case 2%
		tape_status = sys$qiow( 1% by value, tape_chan by value, &
			( io$_rewind or io$m_nowait ) by value,		&
			tape_iosb(0%) , , , , , , , , )
		if tape_status and 1% then
		    tape_status = tape_iosb(0%)
		end if
	    case else
		tape_status = bms_notape
	end select
	tape_marks = 0%			! No tape marks.
	!
	tape_rewind = tape_status
	end function


11040	function long tape_close
	option type = explicit, inactive = (setup)
	map (tape_control) long tape_blocksize, long tape_status,	&
		word tape_iosb(3), word tape_chan,			&
		byte tape_mode, byte tape_marks
	external long constant					&
		io$_readlblk,	io$_skipfile,	io$_rewind,	&
		io$m_nowait,	ss$_normal,	ss$_endoffile,	&
		ss$_endofvolume,bms_notape,	bms_moderr,	&
		bms_endofile
	external long function sys$assign, sys$qiow, sys$dassgn
	!
	select tape_mode
	    case 1%
		close 2%
		tape_status = ss$_normal
	    case 2%
		tape_status = sys$dassgn( tape_chan by value )
	    case else
		tape_status = bms_notape
	end select
	tape_mode = 0%
	!
	tape_close = tape_status
	end function






14000	sub file_init( string file_name )
	option type = explicit
	map (file_control) long file_recsiz
	map (file_buffer) string file_buffer = 32763
	open file_name for output as file 3%,		&
		map file_buffer
	nomargin #3%
	file_recsiz = 0%
	subend

14010	sub file_write( long file_recsiz )
	option type = explicit, inactive = (setup)
	put #3%, count file_recsiz
	subend

14020	sub file_close
	option type = explicit, inactive = (setup)
	map (file_control) long file_recsiz
	map (file_buffer) string file_buffer = 32763
	if file_recsiz > 0% then
	    call file_write( file_recsiz )
	end if
	close 3%
	subend