chiark / gitweb /
libsystemd-bus: add lightweight object vtable implementation for exposing objects...
[elogind.git] / src / libsystemd-bus / bus-internal.c
index cac948e875df4f97a7732b742e6098f20bb54b98..afff7bd7c1253a41c184709ff4d757159d24c2e5 100644 (file)
@@ -61,6 +61,29 @@ bool object_path_is_valid(const char *p) {
         return true;
 }
 
+char* object_path_startswith(const char *a, const char *b) {
+        const char *p;
+
+        if (!object_path_is_valid(a) ||
+            !object_path_is_valid(b))
+                return NULL;
+
+        if (streq(b, "/"))
+                return (char*) a + 1;
+
+        p = startswith(a, b);
+        if (!p)
+                return NULL;
+
+        if (*p == 0)
+                return (char*) p;
+
+        if (*p == '/')
+                return (char*) p + 1;
+
+        return NULL;
+}
+
 bool interface_name_is_valid(const char *p) {
         const char *q;
         bool dot, found_dot = false;