summaryrefslogtreecommitdiff
path: root/src/systemd
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2014-10-30 20:31:48 -0400
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2014-10-30 20:31:48 -0400
commit4a0a74179fcfb85c456794fd91fa2ae5d4d3bc8f (patch)
tree7aa0256e5790c60df2bd945099550b60bd19435c /src/systemd
parente1323fbfbe8a574f28b704f2df8ce7f99e3a28f5 (diff)
bus: add sd_bus_errnomap section
This allows custom "name" ↔ errno mappings to be registered. Tables from all compilation units are concatenated.
Diffstat (limited to 'src/systemd')
-rw-r--r--src/systemd/sd-bus.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/systemd/sd-bus.h b/src/systemd/sd-bus.h
index 18acfc2ad..c95b5e7ab 100644
--- a/src/systemd/sd-bus.h
+++ b/src/systemd/sd-bus.h
@@ -326,8 +326,21 @@ int sd_bus_creds_get_connection_name(sd_bus_creds *c, const char **name);
/* Error structures */
+struct sd_bus_name_error_mapping {
+ const char* name;
+ int code;
+};
+typedef struct sd_bus_name_error_mapping sd_bus_name_error_mapping;
+
#define SD_BUS_ERROR_MAKE_CONST(name, message) ((const sd_bus_error) {(name), (message), 0})
#define SD_BUS_ERROR_NULL SD_BUS_ERROR_MAKE_CONST(NULL, NULL)
+#ifndef SD_BUS_ERROR_MAPPING
+# define _SD_BUS_ERROR_XCONCAT(x, y) x ## y
+# define _SD_BUS_ERROR_CONCAT(x, y) _SD_BUS_ERROR_XCONCAT(x, y)
+# define SD_BUS_ERROR_MAPPING \
+ __attribute((__section__("sd_bus_errnomap"))) __attribute((__used__)) \
+ static const sd_bus_name_error_mapping _SD_BUS_ERROR_CONCAT(_sd_bus_errno_mapping_, __COUNTER__)[]
+#endif
void sd_bus_error_free(sd_bus_error *e);
int sd_bus_error_set(sd_bus_error *e, const char *name, const char *message);