#pragma prototyped
#ifndef _PZIP_H
#define _PZIP_H 1
#include <ast.h>
#include <cdt.h>
#include <option.h>
#include <sfdcgzip.h>
#include <vmalloc.h>
#define PZ_PLUGIN_VERSION AST_PLUGIN_VERSION(PZ_VERSION)
#define PZ_VERSION 19990811L
#if __STDC__
#define PZLIB(m) unsigned long plugin_version(void) { return PZ_PLUGIN_VERSION; }
#else
#define PZLIB(m) unsigned long plugin_version() { return PZ_PLUGIN_VERSION; }
#endif
#define PZ_DATA_SUF "pz"
#define PZ_PART_SUF "prt"
#define PZ_WINDOW (4*1024*1024)
#define PZ_MAGIC_1 0x1f
#define PZ_MAGIC_2 0x10
#define PZ_OPEN 0
#define PZ_REOPEN 1
#define PZ_CLOSE 2
#define PZ_OPTION 3
#define PZ_PARTITION 4
#define PZ_TAILREAD 5
#define PZ_TAILWRITE 6
#define PZ_READ 0x00000001
#define PZ_WRITE 0x00000002
#define PZ_FORCE 0x00000004
#define PZ_STAT 0x00000008
#define PZ_STREAM 0x00000010
#define PZ_CRC 0x00000020
#define PZ_DUMP 0x00000040
#define PZ_VERBOSE 0x00000080
#define PZ_REGRESS 0x00000100
#define PZ_DIO 0x00000200
#define PZ_NOGZIP 0x00000400
#define PZ_SECTION 0x00000800
#define PZ_UPDATE 0x00001000
#define PZ_OVERSIZE 0x00002000
#define PZ_HEAD 0x00004000
#define PZ_NOPZIP 0x00008000
#define PZ_ACCEPT 0x00010000
#define PZ_DISC 0x00020000
#define PZ_APPEND 0x00040000
#define PZ_SUMMARY 0x00080000
#define PZ_PUSHED 0x00100000
#define PZ_SPLIT 0x00200000
#define PZ_SORT 0x00400000
#define PZ_VARIABLE 0x00800000
#define PZ_VAR_OFF(r) ((r)&0x3fff)
#define PZ_VAR_LEN(r) (1<<(((r)>>14)&0x3))
#define PZ_VERIFY PZ_STAT
#define SFPZ_HANDLE SFDCEVENT('P','Z',1)
struct Pz_s; typedef struct Pz_s Pz_t;
struct Pzconvert_s; typedef struct Pzconvert_s Pzconvert_t;
struct Pzcount_s; typedef struct Pzcount_s Pzcount_t;
struct Pzdisc_s; typedef struct Pzdisc_s Pzdisc_t;
struct Pzformat_s; typedef struct Pzformat_s Pzformat_t;
struct Pzindex_s; typedef struct Pzindex_s Pzindex_t;
struct Pzpart_s; typedef struct Pzpart_s Pzpart_t;
struct Pzsplit_s; typedef struct Pzsplit_s Pzsplit_t;
typedef ssize_t (*Pzconvert_f)(Pz_t*, Pzconvert_t*, const unsigned char*, unsigned char*, Pzdisc_t*);
typedef int (*Pzevent_f)(Pz_t*, int, void*, size_t, Pzdisc_t*);
typedef int (*Pzindex_f)(Pz_t*, Pzindex_t*, void*, Pzdisc_t*);
typedef const char* (*Pzinit_f)(Pz_t*, Pzdisc_t*);
typedef char* (*Pzname_f)(Pz_t*, unsigned long, Pzdisc_t*);
typedef Pzsplit_t* (*Pzsplit_f)(Pz_t*, Sfio_t*, Pzdisc_t*);
typedef ssize_t (*Pzread_f)(Pz_t*, Sfio_t*, void*, Pzdisc_t*);
typedef ssize_t (*Pzwrite_f)(Pz_t*, Sfio_t*, const void*, Pzdisc_t*);
struct Pzcount_s
{
Sfulong_t uncompressed;
Sfulong_t compressed;
Sfulong_t windows;
Sfulong_t sections;
Sfulong_t records;
Sfulong_t modules;
Sfulong_t converted;
Sfulong_t repaired;
Sfulong_t truncated;
Sfulong_t dropped;
};
struct Pzformat_s
{
const char* name;
size_t row;
const char* description;
};
struct Pzconvert_s
{
Pzformat_t* from;
Pzformat_t* to;
Pzconvert_f convertf;
Pzevent_f eventf;
void* userdata;
};
struct Pzdisc_s
{
unsigned long version;
const char* comment;
const char* options;
const char* partition;
const char* lib;
size_t window;
Error_f errorf;
Pzevent_f eventf;
Pzinit_f initf;
Pzread_f readf;
Pzwrite_f writef;
Pzindex_f indexf;
Pzsplit_f splitf;
Pzname_f namef;
void* local;
};
struct Pzindex_s
{
Sfulong_t block;
Sfulong_t offset;
};
struct Pzpart_s
{
char* name;
unsigned long flags;
size_t row;
size_t col;
size_t loq;
size_t* map;
size_t* grp;
unsigned char** mix;
size_t* lab;
size_t* inc;
size_t nmap;
size_t ngrp;
unsigned char* low;
int* value;
size_t* fix;
size_t nfix;
void* userdata;
#ifdef _PZ_PART_PRIVATE_
_PZ_PART_PRIVATE_
#endif
};
struct Pzsplit_s
{
unsigned long id;
void* data;
size_t size;
size_t record;
};
struct Pz_s
{
const char* id;
Pzdisc_t* disc;
unsigned long flags;
unsigned long test;
int major;
int minor;
size_t row;
size_t win;
const char* path;
Sfio_t* io;
Vmalloc_t* vm;
Pzpart_t* part;
Pzcount_t count;
unsigned char* buf;
unsigned char* wrk;
unsigned char* pat;
unsigned char* nxt;
unsigned char* val;
void* userdata;
#ifdef _PZ_PRIVATE_
_PZ_PRIVATE_
#endif
};
#if defined(__EXPORT__)
#define extern __EXPORT__
#endif
extern const char* pz_init(Pz_t*, Pzdisc_t*);
#undef extern
#if _BLD_pz && defined(__EXPORT__)
#define extern __EXPORT__
#endif
extern Pz_t* pzopen(Pzdisc_t*, const char*, unsigned long);
extern int pzclose(Pz_t*);
extern ssize_t pzread(Pz_t*, void*, size_t);
extern ssize_t pzwrite(Pz_t*, Sfio_t*, const void*, size_t);
extern int pzsync(Pz_t*);
extern int pzfile(Pz_t*);
extern int pzdeflate(Pz_t*, Sfio_t*);
extern int pzinflate(Pz_t*, Sfio_t*);
extern Sfio_t* pzfind(Pz_t*, const char*, const char*, const char*);
extern int pzlib(Pz_t*, const char*, int);
extern const char* pzinit(Pz_t*, const char*, Pzinit_f);
extern int pzoptions(Pz_t*, Pzpart_t*, char*, int);
extern int pzpartinit(Pz_t*, Pzpart_t*, const char*);
extern int pzpartmap(Pz_t*, Pzpart_t*);
extern int pzpartition(Pz_t*, const char*);
extern int pzpartprint(Pz_t*, Pzpart_t*, Sfio_t*);
extern int pzpartread(Pz_t*);
extern int pzpartwrite(Pz_t*, Sfio_t*);
extern Pzpart_t* pzpartget(Pz_t*, const char*);
extern Pzpart_t* pzpartnext(Pz_t*, Pzpart_t*);
extern Pzpart_t* pzpartset(Pz_t*, Pzpart_t*);
extern int pzheadread(Pz_t*);
extern int pzheadwrite(Pz_t*, Sfio_t*);
extern int pzheadprint(Pz_t*, Sfio_t*, int);
extern int pzdcconvert(Pz_t*, const Pzconvert_t*);
extern ssize_t pzfixed(Pz_t*, Sfio_t*, void*, size_t);
extern int sfdcpzip(Sfio_t*, const char*, unsigned long, Pzdisc_t*);
extern int sfdczip(Sfio_t*, const char*, const char*, Error_f);
#undef extern
#endif