My C function is:
int cluster_info(char *remote_ip, struct NodeStatInfo ***info, int *node_count)
{
/* dynamically creates an array of pointers to struct NodeStatInfo. */
...
(*info) = (struct NodeStatInfo**)malloc( sizeof(struct NodeStatInfo*) * count );
for(i=0; i< count; i++)
(*info)[i] = (struct NodeStatInfo*)malloc( sizeof(struct NodeStatInfo) );
...
*node_count = count;
...
}
I have tried in the following manner:
class NodeStatInfo(Structure):
_fields_ = [('status', c_char*10),
('name', c_char*64) ]
NodeStatInfoPtrType = ctypes.POINTER(NodeStatInfo)
PtrToNodeStatInfoPtrType = ctypes.POINTER(NodeStatInfoPtrType)
node_info = PtrToNodeStatInfoPtrType()
sn_count = c_int(0)
lib.cluster_info( SOME_IP, pointer(node_info) , byref( sn_count ) )
print node_info[0][0].status
The last statement did not print complete value passed from C function.