Heads up - directory reorganization coming

Hal Murray hmurray at megapathdsl.net
Sat Nov 26 21:24:24 UTC 2016


esr at thyrsus.com said:
>> Do you have sample code that calls libc and returns a big struct?
> No, but I know exactly how to do it.  I'll put this on the to-do list at low
> priority. 

I have code that works using ctypes.  It doesn't give me that warm feeling.

libc   = ctypes.CDLL("libc.so.6")
class timex(ctypes.Structure):
  _fields_ = [ ("modes",     ctypes.c_uint),
               ("offset",    ctypes.c_long),
               ("freq",      ctypes.c_long),
               ("maxerror",  ctypes.c_long),
               ("esterror",  ctypes.c_long),
...

  libc.ntp_adjtime(ctypes.byref(ntp))

On at least one system, I have to change that 6 to a 7.  It probably works 
without the number,

The other problem is that there is no check that the layout of the struct 
matches what is on the system.

Is there a preprocessor that would automate building the struct?



-- 
These are my opinions.  I hate spam.





More information about the devel mailing list