swig+structures -> python

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • mwallace1

    swig+structures -> python

    Hi,

    Please help me to solve this problem.
    I have such function written in C:

    search(
    const char *base,
    int scope,
    const char *filter,
    char **attrs,
    LDAP_Entries **entries);

    where LDAP_Entries is a structure.

    When I call this function from Python, :
    search("ou=appl ications;ou=gen eral_data;o=zus ,c=pl",
    SEARCH_SCOPE_SU BTREE,
    "cn=KW_*",attrs ,entries)
    where :
    attrs = ["cn","comma nd"]
    entries = []
    it says:
    TypeError: Type error. Expected _p_p_char

    This function return data in entries parameter.
    I dont want to have access to data in entries,but only an object (handler to
    it), so I can put returned value in entris into other function,also called
    from Python.
    Do i have to make a typdef functions , so wrapper understands what I want to
    have back ?

    thanx for all your help,


    mwallace.



  • vincent wehren

    #2
    Re: swig+structures -> python

    "mwallace1" <mwallace1@wp.p l> schrieb im Newsbeitrag
    news:bdbpm6$91m $1@news.mch.sbs .de...[color=blue]
    > Hi,
    >
    > Please help me to solve this problem.
    > I have such function written in C:
    >
    > search(
    > const char *base,
    > int scope,
    > const char *filter,
    > char **attrs,
    > LDAP_Entries **entries);
    >
    > where LDAP_Entries is a structure.
    >
    > When I call this function from Python, :
    > search("ou=appl ications;ou=gen eral_data;o=zus ,c=pl",
    > SEARCH_SCOPE_SU BTREE,
    > "cn=KW_*",attrs ,entries)
    > where :
    > attrs = ["cn","comma nd"]
    > entries = []
    > it says:
    > TypeError: Type error. Expected _p_p_char
    >
    > This function return data in entries parameter.
    > I dont want to have access to data in entries,but only an object (handler[/color]
    to[color=blue]
    > it), so I can put returned value in entris into other function,also called
    > from Python.[/color]

    You might want to taka a look at
    CObjects


    especially PyCObject_FromV oidPointer and
    PyCObject_AsVoi dPointer


    Regards,
    Vincent Wehren

    [color=blue]
    > Do i have to make a typdef functions , so wrapper understands what I want[/color]
    to[color=blue]
    > have back ?
    >
    > thanx for all your help,
    >
    >
    > mwallace.
    >
    >
    >[/color]


    Comment

    Working...