summaryrefslogtreecommitdiff
path: root/plugins/kaitai/parsers/type.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2023-10-08 13:39:00 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2023-10-08 13:39:00 (GMT)
commit22d7a5277e2526514b8b01983f502c26aeff5747 (patch)
tree1acad2eded62412c5f7a4337830208094ed39323 /plugins/kaitai/parsers/type.c
parentcc43f73bbbdfd1cb6d7129c82e2d221181a3cac3 (diff)
Import external Kaitai definitions when needed.
Diffstat (limited to 'plugins/kaitai/parsers/type.c')
-rw-r--r--plugins/kaitai/parsers/type.c58
1 files changed, 58 insertions, 0 deletions
diff --git a/plugins/kaitai/parsers/type.c b/plugins/kaitai/parsers/type.c
index 30d0373..81efbeb 100644
--- a/plugins/kaitai/parsers/type.c
+++ b/plugins/kaitai/parsers/type.c
@@ -215,6 +215,64 @@ bool g_kaitai_type_create(GKaitaiType *type, GYamlNode *parent)
/******************************************************************************
* *
+* Paramètres : name = nom à attribuer au futur type. *
+* filename = chemin vers une définition Kaitai à charger. *
+* *
+* Description : Construit un lecteur de type externe pour Kaitai. *
+* *
+* Retour : Instance mise en place ou NULL en cas d'échec. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+GKaitaiType *g_kaitai_type_new_as_import(const char *name, const char *filename)
+{
+ GKaitaiType *result; /* Structure à retourner */
+
+ result = g_object_new(G_TYPE_KAITAI_TYPE, NULL);
+
+ if (!g_kaitai_type_create_as_import(result, name, filename))
+ g_clear_object(&result);
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : type = lecteur de type Kaitai à initialiser pleinement. *
+* name = nom à attribuer au futur type. *
+* filename = chemin vers une définition Kaitai à charger. *
+* *
+* Description : Met en place un lecteur de type externe pour Kaitai. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool g_kaitai_type_create_as_import(GKaitaiType *type, const char *name, const char *filename)
+{
+ bool result; /* Bilan à retourner */
+
+ /* Extraction du nom */
+
+ type->name = strdup(name);
+
+ /* Extraction des bases du type */
+
+ result = g_kaitai_structure_create_from_file(G_KAITAI_STRUCT(type), filename);
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : type = définition de type particulier à consulter. *
* *
* Description : Indique le nom de scène du type représenté. *