I would like to know hot to pass address reference to ‘c’ function through python. I am using swig for ‘c’ anf python interfacing


Interface file is:


%module stud

%include "cpointer.i"

%include "cmalloc.i"

%include "cstring.i"

%include "carrays.i"

%include "cdata.i"



#include "stud.h"



%include "stud.h"



%pointer_functions(int, intp);



%array_functions(char *,charp );


%inline %{

extern int sum2(int *,int, int *,char *param);

extern int sum1(stud2 s);

extern int parse_n_encode(const long gtpp_dict, int use_binary_addr_format,

                 int lrsn, const char *gcdr_node_id_str, int show_gcdr,

                 const long gcdr_len, char *ptr, char **s,

                 int custom7_fileformat_flag);



%inline %{

  int print_args(char **argv) {

    int i = 0;

    for(i=0;i<=180;i++) {

      printf("argv[%d] = %c\n", i,*(argv[i]));



    return i;







From python I am using following



>>> f=open(fname,'r')

>>> f.read(28)


>>> tmp=f.read(172)

>>> tmp





>>> import stud

>>> from stud import *

>>> cp=malloc_charp()

>>> stud.parse_n_encode(1,1,65464,'rajasgtfer',1,172,tmp,cp,0)


>>> c

<Swig Object of type 'char **' at 0x286468>







Now I want read  value of  cp in python… How do I do it.

Any type of help is appreciated.






This email and any attachments may contain legally privileged and/or confidential information of Starent Networks, Corp. and is intended only for the individual or entity named in the message. The information transmitted may not be used to create or change any contractual obligations of Starent Networks, Corp. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon this e-mail and its attachments by persons or entities other than the intended recipient is prohibited. If you are not the intended recipient, please notify the sender immediately -- by replying to this message or by sending an email to postmaster@starentnetworks.com -- and destroy all copies of this message and any attachments without reading or disclosing their contents. Thank you.