GNU Linux-libre 4.19.211-gnu1
[releases.git] / tools / perf / util / print_binary.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef PERF_PRINT_BINARY_H
3 #define PERF_PRINT_BINARY_H
4
5 #include <stddef.h>
6 #include <stdio.h>
7
8 enum binary_printer_ops {
9         BINARY_PRINT_DATA_BEGIN,
10         BINARY_PRINT_LINE_BEGIN,
11         BINARY_PRINT_ADDR,
12         BINARY_PRINT_NUM_DATA,
13         BINARY_PRINT_NUM_PAD,
14         BINARY_PRINT_SEP,
15         BINARY_PRINT_CHAR_DATA,
16         BINARY_PRINT_CHAR_PAD,
17         BINARY_PRINT_LINE_END,
18         BINARY_PRINT_DATA_END,
19 };
20
21 typedef int (*binary__fprintf_t)(enum binary_printer_ops op,
22                                  unsigned int val, void *extra, FILE *fp);
23
24 int binary__fprintf(unsigned char *data, size_t len,
25                     size_t bytes_per_line, binary__fprintf_t printer,
26                     void *extra, FILE *fp);
27
28 static inline void print_binary(unsigned char *data, size_t len,
29                                 size_t bytes_per_line, binary__fprintf_t printer,
30                                 void *extra)
31 {
32         binary__fprintf(data, len, bytes_per_line, printer, extra, stdout);
33 }
34
35 int is_printable_array(char *p, unsigned int len);
36
37 #endif /* PERF_PRINT_BINARY_H */