[ltt-dev] [BABELTRACE PATCH] Export the babeltrace API in babeltrace.h

Julien Desfossez julien.desfossez at polymtl.ca
Fri Aug 12 19:27:13 EDT 2011


Rename the previous babeltrace.h as babeltrace-internal.h

Signed-off-by: Julien Desfossez <julien.desfossez at polymtl.ca>
---
 configure.ac                                       |    3 +
 converter/babeltrace-api.h                         |   93 -----------------
 converter/babeltrace-lib.c                         |    5 +-
 converter/babeltrace-log.c                         |    2 +-
 converter/babeltrace.c                             |    2 +-
 formats/bt-dummy/bt-dummy.c                        |    2 +-
 formats/ctf-text/ctf-text.c                        |    2 +-
 formats/ctf/ctf.c                                  |    2 +-
 formats/ctf/metadata/ctf-parser-test.c             |    2 +-
 .../ctf/metadata/ctf-visitor-generate-io-struct.c  |    2 +-
 formats/ctf/metadata/ctf-visitor-parent-links.c    |    2 +-
 .../ctf/metadata/ctf-visitor-semantic-validator.c  |    2 +-
 formats/ctf/metadata/ctf-visitor-xml.c             |    2 +-
 formats/ctf/types/string.c                         |    2 +-
 include/Makefile.am                                |    4 +-
 include/babeltrace/babeltrace-internal.h           |   31 ++++++
 include/babeltrace/babeltrace.h                    |  110 +++++++++++++++-----
 include/babeltrace/ctf-text/types.h                |    2 +-
 include/babeltrace/ctf/types.h                     |    2 +-
 types/types.c                                      |    2 +-
 20 files changed, 139 insertions(+), 135 deletions(-)
 delete mode 100644 converter/babeltrace-api.h
 create mode 100644 include/babeltrace/babeltrace-internal.h

diff --git a/configure.ac b/configure.ac
index 7764b15..1ed70d7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -48,6 +48,9 @@ LIBS="$LIBS $GMODULE_LIBS"
 PACKAGE_CFLAGS="$GMODULE_CFLAGS -Wall -Wformat"
 AC_SUBST(PACKAGE_CFLAGS)
 
