mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-04-28 11:47:48 +02:00
GzipNoCompression witout zlib calls
This commit is contained in:
parent
e301387896
commit
1eead0e885
3 changed files with 25 additions and 7 deletions
|
@ -10,6 +10,7 @@
|
|||
#include <string.h> /* memset */
|
||||
#include <iostream>
|
||||
#include "Log.h"
|
||||
#include "I2PEndian.h"
|
||||
#include "Gzip.h"
|
||||
|
||||
namespace i2p
|
||||
|
@ -111,5 +112,19 @@ namespace data
|
|||
LogPrint (eLogError, "Gzip: Deflate error ", err);
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t GzipNoCompression (const uint8_t * in, uint16_t inLen, uint8_t * out, size_t outLen)
|
||||
{
|
||||
static const uint8_t gzipHeader[11] = { 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x03, 0x01 };
|
||||
if (outLen < (size_t)inLen + 23) return 0;
|
||||
memcpy (out, gzipHeader, 11);
|
||||
htole16buf (out + 11, inLen);
|
||||
htole16buf (out + 13, 0xffff - inLen);
|
||||
memcpy (out + 15, in, inLen);
|
||||
htole32buf (out + inLen + 15, crc32 (0, in, inLen));
|
||||
htole32buf (out + inLen + 19, inLen);
|
||||
return inLen + 23;
|
||||
}
|
||||
|
||||
} // data
|
||||
} // i2p
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue