2019-05-01 06:24:33 -07:00

74 lines
2.9 KiB
C

/*
* Copyright (C) 2018 John Forecast. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY JOHN FORECAST "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __TAPE_H__
#define __TAPE_H__
/*
* Metadata markers
*/
#define ST_EOM 0xFFFFFFFF /* end of medium */
#define ST_GAP 0xFFFFFFFE /* erase gap */
#define ST_TM 0x00000000 /* tape mark */
/*
* Special code for reporting errors. If actually read from a container
* file, this would be considered an error.
*/
#define ST_FAIL 0xFEFEFEFE
/*
* Record length field layout
*/
#define ST_ERROR 0x80000000 /* record contains an error */
#define ST_MBZ 0x7F000000 /* must be zero */
#define ST_LENGTH 0x00FFFFFF /* record length */
/*
* Data in the .tap container file is rounded up to an even number of bytes
*/
#define RECLEN(c) (((c) + 1) & ~1)
extern int tapeVerify(FILE *, off_t *);
extern off_t tapeGetPosition(FILE *);
extern int tapeSetPosition(FILE *, off_t);
extern uint32_t tapeSkipRecordF(FILE *);
extern uint32_t tapeSkipRecordR(FILE *);
extern uint32_t tapePeekRecordLength(FILE *);
extern uint32_t tapeReadRecord(FILE *, void *, int);
extern uint32_t tapeReadRecordLength(FILE *);
extern uint32_t tapeReadRecordLengthReverse(FILE *);
extern int tapeWriteRecord(FILE *, void *, int);
extern int tapeWriteEOM(FILE *, int);
extern int tapeWriteTM(FILE *);
extern int tapeEOM(FILE *, off_t *);
extern void tapeRewind(FILE *);
extern int tapeSkipForward(FILE *, unsigned long);
extern int tapeSkipReverse(FILE *, unsigned long);
#endif