Fix: add missing semicolons after MSG, DBG, ERR print macros
[lttng-tools.git] / src / lib / lttng-ctl / save.c
index f215468a295ab647227cc4f679d3bb6c97f93ff9..f8b9043b634fcf053644721d4770b57250a2377c 100644 (file)
@@ -15,7 +15,7 @@
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#define _GNU_SOURCE
+#define _LGPL_SOURCE
 #include <assert.h>
 #include <string.h>
 
 #include <assert.h>
 #include <string.h>
 
@@ -82,7 +82,7 @@ int lttng_save_session_attr_set_session_name(
                size_t len;
 
                len = strlen(session_name);
                size_t len;
 
                len = strlen(session_name);
-               if (len >= NAME_MAX) {
+               if (len >= LTTNG_NAME_MAX) {
                        ret = -LTTNG_ERR_INVALID;
                        goto error;
                }
                        ret = -LTTNG_ERR_INVALID;
                        goto error;
                }
@@ -99,26 +99,40 @@ int lttng_save_session_attr_set_output_url(
        struct lttng_save_session_attr *attr, const char *url)
 {
        int ret = 0;
        struct lttng_save_session_attr *attr, const char *url)
 {
        int ret = 0;
+       size_t len;
+       ssize_t size;
+       struct lttng_uri *uris = NULL;
 
        if (!attr) {
                ret = -LTTNG_ERR_INVALID;
                goto error;
        }
 
 
        if (!attr) {
                ret = -LTTNG_ERR_INVALID;
                goto error;
        }
 
-       if (url) {
-               size_t len;
+       if (!url) {
+               attr->configuration_url[0] = '\0';
+               ret = 0;
+               goto end;
+       }
 
 
-               len = strlen(url);
-               if (len >= PATH_MAX) {
-                       ret = -LTTNG_ERR_INVALID;
-                       goto error;
-               }
+       len = strlen(url);
+       if (len >= PATH_MAX) {
+               ret = -LTTNG_ERR_INVALID;
+               goto error;
+       }
 
 
-               strncpy(attr->configuration_url, url, len);
-       } else {
-               attr->configuration_url[0] = '\0';
+       size = uri_parse_str_urls(url, NULL, &uris);
+       if (size <= 0 || uris[0].dtype != LTTNG_DST_PATH) {
+               ret = -LTTNG_ERR_INVALID;
+               goto error;
        }
        }
+
+       /* Copy string plus the NULL terminated byte. */
+       lttng_ctl_copy_string(attr->configuration_url, uris[0].dst.path,
+                       sizeof(attr->configuration_url));
+
+end:
 error:
 error:
+       free(uris);
        return ret;
 }
 
        return ret;
 }
 
This page took 0.023625 seconds and 4 git commands to generate.