File: freeze.h

package info (click to toggle)
netboot 0.8.1-9
  • links: PTS
  • area: main
  • in suites: woody
  • size: 2,636 kB
  • ctags: 4,744
  • sloc: ansic: 15,152; asm: 11,623; yacc: 2,248; makefile: 1,117; pascal: 1,108; lex: 748; sh: 233
file content (119 lines) | stat: -rw-r--r-- 2,930 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/*
 * freeze.h  -  include file for compression routines
 *
 * Copyright (C) 1997,1998 Gero Kuhlmann <gero@gkminix.han.de>
 *
 *  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
 *  any later version.
 *
 *  This program 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 this program; if not, write to the Free Software
 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 **************************************************************************
 *
 * Parts of this file have been taken from source code published by
 * leo@s514.ipmce.su without any copyright information.
 */


/*
 * Definitions used for setting the Huffmann tables
 */
typedef unsigned long hash_t;				/* hash table type */

#define BUFSIZE		8192				/* buffer size */
#define PRESENSE	256				/* pre-sense buffer size */
#define ENDOF		256
#define THRESHOLD	2

#define _NIL		BUFSIZE
#define _NCHAR		(ENDOF - THRESHOLD + PRESENSE + 1)	/* code : 0 .. _NCHAR-1 */
#define TABSIZE		(_NCHAR * 2 - 1)		/* size of table */
#define ROOTPOS		(TABSIZE - 1)			/* root position */



/*
 * Definitions used for setting the LZSS tables
 */
#ifndef BITS
#define BITS    18
#endif

#if BITS < 15
#undef BITS
#define BITS	15
#endif

#if BITS > 18
#undef BITS
#define BITS	18
#endif

#define LEN0    (BITS/3 + (BITS%3 != 0))
#define LEN1    (BITS/3 + (BITS%3 == 2))
#define LEN2    (BITS/3)

#define MASK0   ((1 << LEN0) - 1)
#define MASK1   ((1 << LEN1) - 1)
#define MASK2   ((1 << LEN2) - 1)

#define array_size      (BUFSIZE + 1 + (1 << BITS))

#ifndef __XENIX__
# define nextof(i)       next[i]
#else
# define parts (array_size/32768 + 1)
# define nextof(i)       next[(i) >> 15][(i) & 0x7fff]
#endif



/*
 * To eliminate function-call overhead
 */
#define DeleteNode(n) \
{\
       nextof(prev[(n)]) = _NIL;\
       prev[(n)] = _NIL;\
}


#define InsertNode(r)\
{\
	register hash_t p; register unsigned short first_son;\
	register unsigned char  *key;\
	key = &text_buf[(r)];\
	p = BUFSIZE + 1 + ((key[0] & MASK0) |\
		     ((key[1] & MASK1) << LEN0) |\
		     ((key[2] & MASK2) << (LEN0 + LEN1)));\
	first_son = nextof(p);\
	nextof((r)) = first_son;\
	nextof(p) = (r);\
	prev[(r)] = p;\
	prev[first_son] = (r);\
}


#define Next_Char()\
if ((c = charin()) != EOF) {\
	text_buf[s] = c;\
	if (s < PRESENSE - 1)\
		text_buf[s + BUFSIZE] = c;\
	s = (s + 1) & (BUFSIZE - 1);\
	r = (r + 1) & (BUFSIZE - 1);\
	InsertNode(r);\
} else {\
	s = (s + 1) & (BUFSIZE - 1);\
	r = (r + 1) & (BUFSIZE - 1);\
	if (--len) InsertNode(r);\
}