chiark / gitweb /
Prep v221: Update and clean up build system to sync with upstream
[elogind.git] / src / libelogind / sd-bus / bus-internal.c
index 37793e48edb03a5dbdad94028a2d45343700f25b..8bc2a14bf0f819e47d20ec9929f71237079bf840 100644 (file)
@@ -19,6 +19,7 @@
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
 ***/
 
+#include "bus-message.h"
 #include "bus-internal.h"
 
 bool object_path_is_valid(const char *p) {
@@ -166,6 +167,8 @@ bool service_name_is_valid(const char *p) {
         return true;
 }
 
+/// UNNEEDED by elogind
+#if 0
 char* service_name_startswith(const char *a, const char *b) {
         const char *p;
 
@@ -185,6 +188,7 @@ char* service_name_startswith(const char *a, const char *b) {
 
         return NULL;
 }
+#endif // 0
 
 bool member_name_is_valid(const char *p) {
         const char *q;
@@ -345,3 +349,28 @@ char *bus_address_escape(const char *v) {
         *b = 0;
         return r;
 }
+
+int bus_maybe_reply_error(sd_bus_message *m, int r, sd_bus_error *error) {
+        assert(m);
+
+        if (r < 0) {
+                if (m->header->type == SD_BUS_MESSAGE_METHOD_CALL)
+                        sd_bus_reply_method_errno(m, r, error);
+
+        } else if (sd_bus_error_is_set(error)) {
+                if (m->header->type == SD_BUS_MESSAGE_METHOD_CALL)
+                        sd_bus_reply_method_error(m, error);
+        } else
+                return r;
+
+        log_debug("Failed to process message [type=%s sender=%s path=%s interface=%s member=%s signature=%s]: %s",
+                  bus_message_type_to_string(m->header->type),
+                  strna(m->sender),
+                  strna(m->path),
+                  strna(m->interface),
+                  strna(m->member),
+                  strna(m->root_container.signature),
+                  bus_error_message(error, r));
+
+        return 1;
+}