[Pyrex] passing method's args to extern func
Bartosz SKOWRON
getxsick at gmail.com
Wed Jun 10 22:02:16 CEST 2009
On Wed, Jun 10, 2009 at 7:19 AM, Stefan Behnel<stefan_ml at behnel.de> wrote:
>> /home/xsx/__usrsrc__/pypcap/pcap.pyx:235:18: Cannot convert Python
>> object to 'pcap_pkthdr *'
> Maybe you could add some info about what kind of type 'pcap_pkthdr' is?
> Most likely, you will have to convert the data manually in some way.
Propably - yes. This is a struct:
struct pcap_pkthdr {
struct timeval ts; /* time stamp */
bpf_u_int32 caplen; /* length of portion present */
bpf_u_int32 len; /* length this packet (off wire) */
};
I tried to define it as ctypedef, but..hmm maybe i should cast something later?
> You can cast the object to <char*> first to let Pyrex do the conversion,
> and then re-cast that to <unsigned char*> to make the C compiler happy, i.e.
>
> cdef unsigned char* c_val
> c_val = <unsigned char*><char*>some_python_byte_string
>
> Note that this will not work with unicode strings, just plain byte strings.
There will be not a problem with unicode. It should works as you shown. Thanks!
More information about the Pyrex
mailing list