/* nrv2e -- implementation of the NRV2E-99 compression algorithm
This file was part of the UCL data compression library.
Copyright (C) 1996-2002 Markus Franz Xaver Johannes Oberhumer
All Rights Reserved.
The UCL library 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.
The UCL library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with the UCL library; see the file COPYING.
If not, write to the Free Software Foundation, Inc.,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Markus F.X.J. Oberhumer
<markus@oberhumer.com>
http://www.oberhumer.com/opensource/ucl/
*/
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/types.h>
#include <linux/elf.h>
#include <string.h>
#include <sys/mman.h>
#include <limits.h>
//#include <assert.h>
#define assert(x)
#define ucl_memcpy memcpy
#define ucl_malloc malloc
#define ucl_alloc(x,y) malloc(x*y)
#define ucl_free free
#define ucl_memcmp memcmp
#define ucl_memset memset
#define ucl_sizeof(x) (sizeof(x))
#define UCL_PUBLIC(x) x
#define NRV2E
//#define __UCL_CHECKER
#define UCL_BYTE(x) ((unsigned char) (x))
#define UCL_USHORT(x) ((unsigned short) ((x) & 0xffff))
#define UCL_MAX(a,b) ((a) >= (b) ? (a) : (b))
#define UCL_MIN(a,b) ((a) <= (b) ? (a) : (b))
#define UCL_MAX3(a,b,c) ((a) >= (b) ? UCL_MAX(a,c) : UCL_MAX(b,c))
#define UCL_MIN3(a,b,c) ((a) <= (b) ? UCL_MIN(a,c) : UCL_MIN(b,c))
#define UCL_E_OK 0
#define UCL_E_ERROR (-1)
#define UCL_E_INVALID_ARGUMENT (-2)
#define UCL_E_OUT_OF_MEMORY (-3)
/* compression errors */
#define UCL_E_NOT_COMPRESSIBLE (-101)
/* decompression errors */
#define UCL_E_INPUT_OVERRUN (-201)
#define UCL_E_OUTPUT_OVERRUN (-202)
#define UCL_E_LOOKBEHIND_OVERRUN (-203)
#define UCL_E_EOF_NOT_FOUND (-204)
#define UCL_E_INPUT_NOT_CONSUMED (-205)
#define UCL_E_OVERLAP_OVERRUN (-206)
typedef unsigned int ucl_uint32;
typedef int ucl_int32;
#define UCL_UINT32_MAX 0xffffffffUL
#define UCL_INT32_MAX INT_MAX
#define UCL_INT32_MIN INT_MIN
typedef unsigned int ucl_uint;
typedef int ucl_int;
#define UCL_UINT_MAX UINT_MAX
#define UCL_INT_MAX INT_MAX
#define UCL_INT_MIN INT_MIN
#define UCL_UINT32_C(c) c ## UL
#define UCL_UNUSED(x) x = x
struct ucl_compress_config_t {
int bb_endian;
int bb_size;
ucl_uint max_offset;
ucl_uint max_match;
int s_level;
int h_level;
int p_level;
int c_flags;
ucl_uint m_size;
};
#define ucl_compress_config_p ucl_compress_config_t *
#define ucl_byte unsigned char
#define ucl_bytep unsigned char *
#define ucl_charp char *
#define ucl_voidp void *
#define ucl_shortp short *
#define ucl_ushortp unsigned short *
#define ucl_uint32p ucl_uint32 *
#define ucl_int32p ucl_int32 *
#define ucl_uintp ucl_uint *
#define ucl_intp ucl_int *
#define ucl_voidpp ucl_voidp *
#define ucl_bytepp ucl_bytep *
#define ucl_bool int
/* a progress indicator callback function */
typedef struct {
void (*callback) (ucl_uint, ucl_uint, int, ucl_voidp user);
ucl_voidp user;
} ucl_progress_callback_t;
#define ucl_progress_callback_p ucl_progress_callback_t *
#define N (1024*1024ul) /* size of ring buffer */
//#define SWD_USE_MALLOC
#define SWD_HSIZE 65536ul
#if 1
#define THRESHOLD 1 /* lower limit for match length */
#define F 16384 /* upper limit for match length */
#else
#define THRESHOLD 1 /* lower limit for match length */
#define F 2048 /* upper limit for match length */
#endif
#define UCL_COMPRESS_T ucl_nrv2e_t
#define ucl_swd_t ucl_nrv2e_swd_t
#define ucl_nrv_99_compress ucl_nrv2e_99_compress
#define M2_MAX_OFFSET 0x500
#define ucl_swd_p ucl_swd_t *
typedef struct {
int init;
ucl_uint look; /* bytes in lookahead buffer */
ucl_uint m_len;
ucl_uint m_off;
ucl_uint last_m_len;
ucl_uint last_m_off;
const ucl_byte *bp;
const ucl_byte *ip;
const ucl_byte *in;
const ucl_byte *in_end;
ucl_byte *out;
ucl_uint32 bb_b;
unsigned bb_k;
unsigned bb_c_endian;
unsigned bb_c_s;
unsigned bb_c_s8;
ucl_byte *bb_p;
ucl_byte *bb_op;
struct ucl_compress_config_t conf;
ucl_uintp result;
ucl_progress_callback_p cb;
ucl_uint textsize; /* text size counter */
ucl_uint codesize; /* code size counter */
ucl_uint printcount; /* counter for reporting progress every 1K bytes */
/* some stats */
unsigned long lit_bytes;
unsigned long match_bytes;
unsigned long rep_bytes;
unsigned long lazy;
} UCL_COMPRESS_T;
#define getbyte(c) ((c).ip < (c).in_end ? *((c).ip)++ : (-1))
#ifndef SWD_N
# define SWD_N N
#endif
#ifndef SWD_F
# define SWD_F F
#endif
#ifndef SWD_THRESHOLD
# define SWD_THRESHOLD THRESHOLD
#endif
/* unsigned type for dictionary access - don't waste memory here */
#if (SWD_N + SWD_F + SWD_F < USHRT_MAX)
typedef unsigned short swd_uint;
# define SWD_UINT_MAX USHRT_MAX
#else
typedef ucl_uint swd_uint;
# define SWD_UINT_MAX UCL_UINT_MAX
#endif
#define SWD_UINT(x) ((swd_uint)(x))
#ifndef SWD_HSIZE
# define SWD_HSIZE 16384
#endif
#ifndef SWD_MAX_CHAIN
# define SWD_MAX_CHAIN 2048
#endif
#if !defined(HEAD3)
#if 1
# define HEAD3(b,p) \
(((0x9f5f*(((((ucl_uint32)b[p]<<5)^b[p+1])<<5)^b[p+2]))>>5) & (SWD_HSIZE-1))
#else
# define HEAD3(b,p) \
(((0x9f5f*(((((ucl_uint32)b[p+2]<<5)^b[p+1])<<5)^b[p]))>>5) & (SWD_HSIZE-1))
#endif
#endif
#if (SWD_THRESHOLD == 1) && !defined(HEAD2)
# if 1 && defined(UCL_UNALIGNED_OK_2)
# define HEAD2(b,p) (* (const ucl_ushortp) &(b[p]))
# else
# define HEAD2(b,p) (b[p] ^ ((unsigned)b[p+1]<<8))
# endif
# define NIL2 SWD_UINT_MAX
#endif
#if defined(__UCL_CHECKER)
/* malloc arrays of the exact size to detect any overrun */
# ifndef SWD_USE_MALLOC
# define SWD_USE_MALLOC
# endif
#endif
typedef struct {
/* public - "built-in" */
ucl_uint n;
ucl_uint f;
ucl_uint threshold;
/* public - configuration */
ucl_uint max_chain;
ucl_uint nice_length;
ucl_bool use_best_off;
ucl_uint lazy_insert;
/* public - output */
ucl_uint m_len;
ucl_uint m_off;
ucl_uint look;
int b_char;
#if defined(SWD_BEST_OFF)
ucl_uint best_off[SWD_BEST_OFF];
#endif
/* semi public */
UCL_COMPRESS_T *c;
ucl_uint m_pos;
#if defined(SWD_BEST_OFF)
ucl_uint best_pos[SWD_BEST_OFF];
#endif
/* private */
const ucl_byte *dict;
const ucl_byte *dict_end;
ucl_uint dict_len;
/* private */
ucl_uint ip; /* input pointer (lookahead) */
ucl_uint bp; /* buffer pointer */
ucl_uint rp; /* remove pointer */
ucl_uint b_size;
unsigned char *b_wrap;
ucl_uint node_count;
ucl_uint first_rp;
#if defined(SWD_USE_MALLOC)
unsigned char *b;
swd_uint *head3;
swd_uint *succ3;
swd_uint *best3;
swd_uint *llen3;
#ifdef HEAD2
swd_uint *head2;
#endif
#else
unsigned char b[SWD_N + SWD_F + SWD_F];
swd_uint head3[SWD_HSIZE];
swd_uint succ3[SWD_N + SWD_F];
swd_uint best3[SWD_N + SWD_F];
swd_uint llen3[SWD_HSIZE];
#ifdef HEAD2
swd_uint head2[UCL_UINT32_C(65536)];
#endif
#endif
} ucl_swd_t;
/* Access macro for head3.
* head3[key] may be uninitialized if the list is emtpy,
* but then its value will never be used.
*/
#if defined(__UCL_CHECKER)
# define s_head3(s,key) \
((s->llen3[key] == 0) ?
没有合适的资源?快使用搜索试试~ 我知道了~
SK2priv for 2.6 kernel
需积分: 0 37 下载量 181 浏览量
2007-11-21
20:33:56
上传
评论
收藏 455KB GZ 举报
温馨提示
共2000个文件
h:21774个
c:343个
a:322个
classic ootkit
资源详情
资源评论
资源推荐
收起资源包目录
SK2priv for 2.6 kernel (2000个子文件)
nrv2e.c 33KB
_kernel.c 32KB
_suckitd.c 9KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
diet.c 8KB
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
petsatan
- 粉丝: 31
- 资源: 3
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0