Exemplo n.º 1
0
//
// returns the specified piece of auxiliary data from the socket
// if it is a piece of python auxiliary data.
PyObject *PySocket_get_auxiliary(PySocket *self, PyObject *args) {
  char *keyword = NULL;
  if(!PyArg_ParseTuple(args, "s", &keyword)) {
    PyErr_Format(PyExc_TypeError,
		 "getAuxiliary() must be supplied with the name that the "
		 "auxiliary data was installed under!");
    return NULL;
  }

  // make sure we exist
  SOCKET_DATA *sock = PySocket_AsSocket((PyObject *)self);
  if(sock == NULL) {
    PyErr_Format(PyExc_StandardError,
		 "Tried to get auxiliary data for a nonexistant socket.");
    return NULL;
  }

  // make sure the auxiliary data exists
  if(!pyAuxiliaryDataExists(keyword)) {
    PyErr_Format(PyExc_StandardError,
		 "No auxiliary data named '%s' exists!", keyword);
    return NULL;
  }

  PyObject *data = socketGetAuxiliaryData(sock, keyword);
  if(data == NULL)
    data = Py_None;
  PyObject *retval = Py_BuildValue("O", data);
  //  Py_DECREF(data);
  return retval;
}
Exemplo n.º 2
0
PyObject *socketGetPyFormBorrowed(SOCKET_DATA *sock) {
  TRIGGER_AUX_DATA *data = socketGetAuxiliaryData(sock, "trigger_data");
  if(data->pyform == NULL)
    data->pyform = newPySocket(sock);
  return data->pyform;
}