]> mj.ucw.cz Git - libucw.git/blob - ucw/fw-hex.h
Config: Added support for terabyte values, for example "123T".
[libucw.git] / ucw / fw-hex.h
1 /*
2  *      UCW Library -- I/O Wrapper for Hexadecimal Escaped Debugging Output
3  *
4  *      (c) 2015 Martin Mares <mj@ucw.cz>
5  *
6  *      This software may be freely distributed and used according to the terms
7  *      of the GNU Lesser General Public License.
8  */
9
10 #ifndef _UCW_FW_HEX_H
11 #define _UCW_FW_HEX_H
12
13 #include <ucw/fastbuf.h>
14
15 #ifdef CONFIG_UCW_CLEAN_ABI
16 #define fb_wrap_hex_in ucw_fb_wrap_hex_in
17 #define fb_wrap_hex_out ucw_fb_wrap_hex_out
18 #endif
19
20 /***
21  * When debugging a program, you might wonder what strange characters
22  * are there in the output, or you might want to spice up the input
23  * with Unicode snowmen to make the program freeze.
24  *
25  * In such situations, you can wrap your input or output stream in
26  * the hex wrapper, which converts between strange characters and their
27  * hexadecimal representation.
28  ***/
29
30 /**
31  * Creates an output hex wrapper for the given fastbuf. Printable ASCII
32  * characters written to the wrapper are copied verbatim to @f.
33  * Control characters, whitespace and everything outside ASCII
34  * are transcribed hexadecimally as `<XY>`. A newline is appended
35  * at the end of the output.
36  **/
37 struct fastbuf *fb_wrap_hex_out(struct fastbuf *f);
38
39 /**
40  * Creates an input hex wrapper for the given fastbuf. It reads characters
41  * from @f and translates hexadecimal sequences `<XY>`. All other characters
42  * are copied verbatim.
43  **/
44 struct fastbuf *fb_wrap_hex_in(struct fastbuf *f);
45
46 #endif