/***********************************************************************1* *2* This software is part of the ast package *3* Copyright (c) 1998-2011 AT&T Intellectual Property *4* and is licensed under the *5* Eclipse Public License, Version 1.0 *6* by AT&T Intellectual Property *7* *8* A copy of the License is available at *9* http://www.eclipse.org/org/documents/epl-v10.html *10* (with md5 checksum b35adb5213ca9657e911e9befb180842) *11* *12* Information and Software Systems Research *13* AT&T Research *14* Florham Park NJ *15* *16* Glenn Fowler <[email protected]> *17* *18***********************************************************************/19#pragma prototyped2021/*22* partitioned fixed record zip library private definitions23*/2425#ifndef _PZLIB_H26#define _PZLIB_H 12728#include <ast.h>29#include <dt.h>30#include <ctype.h>31#include <error.h>32#include <tv.h>3334#define PZ_VERSION_SPLIT 19990811L /* splitf added */3536#define state _pz_info /* library private state */37#define pznospace _pz_nospace38#define pzsdeflate _pz_sdeflate39#define pzsinflate _pz_sinflate40#define pzssplit _pz_ssplit4142#define _(s) ERROR_translate(0,0,0,s)4344struct Pz_s;4546typedef struct Pzelt_s /* window row order element */47{48Dtlink_t link; /* dictionary link */49unsigned char buf[1]; /* row data */50} Pzelt_t;5152typedef struct Pzrs_s /* read stream state */53{54size_t hi; /* num hi frequency rows in buf */55size_t lo; /* rem lo frequency reps in pat */56} Pzrs_t;5758typedef struct Pzws_s /* write stream state */59{60unsigned char* bp; /* hi freq buf ptr */61unsigned char* vp; /* lo freq code val ptr */62unsigned char* ve; /* lo freq code val end */63unsigned char* pb; /* partial row buffer */6465unsigned char* sp; /* PZ_SORT partial buffer */6667size_t pc; /* partial row count */68size_t rep; /* lo freq repeat count */69size_t row; /* lo freq row count */70size_t sz; /* PZ_SORT partial buffer rem */7172Pzelt_t* se; /* PZ_SORT partial element */7374Sfio_t* io; /* output sync stream */75} Pzws_t;7677typedef struct Pzss_s /* split stream state */78{79char* match; /* strmatch() file pattern */80unsigned long flags; /* PZ_SPLIT_* flags */81size_t* data; /* split data */82size_t size; /* split data size */83} Pzss_t;8485#define _PZ_PART_PRIVATE_ \86Dtlink_t link; /* dictionary by name link */ \87void* discdata; /* discipline specific data */8889#define _PZ_PRIVATE_ \90Vmdisc_t vmdisc; /* vmalloc region discipline */ \91Dtdisc_t partdisc; /* partition discipline */ \92Dt_t* partdict; /* partition dictionary by name */ \93Pzpart_t* mainpart; /* the main partition */ \94Pzpart_t* freepart; /* free partition */ \95char* partname; /* specific part name */ \96size_t mrow; /* max row size */ \97size_t mwin; /* max window size */ \98struct \99{ \100size_t count; /* prefix record count */ \101int skip; /* skip prefix on decompress */ \102int terminator; /* prefix record terminator */ \103char* data; /* prefix data */ \104} prefix; /* header prefix info */ \105struct \106{ \107Dt_t* order; /* order dictionary */ \108Dt_t* free; /* free list dictionary */ \109Dtdisc_t orderdisc; /* order discipline */ \110Dtdisc_t freedisc; /* free list discipline */ \111} sort; /* PZ_SORT info */ \112Sfio_t* oip; /* original input stream */ \113Sfio_t* oop; /* original output stream */ \114Sfio_t* tmp; /* temp string stream */ \115Sfio_t* str; /* sfstrtmp() string stream */ \116Sfio_t* det; /* processed options stream */ \117Sfio_t* pin; /* partition input stream */ \118char* headoptions; /* header options */ \119char* options; /* current options */ \120Pzrs_t rs; /* read stream state */ \121Pzws_t ws; /* read stream state */ \122Pzss_t split; /* split state */ \123Tv_t start; /* elapsed start time */ \124void* discdata; /* discipline specific data */125126#include <pzip.h>127128typedef struct Pzdllpz_s /* initialized pz list for dll */129{130struct Pzdllpz_s*next; /* next in list */131Pz_t* pz; /* pz initialized for dll */132} Pzdllpz_t;133134typedef struct Pzdll_s /* loaded dlls */135{136struct Pzdll_s* next; /* next in list */137char* name; /* name */138void* dll; /* handle */139const char* usage; /* optget() usage */140Pzinit_f initf; /* initialization function */141Pzdllpz_t* pzs; /* initialized pz list */142} Pzdll_t;143144typedef struct145{146const char* id; /* library id */147Pzdll_t* dll; /* loaded dll list */148} Pzstate_t;149150#define PZ_MAJOR 2 /* current format major version */151#define PZ_MINOR 1 /* current format minor version */152153#define PZ_SPLIT_DEFLATE 0x0001 /* split deflate enabled */154#define PZ_SPLIT_HEADER 0x0002 /* split header already written */155#define PZ_SPLIT_INFLATE 0x0004 /* split inflate enabled */156#define PZ_SPLIT_PART 0x0008 /* currently splitting a part */157158#define PZ_DELAY 0x01000000 /* delay unknown error */159#define PZ_HANDLE 0x02000000 /* sfdcpzip() sp arg is Pz_t */160#define PZ_UNKNOWN 0x04000000 /* unknown input row size */161#define PZ_MAINONLY 0x08000000 /* mainpart only in header */162#define PZ_ROWONLY 0x10000000 /* grab row size from prt file */163#define PZ_AGAIN 0x20000000 /* path arg is Pz_t */164#define PZ_POP 0x40000000 /* pop pz->io on pzclose() */165#define PZ_ERROR 0x80000000 /* make pzclose() return error */166167#define PZ_INTERNAL (PZ_HANDLE|PZ_UNKNOWN|PZ_MAINONLY|PZ_ROWONLY|PZ_AGAIN|PZ_POP|PZ_ERROR)168169#define PZ_MARK_TAIL 1 /* tail marker */170#define PZ_MARK_PART 2 /* tail marker */171172#define PZ_HDR_ARR(x) ((x)>=0x41&&(x)<=0x5a) /* header array op */173#define PZ_HDR_BUF(x) ((x)>=0x61&&(x)<=0x7a) /* header buffer op */174175#define PZ_HDR_comment 0x63 /* header comment string */176#define PZ_HDR_options 0x64 /* header options string */177#define PZ_HDR_fix 0x46 /* header fix array */178#define PZ_HDR_grp 0x47 /* header grp array */179#define PZ_HDR_map 0x4d /* header map array */180#define PZ_HDR_part 0x50 /* header partition */181#define PZ_HDR_prefix 0x70 /* header prefix data */182#define PZ_HDR_split 0x53 /* split { major minor } */183184#define PZGETZ(pz,ip,z,i) \185if ((z = sfgetc(ip)) & SF_MORE) \186{ \187z &= (SF_MORE - 1); \188while ((i = sfgetc(ip)) & SF_MORE) \189{ \190if (i < 0) \191{ \192if (pz->disc->errorf) \193(*pz->disc->errorf)(pz, pz->disc, 2, "%s: input truncated", pz->path); \194return -1; \195} \196z = (z << SF_UBITS) | (i & (SF_MORE - 1)); \197} \198z = (z << SF_UBITS) | i; \199}200201#define PZGETP(pz,ip,z,i,a) \202if (!(z = sfgetc(ip))) \203a; \204if (z & SF_MORE) \205{ \206z &= (SF_MORE - 1); \207while ((i = sfgetc(ip)) & SF_MORE) \208{ \209if (i < 0) \210{ \211if (pz->disc->errorf) \212(*pz->disc->errorf)(pz, pz->disc, 2, "%s: input truncated", pz->path); \213return -1; \214} \215z = (z << SF_UBITS) | (i & (SF_MORE - 1)); \216} \217z = (z << SF_UBITS) | i; \218}219220extern Pzstate_t state;221222extern int pznospace(Pz_t*);223extern int pzsdeflate(Pz_t*, Sfio_t*);224extern int pzsinflate(Pz_t*, Sfio_t*);225extern int pzssplit(Pz_t*);226227#endif228229230