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