Thar0 / pygfxd

python3 bindings for libgfxd using ctypes

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`gfxd_input_callback` and `gfxd_output_callback` use `lgfxd.gfxd_macro_fn`

Dragorn421 opened this issue · comments

Randomly noticed this while investigating gfx disassembly options

They should use gfxd_input_callback, gfxd_output_callback instead, most likely

pygfxd/pygfxd.py

Lines 379 to 404 in 605e30e

lgfxd.gfxd_input_callback.argtypes = [CFUNCTYPE(c_int, c_void_p, c_int)]
lgfxd.gfxd_input_callback.restype = None
def gfxd_input_callback(fn: Callable[[bytes, int], int]) -> None:
"""
Use the provided callback function, fn, compatible with the C function type
int gfxd_input_fn_t(void *buf, int count)
fn should copy at most count bytes to/from buf, and return the number of bytes actually copied.
The input callback should return 0 to signal end of input.
"""
cb = CFUNCTYPE(c_int, c_void_p, c_int)(fn)
__gfxd_buffers_callbacks.update({102 : cb})
lgfxd.gfxd_macro_fn(cb)
lgfxd.gfxd_output_callback.argtypes = [CFUNCTYPE(c_int, c_char_p, c_int)]
lgfxd.gfxd_output_callback.restype = None
def gfxd_output_callback(fn: Callable[[bytes, int], int]) -> None:
"""
Use the provided callback function, fn, compatible with C function type
int gfxd_output_fn_t(const char *buf, int count)
fn should copy at most count bytes to/from buf, and return the number of bytes actually copied.
"""
cb = CFUNCTYPE(c_int, c_char_p, c_int)(fn)
__gfxd_buffers_callbacks.update({103 : cb})
lgfxd.gfxd_macro_fn(cb)