summaryrefslogtreecommitdiffstats
path: root/src/sbus/sssd_dbus_meta.h
blob: 2cb9e95e3e12da55b1f101e076a0e05203984215 (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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/*
    Authors:
        Stef Walter <stefw@redhat.com>

    Copyright (C) 2014 Red Hat

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.

    This program 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 General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef _SSSD_DBUS_META_H_
#define _SSSD_DBUS_META_H_

/*
 * Interface metadata
 *
 * For arrays, the last item in each array will have a
 * NULL .name field
 *
 * Typically these structs will be generated by sbus_codegen
 * from canonical XML interface data:
 *
 * http://dbus.freedesktop.org/doc/dbus-specification.html#introspection-format
 */

/* Looks up a vtable func, in a struct derived from struct sbus_vtable */
#define VTABLE_FUNC(vtable, offset) \
    (*((void **)((char *)(vtable) + (offset))))

struct sbus_arg_meta {
    const char *name;
    const char *type;
};

struct sbus_request;
struct sbus_interface;

typedef int (* sbus_method_invoker_fn)(struct sbus_request *dbus_req, void *handler_fn);

struct sbus_method_meta {
    const char *name;
    const struct sbus_arg_meta *in_args;
    const struct sbus_arg_meta *out_args;
    size_t vtable_offset;
    sbus_method_invoker_fn invoker;
};

enum {
    SBUS_PROPERTY_READABLE = 1 << 0,
    SBUS_PROPERTY_WRITABLE = 1 << 1
};

struct sbus_property_meta {
    const char *name;
    const char *type;
    int flags;
    size_t vtable_offset_get;
    sbus_method_invoker_fn invoker_get;
    size_t vtable_offset_set;
    sbus_method_invoker_fn invoker_set;
};

struct sbus_signal_meta {
    const char *name;
    const struct sbus_arg_meta *args;
};

struct sbus_interface_meta {
    const char *name;
    const struct sbus_method_meta *methods;
    const struct sbus_signal_meta *signals;
    const struct sbus_property_meta *properties;
    sbus_method_invoker_fn invoker_get_all;
};

const struct sbus_method_meta *
sbus_meta_find_method (const struct sbus_interface_meta *interface,
                       const char *method_name);

const struct sbus_signal_meta *
sbus_meta_find_signal (const struct sbus_interface_meta *interface,
                       const char *signal_name);

const struct sbus_property_meta *
sbus_meta_find_property (const struct sbus_interface_meta *interface,
                         const char *property_name);

#endif /* _SSSD_DBUS_META_H_ */