summaryrefslogtreecommitdiff
path: root/plugins/kaitai/rost
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2023-10-09 23:49:08 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2023-10-09 23:49:08 (GMT)
commit2e144129d6884f4f9ec5d3f599ec2820613ed419 (patch)
tree76e2b122a5a3391dfb948c50048113c1eda9c2d7 /plugins/kaitai/rost
parent7c6fe94c90d320813d0d78a9dbef707696f31505 (diff)
Load Kaitai definitions from $KSPATH when needed.
Diffstat (limited to 'plugins/kaitai/rost')
-rw-r--r--plugins/kaitai/rost/space.c18
-rw-r--r--plugins/kaitai/rost/trigger.c6
-rw-r--r--plugins/kaitai/rost/trigger.h5
3 files changed, 23 insertions, 6 deletions
diff --git a/plugins/kaitai/rost/space.c b/plugins/kaitai/rost/space.c
index ed24562..ee922d2 100644
--- a/plugins/kaitai/rost/space.c
+++ b/plugins/kaitai/rost/space.c
@@ -27,7 +27,9 @@
#include <string.h>
+#include "trigger.h"
#include "space-int.h"
+#include "../import.h"
@@ -226,14 +228,26 @@ static bool g_kaitai_namespace_resolve(GKaitaiNamespace *item, const char *targe
{
bool result; /* Bilan à retourner */
GScanRegisteredItemClass *parent; /* Version de classe parente */
+ GKaitaiStruct *kstruct; /* Lecteur de définition */
parent = G_SCAN_REGISTERED_ITEM_CLASS(g_kaitai_namespace_parent_class);
result = parent->resolve(G_SCAN_REGISTERED_ITEM(item), target, ctx, scope, out);
-
if (!result)
- printf("NEED external def!!!!\n");
+ {
+ kstruct = load_kaitai_definition(target, NULL);
+
+ if (kstruct != NULL)
+ {
+ *out = g_kaitai_trigger_new(kstruct);
+ result = true;
+
+ g_object_unref(G_OBJECT(kstruct));
+
+ }
+
+ }
return result;
diff --git a/plugins/kaitai/rost/trigger.c b/plugins/kaitai/rost/trigger.c
index 64e6fe4..6bb6e5d 100644
--- a/plugins/kaitai/rost/trigger.c
+++ b/plugins/kaitai/rost/trigger.c
@@ -175,13 +175,13 @@ static void g_kaitai_trigger_finalize(GKaitaiTrigger *trigger)
* *
******************************************************************************/
-GKaitaiTrigger *g_kaitai_trigger_new(GKaitaiStruct *kstruct)
+GScanRegisteredItem *g_kaitai_trigger_new(GKaitaiStruct *kstruct)
{
- GKaitaiTrigger *result; /* Structure à retourner */
+ GScanRegisteredItem *result; /* Structure à retourner */
result = g_object_new(G_TYPE_KAITAI_TRIGGER, NULL);
- if (!g_kaitai_trigger_create(result, kstruct))
+ if (!g_kaitai_trigger_create(G_KAITAI_TRIGGER(result), kstruct))
g_clear_object(&result);
return result;
diff --git a/plugins/kaitai/rost/trigger.h b/plugins/kaitai/rost/trigger.h
index 3de2e8d..f55e998 100644
--- a/plugins/kaitai/rost/trigger.h
+++ b/plugins/kaitai/rost/trigger.h
@@ -28,6 +28,9 @@
#include <glib-object.h>
+#include <analysis/scan/item.h>
+
+
#include "../parsers/struct.h"
@@ -51,7 +54,7 @@ typedef struct _GKaitaiTriggerClass GKaitaiTriggerClass;
GType g_kaitai_trigger_get_type(void);
/* Crée un nouvel accès à une définition Kaitai à instancier. */
-GKaitaiTrigger *g_kaitai_trigger_new(GKaitaiStruct *);
+GScanRegisteredItem *g_kaitai_trigger_new(GKaitaiStruct *);