lib3ddevil1/bindings/py3devil1.py

37 lines
992 B
Python
Raw Normal View History

#!/usr/bin/python3
import ctypes
class PldHeader(ctypes.Structure):
_fields_ = [
("numOffset", ctypes.c_int),
("offsets", ctypes.POINTER(ctypes.c_int))
]
2018-04-22 16:09:08 +05:30
class Devil1PLD_FN(ctypes.Structure):
_fields_ = [
("getheader" , ctypes.CFUNCTYPE(bool, ctypes.POINTER(PldHeader), ctypes.c_char_p)),
("sizeofsector", ctypes.CFUNCTYPE(int, ctypes.POINTER(PldHeader), ctypes.c_int)),
("printheader" , ctypes.CFUNCTYPE(None, ctypes.POINTER(PldHeader)))
]
def main():
sharedlib='./lib3ddevil1.so'
2018-04-22 16:09:08 +05:30
libc = ctypes.cdll.LoadLibrary(sharedlib)
if (not libc):
print("Couldn't load %s" % sharedlib)
return 1
2018-04-22 16:09:08 +05:30
print("OK")
2018-04-22 16:09:08 +05:30
fn = Devil1PLD_FN.in_dll(libc, "DEVIL1PLD")
pldh = PldHeader()
with open("pl01.pld", "rb") as f:
data = f.read()
2018-04-22 16:09:08 +05:30
p = PldHeader()
fn.getheader(ctypes.byref(pldh), data)
fn.printheader(ctypes.byref(pldh))
#---------------------------------------+
main()