*/
#define _LGPL_SOURCE
-#include <string.h>
+#include "lttng-ctl-helper.hpp"
+
+#include <common/sessiond-comm/sessiond-comm.hpp>
-#include <common/sessiond-comm/sessiond-comm.h>
#include <lttng/lttng-error.h>
+#include <lttng/snapshot-internal.hpp>
#include <lttng/snapshot.h>
-#include <lttng/snapshot-internal.h>
-#include "lttng-ctl-helper.h"
+#include <string.h>
/*
* Add an output object to a session identified by name.
*
* Return 0 on success or else a negative LTTNG_ERR code.
*/
-int lttng_snapshot_add_output(const char *session_name,
- struct lttng_snapshot_output *output)
+int lttng_snapshot_add_output(const char *session_name, struct lttng_snapshot_output *output)
{
int ret;
struct lttcomm_session_msg lsm;
}
memset(&lsm, 0, sizeof(lsm));
- lsm.cmd_type = LTTNG_SNAPSHOT_ADD_OUTPUT;
+ lsm.cmd_type = LTTCOMM_SESSIOND_COMMAND_SNAPSHOT_ADD_OUTPUT;
- ret = lttng_strncpy(lsm.session.name, session_name,
- sizeof(lsm.session.name));
+ ret = lttng_strncpy(lsm.session.name, session_name, sizeof(lsm.session.name));
if (ret) {
ret = -LTTNG_ERR_INVALID;
goto end;
}
- memcpy(&lsm.u.snapshot_output.output, output,
- sizeof(lsm.u.snapshot_output.output));
+ memcpy(&lsm.u.snapshot_output.output, output, sizeof(lsm.u.snapshot_output.output));
ret = lttng_ctl_ask_sessiond(&lsm, (void **) &reply);
if (ret < 0) {
*
* Return 0 on success or else a negative LTTNG_ERR code.
*/
-int lttng_snapshot_del_output(const char *session_name,
- struct lttng_snapshot_output *output)
+int lttng_snapshot_del_output(const char *session_name, struct lttng_snapshot_output *output)
{
int ret;
struct lttcomm_session_msg lsm;
}
memset(&lsm, 0, sizeof(lsm));
- lsm.cmd_type = LTTNG_SNAPSHOT_DEL_OUTPUT;
+ lsm.cmd_type = LTTCOMM_SESSIOND_COMMAND_SNAPSHOT_DEL_OUTPUT;
- ret = lttng_strncpy(lsm.session.name, session_name,
- sizeof(lsm.session.name));
+ ret = lttng_strncpy(lsm.session.name, session_name, sizeof(lsm.session.name));
if (ret) {
ret = -LTTNG_ERR_INVALID;
goto end;
}
- memcpy(&lsm.u.snapshot_output.output, output,
- sizeof(lsm.u.snapshot_output.output));
+ memcpy(&lsm.u.snapshot_output.output, output, sizeof(lsm.u.snapshot_output.output));
- ret = lttng_ctl_ask_sessiond(&lsm, NULL);
+ ret = lttng_ctl_ask_sessiond(&lsm, nullptr);
end:
return ret;
}
* Return 0 on success or else a negative LTTNG_ERR code and the list pointer
* is untouched.
*/
-int lttng_snapshot_list_output(const char *session_name,
- struct lttng_snapshot_output_list **list)
+int lttng_snapshot_list_output(const char *session_name, struct lttng_snapshot_output_list **list)
{
int ret;
struct lttcomm_session_msg lsm;
- struct lttng_snapshot_output_list *new_list = NULL;
+ struct lttng_snapshot_output_list *new_list = nullptr;
if (!session_name || !list) {
ret = -LTTNG_ERR_INVALID;
}
memset(&lsm, 0, sizeof(lsm));
- lsm.cmd_type = LTTNG_SNAPSHOT_LIST_OUTPUT;
+ lsm.cmd_type = LTTCOMM_SESSIOND_COMMAND_SNAPSHOT_LIST_OUTPUT;
- ret = lttng_strncpy(lsm.session.name, session_name,
- sizeof(lsm.session.name));
+ ret = lttng_strncpy(lsm.session.name, session_name, sizeof(lsm.session.name));
if (ret) {
ret = -LTTNG_ERR_INVALID;
goto error;
}
- new_list = (lttng_snapshot_output_list *) zmalloc(sizeof(*new_list));
+ new_list = zmalloc<lttng_snapshot_output_list>();
if (!new_list) {
ret = -LTTNG_ERR_NOMEM;
goto error;
* Return the next object on success or else NULL indicating the end of the
* list.
*/
-struct lttng_snapshot_output *lttng_snapshot_output_list_get_next(
- struct lttng_snapshot_output_list *list)
+struct lttng_snapshot_output *
+lttng_snapshot_output_list_get_next(struct lttng_snapshot_output_list *list)
{
- struct lttng_snapshot_output *output = NULL;
+ struct lttng_snapshot_output *output = nullptr;
if (!list) {
goto error;
* Return 0 on success or else a negative LTTNG_ERR value.
*/
int lttng_snapshot_record(const char *session_name,
- struct lttng_snapshot_output *output,
- int wait __attribute__((unused)))
+ struct lttng_snapshot_output *output,
+ int wait __attribute__((unused)))
{
int ret;
struct lttcomm_session_msg lsm;
}
memset(&lsm, 0, sizeof(lsm));
- lsm.cmd_type = LTTNG_SNAPSHOT_RECORD;
+ lsm.cmd_type = LTTCOMM_SESSIOND_COMMAND_SNAPSHOT_RECORD;
- ret = lttng_strncpy(lsm.session.name, session_name,
- sizeof(lsm.session.name));
+ ret = lttng_strncpy(lsm.session.name, session_name, sizeof(lsm.session.name));
if (ret) {
ret = -LTTNG_ERR_INVALID;
goto end;
* record.
*/
if (output) {
- memcpy(&lsm.u.snapshot_record.output, output,
- sizeof(lsm.u.snapshot_record.output));
+ memcpy(&lsm.u.snapshot_record.output, output, sizeof(lsm.u.snapshot_record.output));
}
/* The wait param is ignored. */
- ret = lttng_ctl_ask_sessiond(&lsm, NULL);
+ ret = lttng_ctl_ask_sessiond(&lsm, nullptr);
end:
return ret;
}
{
struct lttng_snapshot_output *output;
- output = (lttng_snapshot_output *) zmalloc(sizeof(struct lttng_snapshot_output));
+ output = zmalloc<lttng_snapshot_output>();
if (!output) {
goto error;
}
return output->id;
}
-const char *lttng_snapshot_output_get_name(
- const struct lttng_snapshot_output *output)
+const char *lttng_snapshot_output_get_name(const struct lttng_snapshot_output *output)
{
return output->name;
}
return output->ctrl_url;
}
-uint64_t lttng_snapshot_output_get_maxsize(
- const struct lttng_snapshot_output *output)
+uint64_t lttng_snapshot_output_get_maxsize(const struct lttng_snapshot_output *output)
{
return output->max_size;
}
* Setter family functions for snapshot output.
*/
-int lttng_snapshot_output_set_id(uint32_t id,
- struct lttng_snapshot_output *output)
+int lttng_snapshot_output_set_id(uint32_t id, struct lttng_snapshot_output *output)
{
if (!output || id == 0) {
return -LTTNG_ERR_INVALID;
return 0;
}
-int lttng_snapshot_output_set_size(uint64_t size,
- struct lttng_snapshot_output *output)
+int lttng_snapshot_output_set_size(uint64_t size, struct lttng_snapshot_output *output)
{
if (!output) {
return -LTTNG_ERR_INVALID;
return 0;
}
-int lttng_snapshot_output_set_name(const char *name,
- struct lttng_snapshot_output *output)
+int lttng_snapshot_output_set_name(const char *name, struct lttng_snapshot_output *output)
{
int ret;
return ret;
}
-int lttng_snapshot_output_set_ctrl_url(const char *url,
- struct lttng_snapshot_output *output)
+int lttng_snapshot_output_set_ctrl_url(const char *url, struct lttng_snapshot_output *output)
{
int ret;
return ret;
}
-int lttng_snapshot_output_set_data_url(const char *url,
- struct lttng_snapshot_output *output)
+int lttng_snapshot_output_set_data_url(const char *url, struct lttng_snapshot_output *output)
{
int ret;
return ret;
}
-int lttng_snapshot_output_set_local_path(const char *path,
- struct lttng_snapshot_output *output)
+int lttng_snapshot_output_set_local_path(const char *path, struct lttng_snapshot_output *output)
{
int ret;
- struct lttng_uri *uris = NULL;
+ struct lttng_uri *uris = nullptr;
ssize_t num_uris;
if (!path || !output) {
goto end;
}
- num_uris = uri_parse_str_urls(path, NULL, &uris);
+ num_uris = uri_parse_str_urls(path, nullptr, &uris);
if (num_uris != 1) {
ret = -LTTNG_ERR_INVALID;
goto end;
return ret;
}
-int lttng_snapshot_output_set_network_url(const char *url,
- struct lttng_snapshot_output *output)
+int lttng_snapshot_output_set_network_url(const char *url, struct lttng_snapshot_output *output)
{
int ret;
- struct lttng_uri *uris = NULL;
+ struct lttng_uri *uris = nullptr;
ssize_t num_uris;
if (!url || !output) {
goto end;
}
- num_uris = uri_parse_str_urls(url, NULL, &uris);
+ num_uris = uri_parse_str_urls(url, nullptr, &uris);
if (num_uris != 2) {
ret = -LTTNG_ERR_INVALID;
goto end;
}
- if (uris[0].dtype != LTTNG_DST_IPV4 &&
- uris[0].dtype != LTTNG_DST_IPV6) {
+ if (uris[0].dtype != LTTNG_DST_IPV4 && uris[0].dtype != LTTNG_DST_IPV6) {
ret = -LTTNG_ERR_INVALID;
goto end;
}
- if (uris[1].dtype != LTTNG_DST_IPV4 &&
- uris[1].dtype != LTTNG_DST_IPV6) {
+ if (uris[1].dtype != LTTNG_DST_IPV4 && uris[1].dtype != LTTNG_DST_IPV6) {
ret = -LTTNG_ERR_INVALID;
goto end;
}
return ret;
}
-int lttng_snapshot_output_set_network_urls(
- const char *ctrl_url, const char *data_url,
- struct lttng_snapshot_output *output)
+int lttng_snapshot_output_set_network_urls(const char *ctrl_url,
+ const char *data_url,
+ struct lttng_snapshot_output *output)
{
int ret;
- struct lttng_uri *uris = NULL;
+ struct lttng_uri *uris = nullptr;
ssize_t num_uris;
if (!ctrl_url || !data_url || !output) {
goto end;
}
- if (uris[0].dtype != LTTNG_DST_IPV4 &&
- uris[0].dtype != LTTNG_DST_IPV6) {
+ if (uris[0].dtype != LTTNG_DST_IPV4 && uris[0].dtype != LTTNG_DST_IPV6) {
ret = -LTTNG_ERR_INVALID;
goto end;
}
- if (uris[1].dtype != LTTNG_DST_IPV4 &&
- uris[1].dtype != LTTNG_DST_IPV6) {
+ if (uris[1].dtype != LTTNG_DST_IPV4 && uris[1].dtype != LTTNG_DST_IPV6) {
ret = -LTTNG_ERR_INVALID;
goto end;
}