On Mon, June 23, 2008 4:31 pm, Stephen Warren wrote:
> On Mon, June 23, 2008 3:11 pm, Andreas Schulz wrote:
>> Well, concordance could do that as well, so what about:
>>   char **get_keynames(uint8_t *data, uint32_t size);
>>   void destroy_keynames(char **names);
>> and be done with the XML data in one call?
>
> That'd work too. I'll have to check whether it's easy to deal with
> "char**" in the Python bindings; it should be...

Yes, it's trivial:

from ctypes import *
import platform
import sys

_dll = cdll.LoadLibrary('ctest.so.1')

def _create_func(
    func_name,
    error_checker,
    *args
):
    ftype = CFUNCTYPE(*args)
    f = ftype((func_name, _dll))
    if error_checker:
        f.errcheck = error_checker(func_name)
    return f

get_array = _create_func(
    "get_array",
    None,
    POINTER(c_char_p)
)

get_array_2 = _create_func(
    "get_array_2",
    None,
    c_int,
    POINTER(POINTER(c_char_p))
)

a1 = get_array()
print a1
print a1[0], a1[1], a1[2], a1[3]

a2 = POINTER(c_char_p)()
i2 = get_array_2(byref(a2))
print i2, a2
print a2[0], a2[1], a2[2], a2[3]


-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
concordance-devel mailing list
concordance-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/concordance-devel

Reply via email to