Move memstream.h and uuid.h to include/babeltrace/compat directory
authorJP Ikaheimonen <jp_ikaheimonen@mentor.com>
Tue, 7 May 2013 19:53:33 +0000 (15:53 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 7 May 2013 19:53:33 +0000 (15:53 -0400)
As preparation for a new compatibility layer, the files memstream.h
and uuid.h are moved to include/babeltrace/compat.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
converter/babeltrace-log.c
formats/ctf/Makefile.am
formats/ctf/ctf.c
formats/ctf/memstream.h [deleted file]
formats/ctf/metadata/ctf-visitor-generate-io-struct.c
include/Makefile.am
include/babeltrace/compat/memstream.h [new file with mode: 0644]
include/babeltrace/compat/uuid.h [new file with mode: 0644]
include/babeltrace/ctf-ir/metadata.h
include/babeltrace/uuid.h [deleted file]

index 563a90f57f1df018d5f75cd18e70a633aea8811b..52a2fe1de89c195d961780d49d5e760ee2be86d4 100644 (file)
@@ -45,7 +45,7 @@
 
 #include <babeltrace/babeltrace-internal.h>
 #include <babeltrace/ctf/types.h>
-#include <babeltrace/uuid.h>
+#include <babeltrace/compat/uuid.h>
 #include <babeltrace/endian.h>
 
 #define USEC_PER_SEC 1000000UL
index d803b69a2205340ee490b28ee8501bac5e143ca0..6dcc1bb3343cb19f8b6e1a3d1d26708e88fd1f22 100644 (file)
@@ -9,8 +9,7 @@ libbabeltrace_ctf_la_SOURCES = \
        events.c \
        iterator.c \
        callbacks.c \
-       events-private.h \
-       memstream.h
+       events-private.h
 
 # Request that the linker keeps all static libraries objects.
 libbabeltrace_ctf_la_LDFLAGS = \
index 9706f7a3bfcd7eb9b777e5bb8e47036cf397deac..b27f2ec8fba14e99fa0a56f90b5b70345d1edc3d 100644 (file)
@@ -33,7 +33,7 @@
 #include <babeltrace/ctf/events-internal.h>
 #include <babeltrace/trace-handle-internal.h>
 #include <babeltrace/context-internal.h>
-#include <babeltrace/uuid.h>
+#include <babeltrace/compat/uuid.h>
 #include <babeltrace/endian.h>
 #include <inttypes.h>
 #include <stdio.h>
@@ -51,7 +51,7 @@
 #include "metadata/ctf-parser.h"
 #include "metadata/ctf-ast.h"
 #include "events-private.h"
-#include "memstream.h"
+#include <babeltrace/compat/memstream.h>"
 
 #define LOG2_CHAR_BIT  3
 
diff --git a/formats/ctf/memstream.h b/formats/ctf/memstream.h
deleted file mode 100644 (file)
index d2a96cb..0000000
+++ /dev/null
@@ -1,236 +0,0 @@
-#ifndef _BABELTRACE_FORMAT_CTF_MEMSTREAM_H
-#define _BABELTRACE_FORMAT_CTF_MEMSTREAM_H
-
-/*
- * format/ctf/memstream.h
- *
- * Copyright 2012 (c) - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * memstream compatibility layer.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#define _GNU_SOURCE
-#include <config.h>
-
-#ifdef BABELTRACE_HAVE_FMEMOPEN
-#include <stdio.h>
-
-static inline
-FILE *babeltrace_fmemopen(void *buf, size_t size, const char *mode)
-{
-       return fmemopen(buf, size, mode);
-}
-
-#else /* BABELTRACE_HAVE_FMEMOPEN */
-
-#include <stdlib.h>
-#include <stdio.h>
-
-/*
- * Fallback for systems which don't have fmemopen. Copy buffer to a
- * temporary file, and use that file as FILE * input.
- */
-static inline
-FILE *babeltrace_fmemopen(void *buf, size_t size, const char *mode)
-{
-       char tmpname[PATH_MAX];
-       size_t len;
-       FILE *fp;
-       int ret;
-
-       /*
-        * Support reading only.
-        */
-       if (strcmp(mode, "rb") != 0) {
-               return NULL;
-       }
-       strncpy(tmpname, "/tmp/babeltrace-tmp-XXXXXX", PATH_MAX);
-       ret = mkstemp(tmpname);
-       if (ret < 0) {
-               return NULL;
-       }
-       /*
-        * We need to write to the file.
-        */
-       fp = fdopen(ret, "w+");
-       if (!fp) {
-               goto error_unlink;
-       }
-       /* Copy the entire buffer to the file */
-       len = fwrite(buf, sizeof(char), size, fp);
-       if (len != size) {
-               goto error_close;
-       }
-       ret = fseek(fp, 0L, SEEK_SET);
-       if (ret < 0) {
-               perror("fseek");
-               goto error_close;
-       }
-       /* We keep the handle open, but can unlink the file on the VFS. */
-       ret = unlink(tmpname);
-       if (ret < 0) {
-               perror("unlink");
-       }
-       return fp;
-
-error_close:
-       ret = fclose(fp);
-       if (ret < 0) {
-               perror("close");
-       }
-error_unlink:
-       ret = unlink(tmpname);
-       if (ret < 0) {
-               perror("unlink");
-       }
-       return NULL;
-}
-
-#endif /* BABELTRACE_HAVE_FMEMOPEN */
-
-#ifdef BABELTRACE_HAVE_OPEN_MEMSTREAM
-
-#include <stdio.h>
-
-static inline
-FILE *babeltrace_open_memstream(char **ptr, size_t *sizeloc)
-{
-       return open_memstream(ptr, sizeloc);
-}
-
-static inline
-int babeltrace_close_memstream(char **buf, size_t *size, FILE *fp)
-{
-       return fclose(fp);
-}
-
-#else /* BABELTRACE_HAVE_OPEN_MEMSTREAM */
-
-#include <stdlib.h>
-#include <stdio.h>
-
-/*
- * Fallback for systems which don't have open_memstream. Create FILE *
- * with babeltrace_open_memstream, but require call to
- * babeltrace_close_memstream to flush all data written to the FILE *
- * into the buffer (which we allocate).
- */
-static inline
-FILE *babeltrace_open_memstream(char **ptr, size_t *sizeloc)
-{
-       char tmpname[PATH_MAX];
-       int ret;
-       FILE *fp;
-
-       strncpy(tmpname, "/tmp/babeltrace-tmp-XXXXXX", PATH_MAX);
-       ret = mkstemp(tmpname);
-       if (ret < 0) {
-               return NULL;
-       }
-       fp = fdopen(ret, "w+");
-       if (!fp) {
-               goto error_unlink;
-       }
-       /*
-        * babeltrace_flush_memstream will update the buffer content
-        * with read from fp. No need to keep the file around, just the
-        * handle.
-        */
-       ret = unlink(tmpname);
-       if (ret < 0) {
-               perror("unlink");
-       }
-       return fp;
-
-error_unlink:
-       ret = unlink(tmpname);
-       if (ret < 0) {
-               perror("unlink");
-       }
-       return NULL;
-}
-
-/* Get file size, allocate buffer, copy. */
-static inline
-int babeltrace_close_memstream(char **buf, size_t *size, FILE *fp)
-{
-       size_t len, n;
-       long pos;
-       int ret;
-
-       ret = fflush(fp);
-       if (ret < 0) {
-               perror("fflush");
-               return ret;
-       }
-       ret = fseek(fp, 0L, SEEK_END);
-       if (ret < 0) {
-               perror("fseek");
-               return ret;
-       }
-       pos = ftell(fp);
-       if (ret < 0) {
-               perror("ftell");
-               return ret;
-       }
-       *size = pos;
-       /* add final \0 */
-       *buf = calloc(pos + 1, sizeof(char));
-       if (!*buf) {
-               return -ENOMEM;
-       }
-       ret = fseek(fp, 0L, SEEK_SET);
-       if (ret < 0) {
-               perror("fseek");
-               goto error_free;
-       }
-       /* Copy the entire file into the buffer */
-       n = 0;
-       clearerr(fp);
-       while (!feof(fp) && !ferror(fp) && (*size - n > 0)) {
-               len = fread(*buf, sizeof(char), *size - n, fp);
-               n += len;
-       }
-       if (n != *size) {
-               ret = -1;
-               goto error_close;
-       }
-       ret = fclose(fp);
-       if (ret < 0) {
-               perror("fclose");
-               return ret;
-       }
-       return 0;
-
-error_close:
-       ret = fclose(fp);
-       if (ret < 0) {
-               perror("fclose");
-       }
-error_free:
-       free(*buf);
-       *buf = NULL;
-       return ret;
-}
-
-#endif /* BABELTRACE_HAVE_OPEN_MEMSTREAM */
-
-#endif /* _BABELTRACE_FORMAT_CTF_MEMSTREAM_H */
index 0002fe4f45dd1135cba510427b86ab5b9cc92cfe..23c4f2f47377da09da3ca3f63b371ee6c547a6f8 100644 (file)
@@ -36,7 +36,7 @@
 #include <babeltrace/list.h>
 #include <babeltrace/types.h>
 #include <babeltrace/ctf/metadata.h>
-#include <babeltrace/uuid.h>
+#include <babeltrace/compat/uuid.h>
 #include <babeltrace/endian.h>
 #include <babeltrace/ctf/events-internal.h>
 #include "ctf-scanner.h"
index 6a65b5cf46946e80594431c3b690562bdf624e4a..eee2ac1048869435c326057966bfe6fcdf51e790 100644 (file)
@@ -31,6 +31,7 @@ noinst_HEADERS = \
        babeltrace/ctf/types.h \
        babeltrace/ctf/callbacks-internal.h \
        babeltrace/trace-handle-internal.h \
-       babeltrace/uuid.h \
+       babeltrace/compat/uuid.h \
+       babeltrace/compat/memstream.h \
        babeltrace/endian.h \
        babeltrace/mmap-align.h
diff --git a/include/babeltrace/compat/memstream.h b/include/babeltrace/compat/memstream.h
new file mode 100644 (file)
index 0000000..d2a96cb
--- /dev/null
@@ -0,0 +1,236 @@
+#ifndef _BABELTRACE_FORMAT_CTF_MEMSTREAM_H
+#define _BABELTRACE_FORMAT_CTF_MEMSTREAM_H
+
+/*
+ * format/ctf/memstream.h
+ *
+ * Copyright 2012 (c) - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * memstream compatibility layer.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#define _GNU_SOURCE
+#include <config.h>
+
+#ifdef BABELTRACE_HAVE_FMEMOPEN
+#include <stdio.h>
+
+static inline
+FILE *babeltrace_fmemopen(void *buf, size_t size, const char *mode)
+{
+       return fmemopen(buf, size, mode);
+}
+
+#else /* BABELTRACE_HAVE_FMEMOPEN */
+
+#include <stdlib.h>
+#include <stdio.h>
+
+/*
+ * Fallback for systems which don't have fmemopen. Copy buffer to a
+ * temporary file, and use that file as FILE * input.
+ */
+static inline
+FILE *babeltrace_fmemopen(void *buf, size_t size, const char *mode)
+{
+       char tmpname[PATH_MAX];
+       size_t len;
+       FILE *fp;
+       int ret;
+
+       /*
+        * Support reading only.
+        */
+       if (strcmp(mode, "rb") != 0) {
+               return NULL;
+       }
+       strncpy(tmpname, "/tmp/babeltrace-tmp-XXXXXX", PATH_MAX);
+       ret = mkstemp(tmpname);
+       if (ret < 0) {
+               return NULL;
+       }
+       /*
+        * We need to write to the file.
+        */
+       fp = fdopen(ret, "w+");
+       if (!fp) {
+               goto error_unlink;
+       }
+       /* Copy the entire buffer to the file */
+       len = fwrite(buf, sizeof(char), size, fp);
+       if (len != size) {
+               goto error_close;
+       }
+       ret = fseek(fp, 0L, SEEK_SET);
+       if (ret < 0) {
+               perror("fseek");
+               goto error_close;
+       }
+       /* We keep the handle open, but can unlink the file on the VFS. */
+       ret = unlink(tmpname);
+       if (ret < 0) {
+               perror("unlink");
+       }
+       return fp;
+
+error_close:
+       ret = fclose(fp);
+       if (ret < 0) {
+               perror("close");
+       }
+error_unlink:
+       ret = unlink(tmpname);
+       if (ret < 0) {
+               perror("unlink");
+       }
+       return NULL;
+}
+
+#endif /* BABELTRACE_HAVE_FMEMOPEN */
+
+#ifdef BABELTRACE_HAVE_OPEN_MEMSTREAM
+
+#include <stdio.h>
+
+static inline
+FILE *babeltrace_open_memstream(char **ptr, size_t *sizeloc)
+{
+       return open_memstream(ptr, sizeloc);
+}
+
+static inline
+int babeltrace_close_memstream(char **buf, size_t *size, FILE *fp)
+{
+       return fclose(fp);
+}
+
+#else /* BABELTRACE_HAVE_OPEN_MEMSTREAM */
+
+#include <stdlib.h>
+#include <stdio.h>
+
+/*
+ * Fallback for systems which don't have open_memstream. Create FILE *
+ * with babeltrace_open_memstream, but require call to
+ * babeltrace_close_memstream to flush all data written to the FILE *
+ * into the buffer (which we allocate).
+ */
+static inline
+FILE *babeltrace_open_memstream(char **ptr, size_t *sizeloc)
+{
+       char tmpname[PATH_MAX];
+       int ret;
+       FILE *fp;
+
+       strncpy(tmpname, "/tmp/babeltrace-tmp-XXXXXX", PATH_MAX);
+       ret = mkstemp(tmpname);
+       if (ret < 0) {
+               return NULL;
+       }
+       fp = fdopen(ret, "w+");
+       if (!fp) {
+               goto error_unlink;
+       }
+       /*
+        * babeltrace_flush_memstream will update the buffer content
+        * with read from fp. No need to keep the file around, just the
+        * handle.
+        */
+       ret = unlink(tmpname);
+       if (ret < 0) {
+               perror("unlink");
+       }
+       return fp;
+
+error_unlink:
+       ret = unlink(tmpname);
+       if (ret < 0) {
+               perror("unlink");
+       }
+       return NULL;
+}
+
+/* Get file size, allocate buffer, copy. */
+static inline
+int babeltrace_close_memstream(char **buf, size_t *size, FILE *fp)
+{
+       size_t len, n;
+       long pos;
+       int ret;
+
+       ret = fflush(fp);
+       if (ret < 0) {
+               perror("fflush");
+               return ret;
+       }
+       ret = fseek(fp, 0L, SEEK_END);
+       if (ret < 0) {
+               perror("fseek");
+               return ret;
+       }
+       pos = ftell(fp);
+       if (ret < 0) {
+               perror("ftell");
+               return ret;
+       }
+       *size = pos;
+       /* add final \0 */
+       *buf = calloc(pos + 1, sizeof(char));
+       if (!*buf) {
+               return -ENOMEM;
+       }
+       ret = fseek(fp, 0L, SEEK_SET);
+       if (ret < 0) {
+               perror("fseek");
+               goto error_free;
+       }
+       /* Copy the entire file into the buffer */
+       n = 0;
+       clearerr(fp);
+       while (!feof(fp) && !ferror(fp) && (*size - n > 0)) {
+               len = fread(*buf, sizeof(char), *size - n, fp);
+               n += len;
+       }
+       if (n != *size) {
+               ret = -1;
+               goto error_close;
+       }
+       ret = fclose(fp);
+       if (ret < 0) {
+               perror("fclose");
+               return ret;
+       }
+       return 0;
+
+error_close:
+       ret = fclose(fp);
+       if (ret < 0) {
+               perror("fclose");
+       }
+error_free:
+       free(*buf);
+       *buf = NULL;
+       return ret;
+}
+
+#endif /* BABELTRACE_HAVE_OPEN_MEMSTREAM */
+
+#endif /* _BABELTRACE_FORMAT_CTF_MEMSTREAM_H */
diff --git a/include/babeltrace/compat/uuid.h b/include/babeltrace/compat/uuid.h
new file mode 100644 (file)
index 0000000..2ce7467
--- /dev/null
@@ -0,0 +1,129 @@
+#ifndef _BABELTRACE_UUID_H
+#define _BABELTRACE_UUID_H
+
+/*
+ * babeltrace/uuid.h
+ *
+ * Copyright (C) 2011   Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <config.h>
+
+/* Includes final \0. */
+#define BABELTRACE_UUID_STR_LEN                37
+#define BABELTRACE_UUID_LEN            16
+
+#ifdef BABELTRACE_HAVE_LIBUUID
+#include <uuid/uuid.h>
+
+static inline
+int babeltrace_uuid_generate(unsigned char *uuid_out)
+{
+       uuid_generate(uuid_out);
+       return 0;
+}
+
+static inline
+int babeltrace_uuid_unparse(const unsigned char *uuid_in, char *str_out)
+{
+       uuid_unparse(uuid_in, str_out);
+       return 0;
+}
+
+static inline
+int babeltrace_uuid_parse(const char *str_in, unsigned char *uuid_out)
+{
+       return uuid_parse(str_in, uuid_out);
+}
+
+static inline
+int babeltrace_uuid_compare(const unsigned char *uuid_a,
+               const unsigned char *uuid_b)
+{
+       return uuid_compare(uuid_a, uuid_b);
+}
+
+#elif defined(BABELTRACE_HAVE_LIBC_UUID)
+#include <uuid.h>
+#include <stdint.h>
+#include <string.h>
+#include <stdlib.h>
+
+static inline
+int babeltrace_uuid_generate(unsigned char *uuid_out)
+{
+       uint32_t status;
+
+       uuid_create((uuid_t *) uuid_out, &status);
+       if (status == uuid_s_ok)
+               return 0;
+       else
+               return -1;
+}
+
+static inline
+int babeltrace_uuid_unparse(const unsigned char *uuid_in, char *str_out)
+{
+       uint32_t status;
+       char *alloc_str;
+       int ret;
+
+       uuid_to_string((uuid_t *) uuid_in, &alloc_str, &status);
+       if (status == uuid_s_ok) {
+               strcpy(str_out, alloc_str);
+               ret = 0;
+       } else {
+               ret = -1;
+       }
+       free(alloc_str);
+       return ret;
+}
+
+static inline
+int babeltrace_uuid_parse(const char *str_in, unsigned char *uuid_out)
+{
+       uint32_t status;
+
+       uuid_from_string(str_in, (uuid_t *) uuid_out, &status);
+       if (status == uuid_s_ok)
+               return 0;
+       else
+               return -1;
+}
+
+static inline
+int babeltrace_uuid_compare(const unsigned char *uuid_a,
+               const unsigned char *uuid_b)
+{
+       uint32_t status;
+
+       uuid_compare((uuid_t *) uuid_a, (uuid_t *) uuid_b, &status);
+       if (status == uuid_s_ok)
+               return 0;
+       else
+               return -1;
+}
+
+#else
+#error "Babeltrace needs to have a UUID generator configured."
+#endif
+
+#endif /* _BABELTRACE_UUID_H */
index 3d684fb661db86759b0080328bfe18597c5c660b..5e92984dba40906c59bb96c5e4455182bc13233e 100644 (file)
@@ -33,7 +33,7 @@
 #include <babeltrace/ctf/types.h>
 #include <sys/types.h>
 #include <dirent.h>
-#include <babeltrace/uuid.h>
+#include <babeltrace/compat/uuid.h>
 #include <assert.h>
 #include <glib.h>
 
diff --git a/include/babeltrace/uuid.h b/include/babeltrace/uuid.h
deleted file mode 100644 (file)
index 2ce7467..0000000
+++ /dev/null
@@ -1,129 +0,0 @@
-#ifndef _BABELTRACE_UUID_H
-#define _BABELTRACE_UUID_H
-
-/*
- * babeltrace/uuid.h
- *
- * Copyright (C) 2011   Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <config.h>
-
-/* Includes final \0. */
-#define BABELTRACE_UUID_STR_LEN                37
-#define BABELTRACE_UUID_LEN            16
-
-#ifdef BABELTRACE_HAVE_LIBUUID
-#include <uuid/uuid.h>
-
-static inline
-int babeltrace_uuid_generate(unsigned char *uuid_out)
-{
-       uuid_generate(uuid_out);
-       return 0;
-}
-
-static inline
-int babeltrace_uuid_unparse(const unsigned char *uuid_in, char *str_out)
-{
-       uuid_unparse(uuid_in, str_out);
-       return 0;
-}
-
-static inline
-int babeltrace_uuid_parse(const char *str_in, unsigned char *uuid_out)
-{
-       return uuid_parse(str_in, uuid_out);
-}
-
-static inline
-int babeltrace_uuid_compare(const unsigned char *uuid_a,
-               const unsigned char *uuid_b)
-{
-       return uuid_compare(uuid_a, uuid_b);
-}
-
-#elif defined(BABELTRACE_HAVE_LIBC_UUID)
-#include <uuid.h>
-#include <stdint.h>
-#include <string.h>
-#include <stdlib.h>
-
-static inline
-int babeltrace_uuid_generate(unsigned char *uuid_out)
-{
-       uint32_t status;
-
-       uuid_create((uuid_t *) uuid_out, &status);
-       if (status == uuid_s_ok)
-               return 0;
-       else
-               return -1;
-}
-
-static inline
-int babeltrace_uuid_unparse(const unsigned char *uuid_in, char *str_out)
-{
-       uint32_t status;
-       char *alloc_str;
-       int ret;
-
-       uuid_to_string((uuid_t *) uuid_in, &alloc_str, &status);
-       if (status == uuid_s_ok) {
-               strcpy(str_out, alloc_str);
-               ret = 0;
-       } else {
-               ret = -1;
-       }
-       free(alloc_str);
-       return ret;
-}
-
-static inline
-int babeltrace_uuid_parse(const char *str_in, unsigned char *uuid_out)
-{
-       uint32_t status;
-
-       uuid_from_string(str_in, (uuid_t *) uuid_out, &status);
-       if (status == uuid_s_ok)
-               return 0;
-       else
-               return -1;
-}
-
-static inline
-int babeltrace_uuid_compare(const unsigned char *uuid_a,
-               const unsigned char *uuid_b)
-{
-       uint32_t status;
-
-       uuid_compare((uuid_t *) uuid_a, (uuid_t *) uuid_b, &status);
-       if (status == uuid_s_ok)
-               return 0;
-       else
-               return -1;
-}
-
-#else
-#error "Babeltrace needs to have a UUID generator configured."
-#endif
-
-#endif /* _BABELTRACE_UUID_H */
This page took 0.034637 seconds and 4 git commands to generate.