Retrieve a function from a library, and set the data types.
(libname, funcname, restype=None, argtypes=())
| 11 | ETIMEDOUT = 60 # Operation timed out |
| 12 | |
| 13 | def get_func(libname, funcname, restype=None, argtypes=()): |
| 14 | """Retrieve a function from a library, and set the data types.""" |
| 15 | from ctypes import cdll |
| 16 | |
| 17 | lib = cdll.LoadLibrary(libname) |
| 18 | func = getattr(lib, funcname) |
| 19 | func.argtypes = argtypes |
| 20 | func.restype = restype |
| 21 | |
| 22 | return func |
| 23 | |
| 24 | class SemError(RuntimeError): |
| 25 | """Exception for errors raised by the Sem class.""" |