shared/bus-util: move string set append/get funcs to bus-message-util and bus-get-properties, respectively
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
#include "bpf-firewall.h"
|
||||
#include "bpf-foreign.h"
|
||||
#include "bus-get-properties.h"
|
||||
#include "bus-message-util.h"
|
||||
#include "bus-util.h"
|
||||
#include "cgroup-util.h"
|
||||
#include "cgroup.h"
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
|
||||
#include "bus-get-properties.h"
|
||||
#include "bus-message-util.h"
|
||||
#include "rlimit-util.h"
|
||||
#include "stdio-util.h"
|
||||
#include "string-util.h"
|
||||
@@ -164,3 +165,21 @@ int bus_property_get_rlimit(
|
||||
|
||||
return sd_bus_message_append(reply, "t", u);
|
||||
}
|
||||
|
||||
int bus_property_get_string_set(
|
||||
sd_bus *bus,
|
||||
const char *path,
|
||||
const char *interface,
|
||||
const char *property,
|
||||
sd_bus_message *reply,
|
||||
void *userdata,
|
||||
sd_bus_error *error) {
|
||||
|
||||
Set **s = ASSERT_PTR(userdata);
|
||||
|
||||
assert(bus);
|
||||
assert(property);
|
||||
assert(reply);
|
||||
|
||||
return bus_message_append_string_set(reply, *s);
|
||||
}
|
||||
|
||||
@@ -52,6 +52,8 @@ assert_cc(sizeof(mode_t) == sizeof(uint32_t));
|
||||
|
||||
int bus_property_get_rlimit(sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *reply, void *userdata, sd_bus_error *error);
|
||||
|
||||
int bus_property_get_string_set(sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *reply, void *userdata, sd_bus_error *error);
|
||||
|
||||
#define BUS_DEFINE_PROPERTY_GET_GLOBAL(function, bus_type, val) \
|
||||
int function(sd_bus *bus, \
|
||||
const char *path, \
|
||||
|
||||
@@ -216,6 +216,25 @@ clear:
|
||||
return r;
|
||||
}
|
||||
|
||||
int bus_message_append_string_set(sd_bus_message *m, const Set *set) {
|
||||
int r;
|
||||
|
||||
assert(m);
|
||||
|
||||
r = sd_bus_message_open_container(m, 'a', "s");
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
const char *s;
|
||||
SET_FOREACH(s, set) {
|
||||
r = sd_bus_message_append(m, "s", s);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
|
||||
return sd_bus_message_close_container(m);
|
||||
}
|
||||
|
||||
int bus_message_dump_string(sd_bus_message *message) {
|
||||
const char *s;
|
||||
int r;
|
||||
|
||||
@@ -19,6 +19,8 @@ int bus_message_read_dns_servers(
|
||||
struct in_addr_full ***ret_dns,
|
||||
size_t *ret_n_dns);
|
||||
|
||||
int bus_message_append_string_set(sd_bus_message *m, const Set *s);
|
||||
|
||||
int bus_message_dump_string(sd_bus_message *message);
|
||||
int bus_message_dump_fd(sd_bus_message *message);
|
||||
|
||||
|
||||
@@ -862,43 +862,6 @@ int bus_register_malloc_status(sd_bus *bus, const char *destination) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bus_message_append_string_set(sd_bus_message *m, Set *set) {
|
||||
const char *s;
|
||||
int r;
|
||||
|
||||
assert(m);
|
||||
|
||||
r = sd_bus_message_open_container(m, 'a', "s");
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
SET_FOREACH(s, set) {
|
||||
r = sd_bus_message_append(m, "s", s);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
|
||||
return sd_bus_message_close_container(m);
|
||||
}
|
||||
|
||||
int bus_property_get_string_set(
|
||||
sd_bus *bus,
|
||||
const char *path,
|
||||
const char *interface,
|
||||
const char *property,
|
||||
sd_bus_message *reply,
|
||||
void *userdata,
|
||||
sd_bus_error *error) {
|
||||
|
||||
Set **s = ASSERT_PTR(userdata);
|
||||
|
||||
assert(bus);
|
||||
assert(property);
|
||||
assert(reply);
|
||||
|
||||
return bus_message_append_string_set(reply, *s);
|
||||
}
|
||||
|
||||
int bus_creds_get_pidref(
|
||||
sd_bus_creds *c,
|
||||
PidRef *ret) {
|
||||
|
||||
@@ -78,10 +78,6 @@ int bus_reply_pair_array(sd_bus_message *m, char **l);
|
||||
/* Listen to GetMallocInfo() calls to 'destination' and return malloc_info() via FD */
|
||||
int bus_register_malloc_status(sd_bus *bus, const char *destination);
|
||||
|
||||
int bus_message_append_string_set(sd_bus_message *m, Set *s);
|
||||
|
||||
int bus_property_get_string_set(sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *reply, void *userdata, sd_bus_error *error);
|
||||
|
||||
int bus_creds_get_pidref(sd_bus_creds *c, PidRef *ret);
|
||||
int bus_query_sender_pidref(sd_bus_message *m, PidRef *ret);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user