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
|
/* Chrysalide - Outil d'analyse de fichiers binaires
* utils.h - prototypes pour les fonctions qui simplifient la vie dans les interactions avec un serveur GDB
*
* Copyright (C) 2016 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 _DEBUG_GDBRSP_UTILS_H
#define _DEBUG_GDBRSP_UTILS_H
#include <stdbool.h>
#include <stdint.h>
#include <sys/types.h>
/* Indique si les données correspondent à un code d'erreur. */
bool is_error_code(const char *, size_t);
/* Relit une valeur sur 8 bits et deux lettres. */
bool read_fixed_byte(const char *, size_t, uint8_t *);
/* Traduit en valeur sur XX bits une forme textuelle. */
bool hex_to_any_u(const char *, size_t, ...);
#define hex_to_u8(h, v) hex_to_any_u(h, 1, v)
#define hex_to_u16(h, v) hex_to_any_u(h, 2, v)
#define hex_to_u32(h, v) hex_to_any_u(h, 4, v)
#define hex_to_u64(h, v) hex_to_any_u(h, 8, v)
/* Traduit une valeur sur XX bits en forme textuelle. */
bool any_u_to_hex(size_t, char [17], ...);
#define u8_to_hex(v, h) any_u_to_hex(1, h, v)
#define u16_to_hex(v, h) any_u_to_hex(2, h, v)
#define u32_to_hex(v, h) any_u_to_hex(4, h, v)
#define u64_to_hex(v, h) any_u_to_hex(8, h, v)
#endif /* _DEBUG_GDBRSP_UTILS_H */
|