/***********************************************************************
* *
* 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 split partition support
*/
#include "pzlib.h"
#include <cdt.h>
struct Deflate_s;
struct Inflate_s;
struct Id_s;
typedef struct Id_s
{
int seq;
int use;
unsigned long id;
int row;
char* bp;
char* name;
unsigned long used;
unsigned long windows;
} Id_t;
typedef struct Deflate_s
{
unsigned int seq;
} Deflate_t;
typedef struct Inflate_s
{
} Inflate_t;
static struct
{
char* comment;
unsigned long flags;
int total;
int verbose;
} state;
#if _ast_intswap
/*
* order by signed int
*/
static int
{
return *(int*)a - *(int*)b;
}
/*
* order by unsigned long
*/
static int
{
if (*(unsigned long*)a < *(unsigned long*)b)
return -1;
if (*(unsigned long*)a > *(unsigned long*)b)
return 1;
return 0;
}
#endif
/*
* free Id_t
*/
static void
{
}
/*
* flush the current partition window
* this function determines the file layout
*/
static int
{
register size_t n;
char* file;
int i;
int line;
if (!use && (!(dp->pz->test & 04) || !(file = getenv("_AST_pzip_debug_use")) || !(use = strton(file, NiL, NiL, 1))))
(*dp->pz->disc->errorf)(dp->pz, dp->pz->disc, 0, "window %I*u %I*u", sizeof(dp->pz->count.windows), dp->pz->count.windows, sizeof(w), w);
/*
* write the actual window size
*/
/*
* count the number of active partitions for this window
*/
i = 0;
{
i++;
{
if (!ip->used++ && !ip->part && !streq(ip->name, "0") && dp->pz->disc->errorf && (dp->pz->flags & (PZ_SUMMARY|PZ_VERBOSE|PZ_DUMP)))
(*dp->pz->disc->errorf)(dp->pz, dp->pz->disc, 1, "%s: generate a partition to improve compression", ip->name);
}
else
}
/*
* write any PZ_UPDATE partition headers
*/
return -1;
/*
* write the number of partitions for this window
* followed by the table entry for each partition
*/
{
(*dp->pz->disc->errorf)(dp->pz, dp->pz->disc, 0, "%8d %12s %2d %4d %4I*u %12I*u%s", ip->seq, ip->name, !!ip->part, ip->use, sizeof(ip->row), ip->row, sizeof(n), n, ip->windows == 1 ? " NEW" : "");
}
{
return -1;
}
/*
* write the data for each pzip partition
*/
{
error_info.line = n;
goto bad;
goto bad;
}
/*
* write the data for the remaining partitions
*/
{
{
error_info.line = n;
goto bad;
}
}
/*
* end the record sequence number list and write it
*/
{
return -1;
}
/*
* done with this window
*/
{
return -1;
}
return 0;
bad:
return -1;
}
/*
* deflate
*/
static int
{
size_t m;
size_t z;
char* file;
char* s;
int line;
int i;
Sfoff_t o;
#if _ast_intswap
#endif
#if _ast_intswap
#endif
goto nospace;
goto nospace;
/*
* write the pzip header
*/
goto bad;
{
goto bad;
}
/*
* loop on the records and deflate a window at a time
*/
else
error_info.line = 0;
{
{
error_info.line++;
}
else
continue;
{
goto bad;
if (indexf)
}
goto bad;
{
else
goto nospace;
{
goto bad;
}
if ((ip->part = pzpartget(def.pz, ip->name)) && pz->disc->errorf && ip->row && ip->part->row != ip->row)
(*pz->disc->errorf)(pz, pz->disc, 1, "%s: partition row %I*u != data row %I*u", ip->name, sizeof(ip->part->row), ip->part->row, sizeof(ip->row), ip->row);
}
(*pz->disc->errorf)(pz, pz->disc, 1, "%s: size %I*u not a multiple of %I*u", ip->name, sizeof(rp->size), rp->size, sizeof(ip->row), ip->row);
{
}
{
extra += o;
}
{
(*pz->disc->errorf)(pz, pz->disc, ERROR_SYSTEM|2, "%s: %I*u byte write error", ip->name, sizeof(rp->size), rp->size);
goto bad;
}
}
{
goto bad;
}
/*
* done with all the data
* a 0 actual window size marks the end of data
*/
{
goto bad;
}
{
(*pz->disc->errorf)(pz, pz->disc, 0, "%8I*u %12s %2u %4I*u %4I*u %12I*u %12I*u%s", sizeof(ip->windows), ip->windows, ip->name, !!ip->part, sizeof(ip->used), ip->used, sizeof(ip->row), ip->row, sizeof(ip->total), ip->total ? ip->total : ip->modules * ip->row, sizeof(ip->modules), ip->modules, ip->used && !ip->part ? " GENERATE PARTITION" : "");
}
i = 0;
goto done;
bad:
i = -1;
done:
return i;
}
/*
* inflate
*/
static int
{
register char* s;
register size_t m;
register size_t n;
register size_t u;
register unsigned char* p;
size_t w;
size_t i;
char* id;
int row;
int use;
char* win = 0;
goto nospace;
goto nospace;
goto nospace;
/*
* loop on all windows
* w is the actual window size
* w <= pz->win guaranteed
*/
{
/*
* read the partition headers
*/
if (pzpartread(pz))
goto bad;
/*
* read the number of partitions
*/
{
goto nospace;
tabsiz = n;
}
/*
* read the partition table
*/
u = 0;
s = win;
for (i = 0; i < parts; i++)
{
{
goto nospace;
if ((ip->part = pzpartget(pz, ip->name)) && pz->disc->errorf && ip->row && ip->part->row != ip->row)
(*pz->disc->errorf)(pz, pz->disc, 1, "%s: partition row %I*u != data row %I*u", ip->name, sizeof(ip->part->row), ip->part->row, sizeof(ip->row), ip->row);
}
{
(*pz->disc->errorf)(pz, pz->disc, 2, "input corrupted [%s partition table size %I*u]", ip->name, sizeof(m), m);
goto bad;
}
{
s += m;
}
else
u += m;
(*pz->disc->errorf)(pz, pz->disc, 0, "%8d %12s %2d %4I*u %4I*u %12I*u%s", i + 1, ip->name, ip->use, sizeof(ip->used), ip->used, sizeof(ip->row), ip->row, sizeof(ip->size), ip->size, ip->used == 1 ? " NEW" : "");
}
/*
* read the pzip partition data
*/
for (i = 0; i < parts; i++)
{
goto bad;
goto bad;
}
/*
* read the remaining partition data
* and set up the table buffer pointers
*/
{
(*pz->disc->errorf)(pz, pz->disc, ERROR_SYSTEM|2, "cannot read %I*u byte partition data buffer", sizeof(u), u);
goto bad;
}
for (i = 0; i < parts; i++)
{
}
/*
* read the record table indices and reconstruct the records
*/
{
if (m > parts)
{
(*pz->disc->errorf)(pz, pz->disc, 2, "input corrupted [partition record index %I*u > %I*u]", sizeof(m), m, sizeof(parts), parts);
goto bad;
}
{
n &= (SF_MORE - 1);
while ((i = *p++) & SF_MORE)
n = (n << SF_UBITS) | i;
}
#if 0
memcpy(s, p, n);
else
#endif
{
goto bad;
}
}
}
{
(*pz->disc->errorf)(pz, pz->disc, 2, "%s: input corrupted [EOF expected at %I*u]", pz->path, sftell(pz->io));
goto bad;
}
{
goto bad;
}
i = 0;
goto done;
bad:
i = -1;
done:
if (ids)
if (tab)
if (win)
return i;
}
int
{
int r;
return r;
}
int
{
int r;
return r;
}
int
{
char* file;
char* s;
int line;
int i;
{
return -1;
}
#if _ast_intswap
#endif
goto nospace;
/*
* loop on the records and split by id
*/
error_info.line = 0;
{
{
error_info.line++;
}
{
else
goto nospace;
{
{
goto bad;
}
}
}
(*pz->disc->errorf)(pz, pz->disc, 1, "%s: size %I*u not a multiple of %I*u", ip->name, sizeof(rp->size), rp->size, sizeof(ip->row), ip->row);
{
{
{
(*pz->disc->errorf)(pz, pz->disc, ERROR_SYSTEM|2, "%s: %I*u byte write error", ip->name, sizeof(rp->size), rp->size);
goto bad;
}
}
}
}
{
(*pz->disc->errorf)(pz, pz->disc, 0, "%8I*u %12s %2u %4I*u %4I*u %12I*u %12I*u%s", sizeof(ip->windows), ip->windows, ip->name, !!ip->part, sizeof(ip->used), ip->used, sizeof(ip->row), ip->row, sizeof(ip->total), ip->total ? ip->total : ip->modules * ip->row, sizeof(ip->modules), ip->modules, ip->used && !ip->part ? " GENERATE PARTITION" : "");
}
{
goto bad;
}
i = 0;
goto done;
bad:
i = -1;
done:
if (ids)
return i;
}