Arnaldo Carvalho de Melo | 4ddd327 | 2015-11-16 11:36:29 -0300 | [diff] [blame] | 1 | #ifndef _TOOLS_LINUX_STRING_H_ |
| 2 | #define _TOOLS_LINUX_STRING_H_ |
| 3 | |
Arnaldo Carvalho de Melo | 4ddd327 | 2015-11-16 11:36:29 -0300 | [diff] [blame] | 4 | #include <linux/types.h> /* for size_t */ |
Arnaldo Carvalho de Melo | 8e99b6d | 2017-07-20 15:27:39 -0300 | [diff] [blame^] | 5 | #include <string.h> |
Arnaldo Carvalho de Melo | 4ddd327 | 2015-11-16 11:36:29 -0300 | [diff] [blame] | 6 | |
| 7 | void *memdup(const void *src, size_t len); |
| 8 | |
Wang Nan | 7d85c43 | 2015-11-16 11:42:05 -0300 | [diff] [blame] | 9 | int strtobool(const char *s, bool *res); |
| 10 | |
Vineet Gupta | 0215d59 | 2016-08-18 09:28:23 -0700 | [diff] [blame] | 11 | /* |
| 12 | * glibc based builds needs the extern while uClibc doesn't. |
| 13 | * However uClibc headers also define __GLIBC__ hence the hack below |
| 14 | */ |
| 15 | #if defined(__GLIBC__) && !defined(__UCLIBC__) |
Josh Poimboeuf | ce99091 | 2015-12-15 09:39:33 -0600 | [diff] [blame] | 16 | extern size_t strlcpy(char *dest, const char *src, size_t size); |
| 17 | #endif |
| 18 | |
Arnaldo Carvalho de Melo | c8b5f2c | 2016-07-06 11:56:20 -0300 | [diff] [blame] | 19 | char *str_error_r(int errnum, char *buf, size_t buflen); |
| 20 | |
Arnaldo Carvalho de Melo | 8e99b6d | 2017-07-20 15:27:39 -0300 | [diff] [blame^] | 21 | /** |
| 22 | * strstarts - does @str start with @prefix? |
| 23 | * @str: string to examine |
| 24 | * @prefix: prefix to look for. |
| 25 | */ |
| 26 | static inline bool strstarts(const char *str, const char *prefix) |
| 27 | { |
| 28 | return strncmp(str, prefix, strlen(prefix)) == 0; |
| 29 | } |
Arnaldo Carvalho de Melo | 96395cb | 2017-04-26 15:49:21 -0300 | [diff] [blame] | 30 | |
Arnaldo Carvalho de Melo | 4ddd327 | 2015-11-16 11:36:29 -0300 | [diff] [blame] | 31 | #endif /* _LINUX_STRING_H_ */ |