MI: support double element
authorJonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Thu, 4 Feb 2021 20:57:56 +0000 (15:57 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 22 Jun 2021 17:40:35 +0000 (13:40 -0400)
Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I97411fea238d8b1275028d3d04a6f4f376624001

src/common/config/session-config.c
src/common/config/session-config.h
src/common/mi-lttng.c
src/common/mi-lttng.h

index b08f40a2e319155074b39d39ddcdf427eb333442..2263d9478039311163fa5bce2e79554b71f5367b 100644 (file)
@@ -639,6 +639,32 @@ int config_writer_write_element_bool(struct config_writer *writer,
                value ? config_xml_true : config_xml_false);
 }
 
+LTTNG_HIDDEN
+int config_writer_write_element_double(struct config_writer *writer,
+               const char *element_name,
+               double value)
+{
+       int ret;
+       xmlChar *encoded_element_name;
+
+       if (!writer || !writer->writer || !element_name || !element_name[0]) {
+               ret = -1;
+               goto end;
+       }
+
+       encoded_element_name = encode_string(element_name);
+       if (!encoded_element_name) {
+               ret = -1;
+               goto end;
+       }
+
+       ret = xmlTextWriterWriteFormatElement(
+                       writer->writer, encoded_element_name, "%f", value);
+       xmlFree(encoded_element_name);
+end:
+       return ret >= 0 ? 0 : ret;
+}
+
 LTTNG_HIDDEN
 int config_writer_write_element_string(struct config_writer *writer,
                const char *element_name, const char *value)
index 82400a5ae8fa1073caba517eec8d355323c429e5..1a6019fb122ed8fdb00195e29e324b01b8f3f071 100644 (file)
@@ -200,6 +200,23 @@ LTTNG_HIDDEN
 int config_writer_write_element_string(struct config_writer *writer,
                const char *element_name, const char *value);
 
+/*
+ * Write an element of type double.
+ *
+ * writer An instance of a configuration writer.
+ *
+ * element_name Element name.
+ *
+ * value Double value of the element
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+LTTNG_HIDDEN
+int config_writer_write_element_double(struct config_writer *writer,
+               const char *element_name,
+               double value);
+
 /*
  * Load session configurations from a file.
  *
index bdd6dcea15be62314c67256603e4bc1e4255f24e..9031677d73fbca94242a7b023c622c6d925e9a28 100644 (file)
@@ -721,6 +721,15 @@ int mi_lttng_writer_write_element_string(struct mi_writer *writer,
                        element_name, value);
 }
 
+LTTNG_HIDDEN
+int mi_lttng_writer_write_element_double(struct mi_writer *writer,
+               const char *element_name,
+               double value)
+{
+       return config_writer_write_element_double(
+                       writer->writer, element_name, value);
+}
+
 LTTNG_HIDDEN
 int mi_lttng_version(struct mi_writer *writer, struct mi_lttng_version *version,
        const char *lttng_description, const char *lttng_license)
index 9c985f6bbe68a720ed867fe96a07d59f07ee845b..ad92832368e8d4d35c6d21da878f457b3453483e 100644 (file)
@@ -353,6 +353,20 @@ int mi_lttng_writer_write_element_bool(struct mi_writer *writer,
 int mi_lttng_writer_write_element_string(struct mi_writer *writer,
                const char *element_name, const char *value);
 
+/*
+ * Write an element of type double.
+ *
+ * writer An instance of a machine interface writer.
+ * element_name Element name.
+ * value Double value of the element.
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int mi_lttng_writer_write_element_double(struct mi_writer *writer,
+               const char *element_name,
+               double value);
+
 /*
  * Machine interface of struct version.
  *
This page took 0.030645 seconds and 4 git commands to generate.