summaryrefslogtreecommitdiff
path: root/src/libsystemd-bus/bus-error.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-10-09 02:37:10 +0200
committerLennart Poettering <lennart@poettering.net>2013-10-09 02:40:07 +0200
commit29ddb38fea134c6132e4f2dd608e9da3871eaebe (patch)
treea3683f3d8064f37efe6d7bb9b454d8a8c81f38d5 /src/libsystemd-bus/bus-error.c
parent8d1a28020409ee4afea6ef8c1c4d3522a209284e (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-error.c')
-rw-r--r--src/libsystemd-bus/bus-error.c33
1 files changed, 29 insertions, 4 deletions
diff --git a/src/libsystemd-bus/bus-error.c b/src/libsystemd-bus/bus-error.c
index 4696a88f76..28fe15467f 100644
--- a/src/libsystemd-bus/bus-error.c
+++ b/src/libsystemd-bus/bus-error.c
@@ -51,7 +51,34 @@ void sd_bus_error_free(sd_bus_error *e) {
e->need_free = false;
}
-int sd_bus_error_set(sd_bus_error *e, const char *name, const char *format, ...) {
+int sd_bus_error_set(sd_bus_error *e, const char *name, const char *message) {
+ char *n, *m = NULL;
+
+ if (!e)
+ return 0;
+ if (bus_error_is_dirty(e))
+ return -EINVAL;
+ if (!name)
+ return -EINVAL;
+
+ n = strdup(name);
+ if (!n)
+ return -ENOMEM;
+
+ if (message) {
+ m = strdup(message);
+ if (!m)
+ return -ENOMEM;
+ }
+
+ e->name = n;
+ e->message = m;
+ e->need_free = true;
+
+ return 0;
+}
+
+int sd_bus_error_setf(sd_bus_error *e, const char *name, const char *format, ...) {
char *n, *m = NULL;
va_list ap;
int r;
@@ -119,9 +146,7 @@ void sd_bus_error_set_const(sd_bus_error *e, const char *name, const char *messa
if (bus_error_is_dirty(e))
return;
- e->name = name;
- e->message = message;
- e->need_free = false;
+ *e = SD_BUS_ERROR_MAKE(name, message);
}
int sd_bus_error_is_set(const sd_bus_error *e) {