The friendly Operating System for the Internet of Things
od.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2014 Martine Lenders <mlenders@inf.fu-berlin.de>
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
27 #ifndef OD_H
28 #define OD_H
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 #include <stdint.h>
35 
39 #define OD_FLAGS_ADDRESS_MASK (0xc000)
40 
44 #define OD_FLAGS_BYTES_MASK (0x3e00)
45 
49 #define OD_FLAGS_LENGTH_MASK (0x00f7)
50 
57 #define OD_FLAGS_ADDRESS_OCTAL (0x0000)
58 #define OD_FLAGS_ADDRESS_HEX (0x4000)
59 #define OD_FLAGS_ADDRESS_DECIMAL (0x8000)
60 #define OD_FLAGS_ADDRESS_NONE (0xc000)
73 #define OD_FLAGS_BYTES_OCTAL (0x0000)
74 
78 #define OD_FLAGS_BYTES_CHAR (0x2000)
79 
84 #define OD_FLAGS_BYTES_INT (0x1000)
85 
89 #define OD_FLAGS_BYTES_DECIMAL (OD_FLAGS_BYTES_INT)
90 
91 /* XXX: No float support for now, but reserved 0x0800 for this */
92 
97 #define OD_FLAGS_BYTES_UINT (0x0400)
98 
103 #define OD_FLAGS_BYTES_HEX (0x0200)
104 
114 #define OD_FLAGS_LENGTH_1 (0x0010)
115 #define OD_FLAGS_LENGTH_2 (0x0020)
116 #define OD_FLAGS_LENGTH_4 (0x0000)
122 #define OD_FLAGS_LENGTH_8 (0x0080)
123 #define OD_FLAGS_LENGTH_CHAR (OD_FLAGS_LENGTH_1)
124 #define OD_FLAGS_LENGTH_SHORT (0x0002)
125 #define OD_FLAGS_LENGTH_LONG (0x0004)
131 #define OD_WIDTH_DEFAULT (16)
132 
144 void od(const void *data, size_t data_len, uint8_t width, uint16_t flags);
145 
156 static inline void od_hex_dump(const void *data, size_t data_len, uint8_t width)
157 {
158  od(data, data_len, width, OD_FLAGS_ADDRESS_HEX | OD_FLAGS_BYTES_HEX | OD_FLAGS_LENGTH_1);
159 }
160 
161 #ifdef __cplusplus
162 }
163 #endif
164 
165 #endif /* OD_H */
166 
#define OD_FLAGS_ADDRESS_HEX
hexadecimal address offset
Definition: od.h:58
static void od_hex_dump(const void *data, size_t data_len, uint8_t width)
Dumps memory stored at data up to data_len in octal, decimal, or hexadecimal representation to stdout...
Definition: od.h:156
void od(const void *data, size_t data_len, uint8_t width, uint16_t flags)
Dumps memory stored at data up to data_len in octal, decimal, or hexadecimal representation to stdout...
#define OD_FLAGS_BYTES_HEX
Print LENGTH bytes as LENGTH-wide hexadecimal integer (LENGTH is defined in the lower significant byt...
Definition: od.h:103
#define OD_FLAGS_LENGTH_1
1 byte
Definition: od.h:114