diff options
author | Jean-Paul Calderone <exarkun@twistedmatrix.com> | 2013-12-31 20:13:07 -0500 |
---|---|---|
committer | Jean-Paul Calderone <exarkun@twistedmatrix.com> | 2013-12-31 20:13:07 -0500 |
commit | 97336662262a6dc4fabca004e54c52b8f46a8e6b (patch) | |
tree | d1e42d8a2d89900712bb1cf9445f97397f803e1c | |
parent | c7cd3e607c359367b8b238e10007ffe644a08e50 (diff) | |
download | pyopenssl-97336662262a6dc4fabca004e54c52b8f46a8e6b.tar.gz |
These are no longer used
-rw-r--r-- | OpenSSL/pymemcompat.h | 86 | ||||
-rw-r--r-- | OpenSSL/util.c | 96 | ||||
-rw-r--r-- | OpenSSL/util.h | 144 |
3 files changed, 0 insertions, 326 deletions
diff --git a/OpenSSL/pymemcompat.h b/OpenSSL/pymemcompat.h deleted file mode 100644 index 24221ec..0000000 --- a/OpenSSL/pymemcompat.h +++ /dev/null @@ -1,86 +0,0 @@ -/* The idea of this file is that you bundle it with your extension, - #include it, program to Python 2.3's memory API and have your - extension build with any version of Python from 1.5.2 through to - 2.3 (and hopefully beyond). */ - -#ifndef Py_PYMEMCOMPAT_H -#define Py_PYMEMCOMPAT_H - -#include "Python.h" - -/* There are three "families" of memory API: the "raw memory", "object - memory" and "object" families. (This is ignoring the matter of the - cycle collector, about which more is said below). - - Raw Memory: - - PyMem_Malloc, PyMem_Realloc, PyMem_Free - - Object Memory: - - PyObject_Malloc, PyObject_Realloc, PyObject_Free - - Object: - - PyObject_New, PyObject_NewVar, PyObject_Del - - The raw memory and object memory allocators both mimic the - malloc/realloc/free interface from ANSI C, but the object memory - allocator can (and, since 2.3, does by default) use a different - allocation strategy biased towards lots of lots of "small" - allocations. - - The object family is used for allocating Python objects, and the - initializers take care of some basic initialization (setting the - refcount to 1 and filling out the ob_type field) as well as having - a somewhat different interface. - - Do not mix the families! E.g. do not allocate memory with - PyMem_Malloc and free it with PyObject_Free. You may get away with - it quite a lot of the time, but there *are* scenarios where this - will break. You Have Been Warned. - - Also, in many versions of Python there are an insane amount of - memory interfaces to choose from. Use the ones described above. */ - -#if PY_VERSION_HEX < 0x01060000 -/* raw memory interface already present */ - -/* there is no object memory interface in 1.5.2 */ -#define PyObject_Malloc PyMem_Malloc -#define PyObject_Realloc PyMem_Realloc -#define PyObject_Free PyMem_Free - -/* the object interface is there, but the names have changed */ -#define PyObject_New PyObject_NEW -#define PyObject_NewVar PyObject_NEW_VAR -#define PyObject_Del PyMem_Free -#endif - -/* If your object is a container you probably want to support the - cycle collector, which was new in Python 2.0. - - Unfortunately, the interface to the collector that was present in - Python 2.0 and 2.1 proved to be tricky to use, and so changed in - 2.2 -- in a way that can't easily be papered over with macros. - - This file contains macros that let you program to the 2.2 GC API. - Your module will compile against any Python since version 1.5.2, - but the type will only participate in the GC in versions 2.2 and - up. Some work is still necessary on your part to only fill out the - tp_traverse and tp_clear fields when they exist and set tp_flags - appropriately. - - It is possible to support both the 2.0 and 2.2 GC APIs, but it's - not pretty and this comment block is too narrow to contain a - desciption of what's required... */ - -#if PY_VERSION_HEX < 0x020200B1 -#define PyObject_GC_New PyObject_New -#define PyObject_GC_NewVar PyObject_NewVar -#define PyObject_GC_Del PyObject_Del -#define PyObject_GC_Track(op) -#define PyObject_GC_UnTrack(op) -#endif - -#endif /* !Py_PYMEMCOMPAT_H */ diff --git a/OpenSSL/util.c b/OpenSSL/util.c deleted file mode 100644 index ca60ccf..0000000 --- a/OpenSSL/util.c +++ /dev/null @@ -1,96 +0,0 @@ -/* - * util.c - * - * Copyright (C) AB Strakt - * Copyright (C) Jean-Paul Calderone - * See LICENSE for details. - * - * Utility functions. - * See the file RATIONALE for a short explanation of why this module was written. - * - * Reviewed 2001-07-23 - */ -#include <Python.h> -#include "util.h" - -/* - * Flush OpenSSL's error queue and return a list of errors (a (library, - * function, reason) string tuple) - * - * Arguments: None - * Returns: A list of errors (new reference) - */ -PyObject * -error_queue_to_list(void) { - PyObject *errlist, *tuple; - long err; - - errlist = PyList_New(0); - - while ((err = ERR_get_error()) != 0) { - tuple = Py_BuildValue("(sss)", ERR_lib_error_string(err), - ERR_func_error_string(err), - ERR_reason_error_string(err)); - PyList_Append(errlist, tuple); - Py_DECREF(tuple); - } - - return errlist; -} - -void exception_from_error_queue(PyObject *the_Error) { - PyObject *errlist = error_queue_to_list(); - PyErr_SetObject(the_Error, errlist); - Py_DECREF(errlist); -} - -/* - * Flush OpenSSL's error queue and ignore the result - * - * Arguments: None - * Returns: None - */ -void -flush_error_queue(void) { - /* - * Make sure to save the errors to a local. Py_DECREF might expand such - * that it evaluates its argument more than once, which would lead to - * very nasty things if we just invoked it with error_queue_to_list(). - */ - PyObject *list = error_queue_to_list(); - Py_DECREF(list); -} - -#if (PY_VERSION_HEX < 0x02600000) -PyObject* PyOpenSSL_LongToHex(PyObject *o) { - PyObject *hex = NULL; - PyObject *format = NULL; - PyObject *format_args = NULL; - - if ((format_args = Py_BuildValue("(O)", o)) == NULL) { - goto err; - } - - if ((format = PyString_FromString("%x")) == NULL) { - goto err; - } - - if ((hex = PyString_Format(format, format_args)) == NULL) { - goto err; - } - - return hex; - - err: - if (format_args) { - Py_DECREF(format_args); - } - if (format) { - Py_DECREF(format); - } - if (hex) { - Py_DECREF(hex); - } - return NULL; -} -#endif diff --git a/OpenSSL/util.h b/OpenSSL/util.h deleted file mode 100644 index e634b01..0000000 --- a/OpenSSL/util.h +++ /dev/null @@ -1,144 +0,0 @@ -/* - * util.h - * - * Copyright (C) AB Strakt - * See LICENSE for details. - * - * Export utility functions and macros. - * See the file RATIONALE for a short explanation of why this module was written. - * - * Reviewed 2001-07-23 - * - */ -#ifndef PyOpenSSL_UTIL_H_ -#define PyOpenSSL_UTIL_H_ - -#include <Python.h> -#include <openssl/err.h> - -/* - * pymemcompat written by Michael Hudson and lets you program to the - * Python 2.3 memory API while keeping backwards compatibility. - */ -#include "pymemcompat.h" - -/* - * py3k defines macros that help with Python 2.x/3.x compatibility. - */ -#include "py3k.h" - - -extern PyObject *error_queue_to_list(void); -extern void exception_from_error_queue(PyObject *the_Error); -extern void flush_error_queue(void); - -/* - * These are needed because there is no "official" way to specify - * WHERE to save the thread state. - */ -#ifdef WITH_THREAD - -/* - * Get the current Python threadstate and put it somewhere any code running - * in this thread can get it, if it needs to restore the threadstate to run - * some Python. - */ -# define MY_BEGIN_ALLOW_THREADS(ignored) \ - PyThread_delete_key_value(_pyOpenSSL_tstate_key); \ - PyThread_set_key_value(_pyOpenSSL_tstate_key, PyEval_SaveThread()); - -/* - * Get the previous Python threadstate and restore it. - */ -# define MY_END_ALLOW_THREADS(ignored) \ - PyEval_RestoreThread(PyThread_get_key_value(_pyOpenSSL_tstate_key)); - -#else -# define MY_BEGIN_ALLOW_THREADS(st) -# define MY_END_ALLOW_THREADS(st) { st = NULL; } -#endif - -#if !defined(PY_MAJOR_VERSION) || PY_VERSION_HEX < 0x02000000 -static int -PyModule_AddObject(PyObject *m, char *name, PyObject *o) -{ - PyObject *dict; - if (!PyModule_Check(m) || o == NULL) - return -1; - dict = PyModule_GetDict(m); - if (dict == NULL) - return -1; - if (PyDict_SetItemString(dict, name, o)) - return -1; - Py_DECREF(o); - return 0; -} - -static int -PyModule_AddIntConstant(PyObject *m, char *name, long value) -{ - return PyModule_AddObject(m, name, PyInt_FromLong(value)); -} - -static int PyObject_AsFileDescriptor(PyObject *o) -{ - int fd; - PyObject *meth; - - if (PyInt_Check(o)) { - fd = PyInt_AsLong(o); - } - else if (PyLong_Check(o)) { - fd = PyLong_AsLong(o); - } - else if ((meth = PyObject_GetAttrString(o, "fileno")) != NULL) - { - PyObject *fno = PyEval_CallObject(meth, NULL); - Py_DECREF(meth); - if (fno == NULL) - return -1; - - if (PyInt_Check(fno)) { - fd = PyInt_AsLong(fno); - Py_DECREF(fno); - } - else if (PyLong_Check(fno)) { - fd = PyLong_AsLong(fno); - Py_DECREF(fno); - } - else { - PyErr_SetString(PyExc_TypeError, "fileno() returned a non-integer"); - Py_DECREF(fno); - return -1; - } - } - else { - PyErr_SetString(PyExc_TypeError, "argument must be an int, or have a fileno() method."); - return -1; - } - - if (fd < 0) { - PyErr_Format(PyExc_ValueError, "file descriptor cannot be a negative integer (%i)", fd); - return -1; - } - return fd; -} -#endif - -#if !defined(PY_SSIZE_T_MIN) -typedef int Py_ssize_t; -#define PY_SSIZE_T_MAX INT_MAX -#define PY_SSIZE_T_MIN INT_MIN -#endif - -#if (PY_VERSION_HEX < 0x02600000) -extern PyObject* PyOpenSSL_LongToHex(PyObject *o); -#else -#define PyOpenSSL_LongToHex(o) PyNumber_ToBase(o, 16) -#endif - -#ifndef Py_TYPE -#define Py_TYPE(ob) (((PyObject*)(ob))->ob_type) -#endif - -#endif |