Refactor the plugin registration and loading machinery
[babeltrace.git] / plugins / trimmer / trimmer.c
index 5168c814c3df90fa28b6b4c1fcaf2c78714874d2..49be358b621d58831e242a25b37411d87bf79255 100644 (file)
  * SOFTWARE.
  */
 
-#include <babeltrace/plugin/plugin-macros.h>
-#include <babeltrace/plugin/component.h>
-#include <babeltrace/plugin/filter.h>
-#include <babeltrace/plugin/notification/notification.h>
-#include <babeltrace/plugin/notification/iterator.h>
-#include <babeltrace/plugin/notification/event.h>
+#include <babeltrace/plugin/plugin-dev.h>
+#include <babeltrace/component/component.h>
+#include <babeltrace/component/filter.h>
+#include <babeltrace/component/notification/notification.h>
+#include <babeltrace/component/notification/iterator.h>
+#include <babeltrace/component/notification/event.h>
 #include "trimmer.h"
 #include "iterator.h"
 #include <assert.h>
@@ -300,7 +300,7 @@ enum bt_component_status init_from_params(struct trimmer *trimmer, struct bt_val
                value_ret = bt_value_bool_get(value, &gmt);
                if (value_ret) {
                        ret = BT_COMPONENT_STATUS_INVALID;
-                       printf_error("Failed to retrieve clock-gmt value. Expecting a boolean.\n");
+                       printf_error("Failed to retrieve clock-gmt value. Expecting a boolean");
                }
        }
        bt_put(value);
@@ -317,7 +317,7 @@ enum bt_component_status init_from_params(struct trimmer *trimmer, struct bt_val
                if (value_ret || timestamp_from_arg(str,
                                trimmer, &trimmer->begin, gmt)) {
                        ret = BT_COMPONENT_STATUS_INVALID;
-                       printf_error("Failed to retrieve begin value. Expecting a timestamp string.\n");
+                       printf_error("Failed to retrieve begin value. Expecting a timestamp string");
                }
        }
        bt_put(value);
@@ -334,11 +334,17 @@ enum bt_component_status init_from_params(struct trimmer *trimmer, struct bt_val
                if (value_ret || timestamp_from_arg(str,
                                trimmer, &trimmer->end, gmt)) {
                        ret = BT_COMPONENT_STATUS_INVALID;
-                       printf_error("Failed to retrieve end value. Expecting a timestamp string.\n");
+                       printf_error("Failed to retrieve end value. Expecting a timestamp string");
                }
        }
        bt_put(value);
 end:
+       if (trimmer->begin.set && trimmer->end.set) {
+               if (trimmer->begin.value > trimmer->end.value) {
+                       printf_error("Unexpected: time range begin value is above end value");
+                       ret = BT_COMPONENT_STATUS_INVALID;
+               }
+       }
        return ret;
 }
 
@@ -379,13 +385,11 @@ error:
 }
 
 /* Initialize plug-in entry points. */
-BT_PLUGIN_NAME("utils");
+BT_PLUGIN(utils);
 BT_PLUGIN_DESCRIPTION("Babeltrace Trace Trimmer Plug-In.");
 BT_PLUGIN_AUTHOR("Jérémie Galarneau");
 BT_PLUGIN_LICENSE("MIT");
-
-BT_PLUGIN_COMPONENT_CLASSES_BEGIN
-BT_PLUGIN_FILTER_COMPONENT_CLASS_ENTRY("trimmer",
-               "Ensure that trace notifications outside of a given range are filtered-out.",
-               trimmer_component_init)
-BT_PLUGIN_COMPONENT_CLASSES_END
+BT_PLUGIN_COMPONENT_CLASS(BT_COMPONENT_TYPE_FILTER, trimmer,
+               trimmer_component_init);
+BT_PLUGIN_COMPONENT_CLASS_DESCRIPTION(BT_COMPONENT_TYPE_FILTER, trimmer,
+       "Ensure that trace notifications outside of a given range are filtered-out.");
This page took 0.027454 seconds and 4 git commands to generate.