/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 1987-2011 AT&T Intellectual Property *
* and is licensed under the *
* Eclipse Public License, Version 1.0 *
* by AT&T Intellectual Property *
* *
* A copy of the License is available at *
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
* *
* Information and Software Systems Research *
* AT&T Research *
* Florham Park NJ *
* *
* Glenn Fowler <gsf@research.att.com> *
* *
***********************************************************************/
#pragma prototyped
/*
* pax slt format for ansi and ibm labeled tapes
*/
#include "format.h"
#include <tm.h>
typedef struct Slt_s
{
} Slt_t;
/*
* get label header number
*/
static long
{
register char* e;
register int c;
long n;
p += byte - 1;
c = *(e = p + width);
*e = 0;
*e = c;
return n;
}
/*
* get label header string
*/
static char*
{
register char* e;
char* v;
v = s;
p += byte - 1;
e = p + width;
while (p < e && (*s = *p++) != ' ')
s++;
*s = 0;
return v;
}
/*
* return length of next label
* variable length labels have label number > 3 and Vnnnn at position 5
* where nnnn is the decimal length of the entire label
* nnnn may be < HDR_SIZE but label block must be >= HDR_SIZE
* 0 returned at end of label group
*/
static int
{
register int c;
register int n;
{
return c;
}
if (slt->buf[4] == 'V' && ((n = getlabnum(slt->buf, 4, 1, 10)) < 1 || n > 3) && (n = getlabnum(slt->buf, 6, 4, 10)) != c)
{
if ((c = n - c) > 0)
{
{
c = HDR_SIZE;
}
else
c = n;
}
else if (n <= VARHDR_SIZE)
c = VARHDR_SIZE;
else
c = n;
}
if (!ap->io->blocked && !*slt->last && slt->buf[3] == '2' && (strneq(slt->buf, "HDR", 3) || strneq(slt->buf, "EOF", 3) || strneq(slt->buf, "EOV", 3)))
return c;
}
/*
*/
static void
{
switch (*type)
{
case 'E':
break;
case 'H':
break;
}
sfsprintf(slt->buf, sizeof(slt->buf), "%s1%-17.17s000001%04d%04d000100 %02d%03d 00000 %06d%-6.6sD%-7.7s ", type, f->id, slt->section, slt->sequence, tm->tm_year, tm->tm_yday, f->record.blocks, slt->format, slt->implementation);
sfsprintf(slt->buf, sizeof(slt->buf), "%s2%c%05d%05d%010d%s%c 00 ", type, state.record.format, state.blocksize, state.record.size, f->st->st_size, type, '2');
{
}
else
}
static int
slt_getprologue(Pax_t* pax, Format_t* fp, register Archive_t* ap, File_t* f, unsigned char* buf, size_t size)
{
char* s;
char* t;
int lab;
long n;
off_t x;
return 0;
{
return 0;
}
else
{
return 0;
}
{
nospace();
return -1;
}
if (ap->checkdelta)
{
return 0;
{
ap->checkdelta = 0;
if (t = strchr(s, ' '))
*t = 0;
}
else
}
return 1;
}
static int
{
{
}
return 0;
}
static int
{
register char* s;
register int i;
register off_t n;
int lab;
int type;
return 0;
f->linkpath = 0;
f->uidname = 0;
f->gidname = 0;
type = 0;
do
{
{
if (type == 1)
{
{
{
break;
*s++ = '.';
}
else
}
else
*s = 0;
#if SAVESET
#endif
{
{
}
}
}
else if (type == 2)
{
{
case 'D': /* decimal variable */
case 'F': /* fixed length */
case 'S': /* spanned */
case 'U': /* input block size */
case 'V': /* binary variable */
break;
default:
f->skip = 1;
}
}
}
{
if (!(getprologue(ap)))
return 0;
goto again;
}
return 1;
}
static int
{
register off_t n;
int c;
int i;
int j;
int k;
int nl;
off_t m;
if (wfd < 0)
wfp = 0;
{
return -1;
}
size = 0;
for (;;)
{
n = 0;
else if (wfp)
{
if (m > state.buffersize)
m = state.buffersize;
}
else
if (n < 0)
break;
if (n == 0)
{
k = 1;
{
k = 0;
else if (!strneq(slt->buf, "EOF", 3) && !strneq(slt->buf, "EOV", 3) && !strneq(slt->buf, "UTL", 3) && ++n >= 16 && !state.keepgoing)
error(3, "%s: %s: %d invalid %s end of file/volume labels detected", ap->name, f->name, n, ap->format->name);
}
if (n)
error(1, "%s: %s: %d invalid %s end of file/volume labels detected", ap->name, f->name, n, ap->format->name);
if (k)
{
break;
}
for (;;)
{
if (getprologue(ap))
{
File_t v;
{
{
break;
}
}
}
}
continue;
}
{
i = 4;
}
else
i = 0;
while (i < n)
{
{
case 'F':
break;
if (j < n)
break;
/*FALLTHROUGH*/
case 'D':
case 'S':
i = n;
continue;
}
/*
* get record size
*/
{
case 'D':
k = -1;
j = i + 4;
break;
case 'F':
k = n - i;
else
k = n;
j = i;
break;
case 'S':
{
case '0':
case '3':
nl = 1;
break;
default:
nl = 0;
break;
}
k = -1;
j = i + 5;
break;
case 'U':
k = n;
j = i;
break;
case 'V':
j = i + 4;
break;
}
if (k < 0)
{
break;
}
m = i += k;
{
case 'F':
case 'U':
m++;
break;
}
k = m - j + nl;
size += k;
if (wfp)
{
if (nl)
{
}
{
break;
}
if (nl)
}
}
}
error(1, "%s: header size %I*d does not match data size %I*d", f->name, sizeof(f->st->st_size), f->st->st_size, sizeof(size), size);
if (wfp)
{
}
if (n < 0)
{
return -1;
}
return 1;
}
static int
{
return 1;
}
static int
{
#ifdef MTIOCTOP
{
return -1;
}
return 0;
#else
return -1;
#endif
}
static int
{
{
}
{
}
#if DEBUG
else
#endif
{
}
{
}
sfsprintf(slt->standards, sizeof(slt->standards), "%-5.5s%-5.5s%-5.5s%-4.4s", "ATT", "1", "EBCDIC", "1979");
else
sfsprintf(slt->standards, sizeof(slt->standards), "%-5.5s%-5.5s%-5.5s%-4.4s", "ISO", "646", "IRV", "1990");
sfsprintf(slt->buf, sizeof(slt->buf), "VOL1%-6.6s %-6.6s%-7.7s%-14.14s 4", state.volume, slt->format, slt->implementation, slt->owner);
{
sfsprintf(slt->buf, sizeof(slt->buf), "UVL1 %-6.6s%c%-6.6s%010ld%010ld ", ID, ap->delta->compress ? TYPE_COMPRESS : TYPE_DELTA, ((Compress_format_t*)ap->delta->format)->variant, state.operation == OUT ? (long)ap->size : (long)0, state.operation == OUT ? ap->checksum : 0L);
}
return 1;
}
static int
{
return 1;
}
static int
{
register int c;
register char* p;
register char* recdat;
register char* blkdat;
char* rec;
char* blk;
int span;
int count = 0;
int partial = 0;
int truncated = 0;
if (!fp)
span = 0;
/*
* file loop
*/
for (;;)
{
p = blk;
{
case 'V':
p += 4;
break;
}
blkdat = p;
/*
* block loop
*/
for (;;)
{
rec = p;
{
case 'D':
case 'V':
p += 4;
break;
case 'S':
p += 5;
break;
}
recdat = p;
/*
* check for partial record from previous block
*/
if (partial)
{
p += partial;
partial = 0;
}
/*
* record loop
*/
span &= 01;
span <<= 1;
for (;;)
{
{
{
truncated++;
}
break;
}
{
{
if (p > recdat)
{
span |= 01;
break;
}
}
{
/*
* save partial record for next block
*/
nospace();
}
p = rec;
goto eob;
}
{
if (p == recdat)
{
p = rec;
goto eob;
}
break;
}
break;
else
*p++ = c;
}
{
case 'D':
c = recdat[0];
recdat[0] = c;
break;
case 'F':
{
}
break;
case 'S':
c = recdat[0];
recdat[0] = c;
break;
case 'U':
if (p == recdat) *p++ = ' ';
break;
case 'V':
rec[3] = 0;
break;
}
count++;
break;
}
eob:
{
case 'D':
case 'S':
{
}
break;
case 'V':
blk[2] = 0;
blk[3] = 0;
break;
}
}
eof:
if (truncated)
return 0;
}
static int
{
register size_t m;
register ssize_t n;
register off_t c;
int r;
return 0;
r = 1;
{
{
/*
* this is faster than recordout()
*/
while (c > 0)
{
/*
* NOTE: we expect that all but the last
* read returns state.record.size
* if not the the intermediate short
* reads are filled with 0's
*/
if (!r)
{
if (rfd >= 0)
{
}
n = -1;
}
if (n <= 0)
{
if (n)
else
r = -1;
}
else
{
c -= n;
{
}
}
}
if (rfd >= 0)
}
else if (rfd < 0)
{
}
else
{
}
}
return r;
}
static int
{
return 0;
}
static off_t
{
{
}
}
static int
{
register char* s;
{
return 0;
}
{
s++;
}
else
s = f->name;
{
return 0;
}
return 1;
}
{
"ansi",
"slt",
"ANSI standard label tape; for tape devices only",
ANSI,
4,
4,
0,
0,
0,
0,
0,
0,
};
static int
ibm_getprologue(Pax_t* pax, Format_t* fp, register Archive_t* ap, File_t* f, unsigned char* buf, size_t size)
{
int n;
{
}
return n;
}
{
"ibm",
"elt",
"EBCDIC standard label tape; for tape devices only",
IBM,
4,
4,
0,
0,
0,
0,
0,
0,
};