+babeltraceincludedir="${includedir}"
+AC_SUBST(babeltraceincludedir)
+
 AC_CONFIG_FILES([
 	Makefile
 	types/Makefile
diff --git a/converter/babeltrace-api.h b/converter/babeltrace-api.h
deleted file mode 100644
index d16352a..0000000
--- a/converter/babeltrace-api.h
+++ /dev/null
@@ -1,93 +0,0 @@
-#ifndef _BABELTRACE_LIB_H
-#define _BABELTRACE_LIB_H
-
-/*
- * BabelTrace API
- *
- * Copyright 2010-2011 - Mathieu Desnoyers <mathieu.desnoyers at 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.
- */
-
-#include <babeltrace/types.h>
-#include <babeltrace/format.h>
-#include <babeltrace/ctf/types.h>
-#include <babeltrace/ctf-ir/metadata.h>
-
-/*
- * struct babeltrace_iter: data structure representing an iterator on a trace
- * collection.
- */
-struct babeltrace_iter {
-	struct ptr_heap *stream_heap;
-	struct trace_collection *tc;
-};
-
-struct babeltrace_iter_pos {
-	GPtrArray *pos; /* struct babeltrace_iter_stream_pos */
-};
-
-struct babeltrace_iter_stream_pos {
-	struct stream_pos parent;
-	ssize_t offset;
-	size_t cur_index;
-};
-
-/*
- * Initialization/teardown.
- */
-struct babeltrace_iter *babeltrace_iter_create(struct trace_collection *tc);
-void babeltrace_iter_destroy(struct babeltrace_iter *iter);
-
-/*
- * Move within the trace.
- */
-/*
- * babeltrace_iter_next: Move stream position to the next event.
- *
- * Returns 0 on success, a negative value on error
- */
-int babeltrace_iter_next(struct babeltrace_iter *iter);
-
-/* Get the current position for each stream of the trace */
-struct babeltrace_iter_pos *
-babeltrace_iter_get_pos(struct babeltrace_iter *iter);
-
-/* The position needs to be freed after use */
-void babeltrace_iter_free_pos(struct babeltrace_iter_pos *pos);
-
-/* Seek the trace to the position */
-int babeltrace_iter_seek_pos(struct babeltrace_iter *iter,
-		struct babeltrace_iter_pos *pos);
-
-/*
- * babeltrace_iter_seek_time: Seek the trace to the given timestamp.
- *
- * Return EOF if timestamp is after the last event of the trace.
- * Return other negative value for other errors.
- * Return 0 for success.
- */
-int babeltrace_iter_seek_time(struct babeltrace_iter *iter,
-		uint64_t timestamp);
-
-/*
- * babeltrace_iter_read_event: Read the current event data.
- *
- * @iter: trace iterator (input)
- * @stream: stream containing event at current position (output)
- * @event: current event (output)
- * Return 0 on success, negative error value on error.
- */
-int babeltrace_iter_read_event(struct babeltrace_iter *iter,
-		struct ctf_stream **stream,
-		struct ctf_stream_event **event);
-
-#endif /* _BABELTRACE_LIB_H */
diff --git a/converter/babeltrace-lib.c b/converter/babeltrace-lib.c
index 656bae8..4f7d790 100644
--- a/converter/babeltrace-lib.c
+++ b/converter/babeltrace-lib.c
@@ -22,14 +22,13 @@
 #include <errno.h>
 #include <stdio.h>
 #include <inttypes.h>
-#include <babeltrace/babeltrace.h>
+#include <babeltrace/babeltrace-internal.h>
 #include <babeltrace/format.h>
 #include <babeltrace/ctf/types.h>
 #include <babeltrace/ctf/metadata.h>
 #include <babeltrace/ctf-text/types.h>
 #include <babeltrace/prio_heap.h>
-
-#include "babeltrace-api.h"
+#include <babeltrace/babeltrace.h>
 
 static int stream_read_event(struct ctf_file_stream *sin)
 {
diff --git a/converter/babeltrace-log.c b/converter/babeltrace-log.c
index 16f9a17..9ca2b47 100644
--- a/converter/babeltrace-log.c
+++ b/converter/babeltrace-log.c
@@ -35,7 +35,7 @@
 #include <string.h>
 #include <endian.h>
 
-#include <babeltrace/babeltrace.h>
+#include <babeltrace/babeltrace-internal.h>
 #include <babeltrace/ctf/types.h>
 
 #define USEC_PER_SEC 1000000UL
diff --git a/converter/babeltrace.c b/converter/babeltrace.c
index ded493c..5c37242 100644
--- a/converter/babeltrace.c
+++ b/converter/babeltrace.c
@@ -20,7 +20,7 @@
 
 #define _XOPEN_SOURCE 700
 #include <config.h>
-#include <babeltrace/babeltrace.h>
+#include <babeltrace/babeltrace-internal.h>
 #include <babeltrace/format.h>
 #include <popt.h>
 #include <errno.h>
diff --git a/formats/bt-dummy/bt-dummy.c b/formats/bt-dummy/bt-dummy.c
index 221b51f..41cfb74 100644
--- a/formats/bt-dummy/bt-dummy.c
+++ b/formats/bt-dummy/bt-dummy.c
@@ -18,7 +18,7 @@
 
 #include <babeltrace/ctf-text/types.h>
 #include <babeltrace/format.h>
-#include <babeltrace/babeltrace.h>
+#include <babeltrace/babeltrace-internal.h>
 #include <inttypes.h>
 #include <uuid/uuid.h>
 #include <sys/mman.h>
diff --git a/formats/ctf-text/ctf-text.c b/formats/ctf-text/ctf-text.c
index ac35cfb..f1ddbaf 100644
--- a/formats/ctf-text/ctf-text.c
+++ b/formats/ctf-text/ctf-text.c
@@ -21,7 +21,7 @@
 #include <babeltrace/format.h>
 #include <babeltrace/ctf-text/types.h>
 #include <babeltrace/ctf/metadata.h>
-#include <babeltrace/babeltrace.h>
+#include <babeltrace/babeltrace-internal.h>
 #include <inttypes.h>
 #include <uuid/uuid.h>
 #include <sys/mman.h>
diff --git a/formats/ctf/ctf.c b/formats/ctf/ctf.c
index b39b869..95a581f 100644
--- a/formats/ctf/ctf.c
+++ b/formats/ctf/ctf.c
@@ -21,7 +21,7 @@
 #include <babeltrace/format.h>
 #include <babeltrace/ctf/types.h>
 #include <babeltrace/ctf/metadata.h>
-#include <babeltrace/babeltrace.h>
+#include <babeltrace/babeltrace-internal.h>
 #include <inttypes.h>
 #include <stdio.h>
 #include <uuid/uuid.h>
diff --git a/formats/ctf/metadata/ctf-parser-test.c b/formats/ctf/metadata/ctf-parser-test.c
index 9d10251..e84dc12 100644
--- a/formats/ctf/metadata/ctf-parser-test.c
+++ b/formats/ctf/metadata/ctf-parser-test.c
@@ -21,7 +21,7 @@
 #include <glib.h>
 #include <errno.h>
 #include <endian.h>
-#include <babeltrace/babeltrace.h>
+#include <babeltrace/babeltrace-internal.h>
 #include <babeltrace/ctf/metadata.h>
 #include "ctf-scanner.h"
 #include "ctf-parser.h"
diff --git a/formats/ctf/metadata/ctf-visitor-generate-io-struct.c b/formats/ctf/metadata/ctf-visitor-generate-io-struct.c
index 6fbc7c0..725235d 100644
--- a/formats/ctf/metadata/ctf-visitor-generate-io-struct.c
+++ b/formats/ctf/metadata/ctf-visitor-generate-io-struct.c
@@ -25,7 +25,7 @@
 #include <inttypes.h>
 #include <endian.h>
 #include <errno.h>
-#include <babeltrace/babeltrace.h>
+#include <babeltrace/babeltrace-internal.h>
 #include <babeltrace/list.h>
 #include <babeltrace/types.h>
 #include <babeltrace/ctf/metadata.h>
diff --git a/formats/ctf/metadata/ctf-visitor-parent-links.c b/formats/ctf/metadata/ctf-visitor-parent-links.c
index 0258fd6..3dea11a 100644
--- a/formats/ctf/metadata/ctf-visitor-parent-links.c
+++ b/formats/ctf/metadata/ctf-visitor-parent-links.c
@@ -24,7 +24,7 @@
 #include <glib.h>
 #include <inttypes.h>
 #include <errno.h>
-#include <babeltrace/babeltrace.h>
+#include <babeltrace/babeltrace-internal.h>
 #include <babeltrace/list.h>
 #include "ctf-scanner.h"
 #include "ctf-parser.h"
diff --git a/formats/ctf/metadata/ctf-visitor-semantic-validator.c b/formats/ctf/metadata/ctf-visitor-semantic-validator.c
index b89f7bd..eab4391 100644
--- a/formats/ctf/metadata/ctf-visitor-semantic-validator.c
+++ b/formats/ctf/metadata/ctf-visitor-semantic-validator.c
@@ -24,7 +24,7 @@
 #include <glib.h>
 #include <inttypes.h>
 #include <errno.h>
-#include <babeltrace/babeltrace.h>
+#include <babeltrace/babeltrace-internal.h>
 #include <babeltrace/list.h>
 #include "ctf-scanner.h"
 #include "ctf-parser.h"
diff --git a/formats/ctf/metadata/ctf-visitor-xml.c b/formats/ctf/metadata/ctf-visitor-xml.c
index c47bd27..56974c3 100644
--- a/formats/ctf/metadata/ctf-visitor-xml.c
+++ b/formats/ctf/metadata/ctf-visitor-xml.c
@@ -24,7 +24,7 @@
 #include <glib.h>
 #include <inttypes.h>
 #include <errno.h>
-#include <babeltrace/babeltrace.h>
+#include <babeltrace/babeltrace-internal.h>
 #include <babeltrace/list.h>
 #include "ctf-scanner.h"
 #include "ctf-parser.h"
diff --git a/formats/ctf/types/string.c b/formats/ctf/types/string.c
index 682bd76..3b54a2d 100644
--- a/formats/ctf/types/string.c
+++ b/formats/ctf/types/string.c
@@ -18,7 +18,7 @@
  * all copies or substantial portions of the Software.
  */
 
-#include <babeltrace/babeltrace.h>
+#include <babeltrace/babeltrace-internal.h>
 #include <babeltrace/ctf/types.h>
 #include <limits.h>		/* C99 limits */
 #include <string.h>
diff --git a/include/Makefile.am b/include/Makefile.am
index 7239596..a5f5454 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -1,6 +1,8 @@
+babeltraceinclude_HEADERS = babeltrace/babeltrace.h
+
 noinst_HEADERS = \
 	babeltrace/align.h \
-	babeltrace/babeltrace.h \
+	babeltrace/babeltrace-internal.h \
 	babeltrace/bitfield.h \
 	babeltrace/compiler.h \
 	babeltrace/format.h \
diff --git a/include/babeltrace/babeltrace-internal.h b/include/babeltrace/babeltrace-internal.h
new file mode 100644
index 0000000..7c02948
--- /dev/null
+++ b/include/babeltrace/babeltrace-internal.h
@@ -0,0 +1,31 @@
+#ifndef _BABELTRACE_INTERNAL_H
+#define _BABELTRACE_INTERNAL_H
+
+#include <stdio.h>
+#include <glib.h>
+
+extern int babeltrace_verbose, babeltrace_debug;
+
+#define printf_verbose(fmt, args...)				\
+	do {							\
+		if (babeltrace_verbose)				\
+			printf("[verbose] " fmt, ## args);	\
+	} while (0)
+
+#define printf_debug(fmt, args...)				\
+	do {							\
+		if (babeltrace_debug)				\
+			printf("[debug] " fmt, ## args);	\
+	} while (0)
+
+struct trace_descriptor;
+struct trace_collection {
+	GPtrArray *array;
+};
+
+int convert_trace(struct trace_descriptor *td_write,
+		  struct trace_collection *trace_collection_read);
+
+extern int opt_field_names;
+
+#endif
diff --git a/include/babeltrace/babeltrace.h b/include/babeltrace/babeltrace.h
index 8091ac4..40bfbea 100644
--- a/include/babeltrace/babeltrace.h
+++ b/include/babeltrace/babeltrace.h
@@ -1,31 +1,93 @@
 #ifndef _BABELTRACE_H
 #define _BABELTRACE_H
 
-#include <stdio.h>
-#include <glib.h>
-
-extern int babeltrace_verbose, babeltrace_debug;
-
-#define printf_verbose(fmt, args...)				\
-	do {							\
-		if (babeltrace_verbose)				\
-			printf("[verbose] " fmt, ## args);	\
-	} while (0)
-
-#define printf_debug(fmt, args...)				\
-	do {							\
-		if (babeltrace_debug)				\
-			printf("[debug] " fmt, ## args);	\
-	} while (0)
-
-struct trace_descriptor;
-struct trace_collection {
-	GPtrArray *array;
+/*
+ * BabelTrace API
+ *
+ * Copyright 2010-2011 - Mathieu Desnoyers <mathieu.desnoyers at 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.
+ */
+
+#include <babeltrace/types.h>
+#include <babeltrace/format.h>
+#include <babeltrace/ctf/types.h>
+#include <babeltrace/ctf-ir/metadata.h>
+
+/*
+ * struct babeltrace_iter: data structure representing an iterator on a trace
+ * collection.
+ */
+struct babeltrace_iter {
+	struct ptr_heap *stream_heap;
+	struct trace_collection *tc;
+};
+
+struct babeltrace_iter_pos {
+	GPtrArray *pos; /* struct babeltrace_iter_stream_pos */
+};
+
+struct babeltrace_iter_stream_pos {
+	struct stream_pos parent;
+	ssize_t offset;
+	size_t cur_index;
 };
 
-int convert_trace(struct trace_descriptor *td_write,
-		  struct trace_collection *trace_collection_read);
+/*
+ * Initialization/teardown.
+ */
+struct babeltrace_iter *babeltrace_iter_create(struct trace_collection *tc);
+void babeltrace_iter_destroy(struct babeltrace_iter *iter);
+
+/*
+ * Move within the trace.
+ */
+/*
+ * babeltrace_iter_next: Move stream position to the next event.
+ *
+ * Returns 0 on success, a negative value on error
+ */
+int babeltrace_iter_next(struct babeltrace_iter *iter);
+
+/* Get the current position for each stream of the trace */
+struct babeltrace_iter_pos *
+babeltrace_iter_get_pos(struct babeltrace_iter *iter);
+
+/* The position needs to be freed after use */
+void babeltrace_iter_free_pos(struct babeltrace_iter_pos *pos);
+
+/* Seek the trace to the position */
+int babeltrace_iter_seek_pos(struct babeltrace_iter *iter,
+		struct babeltrace_iter_pos *pos);
+
+/*
+ * babeltrace_iter_seek_time: Seek the trace to the given timestamp.
+ *
+ * Return EOF if timestamp is after the last event of the trace.
+ * Return other negative value for other errors.
+ * Return 0 for success.
+ */
+int babeltrace_iter_seek_time(struct babeltrace_iter *iter,
+		uint64_t timestamp);
 
-extern int opt_field_names;
+/*
+ * babeltrace_iter_read_event: Read the current event data.
+ *
+ * @iter: trace iterator (input)
+ * @stream: stream containing event at current position (output)
+ * @event: current event (output)
+ * Return 0 on success, negative error value on error.
+ */
+int babeltrace_iter_read_event(struct babeltrace_iter *iter,
+		struct ctf_stream **stream,
+		struct ctf_stream_event **event);
 
-#endif
+#endif /* _BABELTRACE_H */
diff --git a/include/babeltrace/ctf-text/types.h b/include/babeltrace/ctf-text/types.h
index 1b05523..400e62c 100644
--- a/include/babeltrace/ctf-text/types.h
+++ b/include/babeltrace/ctf-text/types.h
@@ -24,7 +24,7 @@
 #include <stdint.h>
 #include <unistd.h>
 #include <glib.h>
-#include <babeltrace/babeltrace.h>
+#include <babeltrace/babeltrace-internal.h>
 #include <babeltrace/types.h>
 #include <babeltrace/format.h>
 
diff --git a/include/babeltrace/ctf/types.h b/include/babeltrace/ctf/types.h
index 8d57ec7..58352ef 100644
--- a/include/babeltrace/ctf/types.h
+++ b/include/babeltrace/ctf/types.h
@@ -20,7 +20,7 @@
  */
 
 #include <babeltrace/types.h>
-#include <babeltrace/babeltrace.h>
+#include <babeltrace/babeltrace-internal.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
diff --git a/types/types.c b/types/types.c
index 11e91b0..4e96f44 100644
--- a/types/types.c
+++ b/types/types.c
@@ -21,7 +21,7 @@
  */
 
 #include <babeltrace/format.h>
-#include <babeltrace/babeltrace.h>
+#include <babeltrace/babeltrace-internal.h>
 #include <limits.h>
 #include <glib.h>
 #include <errno.h>
-- 
1.7.4.1





More information about the lttng-dev mailing list