Simplified doc-site generation
[AGL/documentation.git] / docs / 4_APIs_and_Services / 4.3_Application_Framework_Binder / 3_Binder_references / 3_Functions_of_class_afb_api.md
1 ---
2 edit_link: ''
3 title: Functions of class afb_api
4 origin_url: >-
5   https://git.automotivelinux.org/src/app-framework-binder/plain/docs/reference-v3/func-api.md?h=master
6 ---
7
8 <!-- WARNING: This file is generated by fetch_docs.js using /home/boron/Documents/AGL/docs-webtemplate/site/_data/tocs/apis_services/master/app-framework-binder-developer-guides-api-services-book.yml -->
9
10 Functions of class **afb_api**
11 ============================
12
13 ## General functions
14
15 ### afb_api_name
16
17 ```C
18 /**
19  * Get the name of the 'api'.
20  *
21  * @param api the api whose name is to be returned
22  *
23  * @return the name of the api.
24  *
25  * The returned value must not be changed nor freed.
26  */
27 const char *afb_api_name(
28                         afb_api_t api);
29 ```
30
31 ### afb_api_get_userdata
32
33 ```C
34 /**
35  * Get the "userdata" pointer of the 'api'
36  *
37  * @param api the api whose user's data is to be returned
38  *
39  * @return the user's data  pointer of the api.
40  *
41  * @see afb_api_set_userdata
42  */
43 void *afb_api_get_userdata(
44                         afb_api_t api);
45 ```
46
47 ### afb_api_set_userdata
48
49 ```C
50 /**
51  * Set the "userdata" pointer of the 'api' to 'value'
52  *
53  * @param api   the api whose user's data is to be set
54  * @param value the data to set
55  *
56  * @see afb_api_get_userdata
57  */
58 void afb_api_set_userdata(
59                         afb_api_t api,
60                         void *value);
61 ```
62
63 ### afb_api_require_api
64
65 ```C
66 /**
67  * Check that it requires the API of 'name'.
68  * If 'initialized' is not zero it requests the API to be
69  * initialized, implying its initialization if needed.
70  *
71  * Calling this function is only allowed within init.
72  *
73  * A single request allows to require multiple apis.
74  *
75  * @param api the api that requires the other api by its name
76  * @param name a space separated list of required api names
77  * @param initialized if zero, the api is just required to exist. If not zero,
78  * the api is required to exist and to be initialized at return of the call
79  * (initializing it if needed and possible as a side effect of the call).
80  *
81  * @return 0 in case of success or -1 in case of error with errno set appropriately.
82  */
83 int afb_api_require_api(
84                         afb_api_t api,
85                         const char *name,
86                         int initialized);
87 ```
88
89
90 ## Verbosity functions
91
92 ### afb_api_wants_log_level
93
94 ```C
95 /**
96  * Is the log message of 'level (as defined for syslog) required for the api?
97  *
98  * @param api   the api to check
99  * @param level the level to check as defined for syslog:
100  *
101  *      EMERGENCY         0        System is unusable
102  *      ALERT             1        Action must be taken immediately
103  *      CRITICAL          2        Critical conditions
104  *      ERROR             3        Error conditions
105  *      WARNING           4        Warning conditions
106  *      NOTICE            5        Normal but significant condition
107  *      INFO              6        Informational
108  *      DEBUG             7        Debug-level messages
109  *
110  * @return 0 if not required or a value not null if required
111  *
112  * @see syslog
113  */
114 int afb_api_wants_log_level(
115                         afb_api_t api,
116                         int level);
117 ```
118
119 ### afb_api_vverbose
120
121 ```C
122 /**
123  * Send to the journal with the logging 'level' a message described
124  * by 'fmt' applied to the va-list 'args'.
125  *
126  * 'file', 'line' and 'func' are indicators of code position in source files
127  * (see macros __FILE__, __LINE__ and __func__).
128  *
129  * 'level' is defined by syslog standard:
130  *
131  *      EMERGENCY         0        System is unusable
132  *      ALERT             1        Action must be taken immediately
133  *      CRITICAL          2        Critical conditions
134  *      ERROR             3        Error conditions
135  *      WARNING           4        Warning conditions
136  *      NOTICE            5        Normal but significant condition
137  *      INFO              6        Informational
138  *      DEBUG             7        Debug-level messages
139  *
140  * @param api the api that collects the logging message
141  * @param level the level of the message
142  * @param file the source file that logs the messages or NULL
143  * @param line the line in the source file that logs the message
144  * @param func the name of the function in the source file that logs
145  * @param fmt the format of the message as in printf
146  * @param args the arguments to the format string of the message as a va_list
147  *
148  * @see syslog
149  * @see printf
150  */
151 void afb_api_vverbose(
152                         afb_api_t api,
153                         int level,
154                         const char *file,
155                         int line,
156                         const char *func,
157                         const char *fmt,
158                         va_list args);
159 ```
160
161 ### afb_api_verbose
162
163 ```C
164 /**
165  * Send to the journal with the log 'level' a message described
166  * by 'fmt' and following parameters.
167  *
168  * 'file', 'line' and 'func' are indicators of position of the code in source files
169  * (see macros __FILE__, __LINE__ and __func__).
170  *
171  * 'level' is defined by syslog standard:
172  *      EMERGENCY         0        System is unusable
173  *      ALERT             1        Action must be taken immediately
174  *      CRITICAL          2        Critical conditions
175  *      ERROR             3        Error conditions
176  *      WARNING           4        Warning conditions
177  *      NOTICE            5        Normal but significant condition
178  *      INFO              6        Informational
179  *      DEBUG             7        Debug-level messages
180  *
181  * @param api the api that collects the logging message
182  * @param level the level of the message
183  * @param file the source file that logs the messages or NULL
184  * @param line the line in the source file that logs the message
185  * @param func the name of the function in the source file that logs
186  * @param fmt the format of the message as in printf
187  * @param ... the arguments to the format string of the message
188  *
189  * @see syslog
190  * @see printf
191  */
192 void afb_api_verbose(
193                         afb_api_t api,
194                         int level,
195                         const char *file,
196                         int line,
197                         const char *func,
198                         const char *fmt,
199                         ...);
200 ```
201
202 ## Data retrieval functions
203
204 ### afb_api_rootdir_get_fd
205
206 ```C
207 /**
208  * Get the root directory file descriptor. This file descriptor can
209  * be used with functions 'openat', 'fstatat', ...
210  *
211  * CAUTION, manipulate this descriptor with care, in particular, don't close
212  * it.
213  *
214  * This can be used to get the path of the root directory using:
215  *
216  * char buffer[MAX_PATH], proc[100];
217  * int dirfd = afb_api_rootdir_get_fd(api);
218  * snprintf(proc, sizeof proc, "/proc/self/fd/%d", dirfd);
219  * readlink(proc, buffer, sizeof buffer);
220  *
221  * But note that within AGL this is the value given by the environment variable
222  * AFM_APP_INSTALL_DIR.
223  *
224  * @param api the api that uses the directory file descriptor
225  *
226  * @return the file descriptor of the root directory.
227  *
228  * @see afb_api_rootdir_open_locale
229  */
230 int afb_api_rootdir_get_fd(
231                         afb_api_t api);
232 ```
233
234 ### afb_api_rootdir_open_locale
235
236 ```C
237 /**
238  * Opens 'filename' within the root directory with 'flags' (see function openat)
239  * using the 'locale' definition (example: "jp,en-US") that can be NULL.
240  *
241  * The filename must be relative to the root of the bindings.
242  *
243  * The opening mode must be for read or write but not for O_CREAT.
244  *
245  * The definition of locales and of how files are searched can be checked
246  * here: https://www.w3.org/TR/widgets/#folder-based-localization
247  * and https://tools.ietf.org/html/rfc7231#section-5.3.5
248  *
249  * @param api the api that queries the file
250  * @param filename the relative path to the file to open
251  * @param flags the flags for opening as for C function 'open'
252  * @param locale string indicating how to search content, can be NULL
253  *
254  * @return the file descriptor or -1 in case of error and errno is set with the
255  * error indication.
256  *
257  * @see open
258  * @see afb_api_rootdir_get_fd
259  */
260 int afb_api_rootdir_open_locale(
261                         afb_api_t api,
262                         const char *filename,
263                         int flags,
264                         const char *locale);
265 ```
266
267 ### afb_api_settings
268
269 ```C
270 /**
271  * Settings of the api.
272  *
273  * Get the settings of the API. The settings are recorded
274  * as a JSON object. The returned object should not be modified.
275  * It MUST NOT be released using json_object_put.
276  *
277  * @param api the api whose settings are required
278  *
279  * @returns The setting object.
280  */
281 struct json_object *afb_api_settings(
282                         struct afb_api_x3 *api);
283 ```
284
285 ## Calls and job functions
286
287 ### afb_api_call
288
289 ```C
290 /**
291  * Calls the 'verb' of the 'apiname' with the arguments 'args' and 'verb' in the name of the binding 'api'.
292  * The result of the call is delivered to the 'callback' function with the 'callback_closure'.
293  *
294  * For convenience, the function calls 'json_object_put' for 'args'.
295  * Thus, in the case where 'args' should remain available after
296  * the function returns, the function 'json_object_get' shall be used.
297  *
298  * The 'callback' receives 5 arguments:
299  *  1. 'closure' the user defined closure pointer 'closure',
300  *  2. 'object'  a JSON object returned (can be NULL)
301  *  3. 'error'   a string not NULL in case of error but NULL on success
302  *  4. 'info'    a string handling some info (can be NULL)
303  *  5. 'api'     the api
304  *
305  * NOTE: For convenience, *json_object_put* is called on 'object' after the
306  * callback returns. So, it is wrong to call *json_object_put* in the callback.
307  *
308  * @param api      The api that makes the call
309  * @param apiname  The api name of the method to call
310  * @param verb     The verb name of the method to call
311  * @param args     The arguments to pass to the method
312  * @param callback The to call on completion
313  * @param closure  The closure to pass to the callback
314  *
315  *
316  * @see afb_req_subcall
317  * @see afb_req_subcall_sync
318  * @see afb_api_call_sync
319  */
320 void afb_api_call(
321                         afb_api_t api,
322                         const char *apiname,
323                         const char *verb,
324                         struct json_object *args,
325                         void (*callback)(
326                                         void *closure,
327                                         struct json_object *object,
328                                         const char *error,
329                                         const char * info,
330                                         afb_api_t api),
331                         void *closure);
332 ```
333
334 ### afb_api_call_sync
335
336 ```C
337 /**
338  * Calls the 'verb' of the 'apiname' with the arguments 'args' and 'verb' in the name of the binding 'api'.
339  * 'result' will receive the response.
340  *
341  * For convenience, the function calls 'json_object_put' for 'args'.
342  * Thus, in the case where 'args' should remain available after
343  * the function returns, the function 'json_object_get' shall be used.
344  *
345  * @param api      The api that makes the call
346  * @param apiname  The api name of the method to call
347  * @param verb     The verb name of the method to call
348  * @param args     The arguments to pass to the method
349  * @param object   Where to store the returned object - should call json_object_put on it - can be NULL
350  * @param error    Where to store the copied returned error - should call free on it - can be NULL
351  * @param info     Where to store the copied returned info - should call free on it - can be NULL
352  *
353  * @returns 0 in case of success or a negative value in case of error.
354  *
355  * @see afb_req_subcall
356  * @see afb_req_subcall_sync
357  * @see afb_api_call
358  */
359 int afb_api_call_sync(
360                         afb_api_t api,
361                         const char *apiname,
362                         const char *verb,
363                         struct json_object *args,
364                         struct json_object **object,
365                         char **error,
366                         char **info);
367 ```
368
369 ### afb_api_queue_job
370
371 ```C
372 /**
373  * Queue the job defined by 'callback' and 'argument' for being executed asynchronously
374  * in this thread (later) or in an other thread.
375  *
376  * If 'group' is not NULL, the jobs queued with a same value (as the pointer value 'group')
377  * are executed in sequence in the order of there submission.
378  *
379  * If 'timeout' is not 0, it represent the maximum execution time for the job in seconds.
380  * At first, the job is called with 0 as signum and the given argument.
381  *
382  * The job is executed with the monitoring of its time and some signals like SIGSEGV and
383  * SIGFPE. When a such signal is catched, the job is terminated and reexecuted but with
384  * signum being the signal number (SIGALRM when timeout expired).
385  *
386  * When executed, the callback function receives 2 arguments:
387  *
388  *  - int signum: the signal catched if any or zero at the beginning
389  *  - void *arg: the parameter 'argument'
390  *
391  * A typical implementation of the job callback is:
392  *
393  * void my_job_cb(int signum, void *arg)
394  * {
395  *      struct myarg_t *myarg = arg;
396  *      if (signum)
397  *              AFB_API_ERROR(myarg->api, "job interrupted with signal %s", strsignal(signum));
398  *      else
399  *              really_do_my_job(myarg);
400  * }
401  *
402  * @param api the api that queue the job
403  * @param callback the job as a callback function
404  * @param argument the argument to pass to the queued job
405  * @param group the group of the job, NULL if no group
406  * @param timeout the timeout of execution of the job
407  *
408  * @return 0 in case of success or -1 in case of error with errno set appropriately.
409  */
410 int afb_api_queue_job(
411                         afb_api_t api,
412                         void (*callback)(int signum, void *arg),
413                         void *argument,
414                         void *group,
415                         int timeout);
416 ```
417
418 ## Event functions
419
420 ### afb_api_broadcast_event
421
422 ```C
423 /**
424  * Broadcasts widely the event of 'name' with the data 'object'.
425  * 'object' can be NULL.
426  *
427  * For convenience, the function calls 'json_object_put' for 'object'.
428  * Thus, in the case where 'object' should remain available after
429  * the function returns, the function 'json_object_get' shall be used.
430  *
431  * Calling this function is only forbidden during preinit.
432  *
433  * The event sent as the name API/name where API is the name of the
434  * api.
435  *
436  * @param api the api that broadcast the event
437  * @param name the event name suffix
438  * @param object the object that comes with the event
439  *
440  * @return 0 in case of success or -1 in case of error
441  */
442 int afb_api_broadcast_event(
443                         afb_api_t api,
444                         const char *name,
445                         struct json_object *object);
446 ```
447
448 ### afb_api_make_event
449
450 ```C
451 /**
452  * Creates an event of 'name' and returns it.
453  *
454  * Calling this function is only forbidden during preinit.
455  *
456  * See afb_event_is_valid to check if there is an error.
457  *
458  * The event created as the name API/name where API is the name of the
459  * api.
460  *
461  * @param api the api that creates the event
462  * @param name the event name suffix
463  *
464  * @return the created event. Use the function afb_event_is_valid to check
465  * whether the event is valid (created) or not (error as reported by errno).
466  *
467  * @see afb_event_is_valid
468  */
469 afb_event_t afb_api_make_event(
470                         afb_api_t api,
471                         const char *name);
472 ```
473
474 ### afb_api_event_handler_add
475
476 ```C
477 /**
478  * Add a specific event handler for the api
479  *
480  * The handler callback is called when an event matching the given pattern
481  * is received (it is received if broadcasted or after subscription through
482  * a call or a subcall).
483  *
484  * The handler callback receive 4 arguments:
485  *
486  *  - the closure given here
487  *  - the event full name
488  *  - the companion JSON object of the event
489  *  - the api that subscribed the event
490  *
491  * @param api the api that creates the handler
492  * @param pattern the global pattern of the event to handle
493  * @param callback the handler callback function
494  * @param closure the closure of the handler
495  *
496  * @return 0 in case of success or -1 on failure with errno set
497  *
498  * @see afb_api_on_event
499  * @see afb_api_event_handler_del
500  */
501 int afb_api_event_handler_add(
502                         afb_api_t api,
503                         const char *pattern,
504                         void (*callback)(
505                                         void *,
506                                         const char*,
507                                         struct json_object*,
508                                         afb_api_t),
509                         void *closure);
510 ```
511
512 ### afb_api_event_handler_del
513
514 ```C
515 /**
516  * Delete a specific event handler for the api
517  *
518  * @param api the api that the handler belongs to
519  * @param pattern the global pattern of the handler to remove
520  * @param closure if not NULL it will receive the closure set to the handler
521  *
522  * @return 0 in case of success or -1 on failure with errno set
523  *
524  * @see afb_api_on_event
525  * @see afb_api_event_handler_add
526  */
527 int afb_api_event_handler_del(
528                         afb_api_t api,
529                         const char *pattern,
530                         void **closure);
531
532 ```
533
534 ## Systemd functions
535
536 ### afb_api_get_event_loop
537
538 ```C
539 /**
540  * Retrieves the common systemd's event loop of AFB
541  *
542  * @param api the api that uses the event loop
543  *
544  * @return the systemd event loop if active, NULL otherwise
545  *
546  * @see afb_api_get_user_bus
547  * @see afb_api_get_system_bus
548  */
549 struct sd_event *afb_api_get_event_loop(
550                         afb_api_t api);
551 ```
552
553 ### afb_api_get_user_bus
554
555 ```C
556 /**
557  * Retrieves the common systemd's user/session d-bus of AFB
558  *
559  * @param api the api that uses the user dbus
560  *
561  * @return the systemd user connection to dbus if active, NULL otherwise
562  *
563  * @see afb_api_get_event_loop
564  * @see afb_api_get_system_bus
565  */
566 struct sd_bus *afb_api_get_user_bus(
567                         afb_api_t api);
568 ```
569
570 ### afb_api_get_system_bus
571
572 ```C
573 /**
574  * Retrieves the common systemd's system d-bus of AFB
575  *
576  * @param api the api that uses the system dbus
577  *
578  * @return the systemd system connection to dbus if active, NULL otherwise
579  *
580  * @see afb_api_get_event_loop
581  * @see afb_api_get_user_bus
582  */
583 struct sd_bus *afb_api_get_system_bus(
584                         afb_api_t api);
585 ```
586
587
588 ## Dynamic api functions
589
590 ### afb_api_new_api
591
592 ```C
593 /**
594  * Creates a new api of name 'apiname' briefly described by 'info' (that can
595  * be NULL).
596  *
597  * When the pre-initialization function is given, it is a function that
598  * receives 2 parameters:
599  *
600  *  - the closure as given in the call
601  *  - the created api that can be initialised
602  *
603  * This pre-initialization function must return a negative value to abort
604  * the creation of the api. Otherwise, it returns a non-negative value to
605  * continue.
606  *
607  * @param api the api that creates the other one
608  * @param apiname the name of the new api
609  * @param info the brief description of the new api (can be NULL)
610  * @param noconcurrency zero or not zero whether the new api is reentrant or not
611  * @param preinit the pre-initialization function if any (can be NULL)
612  * @param closure the closure for the pre-initialization preinit
613  *
614  * @return the created api in case of success or NULL on error
615  *
616  * @see afb_api_delete_api
617  */
618 afb_api_t afb_api_new_api(
619                         afb_api_t api,
620                         const char *apiname,
621                         const char *info,
622                         int noconcurrency,
623                         int (*preinit)(void*, afb_api_t ),
624                         void *closure);
625 ```
626
627 ### afb_api_set_verbs_v2
628
629 ```C
630 /**
631  * @deprecated use @ref afb_api_set_verbs_v3 instead
632  *
633  * Set the verbs of the 'api' using description of verbs of the api v2
634  *
635  * @param api the api that will get the verbs
636  * @param verbs the array of verbs to add terminated with an item with name=NULL
637  *
638  * @return 0 in case of success or -1 on failure with errno set
639  *
640  * @see afb_verb_v2
641  * @see afb_api_add_verb
642  * @see afb_api_set_verbs_v3
643  */
644 int afb_api_set_verbs_v2(
645                         afb_api_t api,
646                         const struct afb_verb_v2 *verbs);
647 ```
648
649 ### afb_api_set_verbs_v3
650
651 ```C
652 /**
653  * Set the verbs of the 'api' using description of verbs of the api v2
654  *
655  * @param api the api that will get the verbs
656  * @param verbs the array of verbs to add terminated with an item with name=NULL
657  *
658  * @return 0 in case of success or -1 on failure with errno set
659  *
660  * @see afb_verb_v3
661  * @see afb_api_add_verb
662  * @see afb_api_del_verb
663  */
664 int afb_api_set_verbs_v3(
665                         afb_api_t api,
666                         const struct afb_verb_v3 *verbs);
667 ```
668
669 ### afb_api_add_verb
670
671 ```C
672 /**
673  * Add one verb to the dynamic set of the api
674  *
675  * @param api the api to change
676  * @param verb name of the verb
677  * @param info brief description of the verb, can be NULL
678  * @param callback callback function implementing the verb
679  * @param vcbdata data for the verb callback, available through req
680  * @param auth required authorization, can be NULL
681  * @param session authorization and session requirements of the verb
682  * @param glob is the verb glob name
683  *
684  * @return 0 in case of success or -1 on failure with errno set
685  *
686  * @see afb_verb_v3
687  * @see afb_api_del_verb
688  * @see afb_api_set_verbs_v3
689  * @see fnmatch for matching names using glob
690  */
691 int afb_api_add_verb(
692                         afb_api_t api,
693                         const char *verb,
694                         const char *info,
695                         void (*callback)(struct afb_req_x2 *req),
696                         void *vcbdata,
697                         const struct afb_auth *auth,
698                         uint32_t session,
699                         int glob);
700 ```
701
702 ### afb_api_del_verb
703
704 ```C
705 /**
706  * Delete one verb from the dynamic set of the api
707  *
708  * @param api the api to change
709  * @param verb name of the verb to delete
710  * @param vcbdata if not NULL will receive the vcbdata of the deleted verb
711  *
712  * @return 0 in case of success or -1 on failure with errno set
713  *
714  * @see afb_api_add_verb
715  */
716 int afb_api_del_verb(
717                         afb_api_t api,
718                         const char *verb,
719                         void **vcbdata);
720 ```
721
722 ### afb_api_on_event
723
724 ```C
725 /**
726  * Set the callback 'onevent' to process events in the name of the 'api'.
727  *
728  * This setting can be done statically using the global variable
729  * @ref afbBindingV3.
730  *
731  * This function replace any previously global event callback set.
732  *
733  * When an event is received, the callback 'onevent' is called with 3 parameters
734  *
735  *  - the api that recorded the event handler
736  *  - the full name of the event
737  *  - the companion JSON object of the event
738  *
739  * @param api the api that wants to process events
740  * @param onevent the callback function that will process events (can be NULL
741  *        to remove event callback)
742  *
743  * @return 0 in case of success or -1 on failure with errno set
744  *
745  * @see afbBindingV3
746  * @see afb_binding_v3
747  * @see afb_api_event_handler_add
748  * @see afb_api_event_handler_del
749  */
750 int afb_api_on_event(
751                         afb_api_t api,
752                         void (*onevent)(
753                                         afb_api_t api,
754                                         const char *event,
755                                         struct json_object *object));
756 ```
757
758 ### afb_api_on_init
759
760 ```C
761 /**
762  * Set the callback 'oninit' to process initialization of the 'api'.
763  *
764  * This setting can be done statically using the global variable
765  * @ref afbBindingV3
766  *
767  * This function replace any previously initialization callback set.
768  *
769  * This function is only valid during the pre-initialization stage.
770  *
771  * The callback initialization function will receive one argument: the api
772  * to initialize.
773  *
774  * @param api the api that wants to process events
775  * @param oninit the callback function that initialize the api
776  *
777  * @return 0 in case of success or -1 on failure with errno set
778  *
779  * @see afbBindingV3
780  * @see afb_binding_v3
781  */
782 int afb_api_on_init(
783                         afb_api_t api,
784                         int (*oninit)(afb_api_t api));
785 ```
786
787 ### afb_api_provide_class
788
789 ```C
790 /**
791  * Tells that the api provides a class of features. Classes are intended to
792  * allow ordering of initializations: apis that provides a given class are
793  * initialized before apis requiring it.
794  *
795  * This function is only valid during the pre-initialization stage.
796  *
797  * @param api  the api that provides the classes
798  * @param name a space separated list of the names of the provided classes
799  *
800  * @returns 0 in case of success or a negative value in case of error.
801  *
802  * @see afb_api_require_class
803  */
804 int afb_api_provide_class(
805                         afb_api_t api,
806                         const char *name);
807 ```
808
809 ### afb_api_require_class
810
811 ```C
812 /**
813  * Tells that the api requires a set of class features. Classes are intended to
814  * allow ordering of initializations: apis that provides a given class are
815  * initialized before apis requiring it.
816  *
817  * This function is only valid during the pre-initialization stage.
818  *
819  * @param api  the api that requires the classes
820  * @param name a space separated list of the names of the required classes
821  *
822  * @returns 0 in case of success or a negative value in case of error.
823  *
824  * @see afb_api_provide_class
825  */
826 int afb_api_require_class(
827                         afb_api_t api,
828                         const char *name);
829 ```
830
831 ### afb_api_seal
832
833 ```C
834 /**
835  * Seal the api. After a call to this function the api can not be modified
836  * anymore.
837  *
838  * @param api the api to be sealed
839  */
840 void afb_api_seal(
841                         afb_api_t api);
842 ```
843
844 ### afb_api_delete_api
845
846 ```C
847 /**
848  * Delete the given api.
849  *
850  * It is of the responsibility of the caller to don't used the deleted api
851  * anymore after this function returned.
852  *
853  * @param api the api to delete
854  *
855  * @returns 0 in case of success or a negative value in case of error.
856  *
857  * @see afb_api_new_api
858  */
859 int afb_api_delete_api(
860                         afb_api_t api);
861 ```
862
863 ### afb_api_add_alias
864
865 ```C
866 /**
867  * Create an aliased name 'as_name' for the api 'name'.
868  * Calling this function is only allowed within preinit.
869  *
870  * @param api the api that requires the aliasing
871  * @param name the api to alias
872  * @param as_name the aliased name of the aliased api
873  *
874  * @return 0 in case of success or -1 in case of error with errno set appropriately.
875  */
876 int afb_api_add_alias(
877                         afb_api_t api,
878                         const char *name,
879                         const char *as_name);
880 ```
881
882
883 ## Legacy functions
884
885 The function for legacy calls are still provided for some time because
886 adaptation of existing code to the new call functions require a small amount
887 of work.
888
889 ### afb_api_call_legacy
890
891 ```C
892 /**
893  * @deprecated try to use @ref afb_api_call instead
894  *
895  * Calls the 'verb' of the 'apiname' with the arguments 'args' and 'verb'
896  * in the name of the binding.
897  * The result of the call is delivered to the 'callback' function
898  * with the 'callback_closure'.
899  *
900  * For convenience, the function calls 'json_object_put' for 'args'.
901  * Thus, in the case where 'args' should remain available after
902  * the function returns, the function 'json_object_get' shall be used.
903  *
904  * The 'callback' receives 3 arguments:
905  *  1. 'closure' the user defined closure pointer 'closure',
906  *  2. 'status' a status being 0 on success or negative when an error occurred,
907  *  2. 'result' the resulting data as a JSON object.
908  *
909  * @param api      The api
910  * @param apiname  The api name of the method to call
911  * @param verb     The verb name of the method to call
912  * @param args     The arguments to pass to the method
913  * @param callback The to call on completion
914  * @param closure  The closure to pass to the callback
915  *
916  * @see also 'afb_api_call'
917  * @see also 'afb_api_call_sync'
918  * @see also 'afb_api_call_sync_legacy'
919  * @see also 'afb_req_subcall'
920  * @see also 'afb_req_subcall_sync'
921  */
922 void afb_api_call_legacy(
923                         afb_api_t api,
924                         const char *apiname,
925                         const char *verb,
926                         struct json_object *args,
927                         void (*callback)(
928                                         void *closure,
929                                         int status,
930                                         struct json_object *result,
931                                         afb_api_t api),
932                         void *closure);
933 ```
934
935 ### afb_api_call_sync_legacy
936
937 ```C
938 /**
939  * @deprecated try to use @ref afb_api_call_sync instead
940  *
941  * Calls the 'verb' of the 'apiname' with the arguments 'args' and 'verb'
942  * in the name of the binding.
943  * 'result' will receive the response.
944  *
945  * For convenience, the function calls 'json_object_put' for 'args'.
946  * Thus, in the case where 'args' should remain available after
947  * the function returns, the function 'json_object_get' shall be used.
948  *
949  * @param api      The api
950  * @param apiname  The api name of the method to call
951  * @param verb     The verb name of the method to call
952  * @param args     The arguments to pass to the method
953  * @param result   Where to store the result - should call json_object_put on it -
954  *
955  * @returns 0 in case of success or a negative value in case of error.
956  *
957  * @see also 'afb_api_call'
958  * @see also 'afb_api_call_sync'
959  * @see also 'afb_api_call_legacy'
960  * @see also 'afb_req_subcall'
961  * @see also 'afb_req_subcall_sync'
962  */
963 int afb_api_call_sync_legacy(
964                         afb_api_t api,
965                         const char *apiname,
966                         const char *verb,
967                         struct json_object *args,
968                         struct json_object **result);
969 ```
970