#pragma once
/***
This file is part of systemd.
Copyright 2013 Lennart Poettering
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <pthread.h>
#include "sd-bus.h"
#include "bus-error.h"
#include "bus-kernel.h"
#include "bus-match.h"
#include "hashmap.h"
#include "kdbus.h"
#include "list.h"
#include "prioq.h"
#include "refcnt.h"
#include "socket-util.h"
#include "util.h"
struct reply_callback {
unsigned prioq_idx;
};
struct filter_callback {
unsigned last_iteration;
};
struct match_callback {
unsigned last_iteration;
char *match_string;
};
struct node {
char *path;
};
struct node_callback {
bool is_fallback;
unsigned last_iteration;
};
struct node_enumerator {
unsigned last_iteration;
};
struct node_object_manager {
};
struct node_vtable {
char *interface;
bool is_fallback;
unsigned last_iteration;
};
struct vtable_member {
const char *path;
const char *interface;
const char *member;
unsigned last_iteration;
};
typedef enum BusSlotType {
} BusSlotType;
struct sd_bus_slot {
unsigned n_ref;
void *userdata;
char *description;
union {
};
};
enum bus_state {
};
}
enum bus_auth {
};
struct sd_bus {
/* We use atomic ref counting here since sd_bus_message
objects retain references to their originating sd_bus but
we want to allow them to be processed in a different
thread. We won't provide full thread safety, but only the
bare minimum that makes it possible to use sd_bus and
sd_bus_message objects independently and on different
threads as long as each object is used only once at the
same time. */
int message_version;
int message_endian;
int use_memfd;
void *rbuffer;
unsigned rqueue_size;
unsigned wqueue_size;
char *unique_name;
char *kernel;
char *machine;
char *address;
unsigned address_index;
int last_connect_error;
unsigned auth_index;
char *auth_buffer;
char *label;
int *fds;
unsigned n_fds;
char *exec_path;
char **exec_argv;
unsigned iteration_counter;
void *kdbus_buffer;
/* We do locking around the memfd cache, since we want to
* allow people to process a sd_bus_message in a different
* thread then it was generated on and free it there. Since
* adding something to the memfd cache might happen when a
* message is released, we hence need to protect this bit with
* a mutex. */
unsigned n_memfd_cache;
int event_priority;
void *current_userdata;
char *fake_label;
char *cgroup_root;
char *description;
unsigned bloom_n_hash;
};
/* Defined by the specification as maximum size of an array in
* bytes */
bool interface_name_is_valid(const char *p) _pure_;
bool service_name_is_valid(const char *p) _pure_;
char* service_name_startswith(const char *a, const char *b);
bool member_name_is_valid(const char *p) _pure_;
bool object_path_is_valid(const char *p) _pure_;
char *object_path_startswith(const char *a, const char *b) _pure_;
char *bus_address_escape(const char *v);
for (char *_slash = ({ strcpy((prefix), (path)); streq((prefix), "/") ? NULL : strrchr((prefix), '/'); }) ; \
/* If we are invoking callbacks of a bus object, ensure unreffing the
* bus from the callback doesn't destroy the object we are working
* on */
int bus_remove_match_by_string(sd_bus *bus, const char *match, sd_bus_message_handler_t callback, void *userdata);
do { \
return sd_bus_error_set_errno(error, r); \
} while (false)