From c359e38a2a3d310e00e6885e91495ec5ee556501 Mon Sep 17 00:00:00 2001 From: Rob Austein Date: Fri, 29 May 2009 23:45:41 +0000 Subject: Ssl.fileno() svn path=/pow/POW-0.7/POW.c; revision=2472 --- pow/POW-0.7/POW.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'pow') diff --git a/pow/POW-0.7/POW.c b/pow/POW-0.7/POW.c index ee27a374..f2311f23 100644 --- a/pow/POW-0.7/POW.c +++ b/pow/POW-0.7/POW.c @@ -4059,15 +4059,15 @@ ssl_object_set_fd(ssl_object *self, PyObject *args) goto error; if ((self->ssl = SSL_new(self->ctx)) == NULL) - lose("unable to create ssl sturcture"); + lose("Unable to create ssl structure"); if (!SSL_set_fd(self->ssl, fd)) - lose("unable to set file descriptor"); + lose("Unable to set file descriptor"); if ((self_index = SSL_get_ex_new_index(0, "self_index", NULL, NULL, NULL)) != -1) SSL_set_ex_data(self->ssl, self_index, self); else - lose("unable to create ex data index"); + lose("Unable to create ex data index"); self->ctxset = 1; @@ -4078,6 +4078,22 @@ ssl_object_set_fd(ssl_object *self, PyObject *args) return NULL; } +static PyObject * +ssl_object_fileno(ssl_object *self, PyObject *args) +{ + if (!PyArg_ParseTuple(args, "")) + goto error; + + if (!self->ctxset || !self->ssl) + lose("File descriptor not set"); + + return Py_BuildValue("i", SSL_get_fd(self->ssl)); + + error: + + return NULL; +} + static char ssl_object_accept__doc__[] = "\n" "
\n" @@ -4688,6 +4704,7 @@ static struct PyMethodDef ssl_object_methods[] = { {"useKey", (PyCFunction)ssl_object_use_key, METH_VARARGS, NULL}, {"checkKey", (PyCFunction)ssl_object_check_key, METH_VARARGS, NULL}, {"setFd", (PyCFunction)ssl_object_set_fd, METH_VARARGS, NULL}, + {"fileno", (PyCFunction)ssl_object_fileno, METH_VARARGS, NULL}, {"connect", (PyCFunction)ssl_object_connect, METH_VARARGS, NULL}, {"accept", (PyCFunction)ssl_object_accept, METH_VARARGS, NULL}, {"write", (PyCFunction)ssl_object_write, METH_VARARGS, NULL}, -- cgit v1.2.3