xref: /openbmc/linux/tools/include/linux/string.h (revision b3e45327)
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 
109c10548cSArnaldo Carvalho de Melo char **argv_split(const char *str, int *argcp);
119c10548cSArnaldo Carvalho de Melo void argv_free(char **argv);
129c10548cSArnaldo Carvalho de Melo 
137d85c434SWang Nan int strtobool(const char *s, bool *res);
147d85c434SWang Nan 
150215d59bSVineet Gupta /*
160215d59bSVineet Gupta  * glibc based builds needs the extern while uClibc doesn't.
170215d59bSVineet Gupta  * However uClibc headers also define __GLIBC__ hence the hack below
180215d59bSVineet Gupta  */
190215d59bSVineet Gupta #if defined(__GLIBC__) && !defined(__UCLIBC__)
206c4798d3SVitaly Chikunov // pragma diagnostic was introduced in gcc 4.6
216c4798d3SVitaly Chikunov #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
226c4798d3SVitaly Chikunov #pragma GCC diagnostic push
236c4798d3SVitaly Chikunov #pragma GCC diagnostic ignored "-Wredundant-decls"
246c4798d3SVitaly Chikunov #endif
25ce990917SJosh Poimboeuf extern size_t strlcpy(char *dest, const char *src, size_t size);
266c4798d3SVitaly Chikunov #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
276c4798d3SVitaly Chikunov #pragma GCC diagnostic pop
286c4798d3SVitaly Chikunov #endif
29ce990917SJosh Poimboeuf #endif
30ce990917SJosh Poimboeuf 
31c8b5f2c9SArnaldo Carvalho de Melo char *str_error_r(int errnum, char *buf, size_t buflen);
32c8b5f2c9SArnaldo Carvalho de Melo 
332a60689aSArnaldo Carvalho de Melo char *strreplace(char *s, char old, char new);
342a60689aSArnaldo Carvalho de Melo 
358e99b6d4SArnaldo Carvalho de Melo /**
368e99b6d4SArnaldo Carvalho de Melo  * strstarts - does @str start with @prefix?
378e99b6d4SArnaldo Carvalho de Melo  * @str: string to examine
388e99b6d4SArnaldo Carvalho de Melo  * @prefix: prefix to look for.
398e99b6d4SArnaldo Carvalho de Melo  */
strstarts(const char * str,const char * prefix)408e99b6d4SArnaldo Carvalho de Melo static inline bool strstarts(const char *str, const char *prefix)
418e99b6d4SArnaldo Carvalho de Melo {
428e99b6d4SArnaldo Carvalho de Melo 	return strncmp(str, prefix, strlen(prefix)) == 0;
438e99b6d4SArnaldo Carvalho de Melo }
4496395cbbSArnaldo Carvalho de Melo 
457bd330deSArnaldo Carvalho de Melo extern char * __must_check skip_spaces(const char *);
467bd330deSArnaldo Carvalho de Melo 
4745bfd0acSArnaldo Carvalho de Melo extern char *strim(char *);
4845bfd0acSArnaldo Carvalho de Melo 
49*b3e45327SJiri Olsa extern void *memchr_inv(const void *start, int c, size_t bytes);
507bd330deSArnaldo Carvalho de Melo #endif /* _TOOLS_LINUX_STRING_H_ */
51