python - define *struct in ctypes -


Do I need to regexitem * regex to convert the ctype variable, in any ideas?

C function expects func (Regexitem * regex)

  four * regex1 group [] = {"one", "b", "x", " S ", NULL}; Char * regex2 group [] = {"l", NULL}; Reggaextim regex [] = {{"bla", regex1 group, 4}, {"bla2", regex2 group, 1}};  

first defined me

  class regexitem (structure): _fields = ("regex", c_char_p), ("group", c_char_p * size) "Grouped", c_int)  

And ran into the first problem, declaring the array of regexitem because the size of the groups is not known in advance.

Streaks can only have variables-length arrays at their end, and at the top of it, If you copy the array variable to something, then you are not copying it, you are specifying the memory location of the first element of the array. That's why I'm betting that the pointer is included in the array of char pointers through char points in your regexitem structure. If this is the case, then it can work:

  class regexItem (structure): _fields_ = [("regex", c_char_p), ("group", POINTER (c_char_p)), ("Groupize",  

(If you wish, you can place assignments to Tuples as Tuples instead of _fields_ .)

  regex1Groups = (c_char_p * 5) ("a", "b", "x", "s", none) regex2groups = (C_char_p * 2) ("l", none)  

and then the regexitem s of your code will be:

  Regex = (regexItem * 2) (("bla", regex1Groups, 4), ( 

P>

Comments