/*
- * Copyright (C) 2013 - David Goulet <dgoulet@efficios.com>
+ * Copyright (C) 2013 David Goulet <dgoulet@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.
+ * 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
*/
-#define _GNU_SOURCE
+#define _LGPL_SOURCE
#include <assert.h>
#include <string.h>
lttng_ctl_copy_string(output->data_url, url, sizeof(output->data_url));
return 0;
}
+
+int lttng_snapshot_output_set_local_path(const char *path,
+ struct lttng_snapshot_output *output)
+{
+ int ret;
+ struct lttng_uri *uris = NULL;
+ ssize_t num_uris;
+
+ if (!path || !output) {
+ ret = -LTTNG_ERR_INVALID;
+ goto end;
+ }
+
+ num_uris = uri_parse_str_urls(path, NULL, &uris);
+ if (num_uris != 1) {
+ ret = -LTTNG_ERR_INVALID;
+ goto end;
+ }
+
+ if (uris[0].dtype != LTTNG_DST_PATH) {
+ ret = -LTTNG_ERR_INVALID;
+ goto end;
+ }
+
+ ret = lttng_strncpy(output->ctrl_url, path, sizeof(output->ctrl_url));
+ if (ret != 0) {
+ ret = -LTTNG_ERR_INVALID;
+ goto end;
+ }
+
+end:
+ free(uris);
+ return ret;
+}
+
+int lttng_snapshot_output_set_network_url(const char *url,
+ struct lttng_snapshot_output *output)
+{
+ int ret;
+ struct lttng_uri *uris = NULL;
+ ssize_t num_uris;
+
+ if (!url || !output) {
+ ret = -LTTNG_ERR_INVALID;
+ goto end;
+ }
+
+ num_uris = uri_parse_str_urls(url, NULL, &uris);
+ if (num_uris != 2) {
+ ret = -LTTNG_ERR_INVALID;
+ goto end;
+ }
+
+ 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) {
+ ret = -LTTNG_ERR_INVALID;
+ goto end;
+ }
+
+ ret = lttng_strncpy(output->ctrl_url, url, sizeof(output->ctrl_url));
+ if (ret != 0) {
+ ret = -LTTNG_ERR_INVALID;
+ goto end;
+ }
+
+end:
+ free(uris);
+ return ret;
+}
+
+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;
+ ssize_t num_uris;
+
+ if (!ctrl_url || !data_url || !output) {
+ ret = -LTTNG_ERR_INVALID;
+ goto end;
+ }
+
+ num_uris = uri_parse_str_urls(ctrl_url, data_url, &uris);
+ if (num_uris != 2) {
+ ret = -LTTNG_ERR_INVALID;
+ goto end;
+ }
+
+ 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) {
+ ret = -LTTNG_ERR_INVALID;
+ goto end;
+ }
+
+ ret = lttng_strncpy(output->ctrl_url, ctrl_url, sizeof(output->ctrl_url));
+ if (ret != 0) {
+ ret = -LTTNG_ERR_INVALID;
+ goto end;
+ }
+
+ ret = lttng_strncpy(output->data_url, data_url, sizeof(output->data_url));
+ if (ret != 0) {
+ ret = -LTTNG_ERR_INVALID;
+ goto end;
+ }
+
+end:
+ free(uris);
+ return ret;
+}