I am trying to implement this C structures in python using ctypes:
struct _rows {
int cols_count;
char *cols[];
}
struct _unit {
int rows_count;
struct _rows *rows;
}
int my_func(struct _unit *param);
Problem is that _rows.cols is a dynamically sized array of char pointer and _unit.rows is a dynamically sized array of _rows structure. How can I implement this using ctypes in python?
I was able to define a function that will return a _rows structure with variable number of char pointers:
def get_row(cols):
class Row(ctypes.Structure):
_fields_ = [("cols_count", ctypes.c_int),
("cols", ctypes.c_char_p * cols)
]
I don't know what to do nex, it's all a bit fuzzy and ctypes documentation isn't helping.