From 04552566fa357d3029f06b66690dc28752522e10 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 6 May 2014 19:15:36 +0200 Subject: [PATCH] bus: add userdata API for bus name tracker objects --- src/libsystemd/libsystemd.sym.m4 | 2 ++ src/libsystemd/sd-bus/bus-track.c | 17 +++++++++++++++++ src/systemd/sd-bus.h | 3 +++ 3 files changed, 22 insertions(+) diff --git a/src/libsystemd/libsystemd.sym.m4 b/src/libsystemd/libsystemd.sym.m4 index d18d5767b02..14d9dcf9e92 100644 --- a/src/libsystemd/libsystemd.sym.m4 +++ b/src/libsystemd/libsystemd.sym.m4 @@ -331,6 +331,8 @@ m4_ifdef(`ENABLE_KDBUS', sd_bus_track_ref; sd_bus_track_unref; sd_bus_track_get_bus; + sd_bus_track_get_userdata; + sd_bus_track_set_userdata; sd_bus_track_add_sender; sd_bus_track_remove_sender; sd_bus_track_add_name; diff --git a/src/libsystemd/sd-bus/bus-track.c b/src/libsystemd/sd-bus/bus-track.c index e21959d01d0..0f6a2eafbdf 100644 --- a/src/libsystemd/sd-bus/bus-track.c +++ b/src/libsystemd/sd-bus/bus-track.c @@ -312,3 +312,20 @@ void bus_track_dispatch(sd_bus_track *track) { sd_bus_track_unref(track); } + +_public_ void *sd_bus_track_get_userdata(sd_bus_track *track) { + assert_return(track, NULL); + + return track->userdata; +} + +_public_ void *sd_bus_track_set_userdata(sd_bus_track *track, void *userdata) { + void *ret; + + assert_return(track, NULL); + + ret = track->userdata; + track->userdata = userdata; + + return ret; +} diff --git a/src/systemd/sd-bus.h b/src/systemd/sd-bus.h index ff2333fb4ab..c6787ca8094 100644 --- a/src/systemd/sd-bus.h +++ b/src/systemd/sd-bus.h @@ -358,7 +358,10 @@ int sd_bus_path_decode(const char *path, const char *prefix, char **ret_external int sd_bus_track_new(sd_bus *bus, sd_bus_track **track, sd_bus_track_handler_t handler, void *userdata); sd_bus_track* sd_bus_track_ref(sd_bus_track *track); sd_bus_track* sd_bus_track_unref(sd_bus_track *track); + sd_bus* sd_bus_track_get_bus(sd_bus_track *track); +void *sd_bus_track_get_userdata(sd_bus_track *track); +void *sd_bus_track_set_userdata(sd_bus_track *track, void *userdata); int sd_bus_track_add_sender(sd_bus_track *track, sd_bus_message *m); int sd_bus_track_remove_sender(sd_bus_track *track, sd_bus_message *m);