X-Git-Url: http://git.efficios.com/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fcommon%2Fevaluation.c;h=efd2129217e8829816808901ecf3351baa173d38;hp=c6243d232e82690ab9ca4a39cea3ed4aff1de974;hb=ab5be9fa2eb5ba9600a82cd18fd3cfcbac69169a;hpb=a58c490f0bff52a73717d31d04d1472629180de2 diff --git a/src/common/evaluation.c b/src/common/evaluation.c index c6243d232..efd212921 100644 --- a/src/common/evaluation.c +++ b/src/common/evaluation.c @@ -1,50 +1,47 @@ /* - * Copyright (C) 2017 - Jérémie Galarneau + * Copyright (C) 2017 Jérémie Galarneau * - * 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. + * SPDX-License-Identifier: LGPL-2.1-only * - * 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 #include +#include +#include #include #include #include #include LTTNG_HIDDEN -ssize_t lttng_evaluation_serialize(struct lttng_evaluation *evaluation, - char *buf) +void lttng_evaluation_init(struct lttng_evaluation *evaluation, + enum lttng_condition_type type) { - ssize_t ret, offset = 0; - struct lttng_evaluation_comm evaluation_comm; + evaluation->type = type; +} - evaluation_comm.type = (int8_t) evaluation->type; - if (buf) { - memcpy(buf, &evaluation_comm, sizeof(evaluation_comm)); +LTTNG_HIDDEN +int lttng_evaluation_serialize(const struct lttng_evaluation *evaluation, + struct lttng_dynamic_buffer *buf) +{ + int ret; + struct lttng_evaluation_comm evaluation_comm = { + .type = (int8_t) evaluation->type + }; + + ret = lttng_dynamic_buffer_append(buf, &evaluation_comm, + sizeof(evaluation_comm)); + if (ret) { + goto end; } - offset += sizeof(evaluation_comm); if (evaluation->serialize) { - ret = evaluation->serialize(evaluation, - buf ? (buf + offset) : NULL); - if (ret < 0) { + ret = evaluation->serialize(evaluation, buf); + if (ret) { goto end; } - offset += ret; } - - ret = offset; end: return ret; } @@ -85,6 +82,30 @@ ssize_t lttng_evaluation_create_from_buffer( } evaluation_size += ret; break; + case LTTNG_CONDITION_TYPE_SESSION_CONSUMED_SIZE: + ret = lttng_evaluation_session_consumed_size_create_from_buffer( + &evaluation_view, evaluation); + if (ret < 0) { + goto end; + } + evaluation_size += ret; + break; + case LTTNG_CONDITION_TYPE_SESSION_ROTATION_ONGOING: + ret = lttng_evaluation_session_rotation_ongoing_create_from_buffer( + &evaluation_view, evaluation); + if (ret < 0) { + goto end; + } + evaluation_size += ret; + break; + case LTTNG_CONDITION_TYPE_SESSION_ROTATION_COMPLETED: + ret = lttng_evaluation_session_rotation_completed_create_from_buffer( + &evaluation_view, evaluation); + if (ret < 0) { + goto end; + } + evaluation_size += ret; + break; default: ERR("Attempted to create evaluation of unknown type (%i)", (int) evaluation_comm->type);