Move to kernel style SPDX license identifiers
[babeltrace.git] / src / bindings / python / bt2 / bt2 / native_bt_plugin.i.h
1 /*
2 * SPDX-License-Identifier: MIT
3 *
4 * Copyright (c) 2017 Philippe Proulx <pproulx@efficios.com>
5 */
6
7 /*
8 * Those bt_bt2_*() functions below ensure that when the API function
9 * fails, the output parameter is set to `NULL`. This is necessary
10 * because the epilogue of the `something **OUT` typemap will use that
11 * value to make a Python object. We can't rely on the initial value of
12 * `*OUT`; it could point to unreadable memory.
13 */
14
15 static
16 bt_property_availability bt_bt2_plugin_get_version(
17 const bt_plugin *plugin, unsigned int *major,
18 unsigned int *minor, unsigned int *patch, const char **extra)
19 {
20 bt_property_availability ret;
21
22 ret = bt_plugin_get_version(plugin, major, minor, patch, extra);
23
24 if (ret == BT_PROPERTY_AVAILABILITY_NOT_AVAILABLE) {
25 *extra = NULL;
26 }
27
28 return ret;
29 }
30
31 static
32 bt_plugin_find_status bt_bt2_plugin_find(const char *plugin_name,
33 bt_bool find_in_std_env_var, bt_bool find_in_user_dir,
34 bt_bool find_in_sys_dir, bt_bool find_in_static,
35 bt_bool fail_on_load_error, const bt_plugin **plugin)
36 {
37 bt_plugin_find_status status;
38
39 status = bt_plugin_find(plugin_name, find_in_std_env_var,
40 find_in_user_dir, find_in_sys_dir, find_in_static,
41 fail_on_load_error, plugin);
42 if (status != __BT_FUNC_STATUS_OK) {
43 *plugin = NULL;
44 }
45
46 return status;
47 }
48
49 static
50 bt_plugin_find_all_status bt_bt2_plugin_find_all(bt_bool find_in_std_env_var,
51 bt_bool find_in_user_dir, bt_bool find_in_sys_dir,
52 bt_bool find_in_static, bt_bool fail_on_load_error,
53 const bt_plugin_set **plugin_set)
54 {
55 bt_plugin_find_all_status status;
56
57 status = bt_plugin_find_all(find_in_std_env_var,
58 find_in_user_dir, find_in_sys_dir, find_in_static,
59 fail_on_load_error, plugin_set);
60 if (status != __BT_FUNC_STATUS_OK) {
61 *plugin_set = NULL;
62 }
63
64 return status;
65 }
66
67 static
68 bt_plugin_find_all_from_file_status bt_bt2_plugin_find_all_from_file(
69 const char *path, bt_bool fail_on_load_error,
70 const bt_plugin_set **plugin_set)
71 {
72 bt_plugin_find_all_from_file_status status;
73
74 status = bt_plugin_find_all_from_file(path, fail_on_load_error,
75 plugin_set);
76 if (status != __BT_FUNC_STATUS_OK) {
77 *plugin_set = NULL;
78 }
79
80 return status;
81 }
82
83 static
84 bt_plugin_find_all_from_dir_status bt_bt2_plugin_find_all_from_dir(
85 const char *path, bt_bool recurse, bt_bool fail_on_load_error,
86 const bt_plugin_set **plugin_set)
87 {
88 bt_plugin_find_all_from_dir_status status;
89
90 status = bt_plugin_find_all_from_dir(path, recurse, fail_on_load_error,
91 plugin_set);
92 if (status != __BT_FUNC_STATUS_OK) {
93 *plugin_set = NULL;
94 }
95
96 return status;
97 }
This page took 0.030193 seconds and 4 git commands to generate.