xref: /linux/tools/perf/util/string2.h (revision 9f3926e08c26607a0dd5b1bc8a8aa1d03f72fcdc)
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 extern const char *graph_dotted_line;
10 extern const char *dots;
11 
12 s64 perf_atoll(const char *str);
13 char **argv_split(const char *str, int *argcp);
14 void argv_free(char **argv);
15 bool strglobmatch(const char *str, const char *pat);
16 bool strglobmatch_nocase(const char *str, const char *pat);
17 bool strlazymatch(const char *str, const char *pat);
18 static inline bool strisglob(const char *str)
19 {
20 	return strpbrk(str, "*?[") != NULL;
21 }
22 int strtailcmp(const char *s1, const char *s2);
23 char *strxfrchar(char *s, char from, char to);
24 
25 char *ltrim(char *s);
26 char *rtrim(char *s);
27 
28 static inline char *trim(char *s)
29 {
30 	return ltrim(rtrim(s));
31 }
32 
33 char *asprintf_expr_inout_ints(const char *var, bool in, size_t nints, int *ints);
34 
35 static inline char *asprintf_expr_in_ints(const char *var, size_t nints, int *ints)
36 {
37 	return asprintf_expr_inout_ints(var, true, nints, ints);
38 }
39 
40 static inline char *asprintf_expr_not_in_ints(const char *var, size_t nints, int *ints)
41 {
42 	return asprintf_expr_inout_ints(var, false, nints, ints);
43 }
44 
45 char *strpbrk_esc(char *str, const char *stopset);
46 char *strdup_esc(const char *str);
47 
48 #endif /* PERF_STRING_H */
49