summaryrefslogtreecommitdiff
path: root/tools/d2c/bits/manager.h
blob: 72d3672c2b62e1d661f021bf6c967f29ad61234d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87

/* Chrysalide - Outil d'analyse de fichiers binaires
 * manager.h - prototypes pour la compréhension et la manipulation des champs de bits
 *
 * Copyright (C) 2014 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 Foobar.  If not, see <http://www.gnu.org/licenses/>.
 */


#ifndef _TOOLS_D2C_BITS_MANAGER_H
#define _TOOLS_D2C_BITS_MANAGER_H


#include <stdbool.h>




/* --------------------------- GESTION DES CHAMPS DE BITS --------------------------- */


/* Elément d'un mot décodé */
typedef struct _raw_bitfield raw_bitfield;



/* Indique le nombre de bits utilisés par le champ. */
unsigned int get_raw_bitfield_length(const raw_bitfield *);

/* Marque un champ de bits comme étant utile. */
void mark_raw_bitfield_as_used(raw_bitfield *);





/* Représentation de l'ensemble des bits de codage */
typedef struct _coding_bits coding_bits;



/* Crée un nouveau gestionnaire des bits d'encodage brut. */
coding_bits *create_coding_bits(void);

/* Supprime de la mémoire un gestionnaire de bits d'encodage. */
void delete_coding_bits(coding_bits *);



/* Note la présence d'un champ remarquable dans une définition. */
void register_named_field_in_bits(coding_bits *, char *, unsigned int);

/* Note la présence d'un bit invariable dans une définition. */
void register_bit_in_bits(coding_bits *, int);

/* Indique le nombre de bits traités. */
unsigned int count_coded_bits(const coding_bits *);

/* Recherche un champ donné dans un ensemble de champs de bits. */
raw_bitfield *find_named_field_in_bits(const coding_bits *, const char *);

/* Déclare les variables C associées aux champs de bits. */
bool declare_used_bits_fields(const coding_bits *, int, unsigned int);

/* Vérifie que les bits fixes correspondent au masque attendu. */
bool check_bits_correctness(const coding_bits *, int);

/* Définit les variables C associées aux champs de bits. */
bool define_used_bits_fields(const coding_bits *, int);



#endif  /* _TOOLS_D2C_BITS_MANAGER_H */