libffi is perfectly happy passing structures back and forth.
You must first describe the structure to libffi by creating a
new ffi_type object for it.
The ffi_type has the following members:
size_t sizeThis is set by libffi; you should initialize it to zero.
unsigned short alignmentThis is set by libffi; you should initialize it to zero.
unsigned short typeFor a structure, this should be set to FFI_TYPE_STRUCT.
ffi_type **elementsThis is a ‘NULL’-terminated array of pointers to ffi_type
objects. There is one element per field of the struct.
Note that libffi has no special support for bit-fields. You
must manage these manually.
The size and alignment fields will be filled in by
ffi_prep_cif or ffi_prep_cif_var, as needed.