diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2018-08-16 09:16:53 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2018-08-16 09:16:53 (GMT) |
commit | fb315963527f6412273829f09513325e446eb6c9 (patch) | |
tree | 361f19767812a8f758545e8daa2973fe0b3c9de7 /plugins/pychrysalide/analysis/db/certs.c | |
parent | 36945bffa2ca648b58c99905ebf9b1b536a9188a (diff) |
Reorganized the Python plugin code.
Diffstat (limited to 'plugins/pychrysalide/analysis/db/certs.c')
-rw-r--r-- | plugins/pychrysalide/analysis/db/certs.c | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/plugins/pychrysalide/analysis/db/certs.c b/plugins/pychrysalide/analysis/db/certs.c index e0358d1..385e277 100644 --- a/plugins/pychrysalide/analysis/db/certs.c +++ b/plugins/pychrysalide/analysis/db/certs.c @@ -33,6 +33,7 @@ #include <analysis/db/certs.h> +#include "../../access.h" #include "../../helpers.h" @@ -307,21 +308,31 @@ PyTypeObject *get_python_certs_type(void) * * ******************************************************************************/ -bool register_python_certs(PyObject *module) +bool ensure_python_certs_is_registered(void) { - PyTypeObject *py_certs_type; /* Type Python pour 'certs' */ + PyTypeObject *type; /* Type Python pour 'certs' */ + PyObject *module; /* Module à recompléter */ int ret; /* Bilan d'un appel */ - py_certs_type = get_python_certs_type(); + type = get_python_certs_type(); - py_certs_type->tp_new = PyType_GenericNew; + if (!PyType_HasFeature(type, Py_TPFLAGS_READY)) + { + type->tp_new = PyType_GenericNew; - if (PyType_Ready(py_certs_type) != 0) - return false; + if (PyType_Ready(type) != 0) + return false; - Py_INCREF(py_certs_type); - ret = PyModule_AddObject(module, "certs", (PyObject *)py_certs_type); + module = get_access_to_python_module("pychrysalide.analysis.db"); - return (ret == 0); + Py_INCREF(type); + ret = PyModule_AddObject(module, "certs", (PyObject *)type); + + if (ret != 0) + return false; + + } + + return true; } |