swig+structures -> python

Discussion in 'Python' started by mwallace1, Jun 25, 2003.

  1. mwallace1

    mwallace1 Guest

    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=applications;ou=general_data;o=zus,c=pl",
    SEARCH_SCOPE_SUBTREE,
    "cn=KW_*",attrs,entries)
    where :
    attrs = ["cn","command"]
    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.
     
    mwallace1, Jun 25, 2003
    #1
    1. Advertising

  2. "mwallace1" <> schrieb im Newsbeitrag
    news:bdbpm6$91m$...
    > 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=applications;ou=general_data;o=zus,c=pl",
    > SEARCH_SCOPE_SUBTREE,
    > "cn=KW_*",attrs,entries)
    > where :
    > attrs = ["cn","command"]
    > 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.


    You might want to taka a look at
    CObjects
    http://www.python.org/doc/current/api/cObjects.html

    especially PyCObject_FromVoidPointer and
    PyCObject_AsVoidPointer


    Regards,
    Vincent Wehren


    > 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, Jun 25, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. tweak
    Replies:
    14
    Views:
    2,788
    Eric Sosman
    Jun 11, 2004
  2. Jeff
    Replies:
    0
    Views:
    732
  3. RocketIII

    SWIG, Python and C structures

    RocketIII, Jul 28, 2006, in forum: Python
    Replies:
    0
    Views:
    526
    RocketIII
    Jul 28, 2006
  4. Alfonso Morra
    Replies:
    11
    Views:
    721
    Emmanuel Delahaye
    Sep 24, 2005
  5. Keith Sabine
    Replies:
    0
    Views:
    580
    Keith Sabine
    Jun 6, 2008
Loading...

Share This Page