diff options
author | Lennart Poettering <lennart@poettering.net> | 2013-10-09 02:37:10 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2013-10-09 02:40:07 +0200 |
commit | 29ddb38fea134c6132e4f2dd608e9da3871eaebe (patch) | |
tree | a3683f3d8064f37efe6d7bb9b454d8a8c81f38d5 /src/libsystemd-bus/bus-internal.c | |
parent | 8d1a28020409ee4afea6ef8c1c4d3522a209284e (diff) |
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.
Diffstat (limited to 'src/libsystemd-bus/bus-internal.c')
-rw-r--r-- | src/libsystemd-bus/bus-internal.c | 23 |
1 files changed, 23 insertions, 0 deletions
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; |