"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "xdelta3.h" between
xdelta3-3.0.11.tar.gz and xdelta3-3.1.0.tar.gz

About: xdelta is a tool and library for differential compression (supports VCDIFF encoding and decoding). Beta version.

xdelta3.h  (xdelta3-3.0.11):xdelta3.h  (xdelta3-3.1.0)
skipping to change at line 19 skipping to change at line 19
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
/* To know more about Xdelta, start by reading xdelta3.c. If you are /* To learn more about Xdelta, start by reading xdelta3.c. If you are
* ready to use the API, continue reading here. There are two * ready to use the API, continue reading here. There are two
* interfaces -- xd3_encode_input and xd3_decode_input -- plus a dozen * interfaces -- xd3_encode_input and xd3_decode_input -- plus a dozen
* or so related calls. This interface is styled after Zlib. */ * or so related calls. This interface is styled after Zlib. */
#ifndef _XDELTA3_H_ #ifndef _XDELTA3_H_
#define _XDELTA3_H_ #define _XDELTA3_H_
#define _POSIX_SOURCE #define _POSIX_SOURCE 200112L
#define _ISOC99_SOURCE #define _ISOC99_SOURCE
#define _C99_SOURCE #define _C99_SOURCE
#if HAVE_CONFIG_H #if HAVE_CONFIG_H
#include "config.h" #include "config.h"
#endif #endif
#include <errno.h> #include <errno.h>
#include <stdarg.h> #include <stdarg.h>
#include <stddef.h> #include <stddef.h>
skipping to change at line 73 skipping to change at line 73
#define XD3_ALLOCSIZE (1U<<14) #define XD3_ALLOCSIZE (1U<<14)
#endif #endif
/* The XD3_HARDMAXWINSIZE parameter is a safety mechanism to protect /* The XD3_HARDMAXWINSIZE parameter is a safety mechanism to protect
* decoders against malicious files. The decoder will never decode a * decoders against malicious files. The decoder will never decode a
* window larger than this. If the file specifies VCD_TARGET the * window larger than this. If the file specifies VCD_TARGET the
* decoder may require two buffers of this size. * decoder may require two buffers of this size.
* *
* 8-16MB is reasonable, probably don't need to go larger. */ * 8-16MB is reasonable, probably don't need to go larger. */
#ifndef XD3_HARDMAXWINSIZE #ifndef XD3_HARDMAXWINSIZE
#define XD3_HARDMAXWINSIZE (1U<<24) #define XD3_HARDMAXWINSIZE (1U<<26)
#endif #endif
/* The IOPT_SIZE value sets the size of a buffer used to batch /* The IOPT_SIZE value sets the size of a buffer used to batch
* overlapping copy instructions before they are optimized by picking * overlapping copy instructions before they are optimized by picking
* the best non-overlapping ranges. The larger this buffer, the * the best non-overlapping ranges. The larger this buffer, the
* longer a forced xd3_srcwin_setup() decision is held off. Setting * longer a forced xd3_srcwin_setup() decision is held off. Setting
* this value to 0 causes an unlimited buffer to be used. */ * this value to 0 causes an unlimited buffer to be used. */
#ifndef XD3_DEFAULT_IOPT_SIZE #ifndef XD3_DEFAULT_IOPT_SIZE
#define XD3_DEFAULT_IOPT_SIZE (1U<<15) #define XD3_DEFAULT_IOPT_SIZE (1U<<15)
#endif #endif
/* The maximum distance backward to search for small matches */ /* The maximum distance backward to search for small matches */
#ifndef XD3_DEFAULT_SPREVSZ #ifndef XD3_DEFAULT_SPREVSZ
#define XD3_DEFAULT_SPREVSZ (1U<<18) #define XD3_DEFAULT_SPREVSZ (1U<<18)
#endif #endif
/* The default compression level /* The default compression level */
*/
#ifndef XD3_DEFAULT_LEVEL #ifndef XD3_DEFAULT_LEVEL
#define XD3_DEFAULT_LEVEL 3 #define XD3_DEFAULT_LEVEL 3
#endif #endif
#ifndef XD3_DEFAULT_SECONDARY_LEVEL #ifndef XD3_DEFAULT_SECONDARY_LEVEL
#define XD3_DEFAULT_SECONDARY_LEVEL 6 #define XD3_DEFAULT_SECONDARY_LEVEL 6
#endif #endif
#ifndef XD3_USE_LARGEFILE64 #ifndef XD3_USE_LARGEFILE64
#define XD3_USE_LARGEFILE64 1 #define XD3_USE_LARGEFILE64 1
#endif #endif
/* The source window size is limited to 2GB unless
* XD3_USE_LARGESIZET is defined to 1. */
#ifndef XD3_USE_LARGESIZET
#define XD3_USE_LARGESIZET 1
#endif
/* Sizes and addresses within VCDIFF windows are represented as usize_t /* Sizes and addresses within VCDIFF windows are represented as usize_t
* *
* For source-file offsets and total file sizes, total input and * For source-file offsets and total file sizes, total input and
* output counts, the xoff_t type is used. The decoder and encoder * output counts, the xoff_t type is used. The decoder and encoder
* generally check for overflow of the xoff_t size (this is tested at * generally check for overflow of the xoff_t size (this is tested at
* the 32bit boundary [xdelta3-test.h]). * the 32bit boundary [xdelta3-test.h]).
*/ */
#ifndef _WIN32 #ifndef _WIN32
#define __STDC_FORMAT_MACROS
#include <inttypes.h>
#include <stdint.h> #include <stdint.h>
#else /* WIN32 case */ #else /* WIN32 case */
#define WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN
#ifndef WINVER #ifndef WINVER
#if XD3_USE_LARGEFILE64 #if XD3_USE_LARGEFILE64
/* 64 bit file offsets: uses GetFileSizeEx and SetFilePointerEx. /* 64 bit file offsets: uses GetFileSizeEx and SetFilePointerEx. */
* requires Win2000 or newer version of WinNT */
#define WINVER 0x0500 #define WINVER 0x0500
#define _WIN32_WINNT 0x0500 #define _WIN32_WINNT 0x0500
#else /* xoff_t is 32bit */ #else /* xoff_t is 32bit */
/* 32 bit (DWORD) file offsets: uses GetFileSize and /* 32 bit file offsets: uses GetFileSize and SetFilePointer. */
* SetFilePointer. compatible with win9x-me and WinNT4 */
#define WINVER 0x0400 #define WINVER 0x0400
#define _WIN32_WINNT 0x0400 #define _WIN32_WINNT 0x0400
#endif /* if XD3_USE_LARGEFILE64 */ #endif /* if XD3_USE_LARGEFILE64 */
#endif /* ifndef WINVER */ #endif /* ifndef WINVER */
#include <windows.h> #include <windows.h>
/* _MSV_VER is defined by Microsoft tools, not by mingw32 */ /* _MSV_VER is defined by Microsoft tools, not by Mingw32 */
#ifdef _MSC_VER #ifdef _MSC_VER
/*#define inline*/
typedef signed int ssize_t; typedef signed int ssize_t;
#if _MSC_VER < 1600 #if _MSC_VER < 1600
typedef unsigned char uint8_t; typedef unsigned char uint8_t;
typedef unsigned short uint16_t; typedef unsigned short uint16_t;
typedef unsigned long uint32_t; typedef unsigned long uint32_t;
typedef ULONGLONG uint64_t; typedef ULONGLONG uint64_t;
#else /* _MSC_VER >= 1600 */ #else /* _MSC_VER >= 1600 */
/* For MSVC10 and above */ /* For MSVC10 and above */
#include <stdint.h> #include <stdint.h>
#endif /* _MSC_VER < 1600 */ #endif /* _MSC_VER < 1600 */
#else /* _MSC_VER not defined */ #else /* _MSC_VER not defined */
/* mingw32, lcc and watcom provide a proper header */ /* Mingw32 */
#include <stdint.h> #include <stdint.h>
#endif /* _MSC_VER defined */ #endif /* _MSC_VER defined */
#endif /* _WIN32 defined */
typedef uint32_t usize_t; #endif /* _WIN32 defined */
/* Settings based on the size of xoff_t (32 vs 64 file offsets) */
#if XD3_USE_LARGEFILE64 #if XD3_USE_LARGEFILE64
/* xoff_t is a 64-bit type */ /* xoff_t is a 64-bit type */
#define __USE_FILE_OFFSET64 1 /* GLIBC: for 64bit fileops, ... ? */ #define __USE_FILE_OFFSET64 1 /* GLIBC: for 64bit fileops. */
#ifndef _LARGEFILE_SOURCE #ifndef _LARGEFILE_SOURCE
#define _LARGEFILE_SOURCE #define _LARGEFILE_SOURCE
#endif #endif
#ifndef _FILE_OFFSET_BITS #ifndef _FILE_OFFSET_BITS
#define _FILE_OFFSET_BITS 64 #define _FILE_OFFSET_BITS 64
#endif #endif
/* Set a xoff_t typedef and the "Q" printf insert. */
#if defined(_WIN32) #if defined(_WIN32)
typedef uint64_t xoff_t; typedef uint64_t xoff_t;
/* Note: The following generates benign warnings in a mingw /* Note: The following generates benign warnings in a mingw
* cross-compiler */ * cross-compiler */
#define Q "I64" #define Q "I64"
#elif SIZEOF_UNSIGNED_LONG == 8 #elif SIZEOF_UNSIGNED_LONG == 8
typedef unsigned long xoff_t; typedef unsigned long xoff_t;
#define Q "l" #define Q "l"
#elif SIZEOF_SIZE_T == 8 #elif SIZEOF_SIZE_T == 8
typedef size_t xoff_t; typedef size_t xoff_t;
#define Q "z" #define Q "z"
#elif SIZEOF_UNSIGNED_LONG_LONG == 8 #elif SIZEOF_UNSIGNED_LONG_LONG == 8
typedef unsigned long long xoff_t; typedef unsigned long long xoff_t;
#define Q "ll" #define Q "ll"
#endif /* #define Q */ #endif /* typedef and #define Q */
#define SIZEOF_XOFF_T 8 #define SIZEOF_XOFF_T 8
#else /* XD3_USE_LARGEFILE64 == 0 */ #else /* XD3_USE_LARGEFILE64 == 0 */
#if SIZEOF_UNSIGNED_INT == 4 #if SIZEOF_UNSIGNED_INT == 4
typedef unsigned int xoff_t; typedef unsigned int xoff_t;
#elif SIZEOF_UNSIGNED_LONG == 4 #elif SIZEOF_UNSIGNED_LONG == 4
typedef unsigned long xoff_t; typedef unsigned long xoff_t;
#else #else
typedef uint32_t xoff_t; typedef uint32_t xoff_t;
#endif /* xoff_t is 32 bits */ #endif /* xoff_t is 32 bits */
#define SIZEOF_XOFF_T 4 #define SIZEOF_XOFF_T 4
#define Q #define Q
#endif /* 64 vs 32 bit xoff_t */ #endif /* 64 vs 32 bit xoff_t */
/* Note: This gets modified in the 64bithash branch. */ /* Settings based on the size of usize_t (32 and 64 bit window size) */
#if XD3_USE_LARGESIZET
/* Set a usize_ttypedef and the "W" printf insert. */
#if defined(_WIN32)
typedef uint64_t usize_t;
/* Note: The following generates benign warnings in a mingw
* cross-compiler */
#define W "I64"
#elif SIZEOF_UNSIGNED_LONG == 8
typedef unsigned long usize_t;
#define W "l"
#elif SIZEOF_SIZE_T == 8
typedef size_t usize_t;
#define W "z"
#elif SIZEOF_UNSIGNED_LONG_LONG == 8
typedef unsigned long long usize_t;
#define W "ll"
#endif /* typedef and #define W */
#define SIZEOF_USIZE_T 8
#else /* XD3_USE_LARGESIZET == 0 */
#if SIZEOF_UNSIGNED_INT == 4
typedef unsigned int usize_t;
#elif SIZEOF_UNSIGNED_LONG == 4
typedef unsigned long usize_t;
#else
typedef uint32_t usize_t;
#endif /* usize_t is 32 bits */
#define SIZEOF_USIZE_T 4 #define SIZEOF_USIZE_T 4
#define W
#endif /* 64 vs 32 bit usize_t */
/* Settings based on the size of size_t (the system-provided,
* usually-but-maybe-not an unsigned type) */
#if SIZEOF_SIZE_T == 4 #if SIZEOF_SIZE_T == 4
#define Z "z" #define Z "z"
#elif SIZEOF_SIZE_T == 8 #elif SIZEOF_SIZE_T == 8
#ifdef _WIN32 #ifdef _WIN32
#define Z "I64" #define Z "I64"
#else /* !_WIN32 */ #else /* !_WIN32 */
#define Z "z" #define Z "z"
#endif /* Windows or not */ #endif /* Windows or not */
#else #else
#error Bad configure script #error Bad configure script
skipping to change at line 259 skipping to change at line 300
#endif #endif
#ifndef PYTHON_MODULE #ifndef PYTHON_MODULE
#define PYTHON_MODULE 0 #define PYTHON_MODULE 0
#endif #endif
#ifndef SWIG_MODULE #ifndef SWIG_MODULE
#define SWIG_MODULE 0 #define SWIG_MODULE 0
#endif #endif
#ifndef NOT_MAIN
#define NOT_MAIN 0
#endif
/* There are three string matching functions supplied: one fast, one /* There are three string matching functions supplied: one fast, one
* slow (default), and one soft-configurable. To disable any of * slow (default), and one soft-configurable. To disable any of
* these, use the following definitions. */ * these, use the following definitions. */
#ifndef XD3_BUILD_SLOW #ifndef XD3_BUILD_SLOW
#define XD3_BUILD_SLOW 1 #define XD3_BUILD_SLOW 1
#endif #endif
#ifndef XD3_BUILD_FAST #ifndef XD3_BUILD_FAST
#define XD3_BUILD_FAST 1 #define XD3_BUILD_FAST 1
#endif #endif
#ifndef XD3_BUILD_FASTER #ifndef XD3_BUILD_FASTER
skipping to change at line 285 skipping to change at line 330
#define XD3_BUILD_SOFT 1 #define XD3_BUILD_SOFT 1
#endif #endif
#ifndef XD3_BUILD_DEFAULT #ifndef XD3_BUILD_DEFAULT
#define XD3_BUILD_DEFAULT 1 #define XD3_BUILD_DEFAULT 1
#endif #endif
#if XD3_DEBUG #if XD3_DEBUG
#include <stdio.h> #include <stdio.h>
#endif #endif
/* XPRINT. Debug output and VCDIFF_TOOLS functions report to stderr.
* I have used an irregular style to abbreviate [fprintf(stderr, "] as
* [DP(RINT "]. */
#define DP fprintf
#define RINT stderr,
typedef struct _xd3_stream xd3_stream; typedef struct _xd3_stream xd3_stream;
typedef struct _xd3_source xd3_source; typedef struct _xd3_source xd3_source;
typedef struct _xd3_hash_cfg xd3_hash_cfg; typedef struct _xd3_hash_cfg xd3_hash_cfg;
typedef struct _xd3_smatcher xd3_smatcher; typedef struct _xd3_smatcher xd3_smatcher;
typedef struct _xd3_rinst xd3_rinst; typedef struct _xd3_rinst xd3_rinst;
typedef struct _xd3_dinst xd3_dinst; typedef struct _xd3_dinst xd3_dinst;
typedef struct _xd3_hinst xd3_hinst; typedef struct _xd3_hinst xd3_hinst;
typedef struct _xd3_winst xd3_winst; typedef struct _xd3_winst xd3_winst;
typedef struct _xd3_rpage xd3_rpage; typedef struct _xd3_rpage xd3_rpage;
typedef struct _xd3_addr_cache xd3_addr_cache; typedef struct _xd3_addr_cache xd3_addr_cache;
skipping to change at line 329 skipping to change at line 368
typedef void* (xd3_alloc_func) (void *opaque, typedef void* (xd3_alloc_func) (void *opaque,
size_t items, size_t items,
usize_t size); usize_t size);
typedef void (xd3_free_func) (void *opaque, typedef void (xd3_free_func) (void *opaque,
void *address); void *address);
typedef int (xd3_getblk_func) (xd3_stream *stream, typedef int (xd3_getblk_func) (xd3_stream *stream,
xd3_source *source, xd3_source *source,
xoff_t blkno); xoff_t blkno);
/* These are internal functions to delay construction of encoding
* tables and support alternate code tables. See the comments & code
* enabled by GENERIC_ENCODE_TABLES. */
typedef const xd3_dinst* (xd3_code_table_func) (void); typedef const xd3_dinst* (xd3_code_table_func) (void);
typedef int (xd3_comp_table_func) (xd3_stream *stream,
const uint8_t **data, #ifdef _WIN32
usize_t *size); #define vsnprintf_func _vsnprintf
#define snprintf_func _snprintf
#else
#define vsnprintf_func vsnprintf
#define snprintf_func snprintf
#endif
#define short_sprintf(sb,fmt,...) \
snprintf_func((sb).buf,sizeof((sb).buf),fmt,__VA_ARGS__)
/* Type used for short snprintf calls. */
typedef struct {
char buf[48];
} shortbuf;
#ifndef PRINTF_ATTRIBUTE
#define PRINTF_ATTRIBUTE(x,y) __attribute__ ((__format__ (__printf__, x, y)))
#endif
/* Underlying xprintf() */
int xsnprintf_func (char *str, size_t n, const char *fmt, ...)
PRINTF_ATTRIBUTE(3,4);
/* XPR(NT "", ...) (used by main) prefixes an "xdelta3: " to the output. */
void xprintf(const char *fmt, ...) PRINTF_ATTRIBUTE(1,2);
#define XPR xprintf
#define NT "xdelta3: "
#define NTR ""
/* DP(RINT ...) */
#define DP xprintf
#define RINT ""
#if XD3_DEBUG #if XD3_DEBUG
#define XD3_ASSERT(x) \ #define XD3_ASSERT(x) \
do { if (! (x)) { DP(RINT "%s:%d: XD3 assertion failed: %s\n", __FILE__, __L do { \
INE__, #x); \ if (! (x)) { \
abort (); } } while (0) DP(RINT "%s:%d: XD3 assertion failed: %s\n", \
__FILE__, __LINE__, #x); \
abort (); } } while (0)
#else #else
#define XD3_ASSERT(x) (void)0 #define XD3_ASSERT(x) (void)0
#endif /* XD3_DEBUG */ #endif /* XD3_DEBUG */
#define xd3_max(x,y) ((x) < (y) ? (y) : (x)) #define xd3_max(x,y) ((x) < (y) ? (y) : (x))
#define xd3_min(x,y) ((x) < (y) ? (x) : (y)) #define xd3_min(x,y) ((x) < (y) ? (x) : (y))
/**************************************************************** /****************************************************************
PUBLIC ENUMS PUBLIC ENUMS
******************************************************************/ ******************************************************************/
skipping to change at line 589 skipping to change at line 656
{ {
uint8_t type1; uint8_t type1;
uint8_t size1; uint8_t size1;
uint8_t type2; uint8_t type2;
uint8_t size2; uint8_t size2;
}; };
/* the decoded form of a single (half) instruction. */ /* the decoded form of a single (half) instruction. */
struct _xd3_hinst struct _xd3_hinst
{ {
uint8_t type; uint8_t type;
uint32_t size; /* TODO: why decode breaks if this is usize_t? */ usize_t size;
uint32_t addr; /* TODO: why decode breaks if this is usize_t? */ usize_t addr;
}; };
/* the form of a whole-file instruction */ /* the form of a whole-file instruction */
struct _xd3_winst struct _xd3_winst
{ {
uint8_t type; /* RUN, ADD, COPY */ uint8_t type; /* RUN, ADD, COPY */
uint8_t mode; /* 0, VCD_SOURCE, VCD_TARGET */ uint8_t mode; /* 0, VCD_SOURCE, VCD_TARGET */
usize_t size; usize_t size;
xoff_t addr; xoff_t addr;
xoff_t position; /* absolute position of this inst */ xoff_t position; /* absolute position of this inst */
skipping to change at line 618 skipping to change at line 685
usize_t next; usize_t next;
usize_t avail; usize_t avail;
xd3_output *next_page; xd3_output *next_page;
}; };
/* used by the decoder to buffer input in sections. */ /* used by the decoder to buffer input in sections. */
struct _xd3_desect struct _xd3_desect
{ {
const uint8_t *buf; const uint8_t *buf;
const uint8_t *buf_max; const uint8_t *buf_max;
uint32_t size; /* TODO: why decode breaks if this is usize_t? */ usize_t size;
usize_t pos; usize_t pos;
/* used in xdelta3-decode.h */ /* used in xdelta3-decode.h */
uint8_t *copied1; uint8_t *copied1;
usize_t alloc1; usize_t alloc1;
/* used in xdelta3-second.h */ /* used in xdelta3-second.h */
uint8_t *copied2; uint8_t *copied2;
usize_t alloc2; usize_t alloc2;
}; };
skipping to change at line 666 skipping to change at line 733
usize_t small_look; usize_t small_look;
usize_t small_chain; usize_t small_chain;
usize_t small_lchain; usize_t small_lchain;
usize_t max_lazy; usize_t max_lazy;
usize_t long_enough; usize_t long_enough;
}; };
/* hash table size & power-of-two hash function. */ /* hash table size & power-of-two hash function. */
struct _xd3_hash_cfg struct _xd3_hash_cfg
{ {
usize_t size; usize_t size; // Number of buckets
usize_t shift; usize_t shift;
usize_t mask; usize_t mask;
usize_t look; // How wide is this checksum
usize_t multiplier; // K * powers[0]
usize_t *powers; // Array of [0,look) where powers[look-1] == 1
// and powers[N] = powers[N+1]*K (Rabin-Karp)
}; };
/* the sprev list */ /* the sprev list */
struct _xd3_slist struct _xd3_slist
{ {
usize_t last_pos; usize_t last_pos;
}; };
/* window info (for whole state) */ /* window info (for whole state) */
struct _xd3_wininfo { struct _xd3_wininfo {
skipping to change at line 728 skipping to change at line 799
usize_t sprevsz; /* How far back small string usize_t sprevsz; /* How far back small string
matching goes */ matching goes */
usize_t iopt_size; /* entries in the usize_t iopt_size; /* entries in the
instruction-optimizing instruction-optimizing
buffer */ buffer */
xd3_getblk_func *getblk; /* The three callbacks. */ xd3_getblk_func *getblk; /* The three callbacks. */
xd3_alloc_func *alloc; xd3_alloc_func *alloc;
xd3_free_func *freef; xd3_free_func *freef;
void *opaque; /* Not used. */ void *opaque; /* Not used. */
int flags; /* stream->flags are initialized uint32_t flags; /* stream->flags are initialized
* from xd3_config & never * from xd3_config & never
* modified by the library. Use * modified by the library. Use
* xd3_set_flags to modify flags * xd3_set_flags to modify flags
* settings mid-stream. */ * settings mid-stream. */
xd3_sec_cfg sec_data; /* Secondary compressor config: data */ xd3_sec_cfg sec_data; /* Secondary compressor config: data */
xd3_sec_cfg sec_inst; /* Secondary compressor config: inst */ xd3_sec_cfg sec_inst; /* Secondary compressor config: inst */
xd3_sec_cfg sec_addr; /* Secondary compressor config: addr */ xd3_sec_cfg sec_addr; /* Secondary compressor config: addr */
xd3_smatch_cfg smatch_cfg; /* See enum: use fields below for xd3_smatch_cfg smatch_cfg; /* See enum: use fields below for
skipping to change at line 771 skipping to change at line 842
usize_t onblk; /* number of bytes on current usize_t onblk; /* number of bytes on current
block: client sets, must be >= 0 block: client sets, must be >= 0
and <= blksize */ and <= blksize */
const uint8_t *curblk; /* current block array: client const uint8_t *curblk; /* current block array: client
sets after getblk request */ sets after getblk request */
/* xd3 sets */ /* xd3 sets */
usize_t srclen; /* length of this source window */ usize_t srclen; /* length of this source window */
xoff_t srcbase; /* offset of this source window xoff_t srcbase; /* offset of this source window
in the source itself */ in the source itself */
int shiftby; /* for power-of-two blocksizes */ usize_t shiftby; /* for power-of-two blocksizes */
int maskby; /* for power-of-two blocksizes */ usize_t maskby; /* for power-of-two blocksizes */
xoff_t cpyoff_blocks; /* offset of dec_cpyoff in blocks */ xoff_t cpyoff_blocks; /* offset of dec_cpyoff in blocks */
usize_t cpyoff_blkoff; /* offset of copy window in usize_t cpyoff_blkoff; /* offset of copy window in
blocks, remainder */ blocks, remainder */
xoff_t getblkno; /* request block number: xd3 sets xoff_t getblkno; /* request block number: xd3 sets
current getblk request */ current getblk request */
/* See xd3_getblk() */ /* See xd3_getblk() */
xoff_t max_blkno; /* Maximum block, if eof is known, xoff_t max_blkno; /* Maximum block, if eof is known,
* otherwise, equals frontier_blkno * otherwise, equals frontier_blkno
* (initially 0). */ * (initially 0). */
skipping to change at line 829 skipping to change at line 900
size mask */ size mask */
usize_t iopt_size; usize_t iopt_size;
usize_t iopt_unlimited; usize_t iopt_unlimited;
/* general configuration */ /* general configuration */
xd3_getblk_func *getblk; /* set nxtblk, nxtblkno to scanblkno */ xd3_getblk_func *getblk; /* set nxtblk, nxtblkno to scanblkno */
xd3_alloc_func *alloc; /* malloc function */ xd3_alloc_func *alloc; /* malloc function */
xd3_free_func *free; /* free function */ xd3_free_func *free; /* free function */
void* opaque; /* private data object passed to void* opaque; /* private data object passed to
alloc, free, and getblk */ alloc, free, and getblk */
int flags; /* various options */ uint32_t flags; /* various options */
/* secondary compressor configuration */ /* secondary compressor configuration */
xd3_sec_cfg sec_data; /* Secondary compressor config: data */ xd3_sec_cfg sec_data; /* Secondary compressor config: data */
xd3_sec_cfg sec_inst; /* Secondary compressor config: inst */ xd3_sec_cfg sec_inst; /* Secondary compressor config: inst */
xd3_sec_cfg sec_addr; /* Secondary compressor config: addr */ xd3_sec_cfg sec_addr; /* Secondary compressor config: addr */
xd3_smatcher smatcher; xd3_smatcher smatcher;
usize_t *large_table; /* table of large checksums */ usize_t *large_table; /* table of large checksums */
xd3_hash_cfg large_hash; /* large hash config */ xd3_hash_cfg large_hash; /* large hash config */
skipping to change at line 927 skipping to change at line 998
xd3_decode_state dec_state; /* current DEC_XXX value */ xd3_decode_state dec_state; /* current DEC_XXX value */
usize_t dec_hdr_ind; /* VCDIFF header indicator */ usize_t dec_hdr_ind; /* VCDIFF header indicator */
usize_t dec_win_ind; /* VCDIFF window indicator */ usize_t dec_win_ind; /* VCDIFF window indicator */
usize_t dec_del_ind; /* VCDIFF delta indicator */ usize_t dec_del_ind; /* VCDIFF delta indicator */
uint8_t dec_magic[4]; /* First four bytes */ uint8_t dec_magic[4]; /* First four bytes */
usize_t dec_magicbytes; /* Magic position. */ usize_t dec_magicbytes; /* Magic position. */
usize_t dec_secondid; /* Optional secondary compressor ID. */ usize_t dec_secondid; /* Optional secondary compressor ID. */
/* TODO: why decode breaks if this is usize_t? */ usize_t dec_codetblsz; /* Optional code table: length. */
uint32_t dec_codetblsz; /* Optional code table: length. */
uint8_t *dec_codetbl; /* Optional code table: storage. */ uint8_t *dec_codetbl; /* Optional code table: storage. */
usize_t dec_codetblbytes; /* Optional code table: position. */ usize_t dec_codetblbytes; /* Optional code table: position. */
/* TODO: why decode breaks if this is usize_t? */ usize_t dec_appheadsz; /* Optional application header:
uint32_t dec_appheadsz; /* Optional application header:
size. */ size. */
uint8_t *dec_appheader; /* Optional application header: uint8_t *dec_appheader; /* Optional application header:
storage */ storage */
usize_t dec_appheadbytes; /* Optional application header: usize_t dec_appheadbytes; /* Optional application header:
position. */ position. */
usize_t dec_cksumbytes; /* Optional checksum: position. */ usize_t dec_cksumbytes; /* Optional checksum: position. */
uint8_t dec_cksum[4]; /* Optional checksum: storage. */ uint8_t dec_cksum[4]; /* Optional checksum: storage. */
uint32_t dec_adler32; /* Optional checksum: value. */ uint32_t dec_adler32; /* Optional checksum: value. */
/* TODO: why decode breaks if this is usize_t? */ usize_t dec_cpylen; /* length of copy window
uint32_t dec_cpylen; /* length of copy window
(VCD_SOURCE or VCD_TARGET) */ (VCD_SOURCE or VCD_TARGET) */
xoff_t dec_cpyoff; /* offset of copy window xoff_t dec_cpyoff; /* offset of copy window
(VCD_SOURCE or VCD_TARGET) */ (VCD_SOURCE or VCD_TARGET) */
/* TODO: why decode breaks if this is usize_t? */ usize_t dec_enclen; /* length of delta encoding */
uint32_t dec_enclen; /* length of delta encoding */ usize_t dec_tgtlen; /* length of target window */
/* TODO: why decode breaks if this is usize_t? */
uint32_t dec_tgtlen; /* length of target window */
#if USE_UINT64 #if USE_UINT64
uint64_t dec_64part; /* part of a decoded uint64_t */ uint64_t dec_64part; /* part of a decoded uint64_t */
#endif #endif
#if USE_UINT32 #if USE_UINT32
uint32_t dec_32part; /* part of a decoded uint32_t */ uint32_t dec_32part; /* part of a decoded uint32_t */
#endif #endif
xoff_t dec_winstart; /* offset of the start of xoff_t dec_winstart; /* offset of the start of
current target window */ current target window */
skipping to change at line 1001 skipping to change at line 1067
target window */ target window */
usize_t dec_lastspace; /* allocated space of last usize_t dec_lastspace; /* allocated space of last
target window, for reuse */ target window, for reuse */
xd3_desect inst_sect; /* staging area for decoding xd3_desect inst_sect; /* staging area for decoding
window sections */ window sections */
xd3_desect addr_sect; xd3_desect addr_sect;
xd3_desect data_sect; xd3_desect data_sect;
xd3_code_table_func *code_table_func; xd3_code_table_func *code_table_func;
xd3_comp_table_func *comp_table_func;
const xd3_dinst *code_table; const xd3_dinst *code_table;
const xd3_code_table_desc *code_table_desc; const xd3_code_table_desc *code_table_desc;
xd3_dinst *code_table_alloc; xd3_dinst *code_table_alloc;
/* secondary compression */ /* secondary compression */
const xd3_sec_type *sec_type; const xd3_sec_type *sec_type;
xd3_sec_stream *sec_stream_d; xd3_sec_stream *sec_stream_d;
xd3_sec_stream *sec_stream_i; xd3_sec_stream *sec_stream_i;
xd3_sec_stream *sec_stream_a; xd3_sec_stream *sec_stream_a;
skipping to change at line 1258 skipping to change at line 1323
xoff_t addr, int is_source); xoff_t addr, int is_source);
/* Gives an error string for xdelta3-speficic errors, returns NULL for /* Gives an error string for xdelta3-speficic errors, returns NULL for
system errors */ system errors */
const char* xd3_strerror (int ret); const char* xd3_strerror (int ret);
/* For convenience, zero & initialize the xd3_config structure with /* For convenience, zero & initialize the xd3_config structure with
specified flags. */ specified flags. */
static inline static inline
void xd3_init_config (xd3_config *config, void xd3_init_config (xd3_config *config,
int flags) uint32_t flags)
{ {
memset (config, 0, sizeof (*config)); memset (config, 0, sizeof (*config));
config->flags = flags; config->flags = flags;
} }
/* This supplies some input to the stream. /* This supplies some input to the stream.
* *
* For encoding, if the input is larger than the configured window * For encoding, if the input is larger than the configured window
* size (xd3_config.winsize), the entire input will be consumed and * size (xd3_config.winsize), the entire input will be consumed and
* encoded anyway. If you wish to strictly limit the window size, * encoded anyway. If you wish to strictly limit the window size,
skipping to change at line 1321 skipping to change at line 1386
xoff_t xd3_encoder_srcbase (xd3_stream *stream) { xoff_t xd3_encoder_srcbase (xd3_stream *stream) {
return stream->src->srcbase; return stream->src->srcbase;
} }
static inline static inline
usize_t xd3_encoder_srclen (xd3_stream *stream) { usize_t xd3_encoder_srclen (xd3_stream *stream) {
return stream->src->srclen; return stream->src->srclen;
} }
/* Checks for legal flag changes. */ /* Checks for legal flag changes. */
static inline static inline
void xd3_set_flags (xd3_stream *stream, int flags) void xd3_set_flags (xd3_stream *stream, uint32_t flags)
{ {
/* The bitwise difference should contain only XD3_FLUSH or /* The bitwise difference should contain only XD3_FLUSH or
XD3_SKIP_WINDOW */ XD3_SKIP_WINDOW */
XD3_ASSERT(((flags ^ stream->flags) & ~(XD3_FLUSH | XD3_SKIP_WINDOW)) == 0); XD3_ASSERT(((flags ^ stream->flags) & ~(XD3_FLUSH | XD3_SKIP_WINDOW)) == 0);
stream->flags = flags; stream->flags = flags;
} }
/* Gives some extra information about the latest library error, if any /* Gives some extra information about the latest library error, if any
* is known. */ * is known. */
static inline static inline
skipping to change at line 1345 skipping to change at line 1410
} }
/* 64-bit divisions are expensive, which is why we require a /* 64-bit divisions are expensive, which is why we require a
* power-of-two source->blksize. To relax this restriction is * power-of-two source->blksize. To relax this restriction is
* relatively easy, see the history for xd3_blksize_div(). */ * relatively easy, see the history for xd3_blksize_div(). */
static inline static inline
void xd3_blksize_div (const xoff_t offset, void xd3_blksize_div (const xoff_t offset,
const xd3_source *source, const xd3_source *source,
xoff_t *blkno, xoff_t *blkno,
usize_t *blkoff) { usize_t *blkoff) {
*blkno = (xoff_t) (offset >> source->shiftby); *blkno = offset >> source->shiftby;
*blkoff = (usize_t) (offset & source->maskby); *blkoff = offset & source->maskby;
XD3_ASSERT (*blkoff < source->blksize); XD3_ASSERT (*blkoff < source->blksize);
} }
static inline static inline
void xd3_blksize_add (xoff_t *blkno, void xd3_blksize_add (xoff_t *blkno,
usize_t *blkoff, usize_t *blkoff,
const xd3_source *source, const xd3_source *source,
const usize_t add) const usize_t add)
{ {
usize_t blkdiff; usize_t blkdiff;
 End of changes. 39 change blocks. 
60 lines changed or deleted 124 lines changed or added

Home  |  About  |  All  |  Newest  |  Fossies Dox  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTPS