|
View:
New views
2 Messages
—
Rating Filter:
Alert me
|
|
|
Passng double pointer to 'c' functionHello, 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" %header%{ #include "stud.h" %} %include "stud.h" %pointer_functions(int, intp); %malloc(int); %free(int); %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])); i++; } return i; } %} From python I am using following >>> f=open(fname,'r') >>> f.read(28) "\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00'\xd8\x00\x00\x00\x00\x00\x1bd\x98\x00\x00\x00\x07\x00\x00\ >>> tmp=f.read(172) >>> tmp '\xb5\x81\xa9\x80\x01\x13\x83\x08B\x00!C\x00\x00\x00\xf0\xa4\r\x82\x0b192.168.1.1\x85\x04\x16\xd1@~\ 87\x04apn1\x88\x02\xf1!\xa9\x0c\xa0\n\x82\x0811.0.0.1\x8b\x01\xff\xac806\xa1\x0e\x81\x0c\x00"r\r\x93 e\x81\x0c\x00"r\r\x93\x96xxv\x00\x00\x00\x83\x03\x0f\xa0\x00\x84\x01\x00\x85\x01\x02\x86\t\x08\x07\x 8\x07\x01\x16\x19\x17+\x050\x8e\x01\x0f\x8f\x01\x10\x91\x01\x01\x95\x01\x01\x96\x06\x91\x89gE#\x01\x >>> import stud >>> from stud import * >>> cp=malloc_charp() >>>
stud.parse_n_encode(1,1,65464,'rajasgtfer',1,172,tmp,cp,0) 171 >>> 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. Thanks, Rajashree. 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@... -- and destroy all copies of this message and any attachments without reading or disclosing their contents. Thank you.
|
|
|
|
| Free embeddable forum powered by Nabble | Forum Help |