2017-11-01 15:07:57 +01:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
2015-11-16 11:36:29 -03:00
|
|
|
#ifndef _TOOLS_LINUX_STRING_H_
|
|
|
|
|
#define _TOOLS_LINUX_STRING_H_
|
|
|
|
|
|
|
|
|
|
#include <linux/types.h> /* for size_t */
|
2017-07-20 15:27:39 -03:00
|
|
|
#include <string.h>
|
2015-11-16 11:36:29 -03:00
|
|
|
|
|
|
|
|
void *memdup(const void *src, size_t len);
|
|
|
|
|
|
2019-06-26 15:27:58 -03:00
|
|
|
char **argv_split(const char *str, int *argcp);
|
|
|
|
|
void argv_free(char **argv);
|
|
|
|
|
|
2015-11-16 11:42:05 -03:00
|
|
|
int strtobool(const char *s, bool *res);
|
|
|
|
|
|
2016-08-18 09:28:23 -07:00
|
|
|
/*
|
|
|
|
|
* glibc based builds needs the extern while uClibc doesn't.
|
|
|
|
|
* However uClibc headers also define __GLIBC__ hence the hack below
|
|
|
|
|
*/
|
|
|
|
|
#if defined(__GLIBC__) && !defined(__UCLIBC__)
|
2019-12-24 20:20:29 +03:00
|
|
|
// pragma diagnostic was introduced in gcc 4.6
|
|
|
|
|
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
|
|
|
|
|
#pragma GCC diagnostic push
|
|
|
|
|
#pragma GCC diagnostic ignored "-Wredundant-decls"
|
|
|
|
|
#endif
|
2015-12-15 09:39:33 -06:00
|
|
|
extern size_t strlcpy(char *dest, const char *src, size_t size);
|
2019-12-24 20:20:29 +03:00
|
|
|
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
|
|
|
|
|
#pragma GCC diagnostic pop
|
|
|
|
|
#endif
|
2015-12-15 09:39:33 -06:00
|
|
|
#endif
|
|
|
|
|
|
2016-07-06 11:56:20 -03:00
|
|
|
char *str_error_r(int errnum, char *buf, size_t buflen);
|
|
|
|
|
|
2019-06-26 12:24:03 -03:00
|
|
|
char *strreplace(char *s, char old, char new);
|
|
|
|
|
|
2017-07-20 15:27:39 -03:00
|
|
|
/**
|
|
|
|
|
* strstarts - does @str start with @prefix?
|
|
|
|
|
* @str: string to examine
|
|
|
|
|
* @prefix: prefix to look for.
|
|
|
|
|
*/
|
|
|
|
|
static inline bool strstarts(const char *str, const char *prefix)
|
|
|
|
|
{
|
|
|
|
|
return strncmp(str, prefix, strlen(prefix)) == 0;
|
|
|
|
|
}
|
2017-04-26 15:49:21 -03:00
|
|
|
|
2019-06-25 21:23:18 -03:00
|
|
|
extern char * __must_check skip_spaces(const char *);
|
|
|
|
|
|
2019-06-26 11:50:16 -03:00
|
|
|
extern char *strim(char *);
|
|
|
|
|
|
2020-11-26 18:00:06 +01:00
|
|
|
extern void *memchr_inv(const void *start, int c, size_t bytes);
|
2019-06-25 21:23:18 -03:00
|
|
|
#endif /* _TOOLS_LINUX_STRING_H_ */
|