| VCODEX(3) | C LIBRARY FUNCTIONS | VCODEX(3) |
|---|
#include <vcodex.h>
libvcodex.a -lvcodex
Void_t*;
Vcchar_t;
Vcint_t;
Vcbits_t;
Vcdisc_t;
Vcmethod_t;
Vcmtarg_t;
Vcodex_t;
Vcodex_t* vcopen(Vcdisc_t* disc, Vcmethod_t* meth, Void_t* init,
Vcodex_t* coder, int flags);
ssize_t vcextract(Vcodex_t* vc, Void_t** datap, int state);
Vcodex_t* vcrestore(Vcodex_t* vc, Void_t* data, size_t size);
int vcclose(Vcodex_t* vc);
ssize_t vcapply(Vcodex_t* vc, Void_t* data, size_t size,
Void_t** output);
size_t vcundone(Vcodex_t* vc);
Vcdisc_t* vcdisc(Vcodex_t* vc, Vcdisc_t* disc);
Vcchar_t* vcsetbuf(Vcodex_t* vc, Vcchar_t*, ssize_t size, ssize_t head);
int vccontext(Vcodex_t* vc, int context);
Vcmethod_t* vcgetmeth(const char* name, const char* ident);
Vcmethod_t* vcnextmeth(Vcmethod_t* meth);
Vcmethod_t* Vcdelta;
Vcmethod_t* Vchuffman;
Vcmethod_t* Vchuffgroup;
Vcmethod_t* Vchuffpart;
Vcmethod_t* Vcrle;
Vcmethod_t* Vcmtf;
Vcmethod_t* Vcbw;
Vcmethod_t* Vcmap;
Vcmethod_t* Vctranspose;
typedef int (*Vcevent_f)(Vcodex_t*, int, Void_t*, Vcdisc_t*);
typedef struct
{ Void_t* data; /* source or key string */
size_t size; /* size of string */
Vcevent_f eventf; /* event handler */
} Vcdisc_t;
#define VC_OPENING
#define VC_CLOSING
#define VC_DISC
typedef struct
{ Vcchar_t type;
Vcchar_t size;
Vcchar_t mode;
} Vcdinst_t;
typedef struct
{ Vcinst_t inst1;
Vcinst_t inst2;
} Vcdcode_t;
typedef struct
{ Vcchar_t s_near;
Vcchar_t s_same;
Vcdcode_t code[256];
} Vcdtable_t;
ssize_t vcdputtable(Vcdtable_t* tbl, Void_t* buf, size_t n);
int vcdgettable(Vcdtable_t* tbl, Void_t* buf, size_t n);
typedef struct {...} Vcwindow_t;
typedef struct {...} Vcwmethod_t;
typedef int (*Vcwevent_f)(Vcw_t* vcw, int type, Void_t* data,
Vcwdisc_t* disc);
typedef struct
{ Sfio_t* srcf; /* source file */
Sfio_t* tarf; /* target file */
Vcwevent_f eventf; /* event handler */
} Vcwdisc_t;
typedef struct
{ int type; /* VCD_[SOURCE|TARGET]FILE */
Void_t* wdata; /* window data */
ssize_t wsize; /* window length */
Sfoff_t wpos; /* starting position in file */
ssize_t msize; /* data size to be matched */
} Vcwmatch_t;
Vcwmethod_t* Vcwmirror; /* match by file positions */
Vcwmethod_t* Vcwvote; /* match by n-gram frequencies */
Vcwmethod_t* Vcwprefix; /* use prefix matching */
Vcwindow_t* vcwopen(Vcwdisc_t* disc, Vcwmethod_t* meth);
int vcwclose(Vcwindow_t* vcw);
Vcwmatch_t* vcwapply(Vcwindow_t* vcw, Void_t* data, size_t size,
Sfoff_t pos);
ssize_t vcwfeedback(Vcwindow_t* vcw, ssize_t size);
Vcwmethod_t* vcwgetmeth(char* name);
Vcwmethod_t* vcwnextmeth(Vcwmethod_t* meth);
ssize_t vchsize(ssize_t nsym, ssize_t* freq, ssize_t* size, int* run);
ssize_t vchbits(ssize_t nsym, ssize_t* size, Vcbits_t* bits);
ssize_t vchputcode(ssize_t nsym, ssize_t* size, ssize_t maxs,
Vcchar_t* data, size_t dtsz);
ssize_t vchgetcode(ssize_t nsym, ssize_t* size, ssize_t maxs,
Vcchar_t* data, size_t dtsz);
typedef struct _vcpltrans_s /* column specifications */
{ ssize_t index; /* column index */
ssize_t pred1; /* <0 if self compressing */
ssize_t pred2; /* >=0 if supporting pred1 */
} Vcpltrans_t;
typedef struct _vcplan_s /* transform plan */
{ ssize_t ncols; /* # of columns or row size */
Vcpltrans_t* trans; /* the plan to transform data */
Vcodex_t* bwt; /* BWT to encode the plan */
} Vcplan_t;
Vcplan_t* vcplopen(Void_t* data, size_t size, size_t ncols);
void vcplclose(Vcplan_t* plan);
ssize_t vcplencode(Vcplan_t* plan, Void_t** codep);
Vcplan_t* vcpldecode(Void_t* code, size_t cdsz);
typedef struct _vcsfx_s
{ ssize_t* idx; /* sorted suffix array */
ssize_t* inv; /* inverted index/rank */
Vcchar_t* str; /* string to be sorted */
size_t nstr; /* length of string */
} Vcsfx_t;
Vcsfx_t* vcsfxsort(const Void_t* str, size_t nstr);
ssize_t vcperiod(const Void_t* data, size_t dtsz);
typedef int (*Vcparse_f)(Vcparse_t* vcpa, int type, ssize_t undt,
ssize_t here, ssize_t mtsz, ssize_t mtch);
typedef struct _vcparse_s
{
} Vcparse_t;
int vcparse(Vcparse_t* vcpa, ssize_t prune);
typedef struct _vcio_s
{ ...
Vcbits_t bits; /* bits to be read or being cached */
ssize_t nbits; /* number of bits in the above */
} Vcio_t;
void vcioinit(Vcio_t* io, Vcchar_t* buf, int n);
size_t vciosize(Vcio_t* io);
size_t vciomore(Vcio_t* io);
size_t vcioextent(Vcio_t* io);
Vcchar_t* vciodata(Vcio_t* io);
Vcchar_t* vcionext(Vcio_t* io);
Vcchar_t* vcioskip(Vcio_t* io, int n);
void vciomove(Vcio_t* to, Vcio_t* from, int n);
ssize_t vcioputc(Vcio_t* io, int c);
int vciogetc(Vcio_t* io);
ssize_t vcioputu(Vcio_t* io, Vcint_t v);
Vcint_t vciogetu(Vcio_t* io);
ssize_t vcioputm(Vcio_t* io, Vcint_t v, Vcint_t max);
Vcint_t vciogetm(Vcio_t* io, Vcint_t max);
ssize_t vcioput2(Vcio_t* io, Vcint_t v, Vcchar_t a, Vcchar_t b);
Vcint_t vcioget2(Vcio_t* io, Vcchar_t a, Vcchar_t b);
ssize_t vcioputg(Vcio_t* io, Vcint_t v);
Vcint_t vciogetg(Vcio_t* io);"
ssize_t vcioputs(Vcio_t* io, Void_t* s, size_t len);
ssize_t vciogets(Vcio_t* io, Void_t* s, size_t len);
void vciosetb(Vcio_t* io, Vcbits_t bits, ssize_t nbit, int type);
void vcioendb(Vcio_t* io, Vcbits_t bits, ssize_t nbit, int type);
void vciofilb(Vcio_t* io, Vcbits_t bits, ssize_t nbit, ssize_t need);
Vcbits_t vciodelb(Vcio_t* io, Vcbits_t bits, ssize_t nbit, ssize_t ndel);
void vcioflsb(Vcio_t* io, Vcbits_t bits, ssize_t nbit);
Vcbits_t vcioaddb(Vcio_t* io, Vcbits_t bits, ssize_t nbit,
Vcbits_t add, ssize_t nadd);
Vcsfio_t;
typedef struct _vcsfmeth_s
{ Vcmethod_t* meth; /* requested method to invoke */
Void_t* data; /* argument or init parameters */
ssize_t size; /* size information */
} Vcsfmeth_t;
Vcsfmeth_t* VCSF_WINDOW; /* signal setting window data */
Vcsfmeth_t* VCSF_STATES; /* specifying file for states */
Vcsfio_t* vcsfio(Sfio_t* sf, Vcsfmeth_t* list, ssize_t n, int flags);
ssize_t vcsfread(Vcsfio_t* vcsf, Void_t* buf, size_t n);
ssize_t vcsfwrite(Vcsfio_t* vcsf, const Void_t* data, size_t n);
int vcsfsync(Vcsfio_t* vcsf);
int vcsfclose(Vcsfio_t* vcsf);
Vcsfmeth_t* vcsfmeth(Vcsfio_t* vcsf, ssize_t* nmeth);
double vclog(unsigned int v);
Vcodex provides a collection of data transforms including compression, differencing and encryption via a discipline and method interface (see The Discipline and Method Architecture for Reusable Libraries, Software Practice & Experience, v.30, pp.107-128, 2000).
typedef struct _vcmethod_s
{ ...
char* name; /* the string name of the data transform */
unsigned char* ident; /* identifier to use in persistent data */
char* desc; /* short description of the transform */
Vcmtarg_t* args; /* arguments to be used with vcopen() */
ssize_t window; /* suggested window to use on large files */
} Vcmethod_t;
The args field of Vcmethod_t defines a list of arguments usable
as the third argument of vcopen(). Note that although init is
declared as Void_t* to suit the prototype of vcopen(),
for most methods, it is a character string.
typedef struct _vcmtarg_s
{ char* name; /* the string name of the argument */
unsigned char* ident; /* identifier to use in persistent data */
char* desc; /* short description of the argument */
Void_t* data; /* any associated data */
} Vcmtarg_t;
Vcodex currently provides the following data transforming methods:
A delta compression method such as Vcdelta requires source data to compare against while other methods such as Vctranspose or Vctable may need training data. Such information must be supplied by an application via the discipline structure Vcdisc_t:
typedef struct
{ Void_t* data;
size_t size;
Vcevent_f eventf;
} Vcdisc_t;
The types Vcdinst_t, Vcdcode_t and Vcdtable_t describe the structures of a code table and the instructions. Their usage is described in the paper IETF RFC draft-korn-vcdiff-xx.txt (http://www.ietf.org).
typedef struct _vcpltrans_s /* column specifications */
{ ssize_t index; /* column index */
ssize_t pred1; /* <0 if self compressing */
ssize_t pred2; /* if pred1<0, 1 for doing MTF */
} Vcpltrans_t;
typedef struct _vcplan_s /* transform plan */
{ ssize_t ncols; /* row size or # of columns */
Vcpltrans_t* trans; /* the plan to transform data */
Vcodex_t* bwt; /* BW-transform to code plan */
} Vcplan_t;
typedef struct _vcsfx_s
{ ssize_t* idx; /* sorted suffix indices */
ssize_t* inv; /* inverse permuation of idx[] */
Vcchar_t* str; /* string with sorted suffixes */
size_t nstr; /* length of above string */
} Vcsfx_t;
COPY 5 0 /* copy 5 bytes from 0, the start of source data */
COPY 9 5 /* copy 9 bytes from 5, the start of target data */
ADD 1 f /* add 1 literal byte: f */
typedef int (*Vcparse_f)(Vcparse_t* vcpa, int type, ssize_t undt,
ssize_t here, ssize_t mtsz, ssize_t mtch);
typedef struct _vcparse_s
{
} Vcparse_t;
typedef struct _vcsfmeth_s
{ Vcmethod_t* meth; /* requested method to invoke */
Void_t* data; /* argument or init parameters */
ssize_t size; /* size information */
} Vcsfmeth_t;
The field meth normally specifies a data transform. The data and size
fields give the arguments needed for the particular data transform.
The field meth can also be VCSF_WINDOW or VCSF_STATES.
In the first case, the field data specifies a windowing handle of type Vcwindow_t*
while size specifies the window size, i.e., the amount of data to collect
before transforming.
In the second case, data specifies a file name to use to store data transforming
states in a persistent format. Certain data transforms (e.g., Vctable)
could store and restore states via this mechanism to reduce initialization cost.
| May 01 2005 | November 07, 2006 |