PyArg_ParseTuple for structs or binary data

Alvin Delagon adelagon at gmail.com
Wed Apr 9 04:05:45 EDT 2008


Hello fellow pythonistas,

I'm currently writing a simple python SCTP module in C. So far it works
sending and receiving strings from it. The C sctp function sctp_sendmsg()
has been wrapped and my function looks like this:

sendMessage(PyObject *self, PyObject *args)
{
  const char *msg = "";
  if (!PyArg_ParseTuple(args, "s", &msg))
    return NULL;
  snprintf(buffer, 1025, msg);
  ret = sctp_sendmsg(connSock, (void *)buffer, (size_t)strlen(buffer), 0, 0,
0x03000000, 0, 0, 0, 0);
  return Py_BuildValue("b", "");
}

I'm going to construct an SS7 packet in python using struct.pack(). Here's
the question, how am I going to pass the packet I wrote in python to my
module? Thanks in advance! :)

---
Alvin Delagon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20080409/35f1cdb1/attachment.html>


More information about the Python-list mailing list