Z
zyqnews
hello all,
how to parse the arguments of a c function with PyArg_ParseTuple?
The prototype of the c function is :
int func(unsigned char * in , int inlen, unsigned char * v, unsigned
char * out, int * outlen);
The problem is , when the func returns, there will be results in out
and outlen. Is the following format is correct?
PyObject* wrap_func(PyObject* self, PyObject* args)
{
unsigned char *in;
int inlen;
unsigned char *v;
unsigned char *out;
int outlen;
PyArg_ParseTuple(args, "s|i|s|s|i", &in, &inlen, &v, &out, &outlen);
result = func(in, inlen, v, out, &outlen);// notice out and &outlen
return Py_BuildValue("i", result);
}
Thanks
how to parse the arguments of a c function with PyArg_ParseTuple?
The prototype of the c function is :
int func(unsigned char * in , int inlen, unsigned char * v, unsigned
char * out, int * outlen);
The problem is , when the func returns, there will be results in out
and outlen. Is the following format is correct?
PyObject* wrap_func(PyObject* self, PyObject* args)
{
unsigned char *in;
int inlen;
unsigned char *v;
unsigned char *out;
int outlen;
PyArg_ParseTuple(args, "s|i|s|s|i", &in, &inlen, &v, &out, &outlen);
result = func(in, inlen, v, out, &outlen);// notice out and &outlen
return Py_BuildValue("i", result);
}
Thanks