xref: /linux/tools/perf/util/string2.h (revision 9a379e77033f02c4a071891afdf0f0a01eff8ccb)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef PERF_STRING_H
3 #define PERF_STRING_H
4 
5 #include <linux/types.h>
6 #include <stddef.h>
7 #include <string.h>
8 
9 s64 perf_atoll(const char *str);
10 char **argv_split(const char *str, int *argcp);
11 void argv_free(char **argv);
12 bool strglobmatch(const char *str, const char *pat);
13 bool strglobmatch_nocase(const char *str, const char *pat);
14 bool strlazymatch(const char *str, const char *pat);
15 static inline bool strisglob(const char *str)
16 {
17 	return strpbrk(str, "*?[") != NULL;
18 }
19 int strtailcmp(const char *s1, const char *s2);
20 char *strxfrchar(char *s, char from, char to);
21 
22 char *ltrim(char *s);
23 char *rtrim(char *s);
24 
25 static inline char *trim(char *s)
26 {
27 	return ltrim(rtrim(s));
28 }
29 
30 char *asprintf_expr_inout_ints(const char *var, bool in, size_t nints, int *ints);
31 
32 static inline char *asprintf_expr_in_ints(const char *var, size_t nints, int *ints)
33 {
34 	return asprintf_expr_inout_ints(var, true, nints, ints);
35 }
36 
37 static inline char *asprintf_expr_not_in_ints(const char *var, size_t nints, int *ints)
38 {
39 	return asprintf_expr_inout_ints(var, false, nints, ints);
40 }
41 
42 char *strpbrk_esc(char *str, const char *stopset);
43 char *strdup_esc(const char *str);
44 
45 #endif /* PERF_STRING_H */
46