Move notification API code to libcommon
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 1 Mar 2017 03:17:33 +0000 (22:17 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 1 Mar 2017 04:02:50 +0000 (23:02 -0500)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
18 files changed:
src/common/Makefile.am
src/common/action.c [new file with mode: 0644]
src/common/buffer-usage.c [new file with mode: 0644]
src/common/condition.c [new file with mode: 0644]
src/common/endpoint.c [new file with mode: 0644]
src/common/evaluation.c [new file with mode: 0644]
src/common/notification.c [new file with mode: 0644]
src/common/notify.c [new file with mode: 0644]
src/common/trigger.c [new file with mode: 0644]
src/lib/lttng-ctl/Makefile.am
src/lib/lttng-ctl/action.c [deleted file]
src/lib/lttng-ctl/buffer-usage.c [deleted file]
src/lib/lttng-ctl/condition.c [deleted file]
src/lib/lttng-ctl/endpoint.c [deleted file]
src/lib/lttng-ctl/evaluation.c [deleted file]
src/lib/lttng-ctl/notification.c [deleted file]
src/lib/lttng-ctl/notify.c [deleted file]
src/lib/lttng-ctl/trigger.c [deleted file]

index 8619b5e25f31b627db462a128286ceb0a7872bd9..30f88ae6cafb52416f73022096c316d5475952fa 100644 (file)
@@ -73,7 +73,9 @@ libcommon_la_SOURCES = error.h error.c utils.c utils.h runas.c runas.h \
                        mi-lttng.h mi-lttng.c \
                        daemonize.c daemonize.h \
                        unix.c unix.h \
-                       filter.c filter.h context.c context.h
+                       filter.c filter.h context.c context.h \
+                       action.c notify.c condition.c buffer-usage.c \
+                       evaluation.c notification.c trigger.c endpoint.c
 
 libcommon_la_LIBADD = \
                $(top_builddir)/src/common/config/libconfig.la
diff --git a/src/common/action.c b/src/common/action.c
new file mode 100644 (file)
index 0000000..7deb509
--- /dev/null
@@ -0,0 +1,117 @@
+/*
+ * 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
+ */
+
+#include <lttng/action/action-internal.h>
+#include <lttng/action/notify-internal.h>
+#include <assert.h>
+
+enum lttng_action_type lttng_action_get_type(struct lttng_action *action)
+{
+       return action ? action->type : LTTNG_ACTION_TYPE_UNKNOWN;
+}
+
+void lttng_action_destroy(struct lttng_action *action)
+{
+       if (!action) {
+               return;
+       }
+
+       assert(action->destroy);
+       action->destroy(action);
+}
+
+LTTNG_HIDDEN
+bool lttng_action_validate(struct lttng_action *action)
+{
+       bool valid;
+
+       if (!action) {
+               valid = false;
+               goto end;
+       }
+
+       if (!action->validate) {
+               /* Sub-class guarantees that it can never be invalid. */
+               valid = true;
+               goto end;
+       }
+
+       valid = action->validate(action);
+end:
+       return valid;
+}
+
+LTTNG_HIDDEN
+ssize_t lttng_action_serialize(struct lttng_action *action, char *buf)
+{
+       ssize_t ret, action_size;
+       struct lttng_action_comm action_comm;
+
+       if (!action) {
+               ret = -1;
+               goto end;
+       }
+
+       action_comm.action_type = (int8_t) action->type;
+       ret = sizeof(struct lttng_action_comm);
+       if (buf) {
+               memcpy(buf, &action_comm, ret);
+               buf += ret;
+       }
+
+       action_size = action->serialize(action, buf);
+       if (action_size < 0) {
+               ret = action_size;
+               goto end;
+       }
+       ret += action_size;
+end:
+       return ret;
+}
+
+LTTNG_HIDDEN
+ssize_t lttng_action_create_from_buffer(const char *buf,
+               struct lttng_action **_action)
+{
+       ssize_t ret, action_size = sizeof(struct lttng_action_comm);
+       struct lttng_action *action;
+       struct lttng_action_comm *action_comm =
+                       (struct lttng_action_comm *) buf;
+
+       if (!buf || !_action) {
+               ret = -1;
+               goto end;
+       }
+
+       switch (action_comm->action_type) {
+       case LTTNG_ACTION_TYPE_NOTIFY:
+               action = lttng_action_notify_create();
+               break;
+       default:
+               ret = -1;
+               goto end;
+       }
+
+       if (!action) {
+               ret = -1;
+               goto end;
+       }
+       ret = action_size;
+       *_action = action;
+end:
+       return ret;
+}
diff --git a/src/common/buffer-usage.c b/src/common/buffer-usage.c
new file mode 100644 (file)
index 0000000..eed921a
--- /dev/null
@@ -0,0 +1,574 @@
+/*
+ * 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
+ */
+
+#include <lttng/condition/condition-internal.h>
+#include <lttng/condition/buffer-usage-internal.h>
+#include <common/macros.h>
+#include <assert.h>
+
+static
+bool is_usage_condition(struct lttng_condition *condition)
+{
+       enum lttng_condition_type type = lttng_condition_get_type(condition);
+
+       return type == LTTNG_CONDITION_TYPE_BUFFER_USAGE_LOW ||
+                       type == LTTNG_CONDITION_TYPE_BUFFER_USAGE_HIGH;
+}
+
+static
+bool is_usage_evaluation(struct lttng_evaluation *evaluation)
+{
+       enum lttng_condition_type type = lttng_evaluation_get_type(evaluation);
+
+       return type == LTTNG_CONDITION_TYPE_BUFFER_USAGE_LOW ||
+                       type == LTTNG_CONDITION_TYPE_BUFFER_USAGE_HIGH;
+}
+
+static
+void lttng_condition_buffer_usage_destroy(struct lttng_condition *condition)
+{
+       struct lttng_condition_buffer_usage *usage;
+
+       usage = container_of(condition, struct lttng_condition_buffer_usage,
+                       parent);
+
+       free(usage->session_name);
+       free(usage->channel_name);
+       free(usage);
+}
+
+static
+bool lttng_condition_buffer_usage_validate(struct lttng_condition *condition)
+{
+       bool valid = false;
+       struct lttng_condition_buffer_usage *usage;
+
+       if (!condition) {
+               goto end;
+       }
+
+       usage = container_of(condition, struct lttng_condition_buffer_usage,
+                       parent);
+       if (!usage->session_name) {
+               goto end;
+       }
+       if (!usage->channel_name) {
+               goto end;
+       }
+       if (!usage->threshold_percent.set && !usage->threshold_bytes.set) {
+               goto end;
+       }
+
+       valid = true;
+end:
+       return valid;
+}
+
+static
+ssize_t lttng_condition_buffer_usage_serialize(struct lttng_condition *condition,
+               char *buf)
+{
+       struct lttng_condition_buffer_usage *usage;
+       ssize_t size;
+       size_t session_name_len, channel_name_len;
+
+       if (!condition || !is_usage_condition(condition)) {
+               size = -1;
+               goto end;
+       }
+
+       usage = container_of(condition, struct lttng_condition_buffer_usage,
+                       parent);
+       size = sizeof(struct lttng_condition_buffer_usage_comm);
+       session_name_len = strlen(usage->session_name) + 1;
+       channel_name_len = strlen(usage->channel_name) + 1;
+       size += session_name_len + channel_name_len;
+       if (buf) {
+               struct lttng_condition_buffer_usage_comm usage_comm = {
+                       .threshold_set_in_bytes = usage->threshold_bytes.set ? 1 : 0,
+                       .session_name_len = session_name_len,
+                       .channel_name_len = channel_name_len,
+                       .domain_type = (int8_t) usage->domain.type,
+               };
+
+               if (usage->threshold_bytes.set) {
+                       usage_comm.threshold.bytes =
+                                       usage->threshold_bytes.value;
+               } else {
+                       usage_comm.threshold.percent =
+                                       usage->threshold_percent.value;
+               }
+
+               memcpy(buf, &usage_comm, sizeof(usage_comm));
+               buf += sizeof(usage_comm);
+               memcpy(buf, usage->session_name, session_name_len);
+               buf += session_name_len;
+               memcpy(buf, usage->channel_name, channel_name_len);
+               buf += channel_name_len;
+       }
+end:
+       return size;
+}
+
+static
+struct lttng_condition *lttng_condition_buffer_usage_create(
+               enum lttng_condition_type type)
+{
+       struct lttng_condition_buffer_usage *condition;
+
+       condition = zmalloc(sizeof(struct lttng_condition_buffer_usage));
+       if (!condition) {
+               goto end;
+       }
+
+       condition->parent.type = type;
+       condition->parent.validate = lttng_condition_buffer_usage_validate;
+       condition->parent.serialize = lttng_condition_buffer_usage_serialize;
+       condition->parent.destroy = lttng_condition_buffer_usage_destroy;
+end:
+       return &condition->parent;
+}
+
+struct lttng_condition *lttng_condition_buffer_usage_low_create(void)
+{
+       return lttng_condition_buffer_usage_create(
+                       LTTNG_CONDITION_TYPE_BUFFER_USAGE_LOW);
+}
+
+struct lttng_condition *lttng_condition_buffer_usage_high_create(void)
+{
+       return lttng_condition_buffer_usage_create(
+                       LTTNG_CONDITION_TYPE_BUFFER_USAGE_HIGH);
+}
+
+static
+ssize_t init_from_buffer(struct lttng_condition *condition, const char *buf)
+{
+       ssize_t ret, condition_size;
+       enum lttng_condition_status status;
+       enum lttng_domain_type domain_type;
+       struct lttng_condition_buffer_usage_comm *condition_comm =
+                       (struct lttng_condition_buffer_usage_comm *) buf;
+       const char *session_name, *channel_name;
+
+       if (condition_comm->threshold_set_in_bytes) {
+               status = lttng_condition_buffer_usage_set_threshold(condition,
+                               condition_comm->threshold.bytes);
+       } else {
+               status = lttng_condition_buffer_usage_set_threshold_percentage(
+                               condition, condition_comm->threshold.percent);
+       }
+       if (status != LTTNG_CONDITION_STATUS_OK) {
+               ret = -1;
+               goto end;
+       }
+
+       if (condition_comm->domain_type <= LTTNG_DOMAIN_NONE ||
+                       condition_comm->domain_type > LTTNG_DOMAIN_PYTHON) {
+               /* Invalid domain value. */
+               ret = -1;
+               goto end;
+       }
+
+       domain_type = (enum lttng_domain_type) condition_comm->domain_type;
+       status = lttng_condition_buffer_usage_set_domain_type(condition,
+                       domain_type);
+       if (status != LTTNG_CONDITION_STATUS_OK) {
+               ret = -1;
+               goto end;
+       }
+
+       session_name = buf + sizeof(struct lttng_condition_buffer_usage_comm);
+       channel_name = session_name + condition_comm->session_name_len;
+
+       status = lttng_condition_buffer_usage_set_session_name(condition,
+                       session_name);
+       if (status != LTTNG_CONDITION_STATUS_OK) {
+               ret = -1;
+               goto end;
+       }
+
+       status = lttng_condition_buffer_usage_set_channel_name(condition,
+                       channel_name);
+       if (status != LTTNG_CONDITION_STATUS_OK) {
+               ret = -1;
+               goto end;
+       }
+
+       if (!lttng_condition_validate(condition)) {
+               ret = -1;
+               goto end;
+       }
+
+       condition_size = sizeof(*condition_comm);
+       condition_size += (ssize_t) condition_comm->session_name_len;
+       condition_size += (ssize_t) condition_comm->channel_name_len;
+       ret = condition_size;
+end:
+       return ret;
+}
+
+LTTNG_HIDDEN
+ssize_t lttng_condition_buffer_usage_low_create_from_buffer(const char *buf,
+               struct lttng_condition **_condition)
+{
+       ssize_t ret;
+       struct lttng_condition *condition =
+                       lttng_condition_buffer_usage_low_create();
+
+       if (!_condition || !condition) {
+               ret = -1;
+               goto error;
+       }
+
+       ret = init_from_buffer(condition, buf);
+       if (ret < 0) {
+               goto error;
+       }
+
+       *_condition = condition;
+       return ret;
+error:
+       lttng_condition_destroy(condition);
+       return ret;
+}
+
+LTTNG_HIDDEN
+ssize_t lttng_condition_buffer_usage_high_create_from_buffer(const char *buf,
+               struct lttng_condition **_condition)
+{
+       ssize_t ret;
+       struct lttng_condition *condition =
+                       lttng_condition_buffer_usage_high_create();
+
+       if (!_condition || !condition) {
+               ret = -1;
+               goto error;
+       }
+
+       ret = init_from_buffer(condition, buf);
+       if (ret < 0) {
+               goto error;
+       }
+
+       *_condition = condition;
+       return ret;
+error:
+       lttng_condition_destroy(condition);
+       return ret;
+}
+
+enum lttng_condition_status
+lttng_condition_buffer_usage_get_threshold_percentage(
+               struct lttng_condition *condition, double *threshold_percent)
+{
+       struct lttng_condition_buffer_usage *usage;
+       enum lttng_condition_status status = LTTNG_CONDITION_STATUS_OK;
+
+       if (!condition || !is_usage_condition(condition) ||
+                       !threshold_percent) {
+               status = LTTNG_CONDITION_STATUS_INVALID;
+               goto end;
+       }
+
+       usage = container_of(condition, struct lttng_condition_buffer_usage,
+                       parent);
+       if (!usage->threshold_percent.set) {
+               status = LTTNG_CONDITION_STATUS_UNSET;
+               goto end;
+       }
+       *threshold_percent = usage->threshold_percent.value;
+end:
+       return status;
+}
+
+/* threshold_percent expressed as [0.0, 1.0]. */
+enum lttng_condition_status
+lttng_condition_buffer_usage_set_threshold_percentage(
+               struct lttng_condition *condition, double threshold_percent)
+{
+       struct lttng_condition_buffer_usage *usage;
+       enum lttng_condition_status status = LTTNG_CONDITION_STATUS_OK;
+
+       if (!condition || !is_usage_condition(condition) ||
+               threshold_percent < 0.0 || threshold_percent > 1.0) {
+               status = LTTNG_CONDITION_STATUS_INVALID;
+               goto end;
+       }
+
+       usage = container_of(condition, struct lttng_condition_buffer_usage,
+                       parent);
+       usage->threshold_percent.set = true;
+       usage->threshold_bytes.set = false;
+       usage->threshold_percent.value = threshold_percent;
+end:
+       return status;
+}
+
+enum lttng_condition_status
+lttng_condition_buffer_usage_get_threshold(
+               struct lttng_condition *condition, uint64_t *threshold_bytes)
+{
+       struct lttng_condition_buffer_usage *usage;
+       enum lttng_condition_status status = LTTNG_CONDITION_STATUS_OK;
+
+       if (!condition || !is_usage_condition(condition) || !threshold_bytes) {
+               status = LTTNG_CONDITION_STATUS_INVALID;
+               goto end;
+       }
+
+       usage = container_of(condition, struct lttng_condition_buffer_usage,
+                       parent);
+       if (!usage->threshold_bytes.set) {
+               status = LTTNG_CONDITION_STATUS_UNSET;
+               goto end;
+       }
+       *threshold_bytes = usage->threshold_bytes.value;
+end:
+       return status;
+}
+
+enum lttng_condition_status
+lttng_condition_buffer_usage_set_threshold(
+               struct lttng_condition *condition, uint64_t threshold_bytes)
+{
+       struct lttng_condition_buffer_usage *usage;
+       enum lttng_condition_status status = LTTNG_CONDITION_STATUS_OK;
+
+       if (!condition || !is_usage_condition(condition)) {
+               status = LTTNG_CONDITION_STATUS_INVALID;
+               goto end;
+       }
+
+       usage = container_of(condition, struct lttng_condition_buffer_usage,
+                       parent);
+       usage->threshold_percent.set = false;
+       usage->threshold_bytes.set = true;
+       usage->threshold_bytes.value = threshold_bytes;
+end:
+       return status;
+}
+
+enum lttng_condition_status
+lttng_condition_buffer_usage_get_session_name(
+               struct lttng_condition *condition, const char **session_name)
+{
+       struct lttng_condition_buffer_usage *usage;
+       enum lttng_condition_status status = LTTNG_CONDITION_STATUS_OK;
+
+       if (!condition || !is_usage_condition(condition) || !session_name) {
+               status = LTTNG_CONDITION_STATUS_INVALID;
+               goto end;
+       }
+
+       usage = container_of(condition, struct lttng_condition_buffer_usage,
+                       parent);
+       if (!usage->session_name) {
+               status = LTTNG_CONDITION_STATUS_UNSET;
+               goto end;
+       }
+       *session_name = usage->session_name;
+end:
+       return status;
+}
+
+extern enum lttng_condition_status
+lttng_condition_buffer_usage_set_session_name(
+               struct lttng_condition *condition, const char *session_name)
+{
+       struct lttng_condition_buffer_usage *usage;
+       enum lttng_condition_status status = LTTNG_CONDITION_STATUS_OK;
+
+       if (!condition || !is_usage_condition(condition) || !session_name ||
+                       strlen(session_name) == 0) {
+               status = LTTNG_CONDITION_STATUS_INVALID;
+               goto end;
+       }
+
+       usage = container_of(condition, struct lttng_condition_buffer_usage,
+                       parent);
+       usage->session_name = strdup(session_name);
+       if (!usage->session_name) {
+               status = LTTNG_CONDITION_STATUS_ERROR;
+               goto end;
+       }
+end:
+       return status;
+}
+
+enum lttng_condition_status
+lttng_condition_buffer_usage_get_channel_name(
+               struct lttng_condition *condition, const char **channel_name)
+{
+       struct lttng_condition_buffer_usage *usage;
+       enum lttng_condition_status status = LTTNG_CONDITION_STATUS_OK;
+
+       if (!condition || !is_usage_condition(condition) || !channel_name) {
+               status = LTTNG_CONDITION_STATUS_INVALID;
+               goto end;
+       }
+
+       usage = container_of(condition, struct lttng_condition_buffer_usage,
+                       parent);
+       if (!usage->channel_name) {
+               status = LTTNG_CONDITION_STATUS_UNSET;
+               goto end;
+       }
+       *channel_name = usage->channel_name;
+end:
+       return status;
+}
+
+extern enum lttng_condition_status
+lttng_condition_buffer_usage_set_channel_name(
+               struct lttng_condition *condition, const char *channel_name)
+{
+       struct lttng_condition_buffer_usage *usage;
+       enum lttng_condition_status status = LTTNG_CONDITION_STATUS_OK;
+
+       if (!condition || !is_usage_condition(condition) || !channel_name ||
+                       strlen(channel_name) == 0) {
+               status = LTTNG_CONDITION_STATUS_INVALID;
+               goto end;
+       }
+
+       usage = container_of(condition, struct lttng_condition_buffer_usage,
+                       parent);
+       usage->channel_name = strdup(channel_name);
+       if (!usage->channel_name) {
+               status = LTTNG_CONDITION_STATUS_ERROR;
+               goto end;
+       }
+end:
+       return status;
+}
+
+extern enum lttng_condition_status
+lttng_condition_buffer_usage_get_domain_type(
+               struct lttng_condition *condition, enum lttng_domain_type *type)
+{
+       struct lttng_condition_buffer_usage *usage;
+       enum lttng_condition_status status = LTTNG_CONDITION_STATUS_OK;
+
+       if (!condition || !is_usage_condition(condition) || !type) {
+               status = LTTNG_CONDITION_STATUS_INVALID;
+               goto end;
+       }
+
+       usage = container_of(condition, struct lttng_condition_buffer_usage,
+                       parent);
+       if (!usage->domain.set) {
+               status = LTTNG_CONDITION_STATUS_UNSET;
+               goto end;
+       }
+       *type = usage->domain.type;
+end:
+       return status;
+}
+
+extern enum lttng_condition_status
+lttng_condition_buffer_usage_set_domain_type(
+               struct lttng_condition *condition, enum lttng_domain_type type)
+{
+       struct lttng_condition_buffer_usage *usage;
+       enum lttng_condition_status status = LTTNG_CONDITION_STATUS_OK;
+
+       if (!condition || !is_usage_condition(condition) ||
+                       type == LTTNG_DOMAIN_NONE) {
+               status = LTTNG_CONDITION_STATUS_INVALID;
+               goto end;
+       }
+
+       usage = container_of(condition, struct lttng_condition_buffer_usage,
+                       parent);
+       usage->domain.set = true;
+       usage->domain.type = type;
+end:
+       return status;
+}
+
+static
+void lttng_evaluation_buffer_usage_destroy(
+               struct lttng_evaluation *evaluation)
+{
+       struct lttng_evaluation_buffer_usage *usage;
+
+       usage = container_of(evaluation, struct lttng_evaluation_buffer_usage,
+                       parent);
+       free(usage);
+}
+
+LTTNG_HIDDEN
+struct lttng_evaluation *lttng_evaluation_buffer_usage_create(uint64_t use,
+               uint64_t capacity)
+{
+       struct lttng_evaluation_buffer_usage *usage;
+
+       usage = zmalloc(sizeof(struct lttng_evaluation_buffer_usage));
+       if (!usage) {
+               goto end;
+       }
+
+       usage->buffer_use = use;
+       usage->buffer_capacity = capacity;
+       usage->parent.destroy = lttng_evaluation_buffer_usage_destroy;
+end:
+       return &usage->parent;
+}
+
+/*
+ * Get the sampled buffer usage which caused the associated condition to
+ * evaluate to "true".
+ */
+enum lttng_evaluation_status
+lttng_evaluation_buffer_usage_get_usage_percentage(
+               struct lttng_evaluation *evaluation, double *usage_percent)
+{
+       struct lttng_evaluation_buffer_usage *usage;
+       enum lttng_evaluation_status status = LTTNG_EVALUATION_STATUS_OK;
+
+       if (!evaluation || !is_usage_evaluation(evaluation) || !usage_percent) {
+               status = LTTNG_EVALUATION_STATUS_INVALID;
+               goto end;
+       }
+
+       usage = container_of(evaluation, struct lttng_evaluation_buffer_usage,
+                       parent);
+       *usage_percent = (double) usage->buffer_use /
+                       (double) usage->buffer_capacity;
+end:
+       return status;
+}
+
+enum lttng_evaluation_status
+lttng_evaluation_buffer_usage_get_usage(struct lttng_evaluation *evaluation,
+               uint64_t *usage_bytes)
+{
+       struct lttng_evaluation_buffer_usage *usage;
+       enum lttng_evaluation_status status = LTTNG_EVALUATION_STATUS_OK;
+
+       if (!evaluation || !is_usage_evaluation(evaluation) || !usage_bytes) {
+               status = LTTNG_EVALUATION_STATUS_INVALID;
+               goto end;
+       }
+
+       usage = container_of(evaluation, struct lttng_evaluation_buffer_usage,
+                       parent);
+       *usage_bytes = usage->buffer_use;
+end:
+       return status;
+}
diff --git a/src/common/condition.c b/src/common/condition.c
new file mode 100644 (file)
index 0000000..9f9795d
--- /dev/null
@@ -0,0 +1,129 @@
+/*
+ * 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
+ */
+
+#include <lttng/condition/condition-internal.h>
+#include <lttng/condition/buffer-usage-internal.h>
+#include <common/macros.h>
+#include <stdbool.h>
+#include <assert.h>
+
+enum lttng_condition_type lttng_condition_get_type(
+               struct lttng_condition *condition)
+{
+       return condition ? condition->type : LTTNG_CONDITION_TYPE_UNKNOWN;
+}
+
+void lttng_condition_destroy(struct lttng_condition *condition)
+{
+       if (!condition) {
+               return;
+       }
+
+       assert(condition->destroy);
+       condition->destroy(condition);
+}
+
+LTTNG_HIDDEN
+bool lttng_condition_validate(struct lttng_condition *condition)
+{
+       bool valid;
+
+       if (!condition) {
+               valid = false;
+               goto end;
+       }
+
+       if (!condition->validate) {
+               /* Sub-class guarantees that it can never be invalid. */
+               valid = true;
+               goto end;
+       }
+
+       valid = condition->validate(condition);
+end:
+       return valid;
+}
+
+LTTNG_HIDDEN
+ssize_t lttng_condition_serialize(struct lttng_condition *condition, char *buf)
+{
+       ssize_t ret, condition_size;
+       struct lttng_condition_comm condition_comm;
+
+       if (!condition) {
+               ret = -1;
+               goto end;
+       }
+
+       condition_comm.condition_type = (int8_t) condition->type;
+       ret = sizeof(struct lttng_condition_comm);
+       if (buf) {
+               memcpy(buf, &condition_comm, ret);
+               buf += ret;
+       }
+
+       condition_size = condition->serialize(condition, buf);
+       if (condition_size < 0) {
+               ret = condition_size;
+               goto end;
+       }
+       ret += condition_size;
+end:
+       return ret;
+}
+
+LTTNG_HIDDEN
+ssize_t lttng_condition_create_from_buffer(const char *buf,
+               struct lttng_condition **condition)
+{
+       ssize_t ret, condition_size = 0;
+       struct lttng_condition_comm *condition_comm =
+                       (struct lttng_condition_comm *) buf;
+
+       if (!buf || !condition) {
+               ret = -1;
+               goto end;
+       }
+
+       condition_size += sizeof(*condition_comm);
+       buf += condition_size;
+
+       switch (condition_comm->condition_type) {
+       case LTTNG_CONDITION_TYPE_BUFFER_USAGE_LOW:
+               ret = lttng_condition_buffer_usage_low_create_from_buffer(buf,
+                               condition);
+               if (ret < 0) {
+                       goto end;
+               }
+               condition_size += ret;
+               break;
+       case LTTNG_CONDITION_TYPE_BUFFER_USAGE_HIGH:
+               ret = lttng_condition_buffer_usage_high_create_from_buffer(buf,
+                               condition);
+               if (ret < 0) {
+                       goto end;
+               }
+               condition_size += ret;
+               break;
+       default:
+               ret = -1;
+               goto end;
+       }
+       ret = condition_size;
+end:
+       return ret;
+}
diff --git a/src/common/endpoint.c b/src/common/endpoint.c
new file mode 100644 (file)
index 0000000..89066de
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * 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
+ */
+
+#include <lttng/endpoint-internal.h>
+
+static
+struct lttng_endpoint lttng_session_daemon_notification_endpoint_instance = {
+       .type = LTTNG_ENDPOINT_TYPE_DEFAULT_SESSIOND_NOTIFICATION
+};
+
+struct lttng_endpoint *lttng_session_daemon_notification_endpoint =
+               &lttng_session_daemon_notification_endpoint_instance;
diff --git a/src/common/evaluation.c b/src/common/evaluation.c
new file mode 100644 (file)
index 0000000..41e59c1
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * 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
+ */
+
+#include <lttng/condition/evaluation-internal.h>
+#include <common/macros.h>
+#include <stdbool.h>
+#include <assert.h>
+
+enum lttng_condition_type lttng_evaluation_get_type(
+               struct lttng_evaluation *evaluation)
+{
+       return evaluation ? evaluation->type : LTTNG_CONDITION_TYPE_UNKNOWN;
+}
+
+void lttng_evaluation_destroy(struct lttng_evaluation *evaluation)
+{
+       if (!evaluation) {
+               return;
+       }
+
+       assert(evaluation->destroy);
+       evaluation->destroy(evaluation);
+}
diff --git a/src/common/notification.c b/src/common/notification.c
new file mode 100644 (file)
index 0000000..4d96406
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * 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
+ */
+
+#include <lttng/notification/notification-internal.h>
+#include <lttng/condition/condition.h>
+#include <lttng/condition/evaluation.h>
+#include <assert.h>
+
+LTTNG_HIDDEN
+struct lttng_notification *lttng_notification_create(
+               struct lttng_condition *condition,
+               struct lttng_evaluation *evaluation)
+{
+       struct lttng_notification *notification = NULL;
+
+       if (!condition || !evaluation) {
+               goto end;
+       }
+
+       notification = zmalloc(sizeof(struct lttng_notification));
+       if (!notification) {
+               goto end;
+       }
+
+       notification->condition = condition;
+       notification->evaluation = evaluation;
+end:
+       return notification;
+}
+
+void lttng_notification_destroy(struct lttng_notification *notification)
+{
+       if (!notification) {
+               return;
+       }
+
+       lttng_condition_destroy(notification->condition);
+       lttng_evaluation_destroy(notification->evaluation);
+       free(notification);
+}
+
+struct lttng_condition *lttng_notification_get_condition(
+               struct lttng_notification *notification)
+{
+       return notification ? notification->condition : NULL;
+}
+
+struct lttng_evaluation *lttng_notification_get_evaluation(
+               struct lttng_notification *notification)
+{
+       return notification ? notification->evaluation : NULL;
+}
diff --git a/src/common/notify.c b/src/common/notify.c
new file mode 100644 (file)
index 0000000..956c0ec
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * 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
+ */
+
+#include <lttng/action/action-internal.h>
+#include <lttng/action/notify-internal.h>
+#include <common/macros.h>
+#include <assert.h>
+
+static
+void lttng_action_notify_destroy(struct lttng_action *action)
+{
+       free(action);
+}
+
+static
+ssize_t lttng_action_notify_serialize(struct lttng_action *action, char *buf)
+{
+       return 0;
+}
+
+struct lttng_action *lttng_action_notify_create(void)
+{
+       struct lttng_action_notify *notify;
+
+       notify = zmalloc(sizeof(struct lttng_action_notify));
+       if (!notify) {
+               goto end;
+       }
+
+       notify->parent.type = LTTNG_ACTION_TYPE_NOTIFY;
+       notify->parent.serialize = lttng_action_notify_serialize;
+       notify->parent.destroy = lttng_action_notify_destroy;
+end:
+       return &notify->parent;
+}
diff --git a/src/common/trigger.c b/src/common/trigger.c
new file mode 100644 (file)
index 0000000..1d79a61
--- /dev/null
@@ -0,0 +1,156 @@
+/*
+ * 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
+ */
+
+#include <lttng/trigger/trigger-internal.h>
+#include <lttng/condition/condition-internal.h>
+#include <lttng/action/action-internal.h>
+#include <assert.h>
+
+LTTNG_HIDDEN
+bool lttng_trigger_validate(struct lttng_trigger *trigger)
+{
+       bool valid;
+
+       if (!trigger) {
+               valid = false;
+               goto end;
+       }
+
+       valid = lttng_condition_validate(trigger->condition) &&
+                       lttng_action_validate(trigger->action);
+end:
+       return valid;
+}
+
+struct lttng_trigger *lttng_trigger_create(
+               struct lttng_condition *condition,
+               struct lttng_action *action)
+{
+       struct lttng_trigger *trigger = NULL;
+
+       if (!condition || !action) {
+               goto end;
+       }
+
+       trigger = zmalloc(sizeof(struct lttng_trigger));
+       if (!trigger) {
+               goto end;
+       }
+
+       trigger->condition = condition;
+       trigger->action = action;
+end:
+       return trigger;
+}
+
+void lttng_trigger_destroy(struct lttng_trigger *trigger)
+{
+       if (!trigger) {
+               return;
+       }
+
+       lttng_condition_destroy(trigger->condition);
+       lttng_action_destroy(trigger->action);
+       free(trigger);
+}
+
+LTTNG_HIDDEN
+ssize_t lttng_trigger_create_from_buffer(const char *buf,
+               struct lttng_trigger **trigger)
+{
+       ssize_t ret, trigger_size;
+       struct lttng_condition *condition = NULL;
+       struct lttng_action *action = NULL;
+
+       if (!buf || !trigger) {
+               ret = -1;
+               goto end;
+       }
+
+       ret = lttng_condition_create_from_buffer(buf, &condition);
+       if (ret < 0) {
+               goto end;
+       }
+
+       trigger_size = ret;
+       buf += ret;
+       ret = lttng_action_create_from_buffer(buf, &action);
+       if (ret < 0) {
+               goto end;
+       }
+
+       trigger_size += ret;
+       *trigger = lttng_trigger_create(condition, action);
+       if (!*trigger) {
+               goto error;
+       }
+       ret = trigger_size;
+end:
+       return ret;
+error:
+       lttng_condition_destroy(condition);
+       lttng_action_destroy(action);
+       return ret;
+}
+
+/*
+ * Returns the size of a trigger's condition and action.
+ * Both elements are stored contiguously, see their "*_comm" structure
+ * for the detailed format.
+ */
+LTTNG_HIDDEN
+ssize_t lttng_trigger_serialize(struct lttng_trigger *trigger, char *buf)
+{
+       ssize_t action_size, condition_size, ret;
+
+       if (!trigger) {
+               ret = -1;
+               goto end;
+       }
+
+       condition_size = lttng_condition_serialize(trigger->condition, NULL);
+       if (condition_size < 0) {
+               ret = -1;
+               goto end;
+       }
+
+       action_size = lttng_action_serialize(trigger->action, NULL);
+       if (action_size < 0) {
+               ret = -1;
+               goto end;
+       }
+
+       ret = action_size + condition_size;
+       if (!buf) {
+               goto end;
+       }
+
+       condition_size = lttng_condition_serialize(trigger->condition, buf);
+       if (condition_size < 0) {
+               ret = -1;
+               goto end;
+       }
+
+       buf += condition_size;
+       action_size = lttng_action_serialize(trigger->action, buf);
+       if (action_size < 0) {
+               ret = -1;
+               goto end;
+       }
+end:
+       return ret;
+}
index 2c3428b7c53b02e7744b251013979afe4a071d45..6b6a6eed127525f17a2a94454ea18e8fbf3dacc1 100644 (file)
@@ -5,9 +5,7 @@ SUBDIRS = filter
 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 \
-               action.c notify.c condition.c buffer-usage.c evaluation.c \
-               notification.c trigger.c endpoint.c
+               lttng-ctl-health.c save.c load.c deprecated-symbols.c
 
 liblttng_ctl_la_LDFLAGS = \
                $(LT_NO_UNDEFINED)
diff --git a/src/lib/lttng-ctl/action.c b/src/lib/lttng-ctl/action.c
deleted file mode 100644 (file)
index 7deb509..0000000
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * 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
- */
-
-#include <lttng/action/action-internal.h>
-#include <lttng/action/notify-internal.h>
-#include <assert.h>
-
-enum lttng_action_type lttng_action_get_type(struct lttng_action *action)
-{
-       return action ? action->type : LTTNG_ACTION_TYPE_UNKNOWN;
-}
-
-void lttng_action_destroy(struct lttng_action *action)
-{
-       if (!action) {
-               return;
-       }
-
-       assert(action->destroy);
-       action->destroy(action);
-}
-
-LTTNG_HIDDEN
-bool lttng_action_validate(struct lttng_action *action)
-{
-       bool valid;
-
-       if (!action) {
-               valid = false;
-               goto end;
-       }
-
-       if (!action->validate) {
-               /* Sub-class guarantees that it can never be invalid. */
-               valid = true;
-               goto end;
-       }
-
-       valid = action->validate(action);
-end:
-       return valid;
-}
-
-LTTNG_HIDDEN
-ssize_t lttng_action_serialize(struct lttng_action *action, char *buf)
-{
-       ssize_t ret, action_size;
-       struct lttng_action_comm action_comm;
-
-       if (!action) {
-               ret = -1;
-               goto end;
-       }
-
-       action_comm.action_type = (int8_t) action->type;
-       ret = sizeof(struct lttng_action_comm);
-       if (buf) {
-               memcpy(buf, &action_comm, ret);
-               buf += ret;
-       }
-
-       action_size = action->serialize(action, buf);
-       if (action_size < 0) {
-               ret = action_size;
-               goto end;
-       }
-       ret += action_size;
-end:
-       return ret;
-}
-
-LTTNG_HIDDEN
-ssize_t lttng_action_create_from_buffer(const char *buf,
-               struct lttng_action **_action)
-{
-       ssize_t ret, action_size = sizeof(struct lttng_action_comm);
-       struct lttng_action *action;
-       struct lttng_action_comm *action_comm =
-                       (struct lttng_action_comm *) buf;
-
-       if (!buf || !_action) {
-               ret = -1;
-               goto end;
-       }
-
-       switch (action_comm->action_type) {
-       case LTTNG_ACTION_TYPE_NOTIFY:
-               action = lttng_action_notify_create();
-               break;
-       default:
-               ret = -1;
-               goto end;
-       }
-
-       if (!action) {
-               ret = -1;
-               goto end;
-       }
-       ret = action_size;
-       *_action = action;
-end:
-       return ret;
-}
diff --git a/src/lib/lttng-ctl/buffer-usage.c b/src/lib/lttng-ctl/buffer-usage.c
deleted file mode 100644 (file)
index eed921a..0000000
+++ /dev/null
@@ -1,574 +0,0 @@
-/*
- * 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
- */
-
-#include <lttng/condition/condition-internal.h>
-#include <lttng/condition/buffer-usage-internal.h>
-#include <common/macros.h>
-#include <assert.h>
-
-static
-bool is_usage_condition(struct lttng_condition *condition)
-{
-       enum lttng_condition_type type = lttng_condition_get_type(condition);
-
-       return type == LTTNG_CONDITION_TYPE_BUFFER_USAGE_LOW ||
-                       type == LTTNG_CONDITION_TYPE_BUFFER_USAGE_HIGH;
-}
-
-static
-bool is_usage_evaluation(struct lttng_evaluation *evaluation)
-{
-       enum lttng_condition_type type = lttng_evaluation_get_type(evaluation);
-
-       return type == LTTNG_CONDITION_TYPE_BUFFER_USAGE_LOW ||
-                       type == LTTNG_CONDITION_TYPE_BUFFER_USAGE_HIGH;
-}
-
-static
-void lttng_condition_buffer_usage_destroy(struct lttng_condition *condition)
-{
-       struct lttng_condition_buffer_usage *usage;
-
-       usage = container_of(condition, struct lttng_condition_buffer_usage,
-                       parent);
-
-       free(usage->session_name);
-       free(usage->channel_name);
-       free(usage);
-}
-
-static
-bool lttng_condition_buffer_usage_validate(struct lttng_condition *condition)
-{
-       bool valid = false;
-       struct lttng_condition_buffer_usage *usage;
-
-       if (!condition) {
-               goto end;
-       }
-
-       usage = container_of(condition, struct lttng_condition_buffer_usage,
-                       parent);
-       if (!usage->session_name) {
-               goto end;
-       }
-       if (!usage->channel_name) {
-               goto end;
-       }
-       if (!usage->threshold_percent.set && !usage->threshold_bytes.set) {
-               goto end;
-       }
-
-       valid = true;
-end:
-       return valid;
-}
-
-static
-ssize_t lttng_condition_buffer_usage_serialize(struct lttng_condition *condition,
-               char *buf)
-{
-       struct lttng_condition_buffer_usage *usage;
-       ssize_t size;
-       size_t session_name_len, channel_name_len;
-
-       if (!condition || !is_usage_condition(condition)) {
-               size = -1;
-               goto end;
-       }
-
-       usage = container_of(condition, struct lttng_condition_buffer_usage,
-                       parent);
-       size = sizeof(struct lttng_condition_buffer_usage_comm);
-       session_name_len = strlen(usage->session_name) + 1;
-       channel_name_len = strlen(usage->channel_name) + 1;
-       size += session_name_len + channel_name_len;
-       if (buf) {
-               struct lttng_condition_buffer_usage_comm usage_comm = {
-                       .threshold_set_in_bytes = usage->threshold_bytes.set ? 1 : 0,
-                       .session_name_len = session_name_len,
-                       .channel_name_len = channel_name_len,
-                       .domain_type = (int8_t) usage->domain.type,
-               };
-
-               if (usage->threshold_bytes.set) {
-                       usage_comm.threshold.bytes =
-                                       usage->threshold_bytes.value;
-               } else {
-                       usage_comm.threshold.percent =
-                                       usage->threshold_percent.value;
-               }
-
-               memcpy(buf, &usage_comm, sizeof(usage_comm));
-               buf += sizeof(usage_comm);
-               memcpy(buf, usage->session_name, session_name_len);
-               buf += session_name_len;
-               memcpy(buf, usage->channel_name, channel_name_len);
-               buf += channel_name_len;
-       }
-end:
-       return size;
-}
-
-static
-struct lttng_condition *lttng_condition_buffer_usage_create(
-               enum lttng_condition_type type)
-{
-       struct lttng_condition_buffer_usage *condition;
-
-       condition = zmalloc(sizeof(struct lttng_condition_buffer_usage));
-       if (!condition) {
-               goto end;
-       }
-
-       condition->parent.type = type;
-       condition->parent.validate = lttng_condition_buffer_usage_validate;
-       condition->parent.serialize = lttng_condition_buffer_usage_serialize;
-       condition->parent.destroy = lttng_condition_buffer_usage_destroy;
-end:
-       return &condition->parent;
-}
-
-struct lttng_condition *lttng_condition_buffer_usage_low_create(void)
-{
-       return lttng_condition_buffer_usage_create(
-                       LTTNG_CONDITION_TYPE_BUFFER_USAGE_LOW);
-}
-
-struct lttng_condition *lttng_condition_buffer_usage_high_create(void)
-{
-       return lttng_condition_buffer_usage_create(
-                       LTTNG_CONDITION_TYPE_BUFFER_USAGE_HIGH);
-}
-
-static
-ssize_t init_from_buffer(struct lttng_condition *condition, const char *buf)
-{
-       ssize_t ret, condition_size;
-       enum lttng_condition_status status;
-       enum lttng_domain_type domain_type;
-       struct lttng_condition_buffer_usage_comm *condition_comm =
-                       (struct lttng_condition_buffer_usage_comm *) buf;
-       const char *session_name, *channel_name;
-
-       if (condition_comm->threshold_set_in_bytes) {
-               status = lttng_condition_buffer_usage_set_threshold(condition,
-                               condition_comm->threshold.bytes);
-       } else {
-               status = lttng_condition_buffer_usage_set_threshold_percentage(
-                               condition, condition_comm->threshold.percent);
-       }
-       if (status != LTTNG_CONDITION_STATUS_OK) {
-               ret = -1;
-               goto end;
-       }
-
-       if (condition_comm->domain_type <= LTTNG_DOMAIN_NONE ||
-                       condition_comm->domain_type > LTTNG_DOMAIN_PYTHON) {
-               /* Invalid domain value. */
-               ret = -1;
-               goto end;
-       }
-
-       domain_type = (enum lttng_domain_type) condition_comm->domain_type;
-       status = lttng_condition_buffer_usage_set_domain_type(condition,
-                       domain_type);
-       if (status != LTTNG_CONDITION_STATUS_OK) {
-               ret = -1;
-               goto end;
-       }
-
-       session_name = buf + sizeof(struct lttng_condition_buffer_usage_comm);
-       channel_name = session_name + condition_comm->session_name_len;
-
-       status = lttng_condition_buffer_usage_set_session_name(condition,
-                       session_name);
-       if (status != LTTNG_CONDITION_STATUS_OK) {
-               ret = -1;
-               goto end;
-       }
-
-       status = lttng_condition_buffer_usage_set_channel_name(condition,
-                       channel_name);
-       if (status != LTTNG_CONDITION_STATUS_OK) {
-               ret = -1;
-               goto end;
-       }
-
-       if (!lttng_condition_validate(condition)) {
-               ret = -1;
-               goto end;
-       }
-
-       condition_size = sizeof(*condition_comm);
-       condition_size += (ssize_t) condition_comm->session_name_len;
-       condition_size += (ssize_t) condition_comm->channel_name_len;
-       ret = condition_size;
-end:
-       return ret;
-}
-
-LTTNG_HIDDEN
-ssize_t lttng_condition_buffer_usage_low_create_from_buffer(const char *buf,
-               struct lttng_condition **_condition)
-{
-       ssize_t ret;
-       struct lttng_condition *condition =
-                       lttng_condition_buffer_usage_low_create();
-
-       if (!_condition || !condition) {
-               ret = -1;
-               goto error;
-       }
-
-       ret = init_from_buffer(condition, buf);
-       if (ret < 0) {
-               goto error;
-       }
-
-       *_condition = condition;
-       return ret;
-error:
-       lttng_condition_destroy(condition);
-       return ret;
-}
-
-LTTNG_HIDDEN
-ssize_t lttng_condition_buffer_usage_high_create_from_buffer(const char *buf,
-               struct lttng_condition **_condition)
-{
-       ssize_t ret;
-       struct lttng_condition *condition =
-                       lttng_condition_buffer_usage_high_create();
-
-       if (!_condition || !condition) {
-               ret = -1;
-               goto error;
-       }
-
-       ret = init_from_buffer(condition, buf);
-       if (ret < 0) {
-               goto error;
-       }
-
-       *_condition = condition;
-       return ret;
-error:
-       lttng_condition_destroy(condition);
-       return ret;
-}
-
-enum lttng_condition_status
-lttng_condition_buffer_usage_get_threshold_percentage(
-               struct lttng_condition *condition, double *threshold_percent)
-{
-       struct lttng_condition_buffer_usage *usage;
-       enum lttng_condition_status status = LTTNG_CONDITION_STATUS_OK;
-
-       if (!condition || !is_usage_condition(condition) ||
-                       !threshold_percent) {
-               status = LTTNG_CONDITION_STATUS_INVALID;
-               goto end;
-       }
-
-       usage = container_of(condition, struct lttng_condition_buffer_usage,
-                       parent);
-       if (!usage->threshold_percent.set) {
-               status = LTTNG_CONDITION_STATUS_UNSET;
-               goto end;
-       }
-       *threshold_percent = usage->threshold_percent.value;
-end:
-       return status;
-}
-
-/* threshold_percent expressed as [0.0, 1.0]. */
-enum lttng_condition_status
-lttng_condition_buffer_usage_set_threshold_percentage(
-               struct lttng_condition *condition, double threshold_percent)
-{
-       struct lttng_condition_buffer_usage *usage;
-       enum lttng_condition_status status = LTTNG_CONDITION_STATUS_OK;
-
-       if (!condition || !is_usage_condition(condition) ||
-               threshold_percent < 0.0 || threshold_percent > 1.0) {
-               status = LTTNG_CONDITION_STATUS_INVALID;
-               goto end;
-       }
-
-       usage = container_of(condition, struct lttng_condition_buffer_usage,
-                       parent);
-       usage->threshold_percent.set = true;
-       usage->threshold_bytes.set = false;
-       usage->threshold_percent.value = threshold_percent;
-end:
-       return status;
-}
-
-enum lttng_condition_status
-lttng_condition_buffer_usage_get_threshold(
-               struct lttng_condition *condition, uint64_t *threshold_bytes)
-{
-       struct lttng_condition_buffer_usage *usage;
-       enum lttng_condition_status status = LTTNG_CONDITION_STATUS_OK;
-
-       if (!condition || !is_usage_condition(condition) || !threshold_bytes) {
-               status = LTTNG_CONDITION_STATUS_INVALID;
-               goto end;
-       }
-
-       usage = container_of(condition, struct lttng_condition_buffer_usage,
-                       parent);
-       if (!usage->threshold_bytes.set) {
-               status = LTTNG_CONDITION_STATUS_UNSET;
-               goto end;
-       }
-       *threshold_bytes = usage->threshold_bytes.value;
-end:
-       return status;
-}
-
-enum lttng_condition_status
-lttng_condition_buffer_usage_set_threshold(
-               struct lttng_condition *condition, uint64_t threshold_bytes)
-{
-       struct lttng_condition_buffer_usage *usage;
-       enum lttng_condition_status status = LTTNG_CONDITION_STATUS_OK;
-
-       if (!condition || !is_usage_condition(condition)) {
-               status = LTTNG_CONDITION_STATUS_INVALID;
-               goto end;
-       }
-
-       usage = container_of(condition, struct lttng_condition_buffer_usage,
-                       parent);
-       usage->threshold_percent.set = false;
-       usage->threshold_bytes.set = true;
-       usage->threshold_bytes.value = threshold_bytes;
-end:
-       return status;
-}
-
-enum lttng_condition_status
-lttng_condition_buffer_usage_get_session_name(
-               struct lttng_condition *condition, const char **session_name)
-{
-       struct lttng_condition_buffer_usage *usage;
-       enum lttng_condition_status status = LTTNG_CONDITION_STATUS_OK;
-
-       if (!condition || !is_usage_condition(condition) || !session_name) {
-               status = LTTNG_CONDITION_STATUS_INVALID;
-               goto end;
-       }
-
-       usage = container_of(condition, struct lttng_condition_buffer_usage,
-                       parent);
-       if (!usage->session_name) {
-               status = LTTNG_CONDITION_STATUS_UNSET;
-               goto end;
-       }
-       *session_name = usage->session_name;
-end:
-       return status;
-}
-
-extern enum lttng_condition_status
-lttng_condition_buffer_usage_set_session_name(
-               struct lttng_condition *condition, const char *session_name)
-{
-       struct lttng_condition_buffer_usage *usage;
-       enum lttng_condition_status status = LTTNG_CONDITION_STATUS_OK;
-
-       if (!condition || !is_usage_condition(condition) || !session_name ||
-                       strlen(session_name) == 0) {
-               status = LTTNG_CONDITION_STATUS_INVALID;
-               goto end;
-       }
-
-       usage = container_of(condition, struct lttng_condition_buffer_usage,
-                       parent);
-       usage->session_name = strdup(session_name);
-       if (!usage->session_name) {
-               status = LTTNG_CONDITION_STATUS_ERROR;
-               goto end;
-       }
-end:
-       return status;
-}
-
-enum lttng_condition_status
-lttng_condition_buffer_usage_get_channel_name(
-               struct lttng_condition *condition, const char **channel_name)
-{
-       struct lttng_condition_buffer_usage *usage;
-       enum lttng_condition_status status = LTTNG_CONDITION_STATUS_OK;
-
-       if (!condition || !is_usage_condition(condition) || !channel_name) {
-               status = LTTNG_CONDITION_STATUS_INVALID;
-               goto end;
-       }
-
-       usage = container_of(condition, struct lttng_condition_buffer_usage,
-                       parent);
-       if (!usage->channel_name) {
-               status = LTTNG_CONDITION_STATUS_UNSET;
-               goto end;
-       }
-       *channel_name = usage->channel_name;
-end:
-       return status;
-}
-
-extern enum lttng_condition_status
-lttng_condition_buffer_usage_set_channel_name(
-               struct lttng_condition *condition, const char *channel_name)
-{
-       struct lttng_condition_buffer_usage *usage;
-       enum lttng_condition_status status = LTTNG_CONDITION_STATUS_OK;
-
-       if (!condition || !is_usage_condition(condition) || !channel_name ||
-                       strlen(channel_name) == 0) {
-               status = LTTNG_CONDITION_STATUS_INVALID;
-               goto end;
-       }
-
-       usage = container_of(condition, struct lttng_condition_buffer_usage,
-                       parent);
-       usage->channel_name = strdup(channel_name);
-       if (!usage->channel_name) {
-               status = LTTNG_CONDITION_STATUS_ERROR;
-               goto end;
-       }
-end:
-       return status;
-}
-
-extern enum lttng_condition_status
-lttng_condition_buffer_usage_get_domain_type(
-               struct lttng_condition *condition, enum lttng_domain_type *type)
-{
-       struct lttng_condition_buffer_usage *usage;
-       enum lttng_condition_status status = LTTNG_CONDITION_STATUS_OK;
-
-       if (!condition || !is_usage_condition(condition) || !type) {
-               status = LTTNG_CONDITION_STATUS_INVALID;
-               goto end;
-       }
-
-       usage = container_of(condition, struct lttng_condition_buffer_usage,
-                       parent);
-       if (!usage->domain.set) {
-               status = LTTNG_CONDITION_STATUS_UNSET;
-               goto end;
-       }
-       *type = usage->domain.type;
-end:
-       return status;
-}
-
-extern enum lttng_condition_status
-lttng_condition_buffer_usage_set_domain_type(
-               struct lttng_condition *condition, enum lttng_domain_type type)
-{
-       struct lttng_condition_buffer_usage *usage;
-       enum lttng_condition_status status = LTTNG_CONDITION_STATUS_OK;
-
-       if (!condition || !is_usage_condition(condition) ||
-                       type == LTTNG_DOMAIN_NONE) {
-               status = LTTNG_CONDITION_STATUS_INVALID;
-               goto end;
-       }
-
-       usage = container_of(condition, struct lttng_condition_buffer_usage,
-                       parent);
-       usage->domain.set = true;
-       usage->domain.type = type;
-end:
-       return status;
-}
-
-static
-void lttng_evaluation_buffer_usage_destroy(
-               struct lttng_evaluation *evaluation)
-{
-       struct lttng_evaluation_buffer_usage *usage;
-
-       usage = container_of(evaluation, struct lttng_evaluation_buffer_usage,
-                       parent);
-       free(usage);
-}
-
-LTTNG_HIDDEN
-struct lttng_evaluation *lttng_evaluation_buffer_usage_create(uint64_t use,
-               uint64_t capacity)
-{
-       struct lttng_evaluation_buffer_usage *usage;
-
-       usage = zmalloc(sizeof(struct lttng_evaluation_buffer_usage));
-       if (!usage) {
-               goto end;
-       }
-
-       usage->buffer_use = use;
-       usage->buffer_capacity = capacity;
-       usage->parent.destroy = lttng_evaluation_buffer_usage_destroy;
-end:
-       return &usage->parent;
-}
-
-/*
- * Get the sampled buffer usage which caused the associated condition to
- * evaluate to "true".
- */
-enum lttng_evaluation_status
-lttng_evaluation_buffer_usage_get_usage_percentage(
-               struct lttng_evaluation *evaluation, double *usage_percent)
-{
-       struct lttng_evaluation_buffer_usage *usage;
-       enum lttng_evaluation_status status = LTTNG_EVALUATION_STATUS_OK;
-
-       if (!evaluation || !is_usage_evaluation(evaluation) || !usage_percent) {
-               status = LTTNG_EVALUATION_STATUS_INVALID;
-               goto end;
-       }
-
-       usage = container_of(evaluation, struct lttng_evaluation_buffer_usage,
-                       parent);
-       *usage_percent = (double) usage->buffer_use /
-                       (double) usage->buffer_capacity;
-end:
-       return status;
-}
-
-enum lttng_evaluation_status
-lttng_evaluation_buffer_usage_get_usage(struct lttng_evaluation *evaluation,
-               uint64_t *usage_bytes)
-{
-       struct lttng_evaluation_buffer_usage *usage;
-       enum lttng_evaluation_status status = LTTNG_EVALUATION_STATUS_OK;
-
-       if (!evaluation || !is_usage_evaluation(evaluation) || !usage_bytes) {
-               status = LTTNG_EVALUATION_STATUS_INVALID;
-               goto end;
-       }
-
-       usage = container_of(evaluation, struct lttng_evaluation_buffer_usage,
-                       parent);
-       *usage_bytes = usage->buffer_use;
-end:
-       return status;
-}
diff --git a/src/lib/lttng-ctl/condition.c b/src/lib/lttng-ctl/condition.c
deleted file mode 100644 (file)
index 9f9795d..0000000
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * 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
- */
-
-#include <lttng/condition/condition-internal.h>
-#include <lttng/condition/buffer-usage-internal.h>
-#include <common/macros.h>
-#include <stdbool.h>
-#include <assert.h>
-
-enum lttng_condition_type lttng_condition_get_type(
-               struct lttng_condition *condition)
-{
-       return condition ? condition->type : LTTNG_CONDITION_TYPE_UNKNOWN;
-}
-
-void lttng_condition_destroy(struct lttng_condition *condition)
-{
-       if (!condition) {
-               return;
-       }
-
-       assert(condition->destroy);
-       condition->destroy(condition);
-}
-
-LTTNG_HIDDEN
-bool lttng_condition_validate(struct lttng_condition *condition)
-{
-       bool valid;
-
-       if (!condition) {
-               valid = false;
-               goto end;
-       }
-
-       if (!condition->validate) {
-               /* Sub-class guarantees that it can never be invalid. */
-               valid = true;
-               goto end;
-       }
-
-       valid = condition->validate(condition);
-end:
-       return valid;
-}
-
-LTTNG_HIDDEN
-ssize_t lttng_condition_serialize(struct lttng_condition *condition, char *buf)
-{
-       ssize_t ret, condition_size;
-       struct lttng_condition_comm condition_comm;
-
-       if (!condition) {
-               ret = -1;
-               goto end;
-       }
-
-       condition_comm.condition_type = (int8_t) condition->type;
-       ret = sizeof(struct lttng_condition_comm);
-       if (buf) {
-               memcpy(buf, &condition_comm, ret);
-               buf += ret;
-       }
-
-       condition_size = condition->serialize(condition, buf);
-       if (condition_size < 0) {
-               ret = condition_size;
-               goto end;
-       }
-       ret += condition_size;
-end:
-       return ret;
-}
-
-LTTNG_HIDDEN
-ssize_t lttng_condition_create_from_buffer(const char *buf,
-               struct lttng_condition **condition)
-{
-       ssize_t ret, condition_size = 0;
-       struct lttng_condition_comm *condition_comm =
-                       (struct lttng_condition_comm *) buf;
-
-       if (!buf || !condition) {
-               ret = -1;
-               goto end;
-       }
-
-       condition_size += sizeof(*condition_comm);
-       buf += condition_size;
-
-       switch (condition_comm->condition_type) {
-       case LTTNG_CONDITION_TYPE_BUFFER_USAGE_LOW:
-               ret = lttng_condition_buffer_usage_low_create_from_buffer(buf,
-                               condition);
-               if (ret < 0) {
-                       goto end;
-               }
-               condition_size += ret;
-               break;
-       case LTTNG_CONDITION_TYPE_BUFFER_USAGE_HIGH:
-               ret = lttng_condition_buffer_usage_high_create_from_buffer(buf,
-                               condition);
-               if (ret < 0) {
-                       goto end;
-               }
-               condition_size += ret;
-               break;
-       default:
-               ret = -1;
-               goto end;
-       }
-       ret = condition_size;
-end:
-       return ret;
-}
diff --git a/src/lib/lttng-ctl/endpoint.c b/src/lib/lttng-ctl/endpoint.c
deleted file mode 100644 (file)
index 89066de..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * 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
- */
-
-#include <lttng/endpoint-internal.h>
-
-static
-struct lttng_endpoint lttng_session_daemon_notification_endpoint_instance = {
-       .type = LTTNG_ENDPOINT_TYPE_DEFAULT_SESSIOND_NOTIFICATION
-};
-
-struct lttng_endpoint *lttng_session_daemon_notification_endpoint =
-               &lttng_session_daemon_notification_endpoint_instance;
diff --git a/src/lib/lttng-ctl/evaluation.c b/src/lib/lttng-ctl/evaluation.c
deleted file mode 100644 (file)
index 41e59c1..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * 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
- */
-
-#include <lttng/condition/evaluation-internal.h>
-#include <common/macros.h>
-#include <stdbool.h>
-#include <assert.h>
-
-enum lttng_condition_type lttng_evaluation_get_type(
-               struct lttng_evaluation *evaluation)
-{
-       return evaluation ? evaluation->type : LTTNG_CONDITION_TYPE_UNKNOWN;
-}
-
-void lttng_evaluation_destroy(struct lttng_evaluation *evaluation)
-{
-       if (!evaluation) {
-               return;
-       }
-
-       assert(evaluation->destroy);
-       evaluation->destroy(evaluation);
-}
diff --git a/src/lib/lttng-ctl/notification.c b/src/lib/lttng-ctl/notification.c
deleted file mode 100644 (file)
index 4d96406..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * 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
- */
-
-#include <lttng/notification/notification-internal.h>
-#include <lttng/condition/condition.h>
-#include <lttng/condition/evaluation.h>
-#include <assert.h>
-
-LTTNG_HIDDEN
-struct lttng_notification *lttng_notification_create(
-               struct lttng_condition *condition,
-               struct lttng_evaluation *evaluation)
-{
-       struct lttng_notification *notification = NULL;
-
-       if (!condition || !evaluation) {
-               goto end;
-       }
-
-       notification = zmalloc(sizeof(struct lttng_notification));
-       if (!notification) {
-               goto end;
-       }
-
-       notification->condition = condition;
-       notification->evaluation = evaluation;
-end:
-       return notification;
-}
-
-void lttng_notification_destroy(struct lttng_notification *notification)
-{
-       if (!notification) {
-               return;
-       }
-
-       lttng_condition_destroy(notification->condition);
-       lttng_evaluation_destroy(notification->evaluation);
-       free(notification);
-}
-
-struct lttng_condition *lttng_notification_get_condition(
-               struct lttng_notification *notification)
-{
-       return notification ? notification->condition : NULL;
-}
-
-struct lttng_evaluation *lttng_notification_get_evaluation(
-               struct lttng_notification *notification)
-{
-       return notification ? notification->evaluation : NULL;
-}
diff --git a/src/lib/lttng-ctl/notify.c b/src/lib/lttng-ctl/notify.c
deleted file mode 100644 (file)
index 956c0ec..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * 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
- */
-
-#include <lttng/action/action-internal.h>
-#include <lttng/action/notify-internal.h>
-#include <common/macros.h>
-#include <assert.h>
-
-static
-void lttng_action_notify_destroy(struct lttng_action *action)
-{
-       free(action);
-}
-
-static
-ssize_t lttng_action_notify_serialize(struct lttng_action *action, char *buf)
-{
-       return 0;
-}
-
-struct lttng_action *lttng_action_notify_create(void)
-{
-       struct lttng_action_notify *notify;
-
-       notify = zmalloc(sizeof(struct lttng_action_notify));
-       if (!notify) {
-               goto end;
-       }
-
-       notify->parent.type = LTTNG_ACTION_TYPE_NOTIFY;
-       notify->parent.serialize = lttng_action_notify_serialize;
-       notify->parent.destroy = lttng_action_notify_destroy;
-end:
-       return &notify->parent;
-}
diff --git a/src/lib/lttng-ctl/trigger.c b/src/lib/lttng-ctl/trigger.c
deleted file mode 100644 (file)
index 1d79a61..0000000
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * 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
- */
-
-#include <lttng/trigger/trigger-internal.h>
-#include <lttng/condition/condition-internal.h>
-#include <lttng/action/action-internal.h>
-#include <assert.h>
-
-LTTNG_HIDDEN
-bool lttng_trigger_validate(struct lttng_trigger *trigger)
-{
-       bool valid;
-
-       if (!trigger) {
-               valid = false;
-               goto end;
-       }
-
-       valid = lttng_condition_validate(trigger->condition) &&
-                       lttng_action_validate(trigger->action);
-end:
-       return valid;
-}
-
-struct lttng_trigger *lttng_trigger_create(
-               struct lttng_condition *condition,
-               struct lttng_action *action)
-{
-       struct lttng_trigger *trigger = NULL;
-
-       if (!condition || !action) {
-               goto end;
-       }
-
-       trigger = zmalloc(sizeof(struct lttng_trigger));
-       if (!trigger) {
-               goto end;
-       }
-
-       trigger->condition = condition;
-       trigger->action = action;
-end:
-       return trigger;
-}
-
-void lttng_trigger_destroy(struct lttng_trigger *trigger)
-{
-       if (!trigger) {
-               return;
-       }
-
-       lttng_condition_destroy(trigger->condition);
-       lttng_action_destroy(trigger->action);
-       free(trigger);
-}
-
-LTTNG_HIDDEN
-ssize_t lttng_trigger_create_from_buffer(const char *buf,
-               struct lttng_trigger **trigger)
-{
-       ssize_t ret, trigger_size;
-       struct lttng_condition *condition = NULL;
-       struct lttng_action *action = NULL;
-
-       if (!buf || !trigger) {
-               ret = -1;
-               goto end;
-       }
-
-       ret = lttng_condition_create_from_buffer(buf, &condition);
-       if (ret < 0) {
-               goto end;
-       }
-
-       trigger_size = ret;
-       buf += ret;
-       ret = lttng_action_create_from_buffer(buf, &action);
-       if (ret < 0) {
-               goto end;
-       }
-
-       trigger_size += ret;
-       *trigger = lttng_trigger_create(condition, action);
-       if (!*trigger) {
-               goto error;
-       }
-       ret = trigger_size;
-end:
-       return ret;
-error:
-       lttng_condition_destroy(condition);
-       lttng_action_destroy(action);
-       return ret;
-}
-
-/*
- * Returns the size of a trigger's condition and action.
- * Both elements are stored contiguously, see their "*_comm" structure
- * for the detailed format.
- */
-LTTNG_HIDDEN
-ssize_t lttng_trigger_serialize(struct lttng_trigger *trigger, char *buf)
-{
-       ssize_t action_size, condition_size, ret;
-
-       if (!trigger) {
-               ret = -1;
-               goto end;
-       }
-
-       condition_size = lttng_condition_serialize(trigger->condition, NULL);
-       if (condition_size < 0) {
-               ret = -1;
-               goto end;
-       }
-
-       action_size = lttng_action_serialize(trigger->action, NULL);
-       if (action_size < 0) {
-               ret = -1;
-               goto end;
-       }
-
-       ret = action_size + condition_size;
-       if (!buf) {
-               goto end;
-       }
-
-       condition_size = lttng_condition_serialize(trigger->condition, buf);
-       if (condition_size < 0) {
-               ret = -1;
-               goto end;
-       }
-
-       buf += condition_size;
-       action_size = lttng_action_serialize(trigger->action, buf);
-       if (action_size < 0) {
-               ret = -1;
-               goto end;
-       }
-end:
-       return ret;
-}
This page took 0.050838 seconds and 5 git commands to generate.