From 557bf9c01fd78848167c1db8327aed259c5b3690 Mon Sep 17 00:00:00 2001 From: stderr64 Date: Tue, 28 Oct 2025 18:11:09 +0200 Subject: Added some stuff --- python_cdll_multithread/cdll.py | 49 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100755 python_cdll_multithread/cdll.py (limited to 'python_cdll_multithread/cdll.py') diff --git a/python_cdll_multithread/cdll.py b/python_cdll_multithread/cdll.py new file mode 100755 index 0000000..eb76d35 --- /dev/null +++ b/python_cdll_multithread/cdll.py @@ -0,0 +1,49 @@ +#!/usr/bin/python3 -u +import sys; +import time; +from ctypes import *; + +testlib = CDLL( "./libpcdlltest.so" ); + +print( testlib ); + +testlib.testfunc.restype = c_void_p; +testlib.testfunc2.restype = c_void_p; +testlib.testfunc3.restype = c_char_p; +testlib.cleanup_buffer.restype = c_void_p; + +print( "Executing first test function (simple message from C code)" ); + +testlib.testfunc(); + +print( "Executing test function 2 (pass python value to it)" ); + +pvar = create_string_buffer( bytes("test message", "utf8") ); +testlib.testfunc2( pvar ); +del pvar; + +print( "Executing test function 3 (return value from C code)" ); + +test_value = testlib.testfunc3().decode("utf8"); +print( f"Returned value: {test_value}" ); +del test_value; + +print( "Executing buffer cleanup functiion" ); + +testlib.cleanup_buffer(); + +print( "Starting C thread" ); + +testlib.threadstarter(); + +print( "Printing garbage from python code" ); + +for pcount in range(0, 40): + print( f"Count is now in python {pcount}" ); + time.sleep( 1 ); + +print( "All tests done" ); + +del testlib; + +sys.exit( 0 ); -- cgit v1.2.3-94-g38b9