/***********************************************************************
* *
* 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
/*
* pzip conversion/checksum discipline
*
* pz->discdata State_t*
* pp->discdata Cvt_t*
*/
static const char usage[] =
"[-1l?\n@(#)$Id: pzip conversion library (AT&T Research) 1999-09-11 $\n]"
"[+LIBRARY?pzconvert - pzip conversion library]"
"[+DESCRIPTION?The \bpzip\b convert discipline supports runtime record"
" format conversion. The discipline is enabled by a \b--library\b"
" that provides a conversion table and functions to \bpzconvert\b(3).]"
"[x:checksum?Enables a decompressed data checksum. The checksum is appended"
" to the compressed data as a \bpzip\b trailer. This checksum is"
" checked on decompression and a diagnostic is issued on mismatch."
" The absence of a checksum trailer is not treated as an error unless"
" \b--checksum=warn\b is specified.]:?[warn]"
"[c:convert?Specifies the input format for compression and the output format"
" for decompression. \aformat\a may be omitted for self-identifying"
" input data (e.g., \bpzip\b files.)]:?[format]"
"[f:from?Specifies the input format for data that does not self-identify.]:"
" [format]"
"[s:show?Lists the conversion steps, if any, on the standard output, and exits."
" A diagnostic is issued if the conversion is not implemented. If"
" \ball\b is specified then a description of all supported formats is"
" listed on the standard output and \bpzip\b exits.]:?[all]"
"[t:to?Specifies the decompression output format. This option is not needed"
" for compression since the partition file determines the output"
" format.]:[format]"
"[v:verbose?Emits a message on the standard error if checksumming is enabled"
" and another message showing the conversions being applied, if any.]"
;
#include "pzlib.h"
struct Chain_s
{
unsigned char* buf;
};
typedef struct
{
unsigned long flags;
} Cvt_t;
typedef struct
{
unsigned long flags;
char* from;
char* to;
unsigned char* buf;
} State_t;
/*
* compute the incremental linear congruential hash checksum
*/
static uint32_t
{
register unsigned char* s = (unsigned char*)buf;
register unsigned char* e = s + size;
while (s < e)
return sum;
}
/*
* before it is deflated
*/
static ssize_t
{
ssize_t n;
unsigned char* s;
unsigned char* t;
{
{
return n;
}
{
{
if (n < 0)
return -1;
goto again;
}
s = t;
}
}
else
return n;
}
/*
* and write it to sp
*/
static ssize_t
{
ssize_t n;
unsigned char* b;
unsigned char* s;
unsigned char* t;
{
return -1;
s = (unsigned char*)data;
{
{
return n;
}
s = t;
}
}
else
{
b = (unsigned char*)data;
}
}
/*
* add the next links to the stack that get from stk[i..j] => to
* the recursion unwind returns a shortest chain of links
* 0 returned if there is no path => to
*/
static Chain_t*
closure(Pz_t* pz, Chain_t* cp, int n, Pzconvert_t* tab, unsigned char* hit, Pzconvert_t** stk, int i, int j, const char* to)
{
int k;
int m;
for (k = j; i < j; i++)
for (m = 0; m < n; m++)
{
{
m = k;
goto found;
}
hit[m] = 1;
}
return 0;
if (m >= k)
{
return 0;
}
return xp;
}
/*
* determine a shortest path of conversions from f => t in tab of n elements
*/
static Chain_t*
{
int i;
int j;
size_t m;
unsigned char* a;
unsigned char* b;
unsigned char* x;
unsigned char* hit;
return 0;
{
return 0;
}
for (i = j = 0; i < n; i++)
{
hit[i] = 1;
}
{
{
if (!j)
else
}
return 0;
}
if (i >= j)
{
return 0;
}
/*
* determine the largest convert to row size
* and allocate the temporary buffers
*/
m = 0;
if (m)
{
a = b = 0;
{
return 0;
x = a;
a = b;
b = x;
}
return 0;
}
return cp;
}
/*
* handle pzip events
*/
static int
{
char* f;
char* t;
char** vp;
int i;
size_t n;
unsigned long k;
int r = 0;
return r;
if (!pp)
{
{
{
case 'f':
{
return -1;
}
{
break;
}
{
break;
}
break;
case 's':
{
exit(1);
{
if (!vp[i])
{
}
if (!vp[i])
{
}
}
exit(0);
}
break;
}
}
return 0;
}
{
return -1;
}
switch (op)
{
case PZ_CLOSE:
if ((pz->flags & PZ_READ) && (cvt->flags & (CHECKSUM|CHECKSUM_WARN|CHECKSUM_TAIL)) == (CHECKSUM|CHECKSUM_WARN))
{
r = -1;
(*disc->errorf)(pz, disc, 1, "%s: no checksum -- expected 0x%08I*x", pz->path, sizeof(cvt->checksum), cvt->checksum);
}
break;
break;
case PZ_OPTION:
{
case 'x':
r = 1;
break;
case 'c':
case 'f':
case 't':
r = 1;
{
{
{
return -1;
}
break;
}
{
case 'c':
break;
case 'f':
break;
case 't':
break;
}
return -1;
}
break;
case 's':
r = 1;
break;
default:
break;
break;
}
break;
case PZ_PARTITION:
{
{
{
return -1;
}
{
n = 0;
}
else
{
}
}
else
{
{
return -1;
}
{
n = 0;
}
else
{
}
}
if (!streq(f, t))
{
cp = 0;
{
{
{
{
return -1;
}
break;
}
if (rp)
break;
break;
return -1;
}
{
{
return -1;
break;
}
}
}
{
do
{
return -1;
}
}
}
{
{
(*disc->errorf)(pz, disc, 0, "%s: %s checksum", pz->path, (pz->flags & PZ_WRITE) ? "generating" : "verifying");
{
}
}
}
{
{
}
{
}
exit(0);
}
break;
case PZ_REOPEN:
break;
case PZ_TAILREAD:
{
{
{
(*disc->errorf)(pz, disc, 2, "%s: checksum mismatch -- expected 0x%08I*x != 0x%08I*x", pz->path, sizeof(k), k, sizeof(cvt->checksum), cvt->checksum);
r = -1;
}
else
r = 1;
}
}
break;
case PZ_TAILWRITE:
{
}
break;
}
return r;
}
/*
* install the conversion/checksum table and event function
*/
int
{
{
return -1;
{
return -1;
}
}
return 0;
}