chiark / gitweb /
bus-proxy: whenever we cannot forward a message, report this back to caller, but...
[elogind.git] / src / bus-proxyd / synthesize.c
index 36ffe2930e94a722941c8bfbab210ebb894049b7..e1b0fd35354b3fccb94fac59d1e846134069088c 100644 (file)
@@ -83,7 +83,6 @@ int synthetic_reply_method_errorf(sd_bus_message *call, const char *name, const
 }
 
 int synthetic_reply_method_errno(sd_bus_message *call, int error, const sd_bus_error *p) {
-
         _cleanup_bus_error_free_ sd_bus_error berror = SD_BUS_ERROR_NULL;
 
         assert(call);
@@ -99,6 +98,22 @@ int synthetic_reply_method_errno(sd_bus_message *call, int error, const sd_bus_e
         return synthetic_reply_method_error(call, &berror);
 }
 
+int synthetic_reply_method_errnof(sd_bus_message *call, int error, const char *format, ...) {
+        _cleanup_bus_error_free_ sd_bus_error berror = SD_BUS_ERROR_NULL;
+        va_list ap;
+
+        assert(call);
+
+        if (call->header->flags & BUS_MESSAGE_NO_REPLY_EXPECTED)
+                return 0;
+
+        va_start(ap, format);
+        sd_bus_error_set_errnofv(&berror, error, format, ap);
+        va_end(ap);
+
+        return synthetic_reply_method_error(call, &berror);
+}
+
 int synthetic_reply_method_return(sd_bus_message *call, const char *types, ...) {
         _cleanup_bus_message_unref_ sd_bus_message *m = NULL;
         int r;