Export more constants, so they can be used in NBC

This commit is contained in:
Zahary Karadjov 2020-05-08 22:24:16 +03:00
parent 5e9e2a1f65
commit 20cc8ce1c2
No known key found for this signature in database
GPG Key ID: C8936F8A3073D609
1 changed files with 8 additions and 8 deletions

View File

@ -9,11 +9,11 @@ import
# we can't use nimPNG CRC32 # we can't use nimPNG CRC32
proc masked_crc32c(buf: ptr byte, len: uint): cuint {.cdecl, importc.} proc masked_crc32c(buf: ptr byte, len: uint): cuint {.cdecl, importc.}
func checkCrc(data: openArray[byte], expected: uint32): bool = func checkCrc*(data: openArray[byte], expected: uint32): bool =
let actual = masked_crc32c(data[0].unsafeAddr, data.len.uint) let actual = masked_crc32c(data[0].unsafeAddr, data.len.uint)
result = actual == expected result = actual == expected
proc checkCrcAndAppend(output: OutputStream, data: openArray[byte], crc: uint32): bool = proc checkCrcAndAppend*(output: OutputStream, data: openArray[byte], crc: uint32): bool =
if checkCrc(data, crc): if checkCrc(data, crc):
output.write(data) output.write(data)
return true return true
@ -22,15 +22,15 @@ const
# maximum chunk data length # maximum chunk data length
# MAX_DATA_LEN = 16777215 # MAX_DATA_LEN = 16777215
# maximum uncompressed data length excluding checksum # maximum uncompressed data length excluding checksum
MAX_UNCOMPRESSED_DATA_LEN = 65536 MAX_UNCOMPRESSED_DATA_LEN* = 65536
# maximum uncompressed data length excluding checksum # maximum uncompressed data length excluding checksum
MAX_COMPRESSED_DATA_LEN = maxEncodedLen(MAX_UNCOMPRESSED_DATA_LEN) MAX_COMPRESSED_DATA_LEN* = maxEncodedLen(MAX_UNCOMPRESSED_DATA_LEN)
COMPRESSED_DATA_IDENTIFIER = 0x00 COMPRESSED_DATA_IDENTIFIER* = 0x00
UNCOMPRESSED_DATA_IDENTIFIER = 0x01 UNCOMPRESSED_DATA_IDENTIFIER* = 0x01
STREAM_IDENTIFIER = 0xff STREAM_IDENTIFIER* = 0xff
STREAM_HEADER = "\xff\x06\x00\x00sNaPpY" STREAM_HEADER* = "\xff\x06\x00\x00sNaPpY"
proc uncompressFramedStream*(input: InputStream, output: OutputStream) {.fsMultiSync.} = proc uncompressFramedStream*(input: InputStream, output: OutputStream) {.fsMultiSync.} =
try: try: