Add vfail and vsuccess interfaces
[src/app-framework-binder.git] / include / afb / afb-daemon-common.h
1 /*
2  * Copyright (C) 2016, 2017 "IoT.bzh"
3  * Author: José Bollo <jose.bollo@iot.bzh>
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *   http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17
18 #pragma once
19
20 #include <stdarg.h>
21
22 /* declaration of features of libsystemd */
23 struct sd_event;
24 struct sd_bus;
25
26 /*
27  * Definition of the facilities provided by the daemon.
28  */
29 struct afb_daemon_itf {
30         int (*event_broadcast)(void *closure, const char *name, struct json_object *object); /* broadcasts evant 'name' with 'object' */
31         struct sd_event *(*get_event_loop)(void *closure);      /* gets the common systemd's event loop */
32         struct sd_bus *(*get_user_bus)(void *closure);          /* gets the common systemd's user d-bus */
33         struct sd_bus *(*get_system_bus)(void *closure);        /* gets the common systemd's system d-bus */
34         void (*vverbose_v1)(void*closure, int level, const char *file, int line, const char *fmt, va_list args);
35         struct afb_event (*event_make)(void *closure, const char *name); /* creates an event of 'name' */
36         int (*rootdir_get_fd)(void *closure);
37         int (*rootdir_open_locale)(void *closure, const char *filename, int flags, const char *locale);
38         int (*queue_job)(void *closure, void (*callback)(int signum, void *arg), void *argument, void *group, int timeout);
39         void (*vverbose_v2)(void*closure, int level, const char *file, int line, const char * func, const char *fmt, va_list args);
40 };
41
42 /*
43  * Structure for accessing daemon.
44  * See also: afb_daemon_get_event_sender, afb_daemon_get_event_loop, afb_daemon_get_user_bus, afb_daemon_get_system_bus
45  */
46 struct afb_daemon {
47         const struct afb_daemon_itf *itf;       /* the interfacing functions */
48         void *closure;                          /* the closure when calling these functions */
49 };
50