testing a whim
This commit is contained in:
parent
9f07fb8c53
commit
9ac7b27606
2 changed files with 51 additions and 6 deletions
|
|
@ -177,7 +177,9 @@ namespace Server.Network {
|
|||
public static readonly ICompressor Compressor;
|
||||
|
||||
static Compression() {
|
||||
if ( Core.Is64Bit )
|
||||
if ( Core.Unix )
|
||||
Compressor = new CompressorUnix();
|
||||
else if ( Core.Is64Bit )
|
||||
Compressor = new Compressor64();
|
||||
else
|
||||
Compressor = new Compressor32();
|
||||
|
|
@ -277,6 +279,41 @@ namespace Server.Network {
|
|||
}
|
||||
}
|
||||
|
||||
public sealed class CompressorUnix : ICompressor {
|
||||
[DllImport( "libz" )]
|
||||
private static extern string zlibVersion();
|
||||
|
||||
[DllImport( "libz" )]
|
||||
private static extern ZLibError compress( byte[] dest, ref int destLength, byte[] source, int sourceLength );
|
||||
|
||||
[DllImport( "libz" )]
|
||||
private static extern ZLibError compress2( byte[] dest, ref int destLength, byte[] source, int sourceLength, ZLibQuality quality );
|
||||
|
||||
[DllImport( "libz" )]
|
||||
private static extern ZLibError uncompress( byte[] dest, ref int destLen, byte[] source, int sourceLen );
|
||||
|
||||
public CompressorUnix() {
|
||||
}
|
||||
|
||||
public string Version {
|
||||
get {
|
||||
return zlibVersion();
|
||||
}
|
||||
}
|
||||
|
||||
public ZLibError Compress( byte[] dest, ref int destLength, byte[] source, int sourceLength ) {
|
||||
return compress( dest, ref destLength, source, sourceLength );
|
||||
}
|
||||
|
||||
public ZLibError Compress( byte[] dest, ref int destLength, byte[] source, int sourceLength, ZLibQuality quality ) {
|
||||
return compress2( dest, ref destLength, source, sourceLength, quality );
|
||||
}
|
||||
|
||||
public ZLibError Decompress( byte[] dest, ref int destLength, byte[] source, int sourceLength ) {
|
||||
return uncompress( dest, ref destLength, source, sourceLength );
|
||||
}
|
||||
}
|
||||
|
||||
public enum ZLibError : int {
|
||||
VersionError = -6,
|
||||
BufferError = -5,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue