-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhexdump.h
51 lines (44 loc) · 1.54 KB
/
hexdump.h
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
/*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License") 1.1!
* You may not use this file except in compliance with the License.
*
* See https://spdx.org/licenses/CDDL-1.1.html for the specific
* language governing permissions and limitations under the License.
*
* Copyright 2022 Jens Elkner ([email protected])
*/
/**
* @file hexdump.h
* Diagnostic utils.
*/
#ifndef IPMIMEX_HEXDUMP_H
#define IPMIMEX_HEXDUMP_H
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Hex dump the @data in chunks of 16 bytes.
* @param data Data to dump.
* @param dlen Number of bytes to dump.
* @param buf Where to store the dump.
* @param buflen Size of the @buf. If the size is \c < @dlen, remaining bytes
* are dropped.
* @param hex If \c 0, print offset in decimal, otherwise in hex.
* @return The number of characters written excluding the terminating '\0'.
*/
size_t bdump(const uint8_t *data, size_t dlen, char *buf, size_t buflen, int hex);
/**
* @brief Same as \c bdump() but uses an internal static 64 KiB buffer to
* store the result. The next call of this function overwrites the data in the
* buffer, so not thread-safe.
* @param data Data to dump.
* @param dlen Number of bytes to dump.
* @param hex If 0, print offset in decimal, otherwise in hex.
* @return A pointer to the static internal '\0' terminated result buffer.
*/
char *hexdump(const uint8_t *data, size_t dlen, int hex);
#ifdef __cplusplus
}
#endif
#endif // IPMIMEX_HEXDUMP_H