summaryrefslogtreecommitdiffstats
path: root/src/shared/bus-object.h
blob: 145bbd268f588158071cf87dddc0b4946063a889 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once

#include <stdbool.h>
#include <stdio.h>

#include "sd-bus.h"

typedef struct BusObjectImplementation BusObjectImplementation;

typedef struct BusObjectVtablePair {
        const sd_bus_vtable *vtable;
        sd_bus_object_find_t object_find;
} BusObjectVtablePair;

struct BusObjectImplementation {
        const char *path;
        const char *interface;
        const sd_bus_vtable **vtables;
        const BusObjectVtablePair *fallback_vtables;
        sd_bus_node_enumerator_t node_enumerator;
        bool manager;
        const BusObjectImplementation **children;
};

#define BUS_VTABLES(...) ((const sd_bus_vtable* []){ __VA_ARGS__, NULL })
#define BUS_FALLBACK_VTABLES(...) ((const BusObjectVtablePair[]) { __VA_ARGS__, {} })
#define BUS_IMPLEMENTATIONS(...) ((const BusObjectImplementation* []) { __VA_ARGS__, NULL })

int bus_add_implementation(sd_bus *bus, const BusObjectImplementation *impl, void *userdata);
int bus_introspect_implementations(
                FILE *out,
                const char *pattern,
                const BusObjectImplementation* const* bus_objects);