summaryrefslogtreecommitdiff
path: root/tools/d2c/conv/manager.h
blob: db6e325fe3f31411c141824a4fa7852177059077 (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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103

/* Chrysalide - Outil d'analyse de fichiers binaires
 * manager.h - prototypes pour les substitutions de valeurs depuis un contenu binaire
 *
 * Copyright (C) 2016-2017 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_CONV_MANAGER_H
#define _TOOLS_D2C_CONV_MANAGER_H


#include <stdbool.h>


#include "../pproc.h"
#include "../args/manager.h"
#include "../bits/manager.h"



/* ---------------------------- CONVERSION DES ARGUMENTS ---------------------------- */


/* Fonction de conversion */
typedef struct _conv_func conv_func;


/* Définit une conversion à partir d'une simple expression. */
conv_func *make_conv_from_expr(char *, arg_expr_t *);

/* Définit une conversion à partir d'une function à appeler. */
conv_func *make_conv_from_func(char *, char *, arg_list_t *);

/* Libère de la mémoire une conversion enregistrée. */
void delete_conv_func(conv_func *);

/* Indique la variable de destination d'une conversion. */
const char *get_conv_dest_name(const conv_func *);

/* Indique la nature d'une conversion : fonction ou expression ? */
bool is_conv_func_expression(const conv_func *);

/* Détermine la taille en bits du résultat d'une fonction. */
bool compute_conv_func_size(const conv_func *, const coding_bits *, const conv_list *, unsigned int *);

/* Marque les champs utilisés par une fonction de conversion. */
bool mark_conv_func(conv_func *, bool, const coding_bits *, const conv_list *);

/* Déclare les variables associées à une fonction de conversion. */
bool declare_conv_func(conv_func *, int, const coding_bits *, const conv_list *, const pre_processor *, unsigned int);

/* Indique si une conversion a déjà été définie. */
bool is_conv_func_already_defined(const conv_func *);

/* Définit les variables associées à une fonction de conversion. */
bool define_conv_func(conv_func *, bool, bool, int, const char *, const coding_bits *, const conv_list *, const pre_processor *, bool *);



/* ---------------------------- ENSEMBLES DE CONVERSIONS ---------------------------- */


/* Liste des fonctions de conversions présentes */
typedef struct _conv_list conv_list;


/* Crée un nouvelle liste vierge de fonctions de conversion. */
conv_list *create_conv_list(void);

/* Supprime de la mémoire une de fonctions de conversion. */
void delete_conv_list(conv_list *);

/* Enregistre une function de conversion du brut à l'utile. */
void register_conversion(conv_list *, conv_func *);

/* Recherche un résultat précis dans une liste de fonctions. */
conv_func *find_named_conv_in_list(const conv_list *, const char *);

/* Déclare l'ensemble des variables intermédiaires. */
bool declare_used_intermediate_conversions(const conv_list *, int, const coding_bits *, const pre_processor *, unsigned int);

/* Définit l'ensemble des variables intermédiaires. */
bool define_used_intermediate_conversions(const conv_list *, int, const char *, const coding_bits *, const pre_processor *, bool *);



#endif  /* _TOOLS_D2C_CONV_MANAGER_H */