dernc.c File Reference


Detailed Description

RNC decompression support.

Purpose:
Compiled normally, this file is a well-behaved, re-entrant code module exporting only `rnc_ulen', `rnc_unpack' and `rnc_error'. Compiled with MAIN_DERNC defined, it's a standalone program which will decompress argv[1] into argv[2].
Comment:
in/out buffers should have 8 redundant "safe bytes" at end.
Author:
Jon Skeet
Date:
14 Oct 1997 - 22 Jul 2008
Copying and copyrights:
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

Definition in file dernc.c.

#include "lbfileio.h"
#include "dernc.h"
#include "globals.h"

Go to the source code of this file.

Defines

#define INTERNAL
#define HUFTABLE_ENTRIES   32

Functions

void bitread_init (bit_stream *bs, const unsigned char **p, const unsigned char *pend)
 Initialises a bit stream with the first two bytes of the packed data.
void bitread_fix (bit_stream *bs, const unsigned char **p, const unsigned char *pend)
 Fixes up a bit stream after literals have been read out of the data stream.
unsigned long bit_peek (bit_stream *bs, const unsigned long mask)
 Returns some bits, masked with given bit mask.
void bit_advance (bit_stream *bs, int n, const unsigned char **p, const unsigned char *pend)
 Advances the bit stream.
char * rnc_error (long errcode)
 Returns an error string corresponding to an error code.
long rnc_ulen (void *packed)
 Return the uncompressed length of a packed data block.
long rnc_plen (void *packed)
 Return the compressed length of a packed data block.
long rnc_nocallback (long done, long total)
 Empty callback - for use if no callback is needed.
long rnc_printcallback (long done, long total)
 Console print callback - for use in console tools.
long rnc_unpack (const void *packed, void *unpacked, const unsigned int flags)
 Decompress a packed data block.
long rnc_crc (const void *data, unsigned long len)
 Calculate a CRC, the RNC way.


Define Documentation

#define HUFTABLE_ENTRIES   32

Definition at line 236 of file dernc.c.

#define INTERNAL

Definition at line 27 of file dernc.c.


Function Documentation

void bit_advance ( bit_stream *  bs,
int  n,
const unsigned char **  p,
const unsigned char *  pend 
) [inline]

Advances the bit stream.

Reads n bits from the bit_stream, then makes sure there are still at least 16 bits to read in next operation. The new bits are taken from buffer *p. Checks pend for proper buffer pointers range. The pend should point to the last readable byte in buffer.

Definition at line 653 of file dernc.c.

Referenced by rnc_unpack().

unsigned long bit_peek ( bit_stream *  bs,
unsigned long  mask 
) [inline]

Returns some bits, masked with given bit mask.

Definition at line 641 of file dernc.c.

void bitread_fix ( bit_stream *  bs,
const unsigned char **  p,
const unsigned char *  pend 
) [inline]

Fixes up a bit stream after literals have been read out of the data stream.

Checks pend for proper buffer pointers range. The pend should point to the last readable byte in buffer.

Definition at line 619 of file dernc.c.

Referenced by rnc_unpack().

void bitread_init ( bit_stream *  bs,
const unsigned char **  p,
const unsigned char *  pend 
) [inline]

Initialises a bit stream with the first two bytes of the packed data.

Checks pend for proper buffer pointers range. The pend should point to the last readable byte in buffer. If buffer is exceeded, fills output (or part of output) with zeros.

Definition at line 598 of file dernc.c.

Referenced by rnc_unpack().

long rnc_crc ( const void *  data,
unsigned long  len 
)

Calculate a CRC, the RNC way.

Parameters:
data The data buffer.
len data Length of the data buffer.
Returns:
The CRC value for given data.

Definition at line 715 of file dernc.c.

Referenced by rnc_unpack().

char* rnc_error ( long  errcode  ) 

Returns an error string corresponding to an error code.

Parameters:
errcode Error code returned by a function.
Returns:
Error message string.

Definition at line 272 of file dernc.c.

Referenced by memfile_error().

long rnc_nocallback ( long  done,
long  total 
)

Empty callback - for use if no callback is needed.

Definition at line 327 of file dernc.c.

long rnc_plen ( void *  packed  ) 

Return the compressed length of a packed data block.

The packed buffer must be longer than SIZEOF_RNC_HEADER.

Parameters:
packed Packed buffer.
Returns:
Returns compressed length of the packed block, or a negative error code.

Definition at line 316 of file dernc.c.

Referenced by memfile_read().

long rnc_printcallback ( long  done,
long  total 
)

Console print callback - for use in console tools.

Definition at line 333 of file dernc.c.

long rnc_ulen ( void *  packed  ) 

Return the uncompressed length of a packed data block.

The packed buffer must be longer than SIZEOF_RNC_HEADER.

Parameters:
packed Packed buffer.
Returns:
Uncompressed length of the packed block, or a negative error code.

Definition at line 301 of file dernc.c.

Referenced by memfile_read().

long rnc_unpack ( const void *  packed,
void *  unpacked,
const unsigned int  flags 
)

Decompress a packed data block.

Parameters:
packed Packed source data buffer.
unpacked Unpacked destination data buffer.
flags Option flags for the decompressor.
Returns:
Returns the unpacked length if successful, or negative error code if not. If COMPRESSOR is defined, it also returns the leeway number (which gets stored at offset 16 into the compressed-file header) in `*leeway', if `leeway' isn't NULL.

Definition at line 351 of file dernc.c.

Referenced by memfile_read().


Generated on Tue Sep 2 18:51:48 2008 for libAdikted by  doxygen 1.5.6