1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */ 24ddd3274SArnaldo Carvalho de Melo #ifndef _TOOLS_LINUX_STRING_H_ 34ddd3274SArnaldo Carvalho de Melo #define _TOOLS_LINUX_STRING_H_ 44ddd3274SArnaldo Carvalho de Melo 54ddd3274SArnaldo Carvalho de Melo #include <linux/types.h> /* for size_t */ 68e99b6d4SArnaldo Carvalho de Melo #include <string.h> 74ddd3274SArnaldo Carvalho de Melo 84ddd3274SArnaldo Carvalho de Melo void *memdup(const void *src, size_t len); 94ddd3274SArnaldo Carvalho de Melo 107d85c434SWang Nan int strtobool(const char *s, bool *res); 117d85c434SWang Nan 120215d59bSVineet Gupta /* 130215d59bSVineet Gupta * glibc based builds needs the extern while uClibc doesn't. 140215d59bSVineet Gupta * However uClibc headers also define __GLIBC__ hence the hack below 150215d59bSVineet Gupta */ 160215d59bSVineet Gupta #if defined(__GLIBC__) && !defined(__UCLIBC__) 17ce990917SJosh Poimboeuf extern size_t strlcpy(char *dest, const char *src, size_t size); 18ce990917SJosh Poimboeuf #endif 19ce990917SJosh Poimboeuf 20c8b5f2c9SArnaldo Carvalho de Melo char *str_error_r(int errnum, char *buf, size_t buflen); 21c8b5f2c9SArnaldo Carvalho de Melo 228e99b6d4SArnaldo Carvalho de Melo /** 238e99b6d4SArnaldo Carvalho de Melo * strstarts - does @str start with @prefix? 248e99b6d4SArnaldo Carvalho de Melo * @str: string to examine 258e99b6d4SArnaldo Carvalho de Melo * @prefix: prefix to look for. 268e99b6d4SArnaldo Carvalho de Melo */ 278e99b6d4SArnaldo Carvalho de Melo static inline bool strstarts(const char *str, const char *prefix) 288e99b6d4SArnaldo Carvalho de Melo { 298e99b6d4SArnaldo Carvalho de Melo return strncmp(str, prefix, strlen(prefix)) == 0; 308e99b6d4SArnaldo Carvalho de Melo } 3196395cbbSArnaldo Carvalho de Melo 327bd330deSArnaldo Carvalho de Melo extern char * __must_check skip_spaces(const char *); 337bd330deSArnaldo Carvalho de Melo 3445bfd0acSArnaldo Carvalho de Melo extern char *strim(char *); 3545bfd0acSArnaldo Carvalho de Melo 367bd330deSArnaldo Carvalho de Melo #endif /* _TOOLS_LINUX_STRING_H_ */ 37