From 29ddb38fea134c6132e4f2dd608e9da3871eaebe Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 9 Oct 2013 02:37:10 +0200 Subject: libsystemd-bus: add lightweight object vtable implementation for exposing objects on the bus This adds a lightweight scheme how to define interfaces in static fixed arrays which then can be easily registered on a bus connection. This makes it much easier to write bus services. This automatically handles implementation of the Properties, ObjectManager, and Introspection bus interfaces. --- src/libsystemd-bus/bus-internal.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/libsystemd-bus/bus-internal.c') diff --git a/src/libsystemd-bus/bus-internal.c b/src/libsystemd-bus/bus-internal.c index cac948e875..afff7bd7c1 100644 --- a/src/libsystemd-bus/bus-internal.c +++ b/src/libsystemd-bus/bus-internal.c @@ -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; -- cgit v1.2.3-54-g00ecf