string2.h 1.2 KB

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