439e08cdc5c83b3e5835cb0435983f1da2ffbaf1Pavel Březina/*
439e08cdc5c83b3e5835cb0435983f1da2ffbaf1Pavel Březina Authors:
439e08cdc5c83b3e5835cb0435983f1da2ffbaf1Pavel Březina Pavel Březina <pbrezina@redhat.com>
439e08cdc5c83b3e5835cb0435983f1da2ffbaf1Pavel Březina
439e08cdc5c83b3e5835cb0435983f1da2ffbaf1Pavel Březina Copyright (C) 2016 Red Hat
439e08cdc5c83b3e5835cb0435983f1da2ffbaf1Pavel Březina
439e08cdc5c83b3e5835cb0435983f1da2ffbaf1Pavel Březina This program is free software; you can redistribute it and/or modify
439e08cdc5c83b3e5835cb0435983f1da2ffbaf1Pavel Březina it under the terms of the GNU General Public License as published by
439e08cdc5c83b3e5835cb0435983f1da2ffbaf1Pavel Březina the Free Software Foundation; either version 3 of the License, or
439e08cdc5c83b3e5835cb0435983f1da2ffbaf1Pavel Březina (at your option) any later version.
439e08cdc5c83b3e5835cb0435983f1da2ffbaf1Pavel Březina
439e08cdc5c83b3e5835cb0435983f1da2ffbaf1Pavel Březina This program is distributed in the hope that it will be useful,
439e08cdc5c83b3e5835cb0435983f1da2ffbaf1Pavel Březina but WITHOUT ANY WARRANTY; without even the implied warranty of
439e08cdc5c83b3e5835cb0435983f1da2ffbaf1Pavel Březina MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
439e08cdc5c83b3e5835cb0435983f1da2ffbaf1Pavel Březina GNU General Public License for more details.
439e08cdc5c83b3e5835cb0435983f1da2ffbaf1Pavel Březina
439e08cdc5c83b3e5835cb0435983f1da2ffbaf1Pavel Březina You should have received a copy of the GNU General Public License
439e08cdc5c83b3e5835cb0435983f1da2ffbaf1Pavel Březina along with this program. If not, see <http://www.gnu.org/licenses/>.
439e08cdc5c83b3e5835cb0435983f1da2ffbaf1Pavel Březina*/
439e08cdc5c83b3e5835cb0435983f1da2ffbaf1Pavel Březina
439e08cdc5c83b3e5835cb0435983f1da2ffbaf1Pavel Březina#ifndef SSSD_DBUS_UTILS_H_
439e08cdc5c83b3e5835cb0435983f1da2ffbaf1Pavel Březina#define SSSD_DBUS_UTILS_H_
439e08cdc5c83b3e5835cb0435983f1da2ffbaf1Pavel Březina
439e08cdc5c83b3e5835cb0435983f1da2ffbaf1Pavel Březinaerrno_t sbus_talloc_bound_message(TALLOC_CTX *mem_ctx, DBusMessage *msg);
439e08cdc5c83b3e5835cb0435983f1da2ffbaf1Pavel Březinaerrno_t sbus_error_to_errno(DBusError *error);
439e08cdc5c83b3e5835cb0435983f1da2ffbaf1Pavel Březinaerrno_t sbus_check_reply(DBusMessage *reply);
439e08cdc5c83b3e5835cb0435983f1da2ffbaf1Pavel Březina
0e7047c1533e5e424b28959488e8ffa91613abd9Jakub Hrozek/* Creates a DBusMessage from a vararg list. Please note that even though
0e7047c1533e5e424b28959488e8ffa91613abd9Jakub Hrozek * this function and sbus_create_message accept a talloc memory context,
0e7047c1533e5e424b28959488e8ffa91613abd9Jakub Hrozek * it is not valid to free the resulting message with talloc_free() directly.
0e7047c1533e5e424b28959488e8ffa91613abd9Jakub Hrozek * Instead, either free the parent memory context or directly call
0e7047c1533e5e424b28959488e8ffa91613abd9Jakub Hrozek * dbus_message_unref on the message if you pass NULL memory context to
0e7047c1533e5e424b28959488e8ffa91613abd9Jakub Hrozek * these functions
0e7047c1533e5e424b28959488e8ffa91613abd9Jakub Hrozek */
439e08cdc5c83b3e5835cb0435983f1da2ffbaf1Pavel BřezinaDBusMessage *sbus_create_message_valist(TALLOC_CTX *mem_ctx,
439e08cdc5c83b3e5835cb0435983f1da2ffbaf1Pavel Březina const char *bus,
439e08cdc5c83b3e5835cb0435983f1da2ffbaf1Pavel Březina const char *path,
439e08cdc5c83b3e5835cb0435983f1da2ffbaf1Pavel Březina const char *iface,
439e08cdc5c83b3e5835cb0435983f1da2ffbaf1Pavel Březina const char *method,
439e08cdc5c83b3e5835cb0435983f1da2ffbaf1Pavel Březina int first_arg_type,
439e08cdc5c83b3e5835cb0435983f1da2ffbaf1Pavel Březina va_list va);
439e08cdc5c83b3e5835cb0435983f1da2ffbaf1Pavel Březina
439e08cdc5c83b3e5835cb0435983f1da2ffbaf1Pavel BřezinaDBusMessage *_sbus_create_message(TALLOC_CTX *mem_ctx,
439e08cdc5c83b3e5835cb0435983f1da2ffbaf1Pavel Březina const char *bus,
439e08cdc5c83b3e5835cb0435983f1da2ffbaf1Pavel Březina const char *path,
439e08cdc5c83b3e5835cb0435983f1da2ffbaf1Pavel Březina const char *iface,
439e08cdc5c83b3e5835cb0435983f1da2ffbaf1Pavel Březina const char *method,
439e08cdc5c83b3e5835cb0435983f1da2ffbaf1Pavel Březina int first_arg_type,
439e08cdc5c83b3e5835cb0435983f1da2ffbaf1Pavel Březina ...);
439e08cdc5c83b3e5835cb0435983f1da2ffbaf1Pavel Březina
439e08cdc5c83b3e5835cb0435983f1da2ffbaf1Pavel Březina#define sbus_create_message(mem_ctx, bus, path, iface, method, ...) \
439e08cdc5c83b3e5835cb0435983f1da2ffbaf1Pavel Březina _sbus_create_message(mem_ctx, bus, path, iface, method, \
439e08cdc5c83b3e5835cb0435983f1da2ffbaf1Pavel Březina ##__VA_ARGS__, DBUS_TYPE_INVALID)
439e08cdc5c83b3e5835cb0435983f1da2ffbaf1Pavel Březina
439e08cdc5c83b3e5835cb0435983f1da2ffbaf1Pavel Březinaerrno_t sbus_parse_message_valist(DBusMessage *msg,
439e08cdc5c83b3e5835cb0435983f1da2ffbaf1Pavel Březina bool check_reply,
439e08cdc5c83b3e5835cb0435983f1da2ffbaf1Pavel Březina int first_arg_type,
439e08cdc5c83b3e5835cb0435983f1da2ffbaf1Pavel Březina va_list va);
439e08cdc5c83b3e5835cb0435983f1da2ffbaf1Pavel Březina
439e08cdc5c83b3e5835cb0435983f1da2ffbaf1Pavel Březinaerrno_t _sbus_parse_message(DBusMessage *msg,
439e08cdc5c83b3e5835cb0435983f1da2ffbaf1Pavel Březina bool check_reply,
439e08cdc5c83b3e5835cb0435983f1da2ffbaf1Pavel Březina int first_arg_type,
439e08cdc5c83b3e5835cb0435983f1da2ffbaf1Pavel Březina ...);
439e08cdc5c83b3e5835cb0435983f1da2ffbaf1Pavel Březina
439e08cdc5c83b3e5835cb0435983f1da2ffbaf1Pavel Březina#define sbus_parse_message(msg, ...) \
439e08cdc5c83b3e5835cb0435983f1da2ffbaf1Pavel Březina _sbus_parse_message(msg, false, ##__VA_ARGS__, DBUS_TYPE_INVALID)
439e08cdc5c83b3e5835cb0435983f1da2ffbaf1Pavel Březina
439e08cdc5c83b3e5835cb0435983f1da2ffbaf1Pavel Březina#define sbus_parse_reply(msg, ...) \
439e08cdc5c83b3e5835cb0435983f1da2ffbaf1Pavel Březina _sbus_parse_message(msg, true, ##__VA_ARGS__, DBUS_TYPE_INVALID)
439e08cdc5c83b3e5835cb0435983f1da2ffbaf1Pavel Březina
439e08cdc5c83b3e5835cb0435983f1da2ffbaf1Pavel Březina#endif /* SSSD_DBUS_UTILS_H_ */