{
unsigned int major, minor, patch;
const char *extra;
- enum bt_plugin_status version_status;
+ enum bt_property_availability version_avail;
const char *plugin_name;
const char *path;
const char *author;
author = bt_plugin_get_author(plugin);
license = bt_plugin_get_license(plugin);
plugin_description = bt_plugin_get_description(plugin);
- version_status = bt_plugin_get_version(plugin, &major, &minor,
+ version_avail = bt_plugin_get_version(plugin, &major, &minor,
&patch, &extra);
printf("%s%s%s%s:\n", bt_common_color_bold(),
bt_common_color_fg_blue(), plugin_name,
puts(" Built-in");
}
- if (version_status == BT_PLUGIN_STATUS_OK) {
+ if (version_avail == BT_PROPERTY_AVAILABILITY_AVAILABLE) {
printf(" %sVersion%s: %u.%u.%u",
bt_common_color_bold(), bt_common_color_reset(),
major, minor, patch);
extern "C" {
#endif
-enum bt_plugin_status {
- BT_PLUGIN_STATUS_OK = 0,
- BT_PLUGIN_STATUS_ERROR = -1,
- BT_PLUGIN_STATUS_NOMEM = -12,
-};
-
extern const bt_plugin *bt_plugin_find(const char *plugin_name);
extern const bt_plugin_set *bt_plugin_find_all_from_file(
#define __BT_PLUGIN_VERSION_MINOR 0
/* Plugin initialization function type */
-typedef enum bt_plugin_status (*bt_plugin_init_func)(
+enum bt_plugin_init_status {
+ BT_PLUGIN_INIT_STATUS_OK = 0,
+ BT_PLUGIN_INIT_STATUS_NOMEM = -12,
+ BT_PLUGIN_INIT_STATUS_ERROR = -1,
+};
+
+typedef enum bt_plugin_init_status (*bt_plugin_init_func)(
const bt_plugin *plugin);
/* Plugin exit function type */
-typedef enum bt_plugin_status (*bt_plugin_exit_func)(void);
+typedef void (*bt_plugin_exit_func)(void);
/* Plugin descriptor: describes a single plugin (internal use) */
struct __bt_plugin_descriptor {
BT_PLUGIN_TYPE_PYTHON = 1,
};
+enum bt_plugin_status {
+ BT_PLUGIN_STATUS_OK = 0,
+ BT_PLUGIN_STATUS_ERROR = -1,
+ BT_PLUGIN_STATUS_NOMEM = -12,
+};
+
struct bt_plugin {
struct bt_object base;
enum bt_plugin_type type;
BT_LOGD_STR("Released references from all component classes to shared library handles.");
}
+static inline
+const char *bt_plugin_init_status_string(enum bt_plugin_init_status status)
+{
+ switch (status) {
+ case BT_PLUGIN_INIT_STATUS_OK:
+ return "BT_PLUGIN_INIT_STATUS_OK";
+ case BT_PLUGIN_INIT_STATUS_ERROR:
+ return "BT_PLUGIN_INIT_STATUS_ERROR";
+ case BT_PLUGIN_INIT_STATUS_NOMEM:
+ return "BT_PLUGIN_INIT_STATUS_NOMEM";
+ default:
+ return "(unknown)";
+ }
+}
+
static
void bt_plugin_so_shared_lib_handle_destroy(struct bt_object *obj)
{
shared_lib_handle, path);
if (shared_lib_handle->init_called && shared_lib_handle->exit) {
- enum bt_plugin_status status;
-
BT_LOGD_STR("Calling user's plugin exit function.");
- status = shared_lib_handle->exit();
- BT_LOGD("User function returned: %s",
- bt_plugin_status_string(status));
-
- if (status < 0) {
- BT_LOGW("User's plugin exit function failed: "
- "path=\"%s\"", path);
- }
+ shared_lib_handle->exit();
+ BT_LOGD_STR("User function returned.");
}
if (shared_lib_handle->module) {
/* Initialize plugin */
if (spec->init) {
+ enum bt_plugin_init_status init_status;
BT_LOGD_STR("Calling user's plugin initialization function.");
- status = spec->init(plugin);
+ init_status = spec->init(plugin);
BT_LOGD("User function returned: %s",
- bt_plugin_status_string(status));
+ bt_plugin_init_status_string(init_status));
- if (status < 0) {
+ if (init_status < 0) {
BT_LOGW_STR("User's plugin initialization function failed.");
+ status = BT_PLUGIN_STATUS_ERROR;
goto end;
}
}
#include <stdlib.h>
#include <glib.h>
-static enum bt_plugin_status plugin_init(const bt_plugin *plugin)
+static enum bt_plugin_init_status plugin_init(const bt_plugin *plugin)
{
g_setenv("BT_TEST_PLUGIN_INIT_CALLED", "1", 1);
- return BT_PLUGIN_STATUS_OK;
+ return BT_PLUGIN_INIT_STATUS_OK;
}
-static enum bt_plugin_status plugin_exit(void)
+static void plugin_exit(void)
{
g_setenv("BT_TEST_PLUGIN_EXIT_CALLED", "1", 1);
- return BT_PLUGIN_STATUS_OK;
}
BT_PLUGIN_MODULE();