Fix API: allow packet_seek override
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 17 Feb 2012 17:49:42 +0000 (12:49 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 17 Feb 2012 17:49:42 +0000 (12:49 -0500)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
converter/babeltrace.c
include/babeltrace/context.h
lib/context.c

index 65220183722fdabd91a68d9947f662041c43d829..5bcfc2a745c68c59e49d597b4bca2517fbc36b1a 100644 (file)
@@ -307,14 +307,17 @@ end:
  * bt_context_add_traces_recursive: Open a trace recursively
  *
  * Find each trace present in the subdirectory starting from the given
  * bt_context_add_traces_recursive: Open a trace recursively
  *
  * Find each trace present in the subdirectory starting from the given
- * path, and add them to the context.
+ * path, and add them to the context. The packet_seek parameter can be
+ * NULL: this specify to use the default format packet_seek.
  *
  * Return: 0 on success, nonzero on failure.
  * Unable to open toplevel: failure.
  * Unable to open some subdirectory or file: warn and continue;
  */
 int bt_context_add_traces_recursive(struct bt_context *ctx, const char *path,
  *
  * Return: 0 on success, nonzero on failure.
  * Unable to open toplevel: failure.
  * Unable to open some subdirectory or file: warn and continue;
  */
 int bt_context_add_traces_recursive(struct bt_context *ctx, const char *path,
-               const char *format_str)
+               const char *format_str,
+               void (*packet_seek)(struct stream_pos *pos,
+                       size_t offset, int whence))
 {
        FTS *tree;
        FTSENT *node;
 {
        FTS *tree;
        FTSENT *node;
@@ -374,7 +377,8 @@ int bt_context_add_traces_recursive(struct bt_context *ctx, const char *path,
                        }
 
                        trace_id = bt_context_add_trace(ctx,
                        }
 
                        trace_id = bt_context_add_trace(ctx,
-                               node->fts_accpath, format_str);
+                               node->fts_accpath, format_str,
+                               packet_seek);
                        if (trace_id < 0) {
                                fprintf(stderr, "[error] [Context] opening trace \"%s\" from %s "
                                        "for reading.\n", node->fts_accpath, path);
                        if (trace_id < 0) {
                                fprintf(stderr, "[error] [Context] opening trace \"%s\" from %s "
                                        "for reading.\n", node->fts_accpath, path);
@@ -481,7 +485,7 @@ int main(int argc, char **argv)
        ctx = bt_context_create();
 
        ret = bt_context_add_traces_recursive(ctx, opt_input_path,
        ctx = bt_context_create();
 
        ret = bt_context_add_traces_recursive(ctx, opt_input_path,
-                       opt_input_format);
+                       opt_input_format, NULL);
        if (ret) {
                fprintf(stderr, "[error] opening trace \"%s\" for reading.\n\n",
                        opt_input_path);
        if (ret) {
                fprintf(stderr, "[error] opening trace \"%s\" for reading.\n\n",
                        opt_input_path);
index 261c4d47b625c6aa70382ba93ba02389dc9e5003..6190d37bdbf643518a6c2bba432e643ae560023d 100644 (file)
  * included in all copies or substantial portions of the Software.
  */
 
  * included in all copies or substantial portions of the Software.
  */
 
+#include <unistd.h>
+
 /* struct bt_context is opaque to the user */
 struct bt_context;
 /* struct bt_context is opaque to the user */
 struct bt_context;
+struct stream_pos;
 
 /*
  * bt_context_create : create a Babeltrace context
 
 /*
  * bt_context_create : create a Babeltrace context
@@ -39,13 +42,16 @@ struct bt_context *bt_context_create(void);
 /*
  * bt_context_add_trace : Add a trace by path to the context
  *
 /*
  * bt_context_add_trace : Add a trace by path to the context
  *
- * Open a trace
+ * Open a trace. Parameter packet_seek can be NULL to use the default
+ * packet_seek handle of the format.
  *
  * Return: the trace handle id (>= 0) on success, a negative
  * value on error.
  */
 int bt_context_add_trace(struct bt_context *ctx, const char *path,
  *
  * Return: the trace handle id (>= 0) on success, a negative
  * value on error.
  */
 int bt_context_add_trace(struct bt_context *ctx, const char *path,
-               const char *format);
+               const char *format,
+               void (*packet_seek)(struct stream_pos *pos,
+                       size_t offset, int whence));
 
 /*
  * bt_context_remove_trace: Remove a trace from the context.
 
 /*
  * bt_context_remove_trace: Remove a trace from the context.
index e2c062aa747378a73dd0bd5580af76452042e61e..5021d7add1c56ab92386e4f93cdd43c520509086 100644 (file)
@@ -57,7 +57,9 @@ struct bt_context *bt_context_create(void)
 }
 
 int bt_context_add_trace(struct bt_context *ctx, const char *path,
 }
 
 int bt_context_add_trace(struct bt_context *ctx, const char *path,
-               const char *format_name)
+               const char *format_name,
+               void (*packet_seek)(struct stream_pos *pos,
+                       size_t offset, int whence))
 {
        struct trace_descriptor *td;
        struct format *fmt;
 {
        struct trace_descriptor *td;
        struct format *fmt;
@@ -71,7 +73,7 @@ int bt_context_add_trace(struct bt_context *ctx, const char *path,
                ret = -1;
                goto end;
        }
                ret = -1;
                goto end;
        }
-       td = fmt->open_trace(path, O_RDONLY, NULL, NULL);
+       td = fmt->open_trace(path, O_RDONLY, packet_seek, NULL);
        if (!td) {
                fprintf(stderr, "[error] [Context] Cannot open_trace of the format %s .\n\n",
                                path);
        if (!td) {
                fprintf(stderr, "[error] [Context] Cannot open_trace of the format %s .\n\n",
                                path);
This page took 0.026561 seconds and 4 git commands to generate.