Provide efficient store/unstore for afb_req
[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 struct afb_stored_req;
26 struct afb_req;
27
28 /*
29  * Definition of the facilities provided by the daemon.
30  */
31 struct afb_daemon_itf
32 {
33         int (*event_broadcast)(void *closure, const char *name, struct json_object *object); /* broadcasts evant 'name' with 'object' */
34         struct sd_event *(*get_event_loop)(void *closure);      /* gets the common systemd's event loop */
35         struct sd_bus *(*get_user_bus)(void *closure);          /* gets the common systemd's user d-bus */
36         struct sd_bus *(*get_system_bus)(void *closure);        /* gets the common systemd's system d-bus */
37         void (*vverbose_v1)(void*closure, int level, const char *file, int line, const char *fmt, va_list args);
38         struct afb_event (*event_make)(void *closure, const char *name); /* creates an event of 'name' */
39         int (*rootdir_get_fd)(void *closure);
40         int (*rootdir_open_locale)(void *closure, const char *filename, int flags, const char *locale);
41         int (*queue_job)(void *closure, void (*callback)(int signum, void *arg), void *argument, void *group, int timeout);
42         void (*vverbose_v2)(void*closure, int level, const char *file, int line, const char * func, const char *fmt, va_list args);
43         struct afb_req (*unstore_req)(void*closure, struct afb_stored_req *sreq);
44 };
45
46 /*
47  * Structure for accessing daemon.
48  * See also: afb_daemon_get_event_sender, afb_daemon_get_event_loop, afb_daemon_get_user_bus, afb_daemon_get_system_bus
49  */
50 struct afb_daemon
51 {
52         const struct afb_daemon_itf *itf;       /* the interfacing functions */
53         void *closure;                          /* the closure when calling these functions */
54 };
55