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"
22 /** @addtogroup AFB_DAEMON
26 * @deprecated use bindings version 3
28 * Retrieves the common systemd's event loop of AFB
29 * 'daemon' MUST be the daemon given in interface when activating the binding.
31 static inline struct sd_event *afb_daemon_get_event_loop_v1(struct afb_daemon_x1 daemon)
33 return daemon.itf->get_event_loop(daemon.closure);
37 * @deprecated use bindings version 3
39 * Retrieves the common systemd's user/session d-bus of AFB
40 * 'daemon' MUST be the daemon given in interface when activating the binding.
42 static inline struct sd_bus *afb_daemon_get_user_bus_v1(struct afb_daemon_x1 daemon)
44 return daemon.itf->get_user_bus(daemon.closure);
48 * @deprecated use bindings version 3
50 * Retrieves the common systemd's system d-bus of AFB
51 * 'daemon' MUST be the daemon given in interface when activating the binding.
53 static inline struct sd_bus *afb_daemon_get_system_bus_v1(struct afb_daemon_x1 daemon)
55 return daemon.itf->get_system_bus(daemon.closure);
59 * @deprecated use bindings version 3
61 * Broadcasts widely the event of 'name' with the data 'object'.
62 * 'object' can be NULL.
63 * 'daemon' MUST be the daemon given in interface when activating the binding.
65 * For convenience, the function calls 'json_object_put' for 'object'.
66 * Thus, in the case where 'object' should remain available after
67 * the function returns, the function 'json_object_get' shall be used.
69 * Calling this function is only forbidden during preinit.
71 * Returns the count of clients that received the event.
73 static inline int afb_daemon_broadcast_event_v1(struct afb_daemon_x1 daemon, const char *name, struct json_object *object)
75 return daemon.itf->event_broadcast(daemon.closure, name, object);
79 * @deprecated use bindings version 3
81 * Creates an event of 'name' and returns it.
82 * 'daemon' MUST be the daemon given in interface when activating the binding.
84 * Calling this function is only forbidden during preinit.
86 * See afb_event_is_valid to check if there is an error.
88 static inline struct afb_event_x1 afb_daemon_make_event_v1(struct afb_daemon_x1 daemon, const char *name)
90 return daemon.itf->event_make(daemon.closure, name);
94 * @deprecated use bindings version 3
96 * Send a message described by 'fmt' and following parameters
97 * to the journal for the verbosity 'level'.
99 * 'file' and 'line' are indicators of position of the code in source files
100 * (see macros __FILE__ and __LINE__).
102 * 'daemon' MUST be the daemon given in interface when activating the binding.
104 * 'level' is defined by syslog standard:
105 * EMERGENCY 0 System is unusable
106 * ALERT 1 Action must be taken immediately
107 * CRITICAL 2 Critical conditions
108 * ERROR 3 Error conditions
109 * WARNING 4 Warning conditions
110 * NOTICE 5 Normal but significant condition
111 * INFO 6 Informational
112 * DEBUG 7 Debug-level messages
114 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)));
115 static inline void afb_daemon_verbose_v1(struct afb_daemon_x1 daemon, int level, const char *file, int line, const char *fmt, ...)
119 daemon.itf->vverbose_v1(daemon.closure, level, file, line, fmt, args);
124 * @deprecated use bindings version 3
126 * Send a message described by 'fmt' and following parameters
127 * to the journal for the verbosity 'level'.
129 * 'file', 'line' and 'func' are indicators of position of the code in source files
130 * (see macros __FILE__, __LINE__ and __func__).
132 * 'daemon' MUST be the daemon given in interface when activating the binding.
134 * 'level' is defined by syslog standard:
135 * EMERGENCY 0 System is unusable
136 * ALERT 1 Action must be taken immediately
137 * CRITICAL 2 Critical conditions
138 * ERROR 3 Error conditions
139 * WARNING 4 Warning conditions
140 * NOTICE 5 Normal but significant condition
141 * INFO 6 Informational
142 * DEBUG 7 Debug-level messages
144 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)));
145 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, ...)
149 daemon.itf->vverbose_v2(daemon.closure, level, file, line, func, fmt, args);
154 * @deprecated use bindings version 3
156 * Get the root directory file descriptor. This file descriptor can
157 * be used with functions 'openat', 'fstatat', ...
159 * Returns the file descriptor or -1 in case of error.
161 static inline int afb_daemon_rootdir_get_fd_v1(struct afb_daemon_x1 daemon)
163 return daemon.itf->rootdir_get_fd(daemon.closure);
167 * @deprecated use bindings version 3
169 * using the 'locale' definition (example: "jp,en-US") that can be NULL.
171 * Returns the file descriptor or -1 in case of error.
173 static inline int afb_daemon_rootdir_open_locale_v1(struct afb_daemon_x1 daemon, const char *filename, int flags, const char *locale)
175 return daemon.itf->rootdir_open_locale(daemon.closure, filename, flags, locale);
179 * @deprecated use bindings version 3
181 * Queue the job defined by 'callback' and 'argument' for being executed asynchronously
182 * in this thread (later) or in an other thread.
183 * If 'group' is not NUL, the jobs queued with a same value (as the pointer value 'group')
184 * are executed in sequence in the order of there submission.
185 * If 'timeout' is not 0, it represent the maximum execution time for the job in seconds.
186 * At first, the job is called with 0 as signum and the given argument.
187 * The job is executed with the monitoring of its time and some signals like SIGSEGV and
188 * SIGFPE. When a such signal is catched, the job is terminated and reexecuted but with
189 * signum being the signal number (SIGALRM when timeout expired).
191 * Returns 0 in case of success or -1 in case of error.
193 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)
195 return daemon.itf->queue_job(daemon.closure, callback, argument, group, timeout);
199 * @deprecated use bindings version 3
201 * Tells that it requires the API of "name" to exist
202 * and if 'initialized' is not null to be initialized.
203 * Calling this function is only allowed within init.
205 * Returns 0 in case of success or -1 in case of error.
207 static inline int afb_daemon_require_api_v1(struct afb_daemon_x1 daemon, const char *name, int initialized)
209 return daemon.itf->require_api(daemon.closure, name, initialized);
213 * @deprecated use bindings version 3
215 * Create an aliased name 'as_name' for the api 'name'.
216 * Calling this function is only allowed within preinit.
218 * Returns 0 in case of success or -1 in case of error.
220 static inline int afb_daemon_add_alias_v1(struct afb_daemon_x1 daemon, const char *name, const char *as_name)
222 return daemon.itf->add_alias(daemon.closure, name, as_name);
226 * @deprecated use bindings version 3
228 * Creates a new api of name 'api' with brief 'info'.
230 * Returns 0 in case of success or -1 in case of error.
232 static inline int afb_daemon_new_api_v1(
233 struct afb_daemon_x1 daemon,
237 int (*preinit)(void*, struct afb_api_x3 *),
240 return -!daemon.itf->new_api(daemon.closure, api, info, noconcurrency, preinit, closure);