]> err.no Git - systemd/commitdiff
util: add chars_intersect() call
authorLennart Poettering <lennart@poettering.net>
Wed, 7 Apr 2010 18:27:19 +0000 (20:27 +0200)
committerLennart Poettering <lennart@poettering.net>
Wed, 7 Apr 2010 18:27:19 +0000 (20:27 +0200)
util.c
util.h

diff --git a/util.c b/util.c
index 939b2b06e9ddb2da442f688e30a596ed449b6837..a0f26762dc39b87b3f6cb3c24acb50db14849512 100644 (file)
--- a/util.c
+++ b/util.c
@@ -1193,6 +1193,17 @@ finish:
         return r;
 }
 
+bool chars_intersect(const char *a, const char *b) {
+        const char *p;
+
+        /* Returns true if any of the chars in a are in b. */
+        for (p = a; *p; p++)
+                if (strchr(b, *p))
+                        return true;
+
+        return false;
+}
+
 static const char *const ioprio_class_table[] = {
         [IOPRIO_CLASS_NONE] = "none",
         [IOPRIO_CLASS_RT] = "realtime",
diff --git a/util.h b/util.h
index 3ee536add5694f572cd29eb05c31042007cde808..14f1a7a177d9b7a677b942d46c6ccccf6bf29cab 100644 (file)
--- a/util.h
+++ b/util.h
@@ -157,6 +157,8 @@ char *bus_path_unescape(const char *s);
 
 bool ignore_file(const char *filename);
 
+bool chars_intersect(const char *a, const char *b);
+
 #define DEFINE_STRING_TABLE_LOOKUP(name,type)                           \
         const char *name##_to_string(type i) {                          \
                 if (i < 0 || i >= (type) ELEMENTSOF(name##_table))      \