aboutsummaryrefslogtreecommitdiff
path: root/src/tools/perf/util/strfilter.h
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2015-02-18 18:53:26 -0800
committerElliott Hughes <enh@google.com>2015-02-18 18:53:26 -0800
commitc8ec03e66ee9fe1aefea9555b98aa5f5f7935d5c (patch)
treec74cd86bf0d537c9408f7d60ce6567239ca7ad8d /src/tools/perf/util/strfilter.h
parent9905f7e1a0a1530dfeaa239ffd2eb9e6cfff6ff5 (diff)
downloadlinux-tools-perf-c8ec03e66ee9fe1aefea9555b98aa5f5f7935d5c.tar.gz
Lose the version number from the directory name.
This way, next time we sync with upstream we'll have an actual diff to look at. Change-Id: I6474968f55ba42696c2ee894586d34f84f9f6630
Diffstat (limited to 'src/tools/perf/util/strfilter.h')
-rw-r--r--src/tools/perf/util/strfilter.h48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/tools/perf/util/strfilter.h b/src/tools/perf/util/strfilter.h
new file mode 100644
index 0000000..00f58a7
--- /dev/null
+++ b/src/tools/perf/util/strfilter.h
@@ -0,0 +1,48 @@
+#ifndef __PERF_STRFILTER_H
+#define __PERF_STRFILTER_H
+/* General purpose glob matching filter */
+
+#include <linux/list.h>
+#include <stdbool.h>
+
+/* A node of string filter */
+struct strfilter_node {
+ struct strfilter_node *l; /* Tree left branche (for &,|) */
+ struct strfilter_node *r; /* Tree right branche (for !,&,|) */
+ const char *p; /* Operator or rule */
+};
+
+/* String filter */
+struct strfilter {
+ struct strfilter_node *root;
+};
+
+/**
+ * strfilter__new - Create a new string filter
+ * @rules: Filter rule, which is a combination of glob expressions.
+ * @err: Pointer which points an error detected on @rules
+ *
+ * Parse @rules and return new strfilter. Return NULL if an error detected.
+ * In that case, *@err will indicate where it is detected, and *@err is NULL
+ * if a memory allocation is failed.
+ */
+struct strfilter *strfilter__new(const char *rules, const char **err);
+
+/**
+ * strfilter__compare - compare given string and a string filter
+ * @self: String filter
+ * @str: target string
+ *
+ * Compare @str and @self. Return true if the str match the rule
+ */
+bool strfilter__compare(struct strfilter *self, const char *str);
+
+/**
+ * strfilter__delete - delete a string filter
+ * @self: String filter to delete
+ *
+ * Delete @self.
+ */
+void strfilter__delete(struct strfilter *self);
+
+#endif