diff options
Diffstat (limited to 'src/format/format.c')
-rw-r--r-- | src/format/format.c | 129 |
1 files changed, 129 insertions, 0 deletions
diff --git a/src/format/format.c b/src/format/format.c index 533d641..2be7d5c 100644 --- a/src/format/format.c +++ b/src/format/format.c @@ -123,6 +123,8 @@ static void g_binary_format_class_init(GBinFormatClass *klass) static void g_binary_format_init(GBinFormat *format) { + INIT_BIN_FORMAT_EXTRA(format); + g_rw_lock_init(&format->pt_lock); format->info = g_preload_info_new(); @@ -288,6 +290,133 @@ GBinContent *g_binary_format_get_content(const GBinFormat *format) /****************************************************************************** * * +* Paramètres : format = format à venir modifier. * +* flag = drapeau d'information complémentaire à planter. * +* * +* Description : Ajoute une information complémentaire à un format. * +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool g_binary_format_set_flag(GBinFormat *format, FormatFlag flag) +{ + bool result; /* Bilan à retourner */ + fmt_obj_extra *extra; /* Données insérées à modifier */ + + extra = GET_BIN_FORMAT_EXTRA(format); + + g_bit_lock(&extra->lock, HOLE_LOCK_BIT); + + result = !(extra->flags & flag); + + extra->flags |= flag; + + g_bit_unlock(&extra->lock, HOLE_LOCK_BIT); + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : format = format à venir modifier. * +* flag = drapeau d'information complémentaire à planter. * +* * +* Description : Retire une information complémentaire à un format. * +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool g_binary_format_unset_flag(GBinFormat *format, FormatFlag flag) +{ + bool result; /* Bilan à retourner */ + fmt_obj_extra *extra; /* Données insérées à modifier */ + + extra = GET_BIN_FORMAT_EXTRA(format); + + g_bit_lock(&extra->lock, HOLE_LOCK_BIT); + + result = (extra->flags & flag); + + extra->flags &= ~flag; + + g_bit_unlock(&extra->lock, HOLE_LOCK_BIT); + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : format = format à venir consulter. * +* flag = drapeau d'information à rechercher. * +* * +* Description : Détermine si un format possède un fanion particulier. * +* * +* Retour : Bilan de la détection. * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool g_binary_format_has_flag(const GBinFormat *format, FormatFlag flag) +{ + bool result; /* Bilan à retourner */ + fmt_obj_extra *extra; /* Données insérées à modifier */ + + extra = GET_BIN_FORMAT_EXTRA(format); + + g_bit_lock(&extra->lock, HOLE_LOCK_BIT); + + result = (extra->flags & flag); + + g_bit_unlock(&extra->lock, HOLE_LOCK_BIT); + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : format = format à venir consulter. * +* * +* Description : Fournit les particularités du format. * +* * +* Retour : Somme de tous les fanions associés au format. * +* * +* Remarques : - * +* * +******************************************************************************/ + +FormatFlag g_binary_format_get_flags(const GBinFormat *format) +{ + FormatFlag result; /* Fanions à retourner */ + fmt_obj_extra *extra; /* Données insérées à modifier */ + + extra = GET_BIN_FORMAT_EXTRA(format); + + g_bit_lock(&extra->lock, HOLE_LOCK_BIT); + + result = (extra->flags & FFL_MASK); + + g_bit_unlock(&extra->lock, HOLE_LOCK_BIT); + + return result; + +} + + +/****************************************************************************** +* * * Paramètres : format = description de l'exécutable à consulter. * * * * Description : Indique la désignation interne du format. * |