Linux 4.14-rc6
[linux-2.6-block.git] / tools / include / linux / string.h
CommitLineData
4ddd3274
ACM
1#ifndef _TOOLS_LINUX_STRING_H_
2#define _TOOLS_LINUX_STRING_H_
3
4ddd3274 4#include <linux/types.h> /* for size_t */
8e99b6d4 5#include <string.h>
4ddd3274
ACM
6
7void *memdup(const void *src, size_t len);
8
7d85c434
WN
9int strtobool(const char *s, bool *res);
10
0215d59b
VG
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__)
ce990917
JP
16extern size_t strlcpy(char *dest, const char *src, size_t size);
17#endif
18
c8b5f2c9
ACM
19char *str_error_r(int errnum, char *buf, size_t buflen);
20
8e99b6d4
ACM
21/**
22 * strstarts - does @str start with @prefix?
23 * @str: string to examine
24 * @prefix: prefix to look for.
25 */
26static inline bool strstarts(const char *str, const char *prefix)
27{
28 return strncmp(str, prefix, strlen(prefix)) == 0;
29}
96395cbb 30
4ddd3274 31#endif /* _LINUX_STRING_H_ */