BT_PLUGIN_DESCRIPTOR_ATTRIBUTE_TYPE_AUTHOR = 2,
BT_PLUGIN_DESCRIPTOR_ATTRIBUTE_TYPE_LICENSE = 3,
BT_PLUGIN_DESCRIPTOR_ATTRIBUTE_TYPE_DESCRIPTION = 4,
+ BT_PLUGIN_DESCRIPTOR_ATTRIBUTE_TYPE_VERSION = 5,
+};
+
+/* Plugin (user) version */
+struct __bt_plugin_descriptor_version {
+ uint32_t major;
+ uint32_t minor;
+ uint32_t patch;
+ const char *extra;
};
/* Plugin attribute (internal use) */
/* BT_PLUGIN_DESCRIPTOR_ATTRIBUTE_TYPE_DESCRIPTION */
const char *description;
+
+ /* BT_PLUGIN_DESCRIPTOR_ATTRIBUTE_TYPE_VERSION */
+ struct __bt_plugin_descriptor_version version;
} value;
} __attribute__((packed));
#define BT_PLUGIN_DESCRIPTION_WITH_ID(_id, _x) \
__BT_PLUGIN_DESCRIPTOR_ATTRIBUTE(description, BT_PLUGIN_DESCRIPTOR_ATTRIBUTE_TYPE_DESCRIPTION, _id, _x)
+#define __BT_PLUGIN_VERSION_STRUCT_VALUE(_major, _minor, _patch, _extra) \
+ {.major = _major, .minor = _minor, .patch = _patch, .extra = _extra,}
+
+/*
+ * Defines a version attribute attached to a specific plugin descriptor.
+ *
+ * _id: Plugin descriptor ID (C identifier).
+ * _major: Plugin's major version (uint32_t).
+ * _minor: Plugin's minor version (uint32_t).
+ * _patch: Plugin's patch version (uint32_t).
+ * _extra: Plugin's version extra information (C string).
+ */
+#define BT_PLUGIN_VERSION_WITH_ID(_id, _major, _minor, _patch, _extra) \
+ __BT_PLUGIN_DESCRIPTOR_ATTRIBUTE(version, BT_PLUGIN_DESCRIPTOR_ATTRIBUTE_TYPE_VERSION, _id, __BT_PLUGIN_VERSION_STRUCT_VALUE(_major, _minor, _patch, _extra))
+
/*
* Declaration of start and stop symbols of component class descriptors
* section.
*/
#define BT_PLUGIN_DESCRIPTION(_x) BT_PLUGIN_DESCRIPTION_WITH_ID(auto, _x)
+/*
+ * Defines a version attribute attached to the automatic plugin
+ * descriptor.
+ *
+ * _major: Plugin's major version (uint32_t).
+ * _minor: Plugin's minor version (uint32_t).
+ * _patch: Plugin's patch version (uint32_t).
+ * _extra: Plugin's version extra information (C string).
+ */
+#define BT_PLUGIN_VERSION(_major, _minor, _patch, _extra) BT_PLUGIN_VERSION_WITH_ID(auto, _major, _minor, _patch, _extra)
+
/*
* Defines a source component class attached to the automatic plugin
* descriptor. Its ID is the same as its name, hence its name must be a
case BT_PLUGIN_DESCRIPTOR_ATTRIBUTE_TYPE_DESCRIPTION:
plugin->description = cur_attr->value.description;
break;
+ case BT_PLUGIN_DESCRIPTOR_ATTRIBUTE_TYPE_VERSION:
+ plugin->version = &cur_attr->value.version;
+ break;
default:
printf_verbose("WARNING: Unknown attribute \"%s\" (type %d) for plugin %s\n",
cur_attr->type_name, cur_attr->type,
return plugin ? plugin->description : NULL;
}
+enum bt_plugin_status bt_plugin_get_version(struct bt_plugin *plugin,
+ unsigned int *major, unsigned int *minor, unsigned int *patch,
+ const char **extra)
+{
+ enum bt_plugin_status status = BT_PLUGIN_STATUS_OK;
+
+ if (!plugin || !plugin->version) {
+ status = BT_PLUGIN_STATUS_ERROR;
+ goto end;
+ }
+
+ if (major) {
+ *major = (unsigned int) plugin->version->major;
+ }
+
+ if (minor) {
+ *minor = (unsigned int) plugin->version->minor;
+ }
+
+ if (patch) {
+ *patch = (unsigned int) plugin->version->patch;
+ }
+
+ if (extra) {
+ *extra = plugin->version->extra;
+ }
+
+end:
+ return status;
+}
+
int bt_plugin_get_component_class_count(struct bt_plugin *plugin)
{
return plugin ? plugin->comp_classes->len : -1;