diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2024-06-04 10:34:24 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2024-06-04 10:36:13 (GMT) |
commit | 4218b6e8f87893a31c292dbb32c328b81e18ec61 (patch) | |
tree | aa2e56259aef63dde37fa93e80dc02eb0b512906 /src/glibext/options | |
parent | 20e004389791cce24682a426a183a665247e2920 (diff) |
Define rendering options for content views.
Diffstat (limited to 'src/glibext/options')
-rw-r--r-- | src/glibext/options/Makefile.am | 13 | ||||
-rw-r--r-- | src/glibext/options/hex-int.h | 49 | ||||
-rw-r--r-- | src/glibext/options/hex.c | 169 | ||||
-rw-r--r-- | src/glibext/options/hex.h | 42 |
4 files changed, 273 insertions, 0 deletions
diff --git a/src/glibext/options/Makefile.am b/src/glibext/options/Makefile.am new file mode 100644 index 0000000..448de7b --- /dev/null +++ b/src/glibext/options/Makefile.am @@ -0,0 +1,13 @@ + +noinst_LTLIBRARIES = libglibextoptions.la + + +libglibextoptions_la_SOURCES = \ + hex.h hex.c + +libglibextoptions_la_CFLAGS = $(TOOLKIT_CFLAGS) + + +devdir = $(includedir)/chrysalide/$(subdir:src/%=core/%) + +dev_HEADERS = $(libglibextoptions_la_SOURCES:%c=) diff --git a/src/glibext/options/hex-int.h b/src/glibext/options/hex-int.h new file mode 100644 index 0000000..45c822b --- /dev/null +++ b/src/glibext/options/hex-int.h @@ -0,0 +1,49 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * hex-int.h - prototypes pour les définitions internes d'options de rendus de code héxadécimal + * + * Copyright (C) 2024 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Chrysalide. If not, see <http://www.gnu.org/licenses/>. + */ + + +#ifndef _GLIBEXT_OPTIONS_HEX_INT_H +#define _GLIBEXT_OPTIONS_HEX_INT_H + + +#include "hex.h" +#include "../options-int.h" + + + +/* Options de représentation pour contenu hexadécimal (instance) */ +struct _GHexOptions +{ + GDisplayOptions parent; /* A laisser en premier */ + +}; + +/* Options de représentation pour contenu hexadécimal (classe) */ +struct _GHexOptionsClass +{ + GDisplayOptionsClass parent; /* A laisser en premier */ + +}; + + + +#endif /* _GLIBEXT_OPTIONS_HEX_INT_H */ diff --git a/src/glibext/options/hex.c b/src/glibext/options/hex.c new file mode 100644 index 0000000..5804a57 --- /dev/null +++ b/src/glibext/options/hex.c @@ -0,0 +1,169 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * hex.c - options de rendus de code héxadécimal + * + * Copyright (C) 2024 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Chrysalide. If not, see <http://www.gnu.org/licenses/>. + */ + + +#include "hex.h" + + +#include <assert.h> + + +#include <i18n.h> + + +#include "hex-int.h" + + + +/* Initialise la classe des options pour le rendu d'hexadécimal. */ +static void g_hex_options_class_init(GHexOptionsClass *); + +/* Initialise une instance d'options pour le rendu d'hexa. */ +static void g_hex_options_init(GHexOptions *); + +/* Supprime toutes les références externes. */ +static void g_hex_options_dispose(GHexOptions *); + +/* Procède à la libération totale de la mémoire. */ +static void g_hex_options_finalize(GHexOptions *); + + + +/* Indique le type défini pour une ligne de représentation. */ +G_DEFINE_TYPE(GHexOptions, g_hex_options, G_TYPE_DISPLAY_OPTIONS); + + +/****************************************************************************** +* * +* Paramètres : klass = classe à initialiser. * +* * +* Description : Initialise la classe des options pour le rendu d'hexadécimal.* +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_hex_options_class_init(GHexOptionsClass *klass) +{ + GObjectClass *object; /* Autre version de la classe */ + + object = G_OBJECT_CLASS(klass); + + object->dispose = (GObjectFinalizeFunc/* ! */)g_hex_options_dispose; + object->finalize = (GObjectFinalizeFunc)g_hex_options_finalize; + +} + + +/****************************************************************************** +* * +* Paramètres : options = instance à initialiser. * +* * +* Description : Initialise une instance d'options pour le rendu d'hexa. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_hex_options_init(GHexOptions *options) +{ +#ifndef NDEBUG + bool status; /* Bilan d'un appel */ +#endif + +#ifndef NDEBUG + status = g_display_options_create(G_DISPLAY_OPTIONS(options), +#else + g_display_options_create(G_DISPLAY_OPTIONS(options), +#endif + (const char *[]) { _("Offset") }, + (const bool []) { true }, + 1); + + assert(status); + +} + + +/****************************************************************************** +* * +* Paramètres : options = instance d'objet GLib à traiter. * +* * +* Description : Supprime toutes les références externes. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_hex_options_dispose(GHexOptions *options) +{ + G_OBJECT_CLASS(g_hex_options_parent_class)->dispose(G_OBJECT(options)); + +} + + +/****************************************************************************** +* * +* Paramètres : options = instance d'objet GLib à traiter. * +* * +* Description : Procède à la libération totale de la mémoire. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_hex_options_finalize(GHexOptions *options) +{ + G_OBJECT_CLASS(g_hex_options_parent_class)->finalize(G_OBJECT(options)); + +} + + +/****************************************************************************** +* * +* Paramètres : - * +* * +* Description : Crée un groupe d'options pour le rendu d'hexadécimal. * +* * +* Retour : Adresse de la structure mise en place. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GHexOptions *g_hex_options_new(void) +{ + GHexOptions *result; /* Structure à retourner */ + + result = g_object_new(G_TYPE_HEX_OPTIONS, NULL); + + return result; + +} diff --git a/src/glibext/options/hex.h b/src/glibext/options/hex.h new file mode 100644 index 0000000..48ce942 --- /dev/null +++ b/src/glibext/options/hex.h @@ -0,0 +1,42 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * hex.h - prototypes pour les options de rendus de code héxadécimal + * + * Copyright (C) 2024 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Chrysalide. If not, see <http://www.gnu.org/licenses/>. + */ + + +#ifndef _GLIBEXT_OPTIONS_HEX_H +#define _GLIBEXT_OPTIONS_HEX_H + + +#include "../helpers.h" + + + +#define G_TYPE_HEX_OPTIONS (g_hex_options_get_type()) + +DECLARE_GTYPE(GHexOptions, g_hex_options, G, HEX_OPTIONS); + + +/* Crée un groupe d'options pour le rendu d'hexadécimal. */ +GHexOptions *g_hex_options_new(void); + + + +#endif /* _GLIBEXT_OPTIONS_HEX_H */ |