From 71f6517a94171f4378389eb2794f3e948a4133bd Mon Sep 17 00:00:00 2001 From: _ <_> Date: Sun, 22 Apr 2018 03:39:08 -0700 Subject: [PATCH] Python can read a pld header --- bindings/py3devil1.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/bindings/py3devil1.py b/bindings/py3devil1.py index 61e75b3..7480719 100755 --- a/bindings/py3devil1.py +++ b/bindings/py3devil1.py @@ -7,7 +7,7 @@ class PldHeader(ctypes.Structure): ("offsets", ctypes.POINTER(ctypes.c_int)) ] -class Devil1FN_PLD(ctypes.Structure): +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)), @@ -16,11 +16,21 @@ class Devil1FN_PLD(ctypes.Structure): def main(): sharedlib='./lib3ddevil1.so' - libc = cdll.LoadLibrary(sharedlib) - if (not lib): + libc = ctypes.cdll.LoadLibrary(sharedlib) + if (not libc): print("Couldn't load %s" % sharedlib) return 1 - + print("OK") + fn = Devil1PLD_FN.in_dll(libc, "DEVIL1PLD") + pldh = PldHeader() with open("pl01.pld", "rb") as f: data = f.read() + p = PldHeader() + fn.getheader(ctypes.byref(pldh), data) + fn.printheader(ctypes.byref(pldh)) + +#---------------------------------------+ + +main() +