/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 1998-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
/*
* pz header support
*/
#include "pzlib.h"
/*
* read the pz header from pz->io
*/
int
{
register int i;
register int n;
register unsigned char* s;
size_t m;
return 0;
/*
* check the header magic
*/
{
i = s[0];
n = s[1];
}
else
i = n = 0;
(*pz->disc->errorf)(pz, pz->disc, -1, "%s: pzheadread: f=%08x i=%02x n=%02x partition=%s%s", pz->path, pz->flags, i, n, pz->disc->partition, s ? "" : " (nil)");
{
return 0;
{
return -1;
}
{
{
while (m-- > 0)
{
{
(*pz->disc->errorf)(pz, pz->disc, 2, "%s: cannot read %I*u prefix record%s from data", pz->path, sizeof(pz->prefix.count), pz->prefix.count, pz->prefix.count == 1 ? "" : "s");
return -1;
}
}
}
{
(*pz->disc->errorf)(pz, pz->disc, 2, "%s: cannot read %I*u prefix byte%s from data", pz->path, sizeof(pz->prefix.count), pz->prefix.count, pz->prefix.count == 1 ? "" : "s");
return -1;
}
}
{
n = 1;
{
}
}
if (n <= 0)
{
{
return -1;
}
n = 1;
}
return -1;
}
{
case 1:
goto noway;
break;
case 2:
break;
default:
goto noway;
}
return pzpartread(pz);
(*pz->disc->errorf)(pz, pz->disc, 2, "%s: data %d.%d not supported by implementation %d.%d", pz->path, pz->major, pz->minor, PZ_MAJOR, PZ_MINOR);
return -1;
}
/*
* write the pz header to op
*/
int
{
register size_t i;
register size_t m;
register size_t n;
register char* s;
return 0;
return 0;
return -1;
{
}
{
{
return -1;
}
m++;
}
{
{
m = 0;
while (i-- > 0)
{
{
(*pz->disc->errorf)(pz, pz->disc, 2, "%s: cannot read %I*u prefix record%s from data", pz->path, sizeof(pz->prefix.count), pz->prefix.count, pz->prefix.count == 1 ? "" : "s");
return -1;
}
}
}
else
{
m = i;
{
(*pz->disc->errorf)(pz, pz->disc, 2, "%s: cannot read %I*u prefix byte%s from data", pz->path, sizeof(pz->prefix.count), pz->prefix.count, pz->prefix.count == 1 ? "" : "s");
return -1;
}
}
}
}
/*
* pretty print header info to op
*/
int
{
char t;
else
{
{
{
}
else
}
{
if (pz->headoptions)
{
}
}
}
if (parts)
{
while (pp)
{
return -1;
break;
}
}
}
/*
* pzip files may be concatenated
* pzfile() is called to determine if EOF has been reached
* or if another file is concatenated
* return:
* -1 error
* 0 EOF
* 1 another file found (and initialized in pz)
*/
int
{
unsigned char* s;
int i;
int j;
size_t n;
/*
* 0 or more nul's mean clean EOF
*/
if (i == -1)
return 0;
if (i == PZ_MARK_TAIL)
{
/*
* file trailer
*/
while ((n = sfgetu(pz->io)) && !sferror(pz->io) && !sfeof(pz->io) && (s = (unsigned char*)sfreserve(pz->io, n, 0)))
return -1;
return 0;
}
if (i == PZ_MAGIC_1 && j == PZ_MAGIC_2)
{
/*
* next file header
*/
}
return -1;
}