Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef _TOOLS_LINUX_STRING_H_
0003 #define _TOOLS_LINUX_STRING_H_
0004 
0005 #include <linux/types.h>    /* for size_t */
0006 #include <string.h>
0007 
0008 void *memdup(const void *src, size_t len);
0009 
0010 char **argv_split(const char *str, int *argcp);
0011 void argv_free(char **argv);
0012 
0013 int strtobool(const char *s, bool *res);
0014 
0015 /*
0016  * glibc based builds needs the extern while uClibc doesn't.
0017  * However uClibc headers also define __GLIBC__ hence the hack below
0018  */
0019 #if defined(__GLIBC__) && !defined(__UCLIBC__)
0020 // pragma diagnostic was introduced in gcc 4.6
0021 #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
0022 #pragma GCC diagnostic push
0023 #pragma GCC diagnostic ignored "-Wredundant-decls"
0024 #endif
0025 extern size_t strlcpy(char *dest, const char *src, size_t size);
0026 #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
0027 #pragma GCC diagnostic pop
0028 #endif
0029 #endif
0030 
0031 char *str_error_r(int errnum, char *buf, size_t buflen);
0032 
0033 char *strreplace(char *s, char old, char new);
0034 
0035 /**
0036  * strstarts - does @str start with @prefix?
0037  * @str: string to examine
0038  * @prefix: prefix to look for.
0039  */
0040 static inline bool strstarts(const char *str, const char *prefix)
0041 {
0042     return strncmp(str, prefix, strlen(prefix)) == 0;
0043 }
0044 
0045 extern char * __must_check skip_spaces(const char *);
0046 
0047 extern char *strim(char *);
0048 
0049 extern void *memchr_inv(const void *start, int c, size_t bytes);
0050 #endif /* _TOOLS_LINUX_STRING_H_ */