summaryrefslogtreecommitdiff
path: root/plugins/pychrysalide/analysis/contents/restricted.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/pychrysalide/analysis/contents/restricted.c')
-rw-r--r--plugins/pychrysalide/analysis/contents/restricted.c74
1 files changed, 52 insertions, 22 deletions
diff --git a/plugins/pychrysalide/analysis/contents/restricted.c b/plugins/pychrysalide/analysis/contents/restricted.c
index eb16f13..7db52ed 100644
--- a/plugins/pychrysalide/analysis/contents/restricted.c
+++ b/plugins/pychrysalide/analysis/contents/restricted.c
@@ -44,6 +44,9 @@
/* Crée un nouvel objet Python de type 'BinContent'. */
static PyObject *py_restricted_content_new(PyTypeObject *, PyObject *, PyObject *);
+/* Indique l'espace de restriction appliqué à un contenu. */
+static PyObject *py_restricted_content_get_range(PyObject *, void *);
+
/******************************************************************************
@@ -63,37 +66,63 @@ static PyObject *py_restricted_content_new(PyTypeObject *, PyObject *, PyObject
static PyObject *py_restricted_content_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
PyObject *result; /* Instance à retourner */
- PyObject *content_obj; /* Objet pour le contenu */
- PyObject *range_obj; /* Objet pour la restriction */
- int ret; /* Bilan de lecture des args. */
GBinContent *content; /* Instance GLib correspondante*/
- mrange_t *range; /* Restriction à appliquer */
+ mrange_t range; /* Restriction à appliquer */
+ int ret; /* Bilan de lecture des args. */
GBinContent *restricted; /* Création GLib à transmettre */
- ret = PyArg_ParseTuple(args, "OO", &content_obj, &range_obj);
+#define RESTRICTED_CONTENT_DOC \
+ "RestrictedContent restricts access to a given area for a binary content." \
+ "\n" \
+ "Instances can be created using the following constructor:\n" \
+ "\n" \
+ " RestrictedContent(content, range)" \
+ "\n" \
+ "Where content is a pychrysalide.analysis.BinContent instance and range" \
+ " a Python object which can be converted into pychrysalide.arch.mrange."
+
+ ret = PyArg_ParseTuple(args, "O&O&", convert_to_binary_content, &content, convert_any_to_mrange, &range);
if (!ret) return NULL;
- ret = PyObject_IsInstance(content_obj, (PyObject *)get_python_binary_content_type());
- if (!ret)
- {
- PyErr_SetString(PyExc_TypeError, _("The first argument must be an instance of BinContent."));
- return NULL;
- }
+ restricted = g_restricted_content_new(content, &range);
- ret = PyObject_IsInstance(range_obj, (PyObject *)get_python_mrange_type());
- if (!ret)
- {
- PyErr_SetString(PyExc_TypeError, _("The second argument must be an instance of mrange."));
- return NULL;
- }
+ result = pygobject_new(G_OBJECT(restricted));
- content = G_BIN_CONTENT(pygobject_get(content_obj));
+ return result;
- range = get_internal_mrange(range_obj);
+}
- restricted = g_restricted_content_new(content, range);
- result = pygobject_new(G_OBJECT(restricted));
+/******************************************************************************
+* *
+* Paramètres : self = objet Python concerné par l'appel. *
+* closure = non utilisé ici. *
+* *
+* Description : Indique l'espace de restriction appliqué à un contenu. *
+* *
+* Retour : Couverture mémoire associée au contenu restreint. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static PyObject *py_restricted_content_get_range(PyObject *self, void *closure)
+{
+ PyObject *result; /* Valeur à retourner */
+ GRestrictedContent *content; /* Contenu binaire à consulter */
+ mrange_t range; /* Couverture à transmettre */
+
+#define RESTRICTED_CONTENT_RANGE_ATTRIB PYTHON_GET_DEF_FULL \
+( \
+ range, py_restricted_content, \
+ "Give the restricting range applied to a binary content." \
+)
+
+ content = G_RESTRICTED_CONTENT(pygobject_get(self));
+
+ g_restricted_content_get_range(content, &range);
+
+ result = build_from_internal_mrange(&range);
return result;
@@ -119,6 +148,7 @@ PyTypeObject *get_python_restricted_content_type(void)
};
static PyGetSetDef py_restricted_content_getseters[] = {
+ RESTRICTED_CONTENT_RANGE_ATTRIB,
{ NULL }
};
@@ -131,7 +161,7 @@ PyTypeObject *get_python_restricted_content_type(void)
.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
- .tp_doc = "PyChrysalide binary restricted content",
+ .tp_doc = RESTRICTED_CONTENT_DOC,
.tp_methods = py_restricted_content_methods,
.tp_getset = py_restricted_content_getseters,