lttng-ctl: move lttng_event functions to a new file
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Sun, 15 Oct 2017 20:07:29 +0000 (16:07 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 24 Aug 2018 18:38:01 +0000 (14:38 -0400)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/lib/lttng-ctl/Makefile.am
src/lib/lttng-ctl/event.c [new file with mode: 0644]
src/lib/lttng-ctl/lttng-ctl.c

index bc340d20fcbb14b6872f3724eba736c118d3dd9e..d18328e4b80f7e4817bf89a6a4846fd8be04117e 100644 (file)
@@ -6,7 +6,7 @@ lib_LTLIBRARIES = liblttng-ctl.la
 
 liblttng_ctl_la_SOURCES = lttng-ctl.c snapshot.c lttng-ctl-helper.h \
                lttng-ctl-health.c save.c load.c deprecated-symbols.c \
-               channel.c rotate.c
+               channel.c rotate.c event.c
 
 liblttng_ctl_la_LDFLAGS = \
                $(LT_NO_UNDEFINED)
diff --git a/src/lib/lttng-ctl/event.c b/src/lib/lttng-ctl/event.c
new file mode 100644 (file)
index 0000000..541e371
--- /dev/null
@@ -0,0 +1,120 @@
+/*
+ * event.c
+ *
+ * Linux Trace Toolkit Control Library
+ *
+ * Copyright (C) 2017 - Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License, version 2.1 only,
+ * as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#define _LGPL_SOURCE
+#include <lttng/event.h>
+#include <lttng/lttng-error.h>
+#include <stddef.h>
+#include <common/sessiond-comm/sessiond-comm.h>
+
+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;
+}
index f0f2e801c0128065e1d143b27bc6d929b69c0249..37b2531028c83930537f796bdaca041b83df3bd4 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * liblttngctl.c
+ * lttng-ctl.c
  *
  * Linux Trace Toolkit Control Library
  *
@@ -1913,100 +1913,6 @@ error:
        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;
-}
-
 /*
  * Sets the tracing_group variable with name.
  * This function allocates memory pointed to by tracing_group.
This page took 0.029233 seconds and 4 git commands to generate.