+ /* Set number of events and free command header */
+ nb_events = cmd_header->nb_events;
+ if (nb_events > INT_MAX) {
+ ret = -EOVERFLOW;
+ goto error;
+ }
+ ret = (int) nb_events;
+ free(cmd_header);
+ cmd_header = NULL;
+
+ /* Set extended info pointers */
+ extended_at = ((void*) (*events)) +
+ nb_events * sizeof(struct lttng_event);
+
+ for (i = 0; i < nb_events; i++) {
+ struct lttcomm_event_extended_header *ext_header;
+ struct lttng_event *event = &(*events)[i];
+
+ event->extended.ptr = extended_at;
+ ext_header =
+ (struct lttcomm_event_extended_header *) extended_at;
+ extended_at += sizeof(*ext_header);
+ extended_at += ext_header->filter_len;
+ extended_at +=
+ ext_header->nb_exclusions * LTTNG_SYMBOL_NAME_LEN;
+ }
+
+ return ret;
+error:
+ free(cmd_header);
+ free(*events);
+ return ret;
+}
+
+int lttng_event_get_filter_expression(struct lttng_event *event,
+ const char **filter_expression)
+{
+ int ret = 0;
+ struct lttcomm_event_extended_header *ext_header;
+
+ if (!event || !filter_expression) {
+ ret = -LTTNG_ERR_INVALID;
+ goto end;
+ }
+
+ ext_header = event->extended.ptr;
+
+ if (!ext_header) {
+ /*
+ * This can happen since the lttng_event structure is
+ * used for other tasks where this pointer is never set.
+ */
+ *filter_expression = NULL;
+ goto end;
+ }
+
+ if (ext_header->filter_len) {
+ *filter_expression = ((const char *) (ext_header)) +
+ sizeof(*ext_header);
+ } else {
+ *filter_expression = NULL;
+ }
+
+end:
+ return ret;
+}
+
+int lttng_event_get_exclusion_name_count(struct lttng_event *event)
+{
+ int ret;
+ struct lttcomm_event_extended_header *ext_header;
+
+ if (!event) {
+ ret = -LTTNG_ERR_INVALID;
+ goto end;
+ }
+
+ ext_header = event->extended.ptr;
+ if (!ext_header) {
+ /*
+ * This can happen since the lttng_event structure is
+ * used for other tasks where this pointer is never set.
+ */
+ ret = 0;
+ goto end;
+ }
+
+ if (ext_header->nb_exclusions > INT_MAX) {
+ ret = -LTTNG_ERR_OVERFLOW;
+ goto end;
+ }
+ ret = (int) ext_header->nb_exclusions;
+end:
+ return ret;
+}
+
+int lttng_event_get_exclusion_name(struct lttng_event *event,
+ size_t index, const char **exclusion_name)
+{
+ int ret = 0;
+ struct lttcomm_event_extended_header *ext_header;
+ void *at;
+
+ if (!event || !exclusion_name) {
+ ret = -LTTNG_ERR_INVALID;
+ goto end;
+ }
+
+ ext_header = event->extended.ptr;
+ if (!ext_header) {
+ ret = -LTTNG_ERR_INVALID;
+ goto end;
+ }
+
+ if (index >= ext_header->nb_exclusions) {
+ ret = -LTTNG_ERR_INVALID;
+ goto end;
+ }
+
+ at = (void *) ext_header + sizeof(*ext_header);
+ at += ext_header->filter_len;
+ at += index * LTTNG_SYMBOL_NAME_LEN;
+ *exclusion_name = at;
+
+end:
+ return ret;