diff options
author | Rob Austein <sra@hactrn.net> | 2009-05-29 23:45:41 +0000 |
---|---|---|
committer | Rob Austein <sra@hactrn.net> | 2009-05-29 23:45:41 +0000 |
commit | c359e38a2a3d310e00e6885e91495ec5ee556501 (patch) | |
tree | cc768137a7ad35791d44bc566ec7b7a80f6fd9ae /pow | |
parent | b46abf5580c8b26fd4bdda95d4a4f25a11f4b736 (diff) |
Ssl.fileno()
svn path=/pow/POW-0.7/POW.c; revision=2472
Diffstat (limited to 'pow')
-rw-r--r-- | pow/POW-0.7/POW.c | 23 |
1 files changed, 20 insertions, 3 deletions
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__[] = "<method>\n" " <header>\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}, |