+void _poptContextFree_deleter_func(poptContext ctx)
+{
+ poptFreeContext(ctx);
+}
+
+} /* namespace */
+
+int validate_exclusion_list(const char *pattern,
+ const struct lttng_dynamic_pointer_array *exclusions)
+{
+ int ret;
+
+ /* Event name must be a valid globbing pattern to allow exclusions. */
+ if (!strutils_is_star_glob_pattern(pattern)) {
+ ERR("Event %s: Exclusions can only be used with a globbing pattern", pattern);
+ goto error;
+ }
+
+ /*
+ * If the event name is a star-at-end only globbing pattern,
+ * then we can validate the individual exclusions. Otherwise
+ * all exclusions are passed to the session daemon.
+ */
+ if (strutils_is_star_at_the_end_only_glob_pattern(pattern)) {
+ size_t i, num_exclusions;
+
+ num_exclusions = lttng_dynamic_pointer_array_get_count(exclusions);
+
+ for (i = 0; i < num_exclusions; i++) {
+ const char *exclusion =
+ (const char *) lttng_dynamic_pointer_array_get_pointer(exclusions,
+ i);
+
+ if (!strutils_is_star_glob_pattern(exclusion) ||
+ strutils_is_star_at_the_end_only_glob_pattern(exclusion)) {
+ ret = check_exclusion_subsets(pattern, exclusion);
+ if (ret) {
+ goto error;
+ }
+ }
+ }
+ }
+
+ ret = 0;
+ goto end;
+
+error:
+ ret = -1;
+
+end:
+ return ret;
+}
+