diff options
author | Benjamin Peterson <benjamin@python.org> | 2011-07-08 13:39:56 -0500 |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2011-07-08 13:39:56 -0500 |
commit | 910789f10fb314fe7149be84aa57d6ec12ad4a7b (patch) | |
tree | a658027493df6d758e5d0b802ffa72e66594ad1e /Modules/_ssl.c | |
parent | ae10c0653e5469e7f41f12cee35bfe653a389cbc (diff) | |
parent | 4a183b47f353a25b76aaaf1b7043458dbcab8890 (diff) | |
download | cpython-git-910789f10fb314fe7149be84aa57d6ec12ad4a7b.tar.gz |
merge heads
Diffstat (limited to 'Modules/_ssl.c')
-rw-r--r-- | Modules/_ssl.c | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/Modules/_ssl.c b/Modules/_ssl.c index 3f631e31ac..d2d2480b5c 100644 --- a/Modules/_ssl.c +++ b/Modules/_ssl.c @@ -2101,6 +2101,24 @@ static struct PyModuleDef _sslmodule = { NULL }; + +static void +parse_openssl_version(unsigned long libver, + unsigned int *major, unsigned int *minor, + unsigned int *fix, unsigned int *patch, + unsigned int *status) +{ + *status = libver & 0xF; + libver >>= 4; + *patch = libver & 0xFF; + libver >>= 8; + *fix = libver & 0xFF; + libver >>= 8; + *minor = libver & 0xFF; + libver >>= 8; + *major = libver & 0xFF; +} + PyMODINIT_FUNC PyInit__ssl(void) { @@ -2213,15 +2231,7 @@ PyInit__ssl(void) return NULL; if (PyModule_AddObject(m, "OPENSSL_VERSION_NUMBER", r)) return NULL; - status = libver & 0xF; - libver >>= 4; - patch = libver & 0xFF; - libver >>= 8; - fix = libver & 0xFF; - libver >>= 8; - minor = libver & 0xFF; - libver >>= 8; - major = libver & 0xFF; + parse_openssl_version(libver, &major, &minor, &fix, &patch, &status); r = Py_BuildValue("IIIII", major, minor, fix, patch, status); if (r == NULL || PyModule_AddObject(m, "OPENSSL_VERSION_INFO", r)) return NULL; @@ -2229,5 +2239,11 @@ PyInit__ssl(void) if (r == NULL || PyModule_AddObject(m, "OPENSSL_VERSION", r)) return NULL; + libver = OPENSSL_VERSION_NUMBER; + parse_openssl_version(libver, &major, &minor, &fix, &patch, &status); + r = Py_BuildValue("IIIII", major, minor, fix, patch, status); + if (r == NULL || PyModule_AddObject(m, "_OPENSSL_API_VERSION", r)) + return NULL; + return m; } |