summaryrefslogtreecommitdiff
path: root/src/format/dbg_format.c
blob: 3a36049c43f9e2eab5465a20d6e90c9168dfd16b (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

/* Chrysalide - Outil d'analyse de fichiers binaires
 * dbg_format.c - support des formats de débogage
 *
 * Copyright (C) 2008 Cyrille Bagard
 *
 *  This file is part of Chrysalide.
 *
 *  OpenIDA 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.
 *
 *  OpenIDA 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/>.
 */


#include "dbg_format.h"


#include <malloc.h>



/* liste de tous les formats de débogage enregistrés */
typedef struct _dbg_formats
{
    dbg_format **list;                      /* Série d'éléments            */
    size_t count;                           /* Nombre de ces éléments      */

} dbg_formats;


/* Fournit la liste des formats de débogage enregistrés. */
dbg_formats *get_debug_formats(void);



/******************************************************************************
*                                                                             *
*  Paramètres  : -                                                            *
*                                                                             *
*  Description : Fournit la liste des formats de débogage enregistrés.        *
*                                                                             *
*  Retour      : Liste des formats enregistrés.                               *
*                                                                             *
*  Remarques   : -                                                            *
*                                                                             *
******************************************************************************/

dbg_formats *get_debug_formats(void)
{
    static dbg_formats *result = NULL;      /* Liste à retourner           */

    if (result == NULL)
        result = (dbg_formats *)calloc(1, sizeof(dbg_formats));

    return result;

}


/******************************************************************************
*                                                                             *
*  Paramètres  : format = nouvel élément à inscrire dans l'ensemble.          *
*                                                                             *
*  Description : Ajoute un nouveau format de débogage à la liste supportée.   *
*                                                                             *
*  Retour      : -                                                            *
*                                                                             *
*  Remarques   : -                                                            *
*                                                                             *
******************************************************************************/

void register_debug_format(dbg_format *format)
{
    dbg_formats *formats;                   /* Liste à compléter           */

    formats = get_debug_formats();

    formats->list = (dbg_format **)realloc(formats->list, ++formats->count * sizeof(dbg_format *));
    formats->list[formats->count - 1] = format;

}