chiark / gitweb /
bus: make sure sd_bus_get_timeout() returns a 0 timeout of there are already read...
[elogind.git] / src / libsystemd-bus / bus-internal.c
index 0e66f3d3553521b418308435d20b25107a044fcd..afff7bd7c1253a41c184709ff4d757159d24c2e5 100644 (file)
@@ -61,9 +61,32 @@ 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;
+        bool dot, found_dot = false;
 
         if (isempty(p))
                 return false;
@@ -103,7 +126,7 @@ bool interface_name_is_valid(const char *p) {
 
 bool service_name_is_valid(const char *p) {
         const char *q;
-        bool dot, found_dot, unique;
+        bool dot, found_dot = false, unique;
 
         if (isempty(p))
                 return false;