diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2013-01-26 19:41:04 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2013-01-26 19:41:04 (GMT) |
commit | 2050b07c42c15738662dd9b3c5841694b64ab2a3 (patch) | |
tree | f6283df4b4775f0c4e42e14025d67443f8fdf9b5 /plugins/pychrysa/helpers.c | |
parent | b0b35292cb22899b1b23556be452eb827e4010d7 (diff) |
Provided some debug helpers as plugin samples.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@330 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'plugins/pychrysa/helpers.c')
-rw-r--r-- | plugins/pychrysa/helpers.c | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/plugins/pychrysa/helpers.c b/plugins/pychrysa/helpers.c index bc420c0..d8f7b0b 100644 --- a/plugins/pychrysa/helpers.c +++ b/plugins/pychrysa/helpers.c @@ -2,7 +2,7 @@ /* OpenIDA - Outil d'analyse de fichiers binaires * helpers.c - simplification des interactions de base avec Python * - * Copyright (C) 2012 Cyrille Bagard + * Copyright (C) 2012-2013 Cyrille Bagard * * This file is part of OpenIDA. * @@ -49,6 +49,35 @@ PyObject *run_python_method(PyObject *module, const char *method, PyObject *args func = PyObject_GetAttrString(module, method); if (func == NULL) return NULL; + result = _run_python_method(func, args); + + Py_DECREF(func); + + return result; + +} + + + +/****************************************************************************** +* * +* Paramètres : func = fonction Python à appeler. * +* args = arguments à associer à l'opération. * +* * +* Description : Appelle une routine Python. * +* * +* Retour : Retour obtenu ou NULL si erreur. * +* * +* Remarques : - * +* * +******************************************************************************/ + +PyObject *_run_python_method(PyObject *func, PyObject *args) +{ + PyObject *result; /* Bilan à retourner */ + + result = NULL; + if (PyCallable_Check(func)) { result = PyObject_CallObject(func, args); @@ -56,8 +85,6 @@ PyObject *run_python_method(PyObject *module, const char *method, PyObject *args } else if (PyErr_Occurred()) PyErr_Print(); - Py_DECREF(func); - return result; } |