-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathzUtil.cs
More file actions
76 lines (69 loc) · 2.36 KB
/
zUtil.cs
File metadata and controls
76 lines (69 loc) · 2.36 KB
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
namespace DeflateLib
{
internal class zUtil
{
/// <summary>
/// Default memLevel
/// </summary>
internal const int DEF_MEM_LEVEL = 8;
/// <summary>
/// The minimum match lengths
/// </summary>
internal const int MIN_MATCH = 3;
/// <summary>
/// The maximum match lengths
/// </summary>
internal const int MAX_MATCH = 258;
/// <summary>
/// Sets the OS code, defaults to windows
/// </summary>
internal static readonly byte OS_CODE = 10;
/// <summary>
/// Type of blocks
/// </summary>
internal const int STORED_BLOCK = 0;
internal const int STATIC_TREES = 1;
internal const int DYN_TREES = 2;
internal static readonly string[] errmsg = new string[]
{
"need dictionary", /* Z_NEED_DICT 2 */
"stream end", /* Z_STREAM_END 1 */
"", /* Z_OK 0 */
"file error", /* Z_ERRNO (-1) */
"stream error", /* Z_STREAM_ERROR (-2) */
"data error", /* Z_DATA_ERROR (-3) */
"insufficient memory", /* Z_MEM_ERROR (-4) */
"buffer error", /* Z_BUF_ERROR (-5) */
"incompatible version",/* Z_VERSION_ERROR (-6) */
""
};
//static zUtil()
//{
// try
// {
// /* Inject code to determine the OS we're running on */
// // Windows = 10
// // Apple = 19
// // Unix = 3
// // Dos = 0
// }
// catch { }
//}
/* Reverse the bytes in a 32-bit value */
internal static int ZSWAP32(int q)
{
return ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) +
(((q) & 0xff00) << 8) + (((q) & 0xff) << 24));
}
internal static uint ZSWAP32(uint q)
{
return ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) +
(((q) & 0xff00) << 8) + (((q) & 0xff) << 24));
}
internal static long ZSWAP32(long q)
{
return ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) +
(((q) & 0xff00) << 8) + (((q) & 0xff) << 24));
}
}
}