Skip to content

ZLib and Mojo help needed #1861

Closed Locked Answered by toiletsandpaper
toiletsandpaper asked this question in Q&A
Discussion options

You must be logged in to vote

So, with the help of @jackos in Discord

I've managed to finally wrote it: https://gist.github.com/toiletsandpaper/591dcd934d028440cafea22d5690d19f

from sys import ffi, external_call
from memory import memset_zero, memset

#Z_OK            0
#Z_STREAM_END    1
#Z_NEED_DICT     2
#Z_ERRNO        (-1)
#Z_STREAM_ERROR (-2)
#Z_DATA_ERROR   (-3)
#Z_MEM_ERROR    (-4)
#Z_BUF_ERROR    (-5)
#Z_VERSION_ERROR (-6)

alias Bytef = Scalar[DType.int8]
alias uLong = UInt64
alias zlib_type = fn(
    _out: Pointer[Bytef], 
    _out_len: Pointer[UInt64], 
    _in: Pointer[Bytef], 
    _in_len: uLong
) -> Int
alias ResultType = Tuple[Pointer[Bytef], Pointer[uLong]]

fn log_zlib_result(Z_RES: Int, compressing…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by toiletsandpaper
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant