2 * Copyright (C) 2016, 2017, 2018 "IoT.bzh"
3 * Author: José Bollo <jose.bollo@iot.bzh>
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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
20 #include "afb-daemon-itf-x1.h"
23 * @deprecated use bindings version 3
25 * Retrieves the common systemd's event loop of AFB
26 * 'daemon' MUST be the daemon given in interface when activating the binding.
28 static inline struct sd_event *afb_daemon_get_event_loop_v1(struct afb_daemon_x1 daemon)
30 return daemon.itf->get_event_loop(daemon.closure);
34 * @deprecated use bindings version 3
36 * Retrieves the common systemd's user/session d-bus of AFB
37 * 'daemon' MUST be the daemon given in interface when activating the binding.
39 static inline struct sd_bus *afb_daemon_get_user_bus_v1(struct afb_daemon_x1 daemon)
41 return daemon.itf->get_user_bus(daemon.closure);
45 * @deprecated use bindings version 3
47 * Retrieves the common systemd's system d-bus of AFB
48 * 'daemon' MUST be the daemon given in interface when activating the binding.
50 static inline struct sd_bus *afb_daemon_get_system_bus_v1(struct afb_daemon_x1 daemon)
52 return daemon.itf->get_system_bus(daemon.closure);
56 * @deprecated use bindings version 3
58 * Broadcasts widely the event of 'name' with the data 'object'.
59 * 'object' can be NULL.
60 * 'daemon' MUST be the daemon given in interface when activating the binding.
62 * For convenience, the function calls 'json_object_put' for 'object'.
63 * Thus, in the case where 'object' should remain available after
64 * the function returns, the function 'json_object_get' shall be used.
66 * Calling this function is only forbidden during preinit.
68 * Returns the count of clients that received the event.
70 static inline int afb_daemon_broadcast_event_v1(struct afb_daemon_x1 daemon, const char *name, struct json_object *object)
72 return daemon.itf->event_broadcast(daemon.closure, name, object);
76 * @deprecated use bindings version 3
78 * Creates an event of 'name' and returns it.
79 * 'daemon' MUST be the daemon given in interface when activating the binding.
81 * Calling this function is only forbidden during preinit.
83 * See afb_event_is_valid to check if there is an error.
85 static inline struct afb_event_x1 afb_daemon_make_event_v1(struct afb_daemon_x1 daemon, const char *name)
87 return daemon.itf->event_make(daemon.closure, name);
91 * @deprecated use bindings version 3
93 * Send a message described by 'fmt' and following parameters
94 * to the journal for the verbosity 'level'.
96 * 'file' and 'line' are indicators of position of the code in source files
97 * (see macros __FILE__ and __LINE__).
99 * 'daemon' MUST be the daemon given in interface when activating the binding.
101 * 'level' is defined by syslog standard:
102 * EMERGENCY 0 System is unusable
103 * ALERT 1 Action must be taken immediately
104 * CRITICAL 2 Critical conditions
105 * ERROR 3 Error conditions
106 * WARNING 4 Warning conditions
107 * NOTICE 5 Normal but significant condition
108 * INFO 6 Informational
109 * DEBUG 7 Debug-level messages
111 static inline void afb_daemon_verbose_v1(struct afb_daemon_x1 daemon, int level, const char *file, int line, const char *fmt, ...) __attribute__((format(printf, 5, 6)));
112 static inline void afb_daemon_verbose_v1(struct afb_daemon_x1 daemon, int level, const char *file, int line, const char *fmt, ...)
116 daemon.itf->vverbose_v1(daemon.closure, level, file, line, fmt, args);
121 * @deprecated use bindings version 3
123 * Send a message described by 'fmt' and following parameters
124 * to the journal for the verbosity 'level'.
126 * 'file', 'line' and 'func' are indicators of position of the code in source files
127 * (see macros __FILE__, __LINE__ and __func__).
129 * 'daemon' MUST be the daemon given in interface when activating the binding.
131 * 'level' is defined by syslog standard:
132 * EMERGENCY 0 System is unusable
133 * ALERT 1 Action must be taken immediately
134 * CRITICAL 2 Critical conditions
135 * ERROR 3 Error conditions
136 * WARNING 4 Warning conditions
137 * NOTICE 5 Normal but significant condition
138 * INFO 6 Informational
139 * DEBUG 7 Debug-level messages
141 static inline void afb_daemon_verbose2_v1(struct afb_daemon_x1 daemon, int level, const char *file, int line, const char *func, const char *fmt, ...) __attribute__((format(printf, 6, 7)));
142 static inline void afb_daemon_verbose2_v1(struct afb_daemon_x1 daemon, int level, const char *file, int line, const char *func, const char *fmt, ...)
146 daemon.itf->vverbose_v2(daemon.closure, level, file, line, func, fmt, args);
151 * @deprecated use bindings version 3
153 * Get the root directory file descriptor. This file descriptor can
154 * be used with functions 'openat', 'fstatat', ...
156 * Returns the file descriptor or -1 in case of error.
158 static inline int afb_daemon_rootdir_get_fd_v1(struct afb_daemon_x1 daemon)
160 return daemon.itf->rootdir_get_fd(daemon.closure);
164 * @deprecated use bindings version 3
166 * using the 'locale' definition (example: "jp,en-US") that can be NULL.
168 * Returns the file descriptor or -1 in case of error.
170 static inline int afb_daemon_rootdir_open_locale_v1(struct afb_daemon_x1 daemon, const char *filename, int flags, const char *locale)
172 return daemon.itf->rootdir_open_locale(daemon.closure, filename, flags, locale);
176 * @deprecated use bindings version 3
178 * Queue the job defined by 'callback' and 'argument' for being executed asynchronously
179 * in this thread (later) or in an other thread.
180 * If 'group' is not NUL, the jobs queued with a same value (as the pointer value 'group')
181 * are executed in sequence in the order of there submission.
182 * If 'timeout' is not 0, it represent the maximum execution time for the job in seconds.
183 * At first, the job is called with 0 as signum and the given argument.
184 * The job is executed with the monitoring of its time and some signals like SIGSEGV and
185 * SIGFPE. When a such signal is catched, the job is terminated and reexecuted but with
186 * signum being the signal number (SIGALRM when timeout expired).
188 * Returns 0 in case of success or -1 in case of error.
190 static inline int afb_daemon_queue_job_v1(struct afb_daemon_x1 daemon, void (*callback)(int signum, void *arg), void *argument, void *group, int timeout)
192 return daemon.itf->queue_job(daemon.closure, callback, argument, group, timeout);
196 * @deprecated use bindings version 3
198 * Tells that it requires the API of "name" to exist
199 * and if 'initialized' is not null to be initialized.
200 * Calling this function is only allowed within init.
202 * Returns 0 in case of success or -1 in case of error.
204 static inline int afb_daemon_require_api_v1(struct afb_daemon_x1 daemon, const char *name, int initialized)
206 return daemon.itf->require_api(daemon.closure, name, initialized);
210 * @deprecated use bindings version 3
212 * Create an aliased name 'as_name' for the api 'name'.
213 * Calling this function is only allowed within preinit.
215 * Returns 0 in case of success or -1 in case of error.
217 static inline int afb_daemon_add_alias_v1(struct afb_daemon_x1 daemon, const char *name, const char *as_name)
219 return daemon.itf->add_alias(daemon.closure, name, as_name);
223 * @deprecated use bindings version 3
225 * Creates a new api of name 'api' with brief 'info'.
227 * Returns 0 in case of success or -1 in case of error.
229 static inline int afb_daemon_new_api_v1(
230 struct afb_daemon_x1 daemon,
234 int (*preinit)(void*, struct afb_api_x3 *),
237 return -!daemon.itf->new_api(daemon.closure, api, info, noconcurrency, preinit, closure);