blob: 5a30f2a86239153a8cacde3a2649e082da329b58 [file] [log] [blame]
James Bottomley3c9f3682008-08-31 10:13:54 -05001#ifndef _LINUX_STRING_HELPERS_H_
2#define _LINUX_STRING_HELPERS_H_
3
4#include <linux/types.h>
5
6/* Descriptions of the types of units to
7 * print in */
8enum string_size_units {
9 STRING_UNITS_10, /* use powers of 10^3 (standard SI) */
10 STRING_UNITS_2, /* use binary powers of 2^10 */
11};
12
13int string_get_size(u64 size, enum string_size_units units,
14 char *buf, int len);
15
Andy Shevchenko16c7fa02013-04-30 15:27:30 -070016#define UNESCAPE_SPACE 0x01
17#define UNESCAPE_OCTAL 0x02
18#define UNESCAPE_HEX 0x04
19#define UNESCAPE_SPECIAL 0x08
20#define UNESCAPE_ANY \
21 (UNESCAPE_SPACE | UNESCAPE_OCTAL | UNESCAPE_HEX | UNESCAPE_SPECIAL)
22
Andy Shevchenko16c7fa02013-04-30 15:27:30 -070023int string_unescape(char *src, char *dst, size_t size, unsigned int flags);
24
25static inline int string_unescape_inplace(char *buf, unsigned int flags)
26{
27 return string_unescape(buf, buf, 0, flags);
28}
29
30static inline int string_unescape_any(char *src, char *dst, size_t size)
31{
32 return string_unescape(src, dst, size, UNESCAPE_ANY);
33}
34
35static inline int string_unescape_any_inplace(char *buf)
36{
37 return string_unescape_any(buf, buf, 0);
38}
39
James Bottomley3c9f3682008-08-31 10:13:54 -050040#endif