#!/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 );